index.vue 6.1 KB

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