CuspCustomerProfileList.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <div>
  3. <!--引用表格-->
  4. <BasicTable @register="registerTable" :rowSelection="rowSelection" size="small">
  5. <!--插槽:table标题-->
  6. <template #tableTitle>
  7. <a-button type="primary" v-auth="'cuspCode:cusp_customer_profile:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增(add)</a-button>
  8. <a-button type="primary" v-auth="'cuspCode:cusp_customer_profile:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出(export)</a-button>
  9. <!-- <j-upload-button type="primary" v-auth="'cuspCode:cusp_customer_profile:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> -->
  10. <a-dropdown v-if="selectedRowKeys.length > 0">
  11. <template #overlay>
  12. <a-menu>
  13. <a-menu-item key="1" @click="batchHandleDelete">
  14. <Icon icon="ant-design:delete-outlined"></Icon>
  15. 删除(delete)
  16. </a-menu-item>
  17. </a-menu>
  18. </template>
  19. <a-button v-auth="'cuspCode:cusp_customer_profile:deleteBatch'">批量操作(batch operation)
  20. <Icon icon="mdi:chevron-down"></Icon>
  21. </a-button>
  22. </a-dropdown>
  23. <!-- 高级查询 -->
  24. <!-- <super-query :config="superQueryConfig" @search="handleSuperQuery" /> -->
  25. </template>
  26. <!--操作栏-->
  27. <template #action="{ record }">
  28. <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
  29. </template>
  30. <!--字段回显插槽-->
  31. <template v-slot:bodyCell="{ column, record, index, text }">
  32. </template>
  33. </BasicTable>
  34. <!-- 表单区域 -->
  35. <CuspCustomerProfileModal @register="registerModal" @success="handleSuccess"></CuspCustomerProfileModal>
  36. </div>
  37. </template>
  38. <script lang="ts" name="cuspCode-cuspCustomerProfile" setup>
  39. import {ref, reactive, computed, unref,onMounted} from 'vue';
  40. import {BasicTable, useTable, TableAction} from '/@/components/Table';
  41. import { useListPage } from '/@/hooks/system/useListPage'
  42. import {useModal} from '/@/components/Modal';
  43. import CuspCustomerProfileModal from './components/CuspCustomerProfileModal.vue'
  44. import {columns, searchFormSchema, superQuerySchema,getIntermediatorOptions} from './CuspCustomerProfile.data';
  45. import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CuspCustomerProfile.api';
  46. import {downloadFile} from '/@/utils/common/renderUtils';
  47. import { useUserStore } from '/@/store/modules/user';
  48. const queryParam = reactive<any>({});
  49. const checkedKeys = ref<Array<string | number>>([]);
  50. const userStore = useUserStore();
  51. //注册model
  52. const [registerModal, {openModal}] = useModal();
  53. //注册table数据
  54. const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
  55. tableProps:{
  56. title: '客户档案',
  57. api: list,
  58. columns,
  59. canResize:false,
  60. formConfig: {
  61. //labelWidth: 120,
  62. schemas: searchFormSchema,
  63. autoSubmitOnEnter:true,
  64. showAdvancedButton:true,
  65. fieldMapToNumber: [
  66. ],
  67. fieldMapToTime: [
  68. ],
  69. },
  70. actionColumn: {
  71. width: 200,
  72. fixed:'right'
  73. },
  74. beforeFetch: (params) => {
  75. return Object.assign(params, queryParam);
  76. },
  77. },
  78. exportConfig: {
  79. name:"客户档案",
  80. url: getExportUrl,
  81. params: queryParam,
  82. },
  83. importConfig: {
  84. url: getImportUrl,
  85. success: handleSuccess
  86. },
  87. })
  88. const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
  89. onMounted(() => {
  90. getIntermediatorOptions()
  91. })
  92. // 高级查询配置
  93. const superQueryConfig = reactive(superQuerySchema);
  94. /**
  95. * 高级查询事件
  96. */
  97. function handleSuperQuery(params) {
  98. Object.keys(params).map((k) => {
  99. queryParam[k] = params[k];
  100. });
  101. reload();
  102. }
  103. /**
  104. * 新增事件
  105. */
  106. function handleAdd() {
  107. openModal(true, {
  108. isUpdate: false,
  109. showFooter: true,
  110. });
  111. }
  112. /**
  113. * 编辑事件
  114. */
  115. function handleEdit(record: Recordable) {
  116. openModal(true, {
  117. record,
  118. isUpdate: true,
  119. showFooter: true,
  120. });
  121. }
  122. /**
  123. * 详情
  124. */
  125. function handleDetail(record: Recordable) {
  126. openModal(true, {
  127. record,
  128. isUpdate: true,
  129. showFooter: false,
  130. });
  131. }
  132. /**
  133. * 删除事件
  134. */
  135. async function handleDelete(record) {
  136. await deleteOne({id: record.id}, handleSuccess);
  137. }
  138. /**
  139. * 批量删除事件
  140. */
  141. async function batchHandleDelete() {
  142. await batchDelete({ids: selectedRowKeys.value},handleSuccess);
  143. }
  144. /**
  145. * 成功回调
  146. */
  147. function handleSuccess() {
  148. (selectedRowKeys.value = []) && reload();
  149. }
  150. /**
  151. * 操作栏
  152. */
  153. function getTableAction(record){
  154. return [
  155. {
  156. label: '编辑(edit)',
  157. onClick: handleEdit.bind(null, record),
  158. auth: 'cuspCode:cusp_customer_profile:edit'
  159. }
  160. ]
  161. }
  162. /**
  163. * 下拉操作栏
  164. */
  165. function getDropDownAction(record){
  166. return [
  167. {
  168. label: '详情(detail)',
  169. onClick: handleDetail.bind(null, record),
  170. }, {
  171. label: '删除(delete)',
  172. popConfirm: {
  173. title: '是否确认删除(Are you sure to delete)',
  174. confirm: handleDelete.bind(null, record),
  175. placement: 'topLeft'
  176. },
  177. auth: 'cuspCode:cusp_customer_profile:delete'
  178. }
  179. ]
  180. }
  181. </script>
  182. <style lang="less" scoped>
  183. :deep(.ant-picker),:deep(.ant-input-number){
  184. width: 100%;
  185. }
  186. </style>