index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <a-card :bordered="false">
  3. <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
  4. <a-row :gutter="24">
  5. <a-col :span="6">
  6. <a-form-item label="QUESTION_TYPE" name="questionType">
  7. <a-input v-model:value="searchFormState.questionType" placeholder="请输入QUESTION_TYPE" />
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="6">
  11. <a-form-item label="SUBJECT_ID" name="subjectId">
  12. <a-input v-model:value="searchFormState.subjectId" placeholder="请输入SUBJECT_ID" />
  13. </a-form-item>
  14. </a-col>
  15. <a-col :span="6">
  16. <a-form-item label="GRADE_LEVEL" name="gradeLevel">
  17. <a-input v-model:value="searchFormState.gradeLevel" placeholder="请输入GRADE_LEVEL" />
  18. </a-form-item>
  19. </a-col>
  20. <a-col :span="6">
  21. <a-button type="primary" @click="table.refresh(true)">查询</a-button>
  22. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  23. </a-col>
  24. </a-row>
  25. </a-form>
  26. <s-table
  27. ref="table"
  28. :columns="columns"
  29. :data="loadData"
  30. :alert="options.alert.show"
  31. bordered
  32. :row-key="(record) => record.id"
  33. :tool-config="toolConfig"
  34. :row-selection="options.rowSelection"
  35. >
  36. <template #operator class="table-operator">
  37. <a-space>
  38. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('tQuestionAdd')">
  39. <template #icon><plus-outlined /></template>
  40. 新增
  41. </a-button>
  42. <xn-batch-delete
  43. v-if="hasPerm('tQuestionBatchDelete')"
  44. :selectedRowKeys="selectedRowKeys"
  45. @batchDelete="deleteBatchTQuestion"
  46. />
  47. </a-space>
  48. </template>
  49. <template #bodyCell="{ column, record }">
  50. <template v-if="column.dataIndex === 'action'">
  51. <a-space>
  52. <a @click="formRef.onOpen(record)" v-if="hasPerm('tQuestionEdit')">编辑</a>
  53. <a-divider type="vertical" v-if="hasPerm(['tQuestionEdit', 'tQuestionDelete'], 'and')" />
  54. <a-popconfirm title="确定要删除吗?" @confirm="deleteTQuestion(record)">
  55. <a-button type="link" danger size="small" v-if="hasPerm('tQuestionDelete')">删除</a-button>
  56. </a-popconfirm>
  57. </a-space>
  58. </template>
  59. </template>
  60. </s-table>
  61. </a-card>
  62. <Form ref="formRef" @successful="table.refresh(true)" />
  63. </template>
  64. <script setup name="question">
  65. import Form from './form.vue'
  66. import tQuestionApi from '@/api/question/tQuestionApi'
  67. let searchFormState = reactive({})
  68. const searchFormRef = ref()
  69. const table = ref()
  70. const formRef = ref()
  71. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  72. const columns = [
  73. {
  74. title: 'QUESTION_TYPE',
  75. dataIndex: 'questionType'
  76. },
  77. {
  78. title: 'SUBJECT_ID',
  79. dataIndex: 'subjectId'
  80. },
  81. {
  82. title: 'SCORE',
  83. dataIndex: 'score'
  84. },
  85. {
  86. title: 'GRADE_LEVEL',
  87. dataIndex: 'gradeLevel'
  88. },
  89. {
  90. title: 'DIFFICULT',
  91. dataIndex: 'difficult'
  92. },
  93. {
  94. title: 'CORRECT',
  95. dataIndex: 'correct'
  96. },
  97. {
  98. title: 'INFO_TEXT_CONTENT_ID',
  99. dataIndex: 'infoTextContentId'
  100. },
  101. {
  102. title: 'STATUS',
  103. dataIndex: 'status'
  104. },
  105. {
  106. title: 'DELETED',
  107. dataIndex: 'deleted'
  108. },
  109. ]
  110. // 操作栏通过权限判断是否显示
  111. if (hasPerm(['tQuestionEdit', 'tQuestionDelete'])) {
  112. columns.push({
  113. title: '操作',
  114. dataIndex: 'action',
  115. align: 'center',
  116. width: '150px'
  117. })
  118. }
  119. const selectedRowKeys = ref([])
  120. // 列表选择配置
  121. const options = {
  122. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  123. alert: {
  124. show: true,
  125. clear: () => {
  126. selectedRowKeys.value = ref([])
  127. }
  128. },
  129. rowSelection: {
  130. onChange: (selectedRowKey, selectedRows) => {
  131. selectedRowKeys.value = selectedRowKey
  132. }
  133. }
  134. }
  135. const loadData = (parameter) => {
  136. const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
  137. return tQuestionApi.tQuestionPage(Object.assign(parameter, searchFormParam)).then((data) => {
  138. return data
  139. })
  140. }
  141. // 重置
  142. const reset = () => {
  143. searchFormRef.value.resetFields()
  144. table.value.refresh(true)
  145. }
  146. // 删除
  147. const deleteTQuestion = (record) => {
  148. let params = [
  149. {
  150. id: record.id
  151. }
  152. ]
  153. tQuestionApi.tQuestionDelete(params).then(() => {
  154. table.value.refresh(true)
  155. })
  156. }
  157. // 批量删除
  158. const deleteBatchTQuestion = (params) => {
  159. tQuestionApi.tQuestionDelete(params).then(() => {
  160. table.value.clearRefreshSelected()
  161. })
  162. }
  163. </script>