index.js 4.53 KB
// 搜索model
export const listQuery = {
    'name': '',
    'statusList': '',
    'includeChild': true
};

// 搜索表单配置
export const searchConfig = function() {
    return {
        list: [
            {
                type: 'input',
                label: '关键字',
                model: 'name',
                options: {
                    placeholder: '用户名/姓名/手机号码'
                }
            },
            {
                type: 'select',
                label: '状态',
                model: 'statusList',
                options: {
                    options: this.$enums.USER_STATUS.values()
                }
            }
        ],
        config: {
            onSearch: data => {
                this.handleSubmit();
            },
            model: this.listQuery
        }
    };
};

// 表格展示配置
export const tableColumns = function() {
    return [
        {
            type: 'checkbox',
            fixed: 'left'
        },
        {
            field: 'name',
            text: '姓名',
            minWidth: 100,
            render: (h, param) => {
                return h('QgButton', {
                    props: {},
                    on: {
                        click: () => {
                            // 查看
                            this.$router.push({
                                path: `/uc/user/view`,
                                query: {id: param.row.id}
                            });
                        }
                    }
                }, param.row.name);
            }
        },
        {
            field: 'loginName',
            text: '用户名',
            minWidth: 120
        },
        {
            type: 'mobile',
            field: 'mobile',
            text: '手机号码',
            minWidth: 120
        },
        {
            field: 'orgName',
            text: '部门',
            minWidth: 160
        },
        {
            field: 'status',
            text: '状态',
            render: (h, param) => {
                return this.$enums.USER_STATUS.getText(param.row.status);
            }
        },
        {
            field: 'opt',
            fixed: 'right',
            text: '操作',
            width: 110,
            render: (h, param) => {
                const row = param.row;
                const optArr = [];
                const editBtn = h('QgButton', {
                    props: {
                        toolTip: '编辑',
                        type: 'text',
                        icon: 'el-icon-edit'
                    },
                    on: {
                        click: () => {
                            // 编辑
                            this.handleOpt('edit', row);
                        }
                    }
                });
                const restPwdBtn = h('QgButton', {
                    props: {
                        toolTip: '重置密码',
                        type: 'text',
                        icon: 'rest_pwd'
                    },
                    on: {
                        click: () => {
                            this.handleOpt('resetPwd', [row.id]);
                        }
                    }
                });

                const enableBtn = h('QgButton', {
                    props: {
                        toolTip: '启用',
                        type: 'text',
                        icon: 'enable'
                    },
                    on: {
                        click: () => {
                            this.handleOpt('enable', [row.id]);
                        }
                    }
                });
                const disableBtn = h('QgButton', {
                    props: {
                        toolTip: '停用',
                        type: 'text',
                        icon: 'disable'
                    },
                    on: {
                        click: () => {
                            this.handleOpt('disable', [row.id]);
                        }
                    }
                });
                // 超级管理员 只能修改密码
                if (row.code === 'admin') {
                    return h('div', [restPwdBtn], '');
                }
                optArr.push(editBtn);
                optArr.push(restPwdBtn);
                if (row.status === this.$enums.USER_STATUS.ENABLED.key) {
                    optArr.push(disableBtn);
                } else {
                    optArr.push(enableBtn);
                }
                return h('div', optArr, '');
            }
        }
    ];
};