index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <a-card :bordered="false">
  3. <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
  4. <a-row :gutter="24">
  5. <a-col :span="6">
  6. <a-form-item label="手机号" name="phone">
  7. <a-input v-model:value="searchFormState.phone" placeholder="请输入手机号" />
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="6">
  11. <a-form-item label="姓名" name="name">
  12. <a-input v-model:value="searchFormState.name" placeholder="请输入姓名" />
  13. </a-form-item>
  14. </a-col>
  15. <a-col :span="6">
  16. <a-button type="primary" @click="tableRef.refresh()">查询</a-button>
  17. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  18. </a-col>
  19. </a-row>
  20. </a-form>
  21. <s-table
  22. ref="tableRef"
  23. :columns="columns"
  24. :data="loadData"
  25. :alert="options.alert.show"
  26. bordered
  27. :row-key="(record) => record.id"
  28. :tool-config="toolConfig"
  29. :row-selection="options.rowSelection"
  30. >
  31. <template #operator class="table-operator">
  32. <a-space>
  33. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('bizVipOldAdd')">
  34. <template #icon><plus-outlined /></template>
  35. 新增
  36. </a-button>
  37. <xn-batch-button
  38. v-if="hasPerm('bizVipOldBatchDelete')"
  39. buttonName="批量删除"
  40. icon="DeleteOutlined"
  41. :selectedRowKeys="selectedRowKeys"
  42. @batchCallBack="deleteBatchBizVipOld"
  43. />
  44. </a-space>
  45. </template>
  46. <template #bodyCell="{ column, record }">
  47. <template v-if="column.dataIndex === 'action'">
  48. <a-space>
  49. <a @click="formRef.onOpen(record)" v-if="hasPerm('bizVipOldEdit')">编辑</a>
  50. <a-divider type="vertical" v-if="hasPerm(['bizVipOldEdit', 'bizVipOldDelete'], 'and')" />
  51. <a-popconfirm title="确定要删除吗?" @confirm="deleteBizVipOld(record)">
  52. <a-button type="link" danger size="small" v-if="hasPerm('bizVipOldDelete')">删除</a-button>
  53. </a-popconfirm>
  54. </a-space>
  55. </template>
  56. </template>
  57. </s-table>
  58. </a-card>
  59. <Form ref="formRef" @successful="tableRef.refresh()" />
  60. </template>
  61. <script setup name="vipold">
  62. import { cloneDeep } from 'lodash-es'
  63. import Form from './form.vue'
  64. import bizVipOldApi from '@/api/biz/bizVipOldApi'
  65. const searchFormState = ref({})
  66. const searchFormRef = ref()
  67. const tableRef = ref()
  68. const formRef = ref()
  69. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  70. const columns = [
  71. {
  72. title: '手机号',
  73. dataIndex: 'phone'
  74. },
  75. {
  76. title: '姓名',
  77. dataIndex: 'name'
  78. },
  79. {
  80. title: '余额',
  81. dataIndex: 'balance'
  82. },
  83. {
  84. title: '卡类型',
  85. dataIndex: 'cardType'
  86. },
  87. {
  88. title: '注册时间',
  89. dataIndex: 'cardTime'
  90. },
  91. {
  92. title: '说明',
  93. dataIndex: 'memo'
  94. },
  95. ]
  96. // 操作栏通过权限判断是否显示
  97. if (hasPerm(['bizVipOldEdit', 'bizVipOldDelete'])) {
  98. columns.push({
  99. title: '操作',
  100. dataIndex: 'action',
  101. align: 'center',
  102. width: 150
  103. })
  104. }
  105. const selectedRowKeys = ref([])
  106. // 列表选择配置
  107. const options = {
  108. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  109. alert: {
  110. show: true,
  111. clear: () => {
  112. selectedRowKeys.value = ref([])
  113. }
  114. },
  115. rowSelection: {
  116. onChange: (selectedRowKey, selectedRows) => {
  117. selectedRowKeys.value = selectedRowKey
  118. }
  119. }
  120. }
  121. const loadData = (parameter) => {
  122. const searchFormParam = cloneDeep(searchFormState.value)
  123. return bizVipOldApi.bizVipOldPage(Object.assign(parameter, searchFormParam)).then((data) => {
  124. return data
  125. })
  126. }
  127. // 重置
  128. const reset = () => {
  129. searchFormRef.value.resetFields()
  130. tableRef.value.refresh(true)
  131. }
  132. // 删除
  133. const deleteBizVipOld = (record) => {
  134. let params = [
  135. {
  136. id: record.id
  137. }
  138. ]
  139. bizVipOldApi.bizVipOldDelete(params).then(() => {
  140. tableRef.value.refresh(true)
  141. })
  142. }
  143. // 批量删除
  144. const deleteBatchBizVipOld = (params) => {
  145. bizVipOldApi.bizVipOldDelete(params).then(() => {
  146. tableRef.value.clearRefreshSelected()
  147. })
  148. }
  149. </script>