timeIndex.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <a-drawer :title="title" :width="850" :open="visible" :destroy-on-close="true" @close="onClose">
  3. <a-card :bordered="false" class="mb-2">
  4. <s-table
  5. ref="tableRef"
  6. :columns="columns"
  7. :data="loadData"
  8. bordered
  9. :row-key="(record) => record.id"
  10. >
  11. <template #operator `class="table-operator">
  12. <a-button type="primary" v-if="hasPerm('bizLoadTimeAdd')" @click="addFormRef.onOpen(null, pointId)">
  13. <template #icon><plus-outlined /></template> 新增
  14. </a-button>
  15. </template>`
  16. <template #bodyCell="{ column, record, index }">
  17. <template v-if="column.dataIndex === 'serial'">
  18. {{ index + 1 }}
  19. </template>
  20. <template v-if="column.dataIndex === 'beginEndTime'">
  21. {{ record.beginTime + '~' + record.endTime }}
  22. </template>
  23. <template v-if="column.dataIndex === 'action'">
  24. <a-space>
  25. <a @click="editFormRef.onOpen(record, pointId)" v-if="hasPerm('bizLoadTimeEdit') && Number(record.alreadyNumber) == 0">编辑</a>
  26. <a-divider type="vertical" v-if="hasPerm(['bizLoadTimeEdit', 'bizLoadTimeDelete'], 'and') && Number(record.alreadyNumber) == 0" />
  27. <a-button type="link" danger size="small" v-if="hasPerm('bizLoadTimeDelete') && Number(record.alreadyNumber) == 0" @click="deleteConfig(record)">删除</a-button>
  28. <a @click="alreadyFormRef.onOpen(record, pointId)" v-if="hasPerm('bizLoadTimeAlready') && Number(record.alreadyNumber) != 0">次数</a>
  29. </a-space>
  30. </template>
  31. </template>
  32. </s-table>
  33. </a-card>
  34. </a-drawer>
  35. <TimeAddForm ref="addFormRef" @successful="tableRef.refresh()" />
  36. <TimeEditForm ref="editFormRef" @successful="tableRef.refresh()" />
  37. <TimeAlreadyForm ref="alreadyFormRef" @successful="tableRef.refresh()" />
  38. </template>
  39. <script setup name="bizloadtime">
  40. import { cloneDeep } from 'lodash-es'
  41. import TimeAddForm from './timeAddForm.vue'
  42. import TimeEditForm from './timeEditForm.vue'
  43. import TimeAlreadyForm from './timeAlreadyForm.vue'
  44. import bizLoadTimeApi from '@/api/biz/bizLoadTimeApi'
  45. import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
  46. import {Modal} from 'ant-design-vue';
  47. import {createVNode} from 'vue';
  48. const submitLoading = ref(false)
  49. const toolConfig = { refresh: true, height: false, columnSetting: false, striped: false }
  50. // 默认是关闭状态
  51. const visible = ref(false)
  52. const searchFormState = ref({})
  53. const tableRef = ref()
  54. const addFormRef = ref()
  55. const editFormRef = ref()
  56. const alreadyFormRef = ref()
  57. const recordData = ref()
  58. const title = ref()
  59. const pointId = ref()
  60. const columns = [
  61. {
  62. title: '序号',
  63. width: 50,
  64. dataIndex: 'serial',
  65. align:'center'
  66. },
  67. {
  68. title: '装货时间段',
  69. dataIndex: 'beginEndTime',
  70. align:'center'
  71. },
  72. {
  73. title: '可预约次数',
  74. dataIndex: 'availableNumber',
  75. align:'center'
  76. },
  77. {
  78. title: '已预约次数',
  79. dataIndex: 'alreadyNumber',
  80. align:'center'
  81. },
  82. ]
  83. // 操作栏通过权限判断是否显示
  84. if (hasPerm(['bizLoadTimeEdit', 'bizLoadTimeDelete'])) {
  85. columns.push({
  86. title: '操作',
  87. dataIndex: 'action',
  88. align: 'center',
  89. width: 150
  90. })
  91. }
  92. // 打开抽屉
  93. const onOpen = (record) => {
  94. recordData.value = record
  95. title.value = "【" + record.loadPoint + "】-装货时间配置"
  96. searchFormState.value = {
  97. pointId: record.id
  98. }
  99. pointId.value = record.id
  100. visible.value = true
  101. }
  102. // 加载字段数据
  103. const loadData = (parameter) => {
  104. return bizLoadTimeApi.bizLoadTimePage(Object.assign(parameter, searchFormState.value)).then((res) => {
  105. return res
  106. })
  107. }
  108. // 关闭抽屉
  109. const onClose = () => {
  110. visible.value = false
  111. }
  112. // 删除
  113. const deleteConfig = (record) => {
  114. Modal.confirm({
  115. title: '确定删除该数据吗?',
  116. icon: createVNode(ExclamationCircleOutlined),
  117. content: '',
  118. onOk() {
  119. submitLoading.value = true
  120. let params = [
  121. {
  122. id: record.id
  123. }
  124. ]
  125. bizLoadTimeApi
  126. .bizLoadTimeDelete(params)
  127. .then(() => {
  128. tableRef.value.refresh(true)
  129. })
  130. .finally(() => {
  131. submitLoading.value = false
  132. })
  133. },
  134. onCancel() {}
  135. })
  136. }
  137. // 调用这个函数将子组件的一些数据和方法暴露出去
  138. defineExpose({
  139. onOpen
  140. })
  141. </script>