index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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('bizSettleAdd')">
  13. <template #icon><plus-outlined /></template>
  14. 新增
  15. </a-button>
  16. </a-space>
  17. </template>
  18. <template #bodyCell="{ column, record }">
  19. <template v-if="column.dataIndex === 'action'">
  20. <a-space>
  21. <a @click="formRef.onOpen(record)" v-if="hasPerm('bizSettleEdit')">编辑</a>
  22. <a-divider type="vertical" v-if="hasPerm(['bizSettleEdit', 'bizSettleDelete'], 'and')" />
  23. <a style="color:red" size="small" type="link" @click="deleteConfig(record)">删除</a>
  24. </a-space>
  25. </template>
  26. </template>
  27. </s-table>
  28. </a-card>
  29. <Form ref="formRef" @successful="tableRef.refresh()" />
  30. </template>
  31. <script setup name="bizsettle">
  32. import { cloneDeep } from 'lodash-es'
  33. import Form from './form.vue'
  34. import bizSettleApi from '@/api/biz/bizSettleApi'
  35. import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
  36. import {Modal} from 'ant-design-vue';
  37. import {createVNode} from 'vue';
  38. const submitLoading = ref(false)
  39. const tableRef = ref()
  40. const formRef = ref()
  41. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  42. const columns = [
  43. {
  44. title: '结算单号',
  45. dataIndex: 'settleNo',
  46. align:'center',
  47. },
  48. {
  49. title: '结算类型',
  50. dataIndex: 'settleType',
  51. align:'center',
  52. },
  53. {
  54. title: '结算金额',
  55. dataIndex: 'settleAccount',
  56. align:'center',
  57. },
  58. {
  59. title: '创建日期',
  60. dataIndex: 'createTime',
  61. align:'center',
  62. }
  63. ]
  64. // 操作栏通过权限判断是否显示
  65. columns.push({
  66. title: '操作',
  67. dataIndex: 'action',
  68. align: 'center',
  69. width: 150
  70. })
  71. const selectedRowKeys = ref([])
  72. // 列表选择配置
  73. const options = {
  74. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  75. alert: {
  76. show: true,
  77. clear: () => {
  78. selectedRowKeys.value = ref([])
  79. }
  80. },
  81. rowSelection: {
  82. onChange: (selectedRowKey, selectedRows) => {
  83. selectedRowKeys.value = selectedRowKey
  84. }
  85. }
  86. }
  87. const loadData = (parameter) => {
  88. return bizSettleApi.bizSettlePage(parameter).then((data) => {
  89. return data
  90. })
  91. }
  92. // 重置
  93. const reset = () => {
  94. searchFormRef.value.resetFields()
  95. tableRef.value.refresh(true)
  96. }
  97. // 删除
  98. const deleteBizSettle = (record) => {
  99. let params = [
  100. {
  101. id: record.id
  102. }
  103. ]
  104. bizSettleApi.bizSettleDelete(params).then(() => {
  105. tableRef.value.refresh(true)
  106. })
  107. }
  108. // 删除
  109. const deleteConfig = (record) => {
  110. Modal.confirm({
  111. title: '确定删除该数据吗?',
  112. icon: createVNode(ExclamationCircleOutlined),
  113. content: '',
  114. onOk() {
  115. submitLoading.value = true
  116. let params = [
  117. {
  118. id: record.id
  119. }
  120. ]
  121. bizSettleApi
  122. .bizSettleDelete(params)
  123. .then(() => {
  124. tableRef.value.refresh(true)
  125. })
  126. .finally(() => {
  127. submitLoading.value = false
  128. })
  129. },
  130. onCancel() {}
  131. })
  132. }
  133. // 批量删除
  134. const deleteBatchBizSettle = (params) => {
  135. bizSettleApi.bizSettleDelete(params).then(() => {
  136. tableRef.value.clearRefreshSelected()
  137. })
  138. }
  139. </script>