index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <!-- 客户资料 -->
  3. <mtp-table-scroll>
  4. <template #header>
  5. <Filter @search="search">
  6. <mtp-table-button class="btn-list-sticky" :buttons="addButton" @click="openComponent" />
  7. </Filter>
  8. </template>
  9. <template #default="{ scroll }">
  10. <a-table :columns="getColumns(columns)" class="srcollYTable" :scroll="scroll" :pagination="false" :loading="loading" :expandedRowKeys="expandedRowKeys" :customRow="Rowclick" :rowKey="(record,index)=>index" :data-source="tableList">
  11. <!-- 额外的展开行 -->
  12. <template #expandedRowRender="{ record }">
  13. <mtp-table-button class="btn-list-sticky" :buttons="handleBtnList(buttons,record)" :record="record" @click="openComponent" />
  14. </template>
  15. <template #status="{ text }">
  16. <a>{{ getStatusName(text) }}</a>
  17. </template>
  18. <template #customername="{record}">
  19. {{record.username}}
  20. </template>
  21. <template #birthday="{text}">
  22. {{text && text !== '--' ? formatTime(text, 'd') : '--'}}
  23. </template>
  24. <template #userinfotype="{ text }">
  25. <a>{{ getUserInfoTypeName(text) }}</a>
  26. </template>
  27. <!-- 客户简称 -->
  28. <template #nickname="{ record }">
  29. {{ record.userinfotype === 1 ? record.customername : record.nickname }}
  30. </template>
  31. <template #attachment1="{ text, record }">
  32. <a>{{ text }}</a><a>{{ record.attachment2 }}</a>
  33. </template>
  34. <template #cardtype="{ text }">
  35. <a>{{ getCardTypeEnumItemName(text) }}</a>
  36. </template>
  37. </a-table>
  38. </template>
  39. </mtp-table-scroll>
  40. <!-- 右键 -->
  41. <contextMenu :contextMenu="contextMenu" @cancel="closeContext" :list="buttons"> </contextMenu>
  42. <component :is="componentId" v-if="componentId" :selectedRow="selectedRow" @cancel="closeComponent"> </component>
  43. </template>
  44. <script lang="ts">
  45. import MtpTableScroll from '@/common/components/tableScroll/index.vue';
  46. import { BtnListType } from '@/common/components/btnList/interface';
  47. import { isPingAnOem, isQianHaiJin } from '@/common/config/projectName';
  48. import { EnumRouterName } from '@/common/constants/enumRouterName';
  49. import { getCardTypeEnumItemName, getStatusName, getUserInfoTypeName } from '@/common/constants/enumsName';
  50. import { ComposeTableParam, contextMenu, defineAsyncComponent, defineComponent, handleComposeTable, MtpTableButton, queryTableList, useRouteName } from '@/common/export/commonTable';
  51. import { formatTime } from '@/common/methods';
  52. import { ColumnType } from '@/common/methods/table';
  53. import { getTableButton } from '@/common/setup/table/button';
  54. import { getUserId } from '@/services/bus/user';
  55. import { queryCustomerInfo } from '@/services/go/ermcp/qhj';
  56. import { QhjCustomer } from '@/services/go/ermcp/qhj/interface';
  57. import Filter from './compoments/filterTable/index.vue';
  58. import { pingan_custom_column, qian_hai_jin_custom_column } from './setup';
  59. export default defineComponent({
  60. name: EnumRouterName.plan_audit,
  61. components: {
  62. MtpTableScroll,
  63. contextMenu,
  64. MtpTableButton,
  65. Filter,
  66. detail: defineAsyncComponent(() => import('./compoments/detail/index.vue')), // 详情
  67. add: defineAsyncComponent(() => import('./compoments/add/index.vue')), // 新增
  68. check: defineAsyncComponent(() => import('./compoments/check/index.vue')), // 审核
  69. delete: defineAsyncComponent(() => import('./compoments/delete/index.vue')), // 删除
  70. modify: defineAsyncComponent(() => import('./compoments/modify/index.vue')), // 修改
  71. recover: defineAsyncComponent(() => import('./compoments/recover/index.vue')), // 恢复
  72. disable: defineAsyncComponent(() => import('./compoments/disable/index.vue')), // 停用
  73. cancel: defineAsyncComponent(() => import('./compoments/cancel/index.vue')), // 撤销
  74. },
  75. setup() {
  76. const { isRouterName } = useRouteName();
  77. // 新增权限按钮
  78. const addButton = getTableButton(['add']);
  79. // 表格权限按钮
  80. const buttons = getTableButton(['add'], true);
  81. // 表格列表数据
  82. const { loading, tableList, queryTable } = queryTableList<QhjCustomer>();
  83. // 获取列表数据
  84. const queryTableAction = () => {
  85. const userid = getUserId();
  86. if (isRouterName('custom_unsubmit')) {
  87. // 未提交
  88. queryTable(queryCustomerInfo, { userid, querytype: 1, includesub: 1 });
  89. } else if (isRouterName('custom_checkpending')) {
  90. // 待审核
  91. queryTable(queryCustomerInfo, { userid, querytype: 2, includesub: 1 });
  92. } else if (isRouterName('custom_normal')) {
  93. // 正常
  94. queryTable(queryCustomerInfo, { userid, querytype: 3, includesub: 1 });
  95. } else if (isRouterName('custom_disabled')) {
  96. // 停用
  97. queryTable(queryCustomerInfo, { userid, querytype: 4, includesub: 1 });
  98. }
  99. };
  100. // 处理根据状态显示对应按钮
  101. const handleBtnList = (btnList: BtnListType[], item: QhjCustomer) => {
  102. switch (item.status) {
  103. case 2: // 待审核
  104. return btnList.filter((e) => e.code !== 'modify');
  105. case 5: // 拒绝审核
  106. return btnList.filter((e) => e.code !== 'check');
  107. default:
  108. return btnList;
  109. }
  110. };
  111. // 表头
  112. const getColumns = (columns: ColumnType[]) => {
  113. if (isPingAnOem()) {
  114. // 平安
  115. return pingan_custom_column();
  116. } else if (isQianHaiJin()) {
  117. // 千海金
  118. return qian_hai_jin_custom_column();
  119. } else {
  120. return columns;
  121. }
  122. };
  123. // 搜索
  124. function search() { }
  125. // 表格通用逻辑
  126. const param: ComposeTableParam = {
  127. queryFn: queryTableAction,
  128. menuType: EnumRouterName.plan_audit,
  129. tableName: 'table_pcweb_userinfo',
  130. tableFilterKey: ['userinfotype', 'nickname', 'customername', 'mobile'],
  131. isDetail: true,
  132. };
  133. return {
  134. ...handleComposeTable<QhjCustomer>(param),
  135. loading,
  136. tableList,
  137. getStatusName,
  138. buttons,
  139. addButton,
  140. getUserInfoTypeName,
  141. getCardTypeEnumItemName,
  142. getColumns,
  143. handleBtnList,
  144. formatTime,
  145. search,
  146. };
  147. },
  148. });
  149. </script>