index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div>
  3. <!--引用表格-->
  4. <BasicTable @register="registerTable" :rowSelection="rowSelection">
  5. <!--插槽:table标题-->
  6. <template #tableTitle>
  7. <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
  8. </template>
  9. <!--操作栏-->
  10. <template #action="{ record }">
  11. <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
  12. </template>
  13. </BasicTable>
  14. <!-- 表单区域 -->
  15. <MerchantModel @register="registerModal" @success="handleSuccess"></MerchantModel>
  16. <UnionPayModel @register="registerUnplayModal" @success="handleSuccess"></UnionPayModel>
  17. </div>
  18. </template>
  19. <script lang="ts" setup>
  20. import { message, Switch } from 'ant-design-vue';
  21. import { ref, reactive, computed, unref } from 'vue';
  22. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  23. import { useModal } from '/@/components/Modal';
  24. import { useListPage } from '/@/hooks/system/useListPage';
  25. import MerchantModel from './components/MerchantModel.vue';
  26. import UnionPayModel from './components/UnionPayModel.vue';
  27. import { columns, searchFormSchema } from './Merchant.data';
  28. import { list, resetPassword, getDetaile } from './Merchant.api.';
  29. import { useUserStore } from '/@/store/modules/user';
  30. import { useMessage } from '/@/hooks/web/useMessage';
  31. const queryParam = reactive<any>({});
  32. const checkedKeys = ref<Array<string | number>>([]);
  33. const userStore = useUserStore();
  34. const { createMessage, createWarningModal } = useMessage();
  35. //注册model
  36. const [registerModal, { openModal }] = useModal();
  37. const [registerUnplayModal, { openModal: openUnPlayModal }] = useModal();
  38. //注册table数据
  39. const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
  40. tableProps: {
  41. title: 'Merchant',
  42. api: list,
  43. columns,
  44. canResize: false,
  45. formConfig: {
  46. //labelWidth: 120,
  47. schemas: searchFormSchema,
  48. autoSubmitOnEnter: true,
  49. showAdvancedButton: true,
  50. fieldMapToNumber: [],
  51. fieldMapToTime: [],
  52. },
  53. actionColumn: {
  54. width: 250,
  55. fixed: 'right',
  56. },
  57. beforeFetch: (params) => {
  58. return Object.assign(params, queryParam);
  59. },
  60. },
  61. });
  62. const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
  63. /**
  64. * 新增事件
  65. */
  66. function handleAdd() {
  67. openModal(true, {
  68. isUpdate: false,
  69. showFooter: true,
  70. });
  71. }
  72. /**
  73. * 编辑事件
  74. */
  75. async function handleEdit(record: Recordable) {
  76. const data = await getDetaile({ id: record.id });
  77. openModal(true, {
  78. data,
  79. isUpdate: true,
  80. showFooter: true,
  81. });
  82. }
  83. function handleUnplay(record: Recordable) {
  84. openUnPlayModal(true, {
  85. record,
  86. isUpdate: false,
  87. showFooter: false,
  88. });
  89. }
  90. /**
  91. * 成功回调
  92. */
  93. function handleSuccess() {
  94. (selectedRowKeys.value = []) && reload();
  95. }
  96. /**
  97. * 操作栏
  98. */
  99. function getTableAction(record) {
  100. return [
  101. {
  102. label: '编辑',
  103. onClick: handleEdit.bind(null, record),
  104. },
  105. {
  106. label: '银联账户',
  107. onClick: handleUnplay.bind(null, record),
  108. },
  109. {
  110. label: '重置密码',
  111. onClick: handleResetpassword.bind(null, record),
  112. },
  113. ];
  114. }
  115. async function handleResetpassword(record) {
  116. // await resetPassword({ id: record.id });
  117. createWarningModal({
  118. title: '安全提示',
  119. okText: '确认',
  120. cancelText: '取消',
  121. okCancel: true,
  122. content: `确认要重置该用户的密码吗?重置后的密码为:qlyd+用户后四位手机号。(qlyd${record.phone.slice(-4)})`,
  123. onOk: async () => {
  124. await resetPassword({ id: record.id });
  125. handleSuccess();
  126. },
  127. onCancel: () => {},
  128. });
  129. }
  130. /**
  131. * 下拉操作栏
  132. */
  133. function getDropDownAction(record) {
  134. return [];
  135. }
  136. </script>
  137. <style lang="less" scoped>
  138. :deep(.ant-picker),
  139. :deep(.ant-input-number) {
  140. width: 100%;
  141. }
  142. </style>