|  |  | 
 |  |  |           </QueryFilterItem> | 
 |  |  |         </template> | 
 |  |  |         <template #btn> | 
 |  |  |           <el-button | 
 |  |  |             v-if="checkSubModuleItemShow('pageButton', 'addBtn')" | 
 |  |  |             @click="openDialog()" | 
 |  |  |             icon="Plus" | 
 |  |  |             type="primary" | 
 |  |  |             >新增</el-button | 
 |  |  |           > | 
 |  |  |           <el-button @click="openDialog()" icon="Plus" type="primary">新增</el-button> | 
 |  |  |         </template> | 
 |  |  |       </ProTableQueryFilterBar> | 
 |  |  |       <ProTableV2 v-bind="proTableProps" :columns="column" :operationBtns="operationBtns"> | 
 |  |  | 
 |  |  | <script setup lang="ts"> | 
 |  |  | import { | 
 |  |  |   ProTableQueryFilterBar, | 
 |  |  |   OperationBtnType, | 
 |  |  |   ProTableV2, | 
 |  |  |   SearchInput, | 
 |  |  |   LoadingLayout, | 
 |  |  | 
 |  |  |   QueryFilterItem, | 
 |  |  |   useTable, | 
 |  |  |   useFormDialog, | 
 |  |  |   defineOperationBtns, | 
 |  |  | } from '@bole-core/components'; | 
 |  |  | import { useAccess } from '@/hooks'; | 
 |  |  | import * as userServices from '@/services/api/User'; | 
 |  |  | import { RoleClientType } from '@/constants'; | 
 |  |  | import * as accountServices from '@/services/api/Account'; | 
 |  |  | import { Message, OrderInputType } from '@bole-core/core'; | 
 |  |  | import AddOrEditAccountDialog from './components/AddOrEditAccountDialog.vue'; | 
 |  |  | import { formatRoleName } from '@/utils'; | 
 |  |  | 
 |  |  |   name: 'AccountManageList', | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | const operationBtnMap: Record<string, OperationBtnType> = { | 
 |  |  |   editBtn: { emits: { onClick: (role) => openDialog(role) } }, | 
 |  |  | }; | 
 |  |  | const column: API.CustomModuleColumnDto[] = [ | 
 |  |  |   { | 
 |  |  |     id: '1', | 
 |  |  |     enCode: 'changeFlag', | 
 |  |  |     name: '账号', | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     id: '2', | 
 |  |  |     enCode: 'name', | 
 |  |  |     name: '姓名', | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     id: '3', | 
 |  |  |     enCode: 'idNumber', | 
 |  |  |     name: '手机号', | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     id: '4', | 
 |  |  |     enCode: 'workType', | 
 |  |  |     name: '备注', | 
 |  |  |   }, | 
 |  |  | ]; | 
 |  |  |  | 
 |  |  | const { checkSubModuleItemShow, column, operationBtns } = useAccess({ | 
 |  |  |   operationBtnMap, | 
 |  |  | }); | 
 |  |  | const operationBtns = defineOperationBtns([ | 
 |  |  |   { | 
 |  |  |     data: { | 
 |  |  |       enCode: 'editBtn', | 
 |  |  |       name: '编辑', | 
 |  |  |     }, | 
 |  |  |     emits: { | 
 |  |  |       onClick: (role) => openDialog(role), | 
 |  |  |     }, | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     data: { | 
 |  |  |       enCode: 'resetPasswordBtn', | 
 |  |  |       name: '重置密码', | 
 |  |  |     }, | 
 |  |  |     emits: { | 
 |  |  |       onClick: (role) => handleResetPassword(), | 
 |  |  |     }, | 
 |  |  |   }, | 
 |  |  | ]); | 
 |  |  |  | 
 |  |  | const BaseState = { | 
 |  |  |   loading: true, | 
 |  |  | 
 |  |  |   reset, | 
 |  |  | } = useTable( | 
 |  |  |   async ({ pageIndex, pageSize }, extraParamState) => { | 
 |  |  |     try { | 
 |  |  |       let params: API.QueryUserPageInput = { | 
 |  |  |         pageModel: { | 
 |  |  |           rows: pageSize, | 
 |  |  |           page: pageIndex, | 
 |  |  |           orderInput: extraParamState.orderInput, | 
 |  |  |         }, | 
 |  |  |         searchKey: extraParamState.keyword, | 
 |  |  |       }; | 
 |  |  |       let res = await userServices.getUserPage(params, { | 
 |  |  |         showLoading: !state.loading, | 
 |  |  |       }); | 
 |  |  |       return res; | 
 |  |  |     } catch (error) {} | 
 |  |  |     // try { | 
 |  |  |     //   let params: API.QueryUserPageInput = { | 
 |  |  |     //     pageModel: { | 
 |  |  |     //       rows: pageSize, | 
 |  |  |     //       page: pageIndex, | 
 |  |  |     //       orderInput: extraParamState.orderInput, | 
 |  |  |     //     }, | 
 |  |  |     //     searchKey: extraParamState.keyword, | 
 |  |  |     //   }; | 
 |  |  |     //   let res = await userServices.getUserPage(params, { | 
 |  |  |     //     showLoading: !state.loading, | 
 |  |  |     //   }); | 
 |  |  |     //   return res; | 
 |  |  |     // } catch (error) {} | 
 |  |  |   }, | 
 |  |  |   { | 
 |  |  |     defaultExtraParams: { | 
 |  |  |       orderInput: [{ property: 'id', order: OrderInputType.Desc }], | 
 |  |  |       keyword: '', | 
 |  |  |     }, | 
 |  |  |     columnsRenderProps: { | 
 |  |  |       roleNames: { | 
 |  |  |         formatter: (row: API.UserListOutput) => row.roleNames.map(formatRoleName).join(','), | 
 |  |  |       }, | 
 |  |  |     }, | 
 |  |  |     columnsRenderProps: {}, | 
 |  |  |   } | 
 |  |  | ); | 
 |  |  |  | 
 |  |  | function openDialog(row?: API.UserListOutput) { | 
 |  |  | function openDialog(row?: any) { | 
 |  |  |   if (row) { | 
 |  |  |     handleEdit({ | 
 |  |  |       id: row.id, | 
 |  |  | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | async function handleAddOrEdit() { | 
 |  |  |   try { | 
 |  |  |     let isEdit = !!editForm.id; | 
 |  |  |     let params: API.CreateAccountInput = { | 
 |  |  |       name: editForm.name, | 
 |  |  |       userName: editForm.userName, | 
 |  |  |       remark: editForm.remark, | 
 |  |  |       password: editForm.password, | 
 |  |  |       phoneNumber: editForm.phoneNumber, | 
 |  |  |       channel: editForm.channel, | 
 |  |  |       // clientId: RoleClientType.RoleBackendClientId, | 
 |  |  |       roleNames: [editForm.roleName], | 
 |  |  |     }; | 
 |  |  |     let res; | 
 |  |  |     if (isEdit) { | 
 |  |  |       (params as API.UpdateAccountInput).id = editForm.id; | 
 |  |  |       res = await userServices.updateAccount(params); | 
 |  |  |     } else { | 
 |  |  |       res = await userServices.createAccount(params); | 
 |  |  |     } | 
 |  |  |     if (res) { | 
 |  |  |       Message.successMessage('操作成功'); | 
 |  |  |       getList(isEdit ? paginationState.pageIndex : 1); | 
 |  |  |     } | 
 |  |  |   } catch (error) {} | 
 |  |  |   // try { | 
 |  |  |   //   let isEdit = !!editForm.id; | 
 |  |  |   //   let params: API.CreateAccountInput = { | 
 |  |  |   //     name: editForm.name, | 
 |  |  |   //     userName: editForm.userName, | 
 |  |  |   //     remark: editForm.remark, | 
 |  |  |   //     password: editForm.password, | 
 |  |  |   //     phoneNumber: editForm.phoneNumber, | 
 |  |  |   //     channel: editForm.channel, | 
 |  |  |   //     // clientId: RoleClientType.RoleBackendClientId, | 
 |  |  |   //     roleNames: [editForm.roleName], | 
 |  |  |   //   }; | 
 |  |  |   //   let res; | 
 |  |  |   //   if (isEdit) { | 
 |  |  |   //     (params as API.UpdateAccountInput).id = editForm.id; | 
 |  |  |   //     res = await accountServices.updateAccount(params); | 
 |  |  |   //   } else { | 
 |  |  |   //     res = await accountServices.createAccount(params); | 
 |  |  |   //   } | 
 |  |  |   //   if (res) { | 
 |  |  |   //     Message.successMessage('操作成功'); | 
 |  |  |   //     getList(isEdit ? paginationState.pageIndex : 1); | 
 |  |  |   //   } | 
 |  |  |   // } catch (error) {} | 
 |  |  | } | 
 |  |  |  | 
 |  |  | function handleResetPassword() {} | 
 |  |  | </script> |