index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <a-card :bordered="false">
  3. <s-table
  4. ref="tableRef"
  5. :columns="columns"
  6. :data="loadData"
  7. bordered
  8. :row-key="(record) => record.id"
  9. >
  10. <template #operator class="table-operator">
  11. <a-space>
  12. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('bizAppointmentTimeAdd')">
  13. <template #icon><plus-outlined /></template>
  14. 新增
  15. </a-button>
  16. </a-space>
  17. </template>
  18. <template #bodyCell="{ column, record, index }">
  19. <template v-if="column.dataIndex === 'serial'">
  20. {{ index + 1 }}
  21. </template>
  22. <template v-if="column.dataIndex === 'action'">
  23. <a-space>
  24. <a @click="formRef.onOpen(record)" v-if="hasPerm('bizAppointmentTimeEdit')">编辑</a>
  25. <a-divider type="vertical" v-if="hasPerm(['bizAppointmentTimeEdit', 'bizAppointmentTimeDelete'], 'and')" />
  26. <a-button type="link" danger size="small" v-if="hasPerm('bizAppointmentTimeDelete')" @click="deleteConfig(record)">删除</a-button>
  27. </a-space>
  28. </template>
  29. <template v-if="column.dataIndex === 'appointment'">
  30. <span>{{record.beginTime+'~'+record.endTime}}</span>
  31. </template>
  32. <template v-if="column.dataIndex === 'applyNumberSurplus'">
  33. <span>{{record.applyNumber-record.applyNumberAlready}}</span>
  34. </template>
  35. </template>
  36. </s-table>
  37. </a-card>
  38. <Form ref="formRef" @successful="tableRef.refresh()" />
  39. </template>
  40. <script setup name="bizappointmenttime">
  41. import { cloneDeep } from 'lodash-es'
  42. import Form from './form.vue'
  43. import bizAppointmentTimeApi from '@/api/biz/bizAppointmentTimeApi'
  44. import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
  45. import {Modal} from 'ant-design-vue';
  46. import {createVNode} from 'vue';
  47. const tableRef = ref()
  48. const formRef = ref()
  49. const submitLoading = ref(false)
  50. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  51. const columns = [
  52. {
  53. title: '序号',
  54. width: 80,
  55. dataIndex: 'serial',
  56. align:'center'
  57. },
  58. {
  59. title: '预约时段',
  60. dataIndex: 'appointment',
  61. align:'center'
  62. },
  63. {
  64. title: '申请数量',
  65. dataIndex: 'applyNumber',
  66. align:'center'
  67. },
  68. {
  69. title: '已约数量',
  70. dataIndex: 'applyNumberAlready',
  71. align:'center'
  72. },
  73. {
  74. title: '可约数量',
  75. dataIndex: 'applyNumberSurplus',
  76. align:'center'
  77. },
  78. ]
  79. // 操作栏通过权限判断是否显示
  80. columns.push({
  81. title: '操作',
  82. dataIndex: 'action',
  83. align: 'center',
  84. width: 150
  85. })
  86. const selectedRowKeys = ref([])
  87. // 列表选择配置
  88. const options = {
  89. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  90. alert: {
  91. show: true,
  92. clear: () => {
  93. selectedRowKeys.value = ref([])
  94. }
  95. },
  96. rowSelection: {
  97. onChange: (selectedRowKey, selectedRows) => {
  98. selectedRowKeys.value = selectedRowKey
  99. }
  100. }
  101. }
  102. const loadData = (parameter) => {
  103. return bizAppointmentTimeApi.bizAppointmentTimePage(parameter).then((data) => {
  104. return data
  105. })
  106. }
  107. // 重置
  108. const reset = () => {
  109. searchFormRef.value.resetFields()
  110. tableRef.value.refresh(true)
  111. }
  112. // 删除
  113. const deleteBizAppointmentTime = (record) => {
  114. let params = [
  115. {
  116. id: record.id
  117. }
  118. ]
  119. bizAppointmentTimeApi.bizAppointmentTimeDelete(params).then(() => {
  120. tableRef.value.refresh(true)
  121. })
  122. }
  123. // 删除
  124. const deleteConfig = (record) => {
  125. Modal.confirm({
  126. title: '确定删除该数据吗?',
  127. icon: createVNode(ExclamationCircleOutlined),
  128. content: '',
  129. onOk() {
  130. submitLoading.value = true
  131. let params = [
  132. {
  133. id: record.id
  134. }
  135. ]
  136. bizAppointmentTimeApi
  137. .bizAppointmentTimeDelete(params)
  138. .then(() => {
  139. tableRef.value.refresh(true)
  140. })
  141. .finally(() => {
  142. submitLoading.value = false
  143. })
  144. },
  145. onCancel() {}
  146. })
  147. }
  148. // 批量删除
  149. const deleteBatchBizAppointmentTime = (params) => {
  150. bizAppointmentTimeApi.bizAppointmentTimeDelete(params).then(() => {
  151. tableRef.value.clearRefreshSelected()
  152. })
  153. }
  154. </script>