index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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: '文件格式',
  46. dataIndex: 'fileExtendName'
  47. },
  48. {
  49. title: '操作',
  50. dataIndex: 'action',
  51. align: 'center',
  52. width: '150px'
  53. }
  54. ]
  55. // // 操作栏通过权限判断是否显示
  56. // if (hasPerm(['resourceFileFormatEdit', 'resourceFileFormatDelete'])) {
  57. // columns.push({
  58. // title: '操作',
  59. // dataIndex: 'action',
  60. // align: 'center',
  61. // width: '150px'
  62. // })
  63. // }
  64. const selectedRowKeys = ref([])
  65. // 列表选择配置
  66. const options = {
  67. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  68. alert: {
  69. show: true,
  70. clear: () => {
  71. selectedRowKeys.value = ref([])
  72. }
  73. },
  74. rowSelection: {
  75. onChange: (selectedRowKey, selectedRows) => {
  76. selectedRowKeys.value = selectedRowKey
  77. }
  78. }
  79. }
  80. const loadData = (parameter) => {
  81. return resourceFileFormatApi.resourceFileFormatPage(parameter).then((data) => {
  82. return data
  83. })
  84. }
  85. // 重置
  86. const reset = () => {
  87. searchFormRef.value.resetFields()
  88. table.value.refresh(true)
  89. }
  90. // 删除
  91. const deleteResourceFileFormat = (record) => {
  92. let params = [
  93. {
  94. id: record.id
  95. }
  96. ]
  97. resourceFileFormatApi.resourceFileFormatDelete(params).then(() => {
  98. table.value.refresh(true)
  99. })
  100. }
  101. // 批量删除
  102. const deleteBatchResourceFileFormat = (params) => {
  103. resourceFileFormatApi.resourceFileFormatDelete(params).then(() => {
  104. table.value.clearRefreshSelected()
  105. })
  106. }
  107. </script>