index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <a-card :bordered="false">
  3. <s-table
  4. ref="table"
  5. :columns="columns"
  6. :data="loadData"
  7. :alert="options.alert.show"
  8. bordered
  9. :row-key="(record) => record.id"
  10. :tool-config="toolConfig"
  11. :row-selection="options.rowSelection"
  12. >
  13. <template #operator class="table-operator">
  14. <a-space>
  15. <a-button type="primary" @click="formRef.onOpen()" >
  16. <template #icon><plus-outlined /></template>
  17. 新增
  18. </a-button>
  19. <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchResourceFileFormat" />
  20. </a-space>
  21. </template>
  22. <template #bodyCell="{ column, record }">
  23. <template v-if="column.dataIndex === 'action'">
  24. <a-space>
  25. <a @click="formRef.onOpen(record)">编辑</a>
  26. <a-divider type="vertical" />
  27. <a-popconfirm title="确定要删除吗?" @confirm="deleteResourceFileFormat(record)">
  28. <a-button type="link" danger size="small">删除</a-button>
  29. </a-popconfirm>
  30. </a-space>
  31. </template>
  32. </template>
  33. </s-table>
  34. </a-card>
  35. <Form ref="formRef" @successful="table.refresh(true)" />
  36. </template>
  37. <script setup name="fileformat">
  38. import Form from './form.vue'
  39. import resourceFileFormatApi from '@/api/course/resourceFileFormatApi'
  40. const table = ref()
  41. const formRef = ref()
  42. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  43. const columns = [
  44. {
  45. title: 'FILE_EXTEND_NAME',
  46. dataIndex: 'fileExtendName'
  47. },
  48. {
  49. title: 'FILE_TYPE_ID',
  50. dataIndex: 'fileTypeId'
  51. },
  52. {
  53. title: 'FUNCTION_TYPE',
  54. dataIndex: 'functionType'
  55. },
  56. {
  57. title: '操作',
  58. dataIndex: 'action',
  59. align: 'center',
  60. width: '150px'
  61. }
  62. ]
  63. // // 操作栏通过权限判断是否显示
  64. // if (hasPerm(['resourceFileFormatEdit', 'resourceFileFormatDelete'])) {
  65. // columns.push({
  66. // title: '操作',
  67. // dataIndex: 'action',
  68. // align: 'center',
  69. // width: '150px'
  70. // })
  71. // }
  72. const selectedRowKeys = ref([])
  73. // 列表选择配置
  74. const options = {
  75. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  76. alert: {
  77. show: true,
  78. clear: () => {
  79. selectedRowKeys.value = ref([])
  80. }
  81. },
  82. rowSelection: {
  83. onChange: (selectedRowKey, selectedRows) => {
  84. selectedRowKeys.value = selectedRowKey
  85. }
  86. }
  87. }
  88. const loadData = (parameter) => {
  89. return resourceFileFormatApi.resourceFileFormatPage(parameter).then((data) => {
  90. return data
  91. })
  92. }
  93. // 重置
  94. const reset = () => {
  95. searchFormRef.value.resetFields()
  96. table.value.refresh(true)
  97. }
  98. // 删除
  99. const deleteResourceFileFormat = (record) => {
  100. let params = [
  101. {
  102. id: record.id
  103. }
  104. ]
  105. resourceFileFormatApi.resourceFileFormatDelete(params).then(() => {
  106. table.value.refresh(true)
  107. })
  108. }
  109. // 批量删除
  110. const deleteBatchResourceFileFormat = (params) => {
  111. resourceFileFormatApi.resourceFileFormatDelete(params).then(() => {
  112. table.value.clearRefreshSelected()
  113. })
  114. }
  115. </script>