index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-row>
  12. <el-col :span="24">
  13. <el-form-item label="试题:" prop="cqoQuestId">
  14. <!-- 替换为模拟输入框样式的 div 容器 -->
  15. <div v-html="queryParams.cqoQuestion">
  16. </div>
  17. </el-form-item>
  18. </el-col>
  19. </el-row>
  20. <el-form-item label="选项内容" prop="cqoOption">
  21. <el-input
  22. v-model="queryParams.cqoOption"
  23. placeholder="请输入选项内容"
  24. clearable
  25. @keyup.enter="handleQuery"
  26. class="!w-240px"
  27. />
  28. </el-form-item>
  29. <el-form-item label="选项分值" prop="cqoSocre">
  30. <el-input
  31. v-model="queryParams.cqoSocre"
  32. placeholder="请输入选项分值"
  33. clearable
  34. @keyup.enter="handleQuery"
  35. class="!w-240px"
  36. />
  37. </el-form-item>
  38. <el-form-item label="答案" prop="cqoIsAnswer">
  39. <el-select
  40. v-model="queryParams.cqoIsAnswer"
  41. placeholder="请选择答案"
  42. clearable
  43. class="!w-240px"
  44. >
  45. <el-option
  46. v-for="dict in getStrDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
  47. :key="dict.value"
  48. :label="dict.label"
  49. :value="dict.value"
  50. />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item>
  54. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  55. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  56. <el-button
  57. type="primary"
  58. plain
  59. @click="openForm('create', null, queryParams.cqoQuestId)"
  60. v-hasPermi="['bjdx:course-quest-option:create']"
  61. >
  62. <Icon icon="ep:plus" class="mr-5px" /> 新增
  63. </el-button>
  64. <el-button
  65. type="success"
  66. plain
  67. @click="handleExport"
  68. :loading="exportLoading"
  69. v-hasPermi="['bjdx:course-quest-option:export']"
  70. >
  71. <Icon icon="ep:download" class="mr-5px" /> 导出
  72. </el-button>
  73. </el-form-item>
  74. </el-form>
  75. </ContentWrap>
  76. <!-- 列表 -->
  77. <ContentWrap>
  78. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  79. <!-- <el-table-column label="课程试题选项id" align="center" prop="id" />-->
  80. <!-- <el-table-column label="试题id" align="center" prop="cqoQuestId" />-->
  81. <el-table-column label="选项" align="center" prop="cqoValue" />
  82. <el-table-column label="选项内容" align="center" prop="cqoOption" >
  83. <template #default="scope">
  84. <div v-html="scope.row.cqoOption"></div>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="选项分值" align="center" prop="cqoSocre" />
  88. <el-table-column label="答案" align="center" prop="cqoIsAnswer">
  89. <template #default="scope">
  90. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.cqoIsAnswer" />
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="操作" align="center" min-width="120px">
  94. <template #default="scope">
  95. <el-button
  96. link
  97. type="primary"
  98. @click="openForm('update', scope.row.id, queryParams.cqoQuestId)"
  99. v-hasPermi="['bjdx:course-quest-option:update']"
  100. >
  101. 编辑
  102. </el-button>
  103. <el-button
  104. link
  105. type="danger"
  106. @click="handleDelete(scope.row.id)"
  107. v-hasPermi="['bjdx:course-quest-option:delete']"
  108. >
  109. 删除
  110. </el-button>
  111. </template>
  112. </el-table-column>
  113. </el-table>
  114. <!-- 分页 -->
  115. <Pagination
  116. :total="total"
  117. v-model:page="queryParams.pageNo"
  118. v-model:limit="queryParams.pageSize"
  119. @pagination="getList"
  120. />
  121. </ContentWrap>
  122. <!-- 表单弹窗:添加/修改 -->
  123. <CourseQuestOptionForm ref="formRef" @success="getList" />
  124. </template>
  125. <script setup lang="ts">
  126. import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
  127. import download from '@/utils/download'
  128. import { CourseQuestOptionApi, CourseQuestOptionVO } from '@/api/bjdx/coursequestoption'
  129. import CourseQuestOptionForm from './CourseQuestOptionForm.vue'
  130. import { useRoute } from 'vue-router'
  131. /** 课程-试题-选项 列表 */
  132. defineOptions({ name: 'CourseQuestOption' })
  133. const message = useMessage() // 消息弹窗
  134. const { t } = useI18n() // 国际化
  135. const loading = ref(true) // 列表的加载中
  136. const list = ref<CourseQuestOptionVO[]>([]) // 列表的数据
  137. const total = ref(0) // 列表的总页数
  138. const queryParams = reactive({
  139. pageNo: 1,
  140. pageSize: 10,
  141. cqoQuestId: undefined,
  142. cqoQuestion: undefined,
  143. cqoValue: undefined,
  144. cqoOption: undefined,
  145. cqoSocre: undefined,
  146. cqoIsAnswer: undefined
  147. })
  148. const queryFormRef = ref() // 搜索的表单
  149. const exportLoading = ref(false) // 导出的加载中
  150. const route = useRoute()
  151. /** 查询列表 */
  152. const getList = async () => {
  153. loading.value = true
  154. try {
  155. queryParams.cqoQuestId = route.query.questId
  156. queryParams.cqoQuestion = route.query.question
  157. const data = await CourseQuestOptionApi.getCourseQuestOptionPage(queryParams)
  158. list.value = data.list
  159. total.value = data.total
  160. } finally {
  161. loading.value = false
  162. }
  163. }
  164. /** 搜索按钮操作 */
  165. const handleQuery = () => {
  166. queryParams.pageNo = 1
  167. getList()
  168. }
  169. /** 重置按钮操作 */
  170. const resetQuery = () => {
  171. queryFormRef.value.resetFields()
  172. handleQuery()
  173. }
  174. /** 添加/修改操作 */
  175. const formRef = ref()
  176. const openForm = (type: string, id?: number, questId?: number) => {
  177. formRef.value.open(type, id, questId)
  178. }
  179. /** 删除按钮操作 */
  180. const handleDelete = async (id: number) => {
  181. try {
  182. // 删除的二次确认
  183. await message.delConfirm()
  184. // 发起删除
  185. await CourseQuestOptionApi.deleteCourseQuestOption(id)
  186. message.success(t('common.delSuccess'))
  187. // 刷新列表
  188. await getList()
  189. } catch {}
  190. }
  191. /** 导出按钮操作 */
  192. const handleExport = async () => {
  193. try {
  194. // 导出的二次确认
  195. await message.exportConfirm()
  196. // 发起导出
  197. exportLoading.value = true
  198. const data = await CourseQuestOptionApi.exportCourseQuestOption(queryParams)
  199. download.excel(data, '课程-试题-选项.xls')
  200. } catch {
  201. } finally {
  202. exportLoading.value = false
  203. }
  204. }
  205. /** 初始化 **/
  206. onMounted(() => {
  207. getList()
  208. })
  209. </script>