index.vue 6.4 KB

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