import { BasicColumn } from '/@/components/Table'; import { FormSchema } from '/@/components/Table'; import { h } from 'vue'; import { Switch } from 'ant-design-vue'; import { Time } from '/@/components/Time'; import { getAllRoleList } from '/@/api/sys/system' import { saveRoleApi } from '/@/api/sys/system'; // import { ListAllCompanyApi } from '/@/api/corporation/list'; import { useMessage } from '/@/hooks/web/useMessage'; import { useI18n } from '/@/hooks/web/useI18n'; const { t } = useI18n(); const { createMessage } = useMessage(); export const columns: BasicColumn[] = [ // { // title: 'ID', // dataIndex: 'id', // width: 80, // }, { title: t('common.roleNameText'), dataIndex: 'roleName', width: 200, }, { title: t('routes.system.description'), dataIndex: 'description', width: 180, }, { title: '系统用户数', dataIndex: 'adminCount', width: 100, customRender: ({ record }) => { return record.adminCount || 0; }, }, { title: '创建人', dataIndex: 'createUserName', width: 100, }, { title: t('routes.staff.createTime'), dataIndex: 'createTime', width: 180, customRender: ({ record }) => { return h(Time, { value: record.createTime, mode: 'datetime', }); }, }, { title: '状态', dataIndex: 'status', width: 80, customRender: ({ record }) => { if (!Reflect.has(record, 'pendingStatus')) { record.pendingStatus = false; } return h(Switch, { checked: record.status === 1, disabled:record.id === 1, checkedChildren: '启用', unCheckedChildren: '禁用', loading: false, onChange: async (checked: boolean) => { record.pendingStatus = true; const newStatus = checked ? 1 : 0; Reflect.set(record, 'status', newStatus); await saveRoleApi({ ...record, isShow: newStatus }); createMessage.success(t('common.optSuccess')); // reload() }, }); }, }, // { // title: t('routes.system.remarks'), // dataIndex: 'remark', // }, ]; export const searchFormSchema: FormSchema[] = [ { field: 'roleName', label: t('common.roleNameText'), component: 'Input', componentProps: { maxLength: 100, }, colProps: { span: 8 }, }, // { // field: 'canShow', // label: '状态', // component: 'Select', // componentProps: { // options: [ // { label: '启用', value: '0' }, // { label: '停用', value: '1' }, // ], // }, // colProps: { span: 8 }, // }, ]; export const formSchema: FormSchema[] = [ { label: '', field: 'id', component: 'Input', show:false, }, { field: 'roleName', label: t('common.roleNameText'), required: true, component: 'Input', componentProps:{ maxLength: 15, } }, // { // field: 'companyId', // label: t('routes.staff.companyId'), // component: 'ApiSelect', // // required: true, // itemProps: { // validateTrigger: 'blur', // }, // componentProps: { // api: getAllRoleList, // resultField: 'data', // labelField: 'roleName', // valueField: 'id', // immediate: true, // onChange: function () { // // Reflect.set(modalRecord, 'shippingName', opt.label); // }, // params: { // page: 1, // limit: 1000, // }, // required: true, // }, // }, // { // field: 'canShow', // label: '状态', // component: 'RadioButtonGroup', // defaultValue: 0, // componentProps: { // options: [ // { label: '启用', value: 0 }, // { label: '停用', value: 1 }, // ], // }, // }, // { // field: 'status', // label: t('routes.system.isPlatformRole'), // component: 'RadioButtonGroup', // defaultValue: 1, // componentProps: { // options: [ // { label: '启用', value: 1 }, // { label: '禁用', value: 0 }, // ], // }, // }, { label: t('routes.system.description'), field: 'description', component: 'InputTextArea', required: true, componentProps:{ rows:4, maxLength: 200, } }, // { // label: ' ', // field: 'menuIdList', // slot: 'menu', // component: 'Input', // }, // { // label: ' ', // field: 'deptIdList', // slot: 'dept', // component: 'Input', // }, ];