<template> <PageWrapper dense contentFullHeight fixedHeight contentClass="flex"> <!-- <DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" /> --> <BasicTable @register="registerTable" :searchInfo="searchInfo"> <template #toolbar> <a-button type="primary" @click="handleCreate">新增账号</a-button> </template> <template #bodyCell="{ column, record }"> <template v-if="column.key === 'action'"> <TableAction :actions="[ // { // icon: 'clarity:info-standard-line', // tooltip: '查看用户详情', // onClick: handleView.bind(null, record), // }, { label: '编辑', // tooltip: '编辑用户资料', onClick: handleEdit.bind(null, record), }, { label: '重置密码', // tooltip: '编辑用户资料', popConfirm: { title: '是否确认重置密码', placement: 'left', confirm: handleResetPassword.bind(null, record), }, }, { // icon: 'ant-design:delete-outlined', color: 'error', label: record.status === 10 ? '离职' : '启用', popConfirm: { title: record.status === 10 ? '是否确认离职该用户,离职用户无法通过忘记密码进行手机验证码修改密码。请管理员重置其账号密码并修改。' : '是否确认启用', placement: 'left', confirm: handleForbid.bind(null, record), }, }, { // icon: 'ant-design:delete-outlined', color: 'error', label: '删除', popConfirm: { title: '是否确认删除', placement: 'left', confirm: handleDelete.bind(null, record), }, }, ]" /> </template> </template> </BasicTable> <AccountModal @register="registerModal" @success="handleSuccess" /> </PageWrapper> </template> <script lang="ts"> import { defineComponent, reactive } from 'vue'; import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { getUserList, userAdd, userEdit, userOpt, userResetPassword, } from '/@/api/project/account'; import { PageWrapper } from '/@/components/Page'; import DeptTree from './DeptTree.vue'; import { useModal } from '/@/components/Modal'; import AccountModal from './AccountModal.vue'; import { columns, searchFormSchema } from './account.data'; import { useGo } from '/@/hooks/web/usePage'; export default defineComponent({ name: 'AccountManagement', components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction }, setup() { const go = useGo(); const [registerModal, { openModal }] = useModal(); const searchInfo = reactive({}); const [registerTable, { reload }] = useTable({ title: '账号列表', api: getUserList, rowKey: 'id', columns, formConfig: { labelWidth: 120, schemas: searchFormSchema, autoSubmitOnEnter: true, }, useSearchForm: true, showTableSetting: true, tableSetting: { setting: false, }, bordered: true, handleSearchInfoFn(info) { console.log('handleSearchInfoFn', info); return info; }, actionColumn: { width: 280, title: '操作', dataIndex: 'action', // slots: { customRender: 'action' }, }, }); function handleCreate() { openModal(true, { isUpdate: false, }); } function handleEdit(record) { console.log(record); openModal(true, { record, isUpdate: true, }); } async function handleDelete(record) { await userOpt({ ids: [record.id], optType: 20 }); reload(); } async function handleSuccess({ isUpdate, values }) { if (isUpdate) { await userEdit({ ...values }); } else { await userAdd({ ...values }); } reload(); } async function handleForbid(record) { await userOpt({ ids: [record.id], optType: record.status === 10 ? 30 : 10 }); reload(); } async function handleResetPassword(record) { await userResetPassword({ userId: record.id }); // reload(); } function handleSelect(deptId = '') { searchInfo.deptId = deptId; reload(); } function handleView(record) { go('/system/account_detail/' + record.id); } return { registerTable, registerModal, handleCreate, handleEdit, handleDelete, handleSuccess, handleSelect, handleView, handleForbid, handleResetPassword, searchInfo, }; }, }); </script>