diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index edf23b70..672d5c00 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -12,7 +12,7 @@ import { addDept, updateDept, listDeptExcludeChild, -} from '@/api/system/tenant'; +} from '@/api/system/dept'; import { parseDateToStr } from '@/utils/date-utils'; import { regExpMobile, regExpEmail } from '@/utils/regular-utils'; import useDictStore from '@/store/modules/dict'; @@ -33,7 +33,7 @@ let dict: { /**查询参数 */ let queryParams = reactive({ /**部门名称 */ - tenantName: '', + deptName: '', /**部门状态 */ status: undefined, }); @@ -41,14 +41,14 @@ let queryParams = reactive({ /**查询参数重置 */ function fnQueryReset() { queryParams = Object.assign(queryParams, { - tenantName: '', + deptName: '', status: undefined, }); fnGetList(); } /**表格全展开行key */ -let expandedRowKeys: any[] = []; +let expandedRowKeys: string[] = []; /**表格状态类型 */ type TabeStateType = { @@ -80,34 +80,21 @@ let tableState: TabeStateType = reactive({ let tableColumns: ColumnsType = [ { title: t('views.system.dept.className'), - dataIndex: 'tenantName', + dataIndex: 'deptName', align: 'left', width: 300, }, { - title: t('views.system.dept.key'), - dataIndex: 'tenancyKey', + title: t('views.system.dept.classId'), + dataIndex: 'deptId', align: 'left', - width: 200, + width: 150, }, { - title: t('views.system.dept.type'), - dataIndex: 'tenancyType', - key: 'tenancyType', - align: 'center', - width: 150, - customRender(opt) { - switch (opt.value) { - case 'SD-SST': - return t('views.system.dept.SDSST'); - case 'APN': - return t('views.system.dept.APN'); - case 'IMSI': - return t('views.system.dept.IMSI'); - default: - return ''; - } - }, + title: t('views.system.dept.classSort'), + dataIndex: 'orderNum', + align: 'left', + width: 200, }, { title: t('views.system.dept.status'), @@ -116,7 +103,6 @@ let tableColumns: ColumnsType = [ align: 'center', width: 150, }, - { title: t('views.system.dept.createTime'), dataIndex: 'createTime', @@ -129,19 +115,11 @@ let tableColumns: ColumnsType = [ }, { title: t('common.operate'), - key: 'tenantId', + key: 'deptId', align: 'left', }, ]; -const modalStateFromOption = reactive({ - tenantType: [ - { label: t('views.system.dept.SDSST'), value: 'SD-SST' }, - { label: t('views.system.dept.APN'), value: 'APN' }, - { label: t('views.system.dept.IMSI'), value: 'IMSI' }, - ], -}); - /**表格紧凑型变更操作 */ function fnTableSize({ key }: MenuInfo) { tableState.size = key as SizeType; @@ -182,17 +160,15 @@ let modalState: ModalStateType = reactive({ visibleByEdit: false, title: '部门', from: { - tenantId: undefined, - tenantName: '', + deptId: undefined, + deptName: '', email: '', leader: '', orderNum: 0, - parentId: '', + parentId: '100', ancestors: '', parentName: null, phone: '', - tenancyKey: '', - tenancyType: '', status: '0', }, confirmLoading: false, @@ -209,7 +185,7 @@ const modalStateFrom = Form.useForm( message: t('views.system.dept.highClass') + t('common.unableNull'), }, ], - tenantName: [ + deptName: [ { required: true, min: 1, @@ -217,35 +193,45 @@ const modalStateFrom = Form.useForm( message: t('views.system.dept.className') + t('common.unableNull'), }, ], + email: [ + { + required: false, + pattern: regExpEmail, + message: t('views.system.dept.emailTip'), + }, + ], + phone: [ + { + required: false, + pattern: regExpMobile, + message: t('views.system.dept.phoneTip'), + }, + ], }) ); /** * 对话框弹出显示为 查看 - * @param tenantId 部门编号id + * @param deptId 部门编号id */ -function fnModalVisibleByVive(tenantId: string | number) { - if (!tenantId) { +function fnModalVisibleByVive(deptId: string | number) { + if (!deptId) { message.error(t('common.getInfoFail'), 2); return; } if (modalState.confirmLoading) return; const hide = message.loading(t('common.loading'), 0); modalState.confirmLoading = true; - getDept(tenantId).then(res => { + getDept(deptId).then(res => { modalState.confirmLoading = false; hide(); if (res.code === RESULT_CODE_SUCCESS && res.data) { if (res.data.parentId === '0') { modalState.treeData = [ - { - tenantId: '0', - parentId: '0', - tenantName: t('views.system.dept.node'), - }, + { deptId: '0', parentId: '0', deptName: t('views.system.dept.node') }, ]; } else { - //modalState.treeData = treeDataAll; + modalState.treeData = treeDataAll; } modalState.from = Object.assign(modalState.from, res.data); modalState.title = t('views.system.dept.classInfo'); @@ -258,14 +244,14 @@ function fnModalVisibleByVive(tenantId: string | number) { /** * 对话框弹出显示为 新增或者修改 - * @param tenantId 部门编号id, 不传为新增 + * @param deptId 部门编号id, 不传为新增 * @param parentId 上级部门id */ function fnModalVisibleByEdit( - tenantId?: string | number, + deptId?: string | number, parentId?: string | number ) { - if (!tenantId) { + if (!deptId) { modalStateFrom.resetFields(); if (parentId) { modalState.from.parentId = parentId; @@ -278,7 +264,7 @@ function fnModalVisibleByEdit( const hide = message.loading(t('common.loading'), 0); modalState.confirmLoading = true; // 获取部门信息同时查询部门列表(排除节点) - Promise.all([getDept(tenantId), listDeptExcludeChild(tenantId)]) + Promise.all([getDept(deptId), listDeptExcludeChild(deptId)]) .then(resArr => { if (resArr[0].code === RESULT_CODE_SUCCESS && resArr[0].data) { modalState.from = Object.assign(modalState.from, resArr[0].data); @@ -289,13 +275,13 @@ function fnModalVisibleByEdit( if (resArr[1].data.length === 0) { modalState.treeData = [ { - tenantId: '0', + deptId: '0', parentId: '0', - tenantName: t('views.system.dept.node'), + deptName: t('views.system.dept.node'), }, ]; } else { - modalState.treeData = parseDataToTree(resArr[1].data, 'tenantId'); + modalState.treeData = parseDataToTree(resArr[1].data, 'deptId'); } } modalState.title = @@ -322,8 +308,7 @@ function fnModalOk() { .then(() => { modalState.confirmLoading = true; const from = toRaw(modalState.from); - console.log('from', from); - const dept = from.tenantId ? updateDept(from) : addDept(from); + const dept = from.deptId ? updateDept(from) : addDept(from); const hide = message.loading(t('common.loading'), 0); dept .then(res => { @@ -334,7 +319,7 @@ function fnModalOk() { }); modalState.visibleByEdit = false; // 新增时清空上级部门树重新获取 - if (!from.tenantId) { + if (!from.deptId) { treeDataAll = []; } modalStateFrom.resetFields(); @@ -368,15 +353,15 @@ function fnModalCancel() { /** * 部门删除 - * @param tenantId 部门编号id + * @param deptId 部门编号id */ -function fnRecordDelete(tenantId: string | number) { +function fnRecordDelete(deptId: string | number) { Modal.confirm({ title: t('common.tipTitle'), - content: t('views.system.dept.delSure', { tenantId: tenantId }), + content: t('views.system.dept.delSure', { deptId: deptId }), onOk() { const hide = message.loading(t('common.loading'), 0); - delDept(tenantId).then(res => { + delDept(deptId).then(res => { hide(); if (res.code === RESULT_CODE_SUCCESS) { message.success({ @@ -401,16 +386,13 @@ function fnGetList() { tableState.loading = true; listDept(toRaw(queryParams)).then(res => { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { - // 转换树状数据 - const treeData = parseDataToTree(res.data, 'tenantId'); + const treeData = parseDataToTree(res.data, 'deptId'); // 初始上级部门和展开编号key if (treeDataAll.length <= 0) { // 转换树状数据 treeDataAll = treeData; // 展开编号key - expandedRowKeys = [ - ...new Set(res.data.map((item: any) => item.parentId)), - ]; + expandedRowKeys = [...new Set(res.data.map(item => item.parentId))]; fnTableExpandedRowsAll(tableState.expandedRowAll); } tableState.data = treeData; @@ -444,10 +426,10 @@ onMounted(() => { @@ -552,7 +534,7 @@ onMounted(() => { { -