index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 搜索和操作区域 -->
  4. <a-row :gutter="60" style="margin-bottom: 16px">
  5. <a-col>
  6. <span>试卷名称:</span>
  7. <a-input v-model:value="formState.name" placeholder="请输入试卷名称" style="width: 150px;" />
  8. </a-col>
  9. <a-col>
  10. <span>学科名称:</span>
  11. <a-input v-model:value="formState.fileName" placeholder="请输入学科名称" style="width: 150px" />
  12. </a-col>
  13. <a-col>
  14. <a-button type="primary" style="margin-left: 8px" @click="handleSearch">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="handleReset">重置</a-button>
  16. </a-col>
  17. </a-row>
  18. <s-table
  19. ref="table"
  20. :columns="columns"
  21. :data="loadData"
  22. :alert="options.alert.show"
  23. bordered
  24. :row-key="(record) => record.id"
  25. :tool-config="toolConfig"
  26. :row-selection="options.rowSelection"
  27. >
  28. <template #operator class="table-operator">
  29. <a-space>
  30. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('tExamPaperAdd')">
  31. <template #icon><plus-outlined /></template>
  32. 新增
  33. </a-button>
  34. <xn-batch-delete
  35. v-if="hasPerm('tExamPaperBatchDelete')"
  36. :selectedRowKeys="selectedRowKeys"
  37. @batchDelete="deleteBatchTExamPaper"
  38. />
  39. </a-space>
  40. </template>
  41. <template #bodyCell="{ column, record }">
  42. <template v-if="column.dataIndex === 'action'">
  43. <a-space>
  44. <a @click="formRef.onOpen(record)" v-if="hasPerm('tExamPaperEdit')">编辑</a>
  45. <a-divider type="vertical" v-if="hasPerm(['tExamPaperEdit', 'tExamPaperDelete'], 'and')" />
  46. <a-popconfirm title="确定要删除吗?" @confirm="deleteTExamPaper(record)">
  47. <a-button type="link" danger size="small" v-if="hasPerm('tExamPaperDelete')">删除</a-button>
  48. </a-popconfirm>
  49. </a-space>
  50. </template>
  51. </template>
  52. </s-table>
  53. </a-card>
  54. <Form ref="formRef" @successful="table.refresh(true)" />
  55. </template>
  56. <script setup name="exampaper">
  57. import Form from './form.vue'
  58. import tExamPaperApi from '@/api/paper/examPaperApi'
  59. const formState = reactive({
  60. id: null,
  61. verifyStatus: '0',
  62. resourcesId: null,
  63. })
  64. const table = ref()
  65. const formRef = ref()
  66. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  67. const columns = [
  68. {
  69. title: 'ID',
  70. dataIndex: 'ID'
  71. },
  72. {
  73. title: '学科',
  74. dataIndex: 'subjectId'
  75. },
  76. {
  77. title: '名称',
  78. dataIndex: 'name'
  79. },
  80. {
  81. title: '创建时间',
  82. dataIndex: 'createTime'
  83. }
  84. ]
  85. // 操作栏通过权限判断是否显示
  86. if (hasPerm(['tExamPaperEdit', 'tExamPaperDelete'])) {
  87. columns.push({
  88. title: '操作',
  89. dataIndex: 'action',
  90. align: 'center',
  91. width: '150px'
  92. })
  93. }
  94. const selectedRowKeys = ref([])
  95. // 列表选择配置
  96. const options = {
  97. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  98. alert: {
  99. show: true,
  100. clear: () => {
  101. selectedRowKeys.value = ref([])
  102. }
  103. },
  104. rowSelection: {
  105. onChange: (selectedRowKey, selectedRows) => {
  106. selectedRowKeys.value = selectedRowKey
  107. }
  108. }
  109. }
  110. const loadData = (parameter) => {
  111. return tExamPaperApi.tExamPaperPage(parameter).then((data) => {
  112. return data
  113. })
  114. }
  115. // 重置
  116. const reset = () => {
  117. searchFormRef.value.resetFields()
  118. table.value.refresh(true)
  119. }
  120. // 删除
  121. const deleteTExamPaper = (record) => {
  122. let params = [
  123. {
  124. id: record.id
  125. }
  126. ]
  127. tExamPaperApi.tExamPaperDelete(params).then(() => {
  128. table.value.refresh(true)
  129. })
  130. }
  131. // 批量删除
  132. const deleteBatchTExamPaper = (params) => {
  133. tExamPaperApi.tExamPaperDelete(params).then(() => {
  134. table.value.clearRefreshSelected()
  135. })
  136. }
  137. </script>