index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <a-card :bordered="false">
  3. <s-table
  4. ref="tableRef"
  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()" v-if="hasPerm('bizLoadTimeAdd')">
  16. <template #icon><plus-outlined /></template>
  17. 新增
  18. </a-button>
  19. <xn-batch-button
  20. v-if="hasPerm('bizLoadTimeBatchDelete')"
  21. buttonName="批量删除"
  22. icon="DeleteOutlined"
  23. :selectedRowKeys="selectedRowKeys"
  24. @batchCallBack="deleteBatchBizLoadTime"
  25. />
  26. </a-space>
  27. </template>
  28. <template #bodyCell="{ column, record }">
  29. <template v-if="column.dataIndex === 'action'">
  30. <a-space>
  31. <a @click="formRef.onOpen(record)" v-if="hasPerm('bizLoadTimeEdit')">编辑</a>
  32. <a-divider type="vertical" v-if="hasPerm(['bizLoadTimeEdit', 'bizLoadTimeDelete'], 'and')" />
  33. <a-popconfirm title="确定要删除吗?" @confirm="deleteBizLoadTime(record)">
  34. <a-button type="link" danger size="small" v-if="hasPerm('bizLoadTimeDelete')">删除</a-button>
  35. </a-popconfirm>
  36. </a-space>
  37. </template>
  38. </template>
  39. </s-table>
  40. </a-card>
  41. <Form ref="formRef" @successful="tableRef.refresh()" />
  42. </template>
  43. <script setup name="bizloadtime">
  44. import { cloneDeep } from 'lodash-es'
  45. import Form from './form.vue'
  46. import bizLoadTimeApi from '@/api/biz/bizLoadTimeApi'
  47. const tableRef = ref()
  48. const formRef = ref()
  49. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  50. const columns = [
  51. {
  52. title: '装货点位id',
  53. dataIndex: 'pointId'
  54. },
  55. {
  56. title: '开始时间',
  57. dataIndex: 'beginTime'
  58. },
  59. {
  60. title: '结束时间',
  61. dataIndex: 'endTime'
  62. },
  63. {
  64. title: '可约次数',
  65. dataIndex: 'availableNumber'
  66. },
  67. {
  68. title: '已约次数',
  69. dataIndex: 'alreadyNumber'
  70. },
  71. ]
  72. // 操作栏通过权限判断是否显示
  73. if (hasPerm(['bizLoadTimeEdit', 'bizLoadTimeDelete'])) {
  74. columns.push({
  75. title: '操作',
  76. dataIndex: 'action',
  77. align: 'center',
  78. width: 150
  79. })
  80. }
  81. const selectedRowKeys = ref([])
  82. // 列表选择配置
  83. const options = {
  84. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  85. alert: {
  86. show: true,
  87. clear: () => {
  88. selectedRowKeys.value = ref([])
  89. }
  90. },
  91. rowSelection: {
  92. onChange: (selectedRowKey, selectedRows) => {
  93. selectedRowKeys.value = selectedRowKey
  94. }
  95. }
  96. }
  97. const loadData = (parameter) => {
  98. return bizLoadTimeApi.bizLoadTimePage(parameter).then((data) => {
  99. return data
  100. })
  101. }
  102. // 重置
  103. const reset = () => {
  104. searchFormRef.value.resetFields()
  105. tableRef.value.refresh(true)
  106. }
  107. // 删除
  108. const deleteBizLoadTime = (record) => {
  109. let params = [
  110. {
  111. id: record.id
  112. }
  113. ]
  114. bizLoadTimeApi.bizLoadTimeDelete(params).then(() => {
  115. tableRef.value.refresh(true)
  116. })
  117. }
  118. // 批量删除
  119. const deleteBatchBizLoadTime = (params) => {
  120. bizLoadTimeApi.bizLoadTimeDelete(params).then(() => {
  121. tableRef.value.clearRefreshSelected()
  122. })
  123. }
  124. </script>