| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <template>
- <div class="p-4">
- <div class="account-body">
- <BasicTable @register="registerTable" class="basic-table">
- <template #toolbar>
- <Button type="primary" @click="handleAdd">
- 新增
- </Button>
- <!-- 接口不支持多选后统一绑定角色,所以暂时隐藏 -->
- <!-- <Button type="primary" @click="handlePermissionEdit">
- 角色绑定
- </Button> -->
- </template>
- <template #SEX="{ record }">
- <span>{{ record.SEX ? '男' : '女' }}</span>
- </template>
- <template #action="{ record }">
- <TableAction :actions="[
- {
- label: '编辑',
- tooltip: '编辑',
- onClick: handleEdit.bind(null, record),
- },
- {
- label: '删除',
- tooltip: '删除',
- color: 'error',
- onClick: handleDelete.bind(null, record),
- },
- ]" />
- </template>
- </BasicTable>
- </div>
- <AccountModal1 @register="registerModal" @onSubmit="onSubmit" />
- </div>
- </template>
- <script>
- import { defineComponent, reactive, ref, toRefs, computed, onMounted, watch, createVNode } from 'vue';
- // 导入表格组件,表格事件
- import { BasicTable, useTable, TableAction } from '/@/components/Table';
- import AccountModal1 from './AccountModal1.vue';
- // 操作用户数据api
- import { deleteUser, getAccountList } from '/@/api/system/system';
- import { useModal } from '/@/components/Modal';
- import { FormOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue';
- import moment from 'moment';
- import { Button, Modal, message } from 'ant-design-vue';
- import { getUserInfoByLoginCode } from '/@/api/system/system';
- import { getUserIdInfo } from '/@/api/sys/user';
- import { session } from '/@/utils/Memory';
- export default defineComponent({
- name: 'account',
- components: { BasicTable, TableAction, Button, AccountModal1, ExclamationCircleOutlined },
- setup() {
- const [registerModal, { openModal }] = useModal();
- const getAllData = () => {
- return new Promise((resolve) => {
- let params = {
- keyStr: '',
- page: 1,
- pageSize: 100000000,
- }
- getAccountList(params).then(res => {
- if (res.items?.length) {
- resolve(res.items)
- } else {
- message.info('未查询到用户数据')
- resolve([])
- }
- })
- })
- }
- const columns = [
- {
- title: '用户姓名',
- dataIndex: 'NAME',
- align: 'center'
- },
- {
- title: '登录名',
- dataIndex: 'LOGIN_NAME',
- align: 'center'
- },
- // {
- // title: '用户ID',
- // dataIndex: 'EMPLOYEE_ID',
- // align: 'center'
- // },
- {
- title: '性别',
- dataIndex: 'SEX',
- align: 'center',
- slots: { customRender: 'SEX' },
- },
- ]
- //注册表格
- const [
- registerTable,
- { reload },
- ] = useTable({
- title: '用户列表', //'菜单列表'
- api: getAllData, //加载数据
- // dataSource: [],
- columns: columns,
- useSearchForm: false, //开启搜索区域
- bordered: true,
- striped: false,
- showTableSetting: true, // 显示表格设置
- tableSetting: {
- redo: true,
- size: true,
- setting: false,
- fullScreen: false
- },
- canResize: false,
- showIndexColumn: true,
- pagination: {
- // pageSize: 10,
- hideOnSinglePage: false
- },
- actionColumn: {
- width: 100,
- title: '操作',
- dataIndex: 'action',
- slots: { customRender: 'action' },
- },
- // rowSelection: {
- // type: 'checkbox',
- // },
- });
- const formData = ref(null)
- const modalTitle = ref('新增用户')
- //绑定权限
- const handlePermissionEdit = () => {
- }
- // 新增
- const handleAdd = () => {
- formData.value = {
- loginName: "",
- userName: "",
- pwd: '',
- mobile: "",
- sex: '0',
- sszw: "",
- ssgw: "",
- userjs: [],
- userid: ""
- }
- openModal(true, {
- status:'add',
- title: '新增用户',
- form: {
- loginName: "",
- userName: "",
- pwd: '',
- mobile: "",
- sex: '0',
- sszw: "",
- ssgw: "",
- userjs: [],
- userid: ""
- }
- })
- }
- // 编辑
- const handleEdit = (record) => {
- getUserInfoByLoginCode(record.LOGIN_NAME).then(res => {
- if (res.user?.userid) {
- getUserIdInfo(res.user.userid).then(roleRes => {
- //组合信息传给修改弹窗
- formData.value = {
- loginName: res.user.loginName,
- userName: res.user.userName,
- pwd: "",
- mobile: res.user.mobile,
- sex: res.user.sex,
- ssjg: res.department[0]?.departid || '',
- sszw: res.zw[0]?.departid || '',
- ssgw: res.gw[0]?.id || '',
- userjsArr: roleRes,
- userjs: roleRes.join(';'),
- userid: res.user.userid
- }
- openModal(true, {
- title: '修改用户',
- status:'edit',
- form: {
- loginName: res.user.loginName,
- userName: res.user.userName,
- pwd: "",
- mobile: res.user.mobile,
- sex: res.user.sex,
- ssjg: res.department[0]?.departid || '',
- sszw: res.zw[0]?.departid || '',
- ssgw: res.gw[0]?.id || '',
- userjsArr: roleRes,
- userjs: roleRes.join(';'),
- userid: res.user.userid
- }
- })
- })
- } else {
- message.error('用户信息查询失败')
- }
- })
- }
- // 删除
- const handleDelete = (record) => {
- if (record.EMPLOYEE_ID === session.getItem('userId')) {
- message.error('不能删除当前登录用户');
- return;
- }
- Modal.confirm({
- title: '提示',
- icon: createVNode(ExclamationCircleOutlined),
- content: '确定删除该用户数据?',
- centered: true,
- okText: '确定',
- okType: 'danger',
- cancelText: '取消',
- onOk: (() => {
- deleteUser(record.EMPLOYEE_ID).then(res => {
- reload();
- })
- })
- });
- }
- //新增或修改的提交
- const onSubmit = () => {
- reload();
- }
- return {
- formData,
- registerTable,
- handlePermissionEdit,
- registerModal,
- handleAdd,
- handleEdit,
- handleDelete,
- onSubmit
- };
- },
- });
- </script>
- <style lang="less" scoped>
- .p-4 {
- height: 100%;
- .account-body {
- padding: 0 20px;
- width: 100%;
- height: 100%;
- background-color: #fff;
- .basic-table {
- height: 100%;
- ::v-deep .ant-table-title {
- padding: 0 !important;
- .vben-basic-title {
- font-family: '阿里巴巴普惠体 2.0';
- font-size: 16px;
- font-weight: bold;
- color: #333333;
- }
- }
- }
- }
- }
- </style>
|