timeIndex.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <a-drawer title="装货时间配置" :width="650" :open="visible" :destroy-on-close="true" @close="onClose">
  3. <a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
  4. <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
  5. <a-row :gutter="24">
  6. <a-col :span="9">
  7. <a-form-item label="装货开始时间" name="confStartTime">
  8. <a-range-picker v-model:value="searchFormState.confStartTime" value-format="YYYY-MM-DD HH:mm" show-time allow-clear />
  9. </a-form-item>
  10. </a-col>
  11. <a-col :span="9">
  12. <a-form-item label="装货结束时间" name="confEndTime">
  13. <a-range-picker v-model:value="searchFormState.confEndTime" value-format="YYYY-MM-DD HH:mm" show-time allow-clear />
  14. </a-form-item>
  15. </a-col>
  16. <a-col :span="6">
  17. <a-button type="primary" @click="tableRef.refresh()">查询</a-button>
  18. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  19. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('bizLoadTimeAdd')">
  20. <template #icon><plus-outlined /></template>
  21. 新增
  22. </a-button>
  23. </a-col>
  24. </a-row>
  25. </a-form>
  26. </a-card>
  27. <a-card :bordered="false">
  28. <s-table
  29. ref="tableRef"
  30. :columns="columns"
  31. :data="loadData"
  32. bordered
  33. :row-key="(record) => record.id"
  34. >
  35. <template #bodyCell="{ column, record, index }">
  36. <template v-if="column.dataIndex === 'serial'">
  37. {{ index + 1 }}
  38. </template>
  39. <template v-if="column.dataIndex === 'action'">
  40. <a-space>
  41. <a @click="formRef.onOpen(record)" v-if="hasPerm('bizLoadTimeEdit')">编辑</a>
  42. <a-divider type="vertical" v-if="hasPerm(['bizLoadTimeEdit', 'bizLoadTimeDelete'], 'and')" />
  43. <a-button type="link" danger size="small" v-if="hasPerm('bizLoadTimeDelete')" @click="deleteConfig(record)">删除</a-button>
  44. </a-space>
  45. </template>
  46. </template>
  47. </s-table>
  48. </a-card>
  49. </a-drawer>
  50. <Form ref="formRef" @successful="tableRef.refresh()" />
  51. </template>
  52. <script setup name="bizloadtime">
  53. import { cloneDeep } from 'lodash-es'
  54. import Form from './timeform.vue'
  55. import bizLoadTimeApi from '@/api/biz/bizLoadTimeApi'
  56. const searchFormState = ref({})
  57. const searchFormRef = ref()
  58. const tableRef = ref()
  59. const formRef = ref()
  60. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  61. const columns = [
  62. {
  63. title: '装货点位',
  64. dataIndex: 'loadPoint'
  65. },
  66. {
  67. title: '装货时间段',
  68. dataIndex: 'beginTime-endTime'
  69. },
  70. {
  71. title: '可预约次数',
  72. dataIndex: 'availableNumber'
  73. },
  74. {
  75. title: '已预约日期',
  76. dataIndex: 'alreadyDate'
  77. },
  78. {
  79. title: '已预约次数',
  80. dataIndex: 'alreadyNumber'
  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. searchFormState.value = {
  96. loadPointId: record.id
  97. }
  98. visible.value = true
  99. }
  100. // 加载字段数据
  101. const loadData = (parameter) => {
  102. return bizLoadTimeApi.bizLoadTimePage(Object.assign(parameter, searchFormState.value)).then((res) => {
  103. return res
  104. })
  105. }
  106. // 关闭抽屉
  107. const onClose = () => {
  108. visible.value = false
  109. }
  110. // 删除
  111. const deleteConfig = (record) => {
  112. Modal.confirm({
  113. title: '确定删除该数据吗?',
  114. icon: createVNode(ExclamationCircleOutlined),
  115. content: '',
  116. onOk() {
  117. submitLoading.value = true
  118. let params = [
  119. {
  120. id: record.id
  121. }
  122. ]
  123. customerAccountApi
  124. .customerAccountDelete(params)
  125. .then(() => {
  126. tableRef.value.refresh(true)
  127. })
  128. .finally(() => {
  129. submitLoading.value = false
  130. })
  131. },
  132. onCancel() {}
  133. })
  134. }
  135. // 调用这个函数将子组件的一些数据和方法暴露出去
  136. defineExpose({
  137. onOpen
  138. })
  139. </script>