部门管理代码还原

This commit is contained in:
lai
2024-06-18 18:31:41 +08:00
parent 197a962c0d
commit 1aa2f2382a

View File

@@ -12,7 +12,7 @@ import {
addDept, addDept,
updateDept, updateDept,
listDeptExcludeChild, listDeptExcludeChild,
} from '@/api/system/tenant'; } from '@/api/system/dept';
import { parseDateToStr } from '@/utils/date-utils'; import { parseDateToStr } from '@/utils/date-utils';
import { regExpMobile, regExpEmail } from '@/utils/regular-utils'; import { regExpMobile, regExpEmail } from '@/utils/regular-utils';
import useDictStore from '@/store/modules/dict'; import useDictStore from '@/store/modules/dict';
@@ -33,7 +33,7 @@ let dict: {
/**查询参数 */ /**查询参数 */
let queryParams = reactive({ let queryParams = reactive({
/**部门名称 */ /**部门名称 */
tenantName: '', deptName: '',
/**部门状态 */ /**部门状态 */
status: undefined, status: undefined,
}); });
@@ -41,14 +41,14 @@ let queryParams = reactive({
/**查询参数重置 */ /**查询参数重置 */
function fnQueryReset() { function fnQueryReset() {
queryParams = Object.assign(queryParams, { queryParams = Object.assign(queryParams, {
tenantName: '', deptName: '',
status: undefined, status: undefined,
}); });
fnGetList(); fnGetList();
} }
/**表格全展开行key */ /**表格全展开行key */
let expandedRowKeys: any[] = []; let expandedRowKeys: string[] = [];
/**表格状态类型 */ /**表格状态类型 */
type TabeStateType = { type TabeStateType = {
@@ -80,34 +80,21 @@ let tableState: TabeStateType = reactive({
let tableColumns: ColumnsType = [ let tableColumns: ColumnsType = [
{ {
title: t('views.system.dept.className'), title: t('views.system.dept.className'),
dataIndex: 'tenantName', dataIndex: 'deptName',
align: 'left', align: 'left',
width: 300, width: 300,
}, },
{ {
title: t('views.system.dept.key'), title: t('views.system.dept.classId'),
dataIndex: 'tenancyKey', dataIndex: 'deptId',
align: 'left', align: 'left',
width: 200, width: 150,
}, },
{ {
title: t('views.system.dept.type'), title: t('views.system.dept.classSort'),
dataIndex: 'tenancyType', dataIndex: 'orderNum',
key: 'tenancyType', align: 'left',
align: 'center', width: 200,
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.status'), title: t('views.system.dept.status'),
@@ -116,7 +103,6 @@ let tableColumns: ColumnsType = [
align: 'center', align: 'center',
width: 150, width: 150,
}, },
{ {
title: t('views.system.dept.createTime'), title: t('views.system.dept.createTime'),
dataIndex: 'createTime', dataIndex: 'createTime',
@@ -129,19 +115,11 @@ let tableColumns: ColumnsType = [
}, },
{ {
title: t('common.operate'), title: t('common.operate'),
key: 'tenantId', key: 'deptId',
align: 'left', 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) { function fnTableSize({ key }: MenuInfo) {
tableState.size = key as SizeType; tableState.size = key as SizeType;
@@ -182,17 +160,15 @@ let modalState: ModalStateType = reactive({
visibleByEdit: false, visibleByEdit: false,
title: '部门', title: '部门',
from: { from: {
tenantId: undefined, deptId: undefined,
tenantName: '', deptName: '',
email: '', email: '',
leader: '', leader: '',
orderNum: 0, orderNum: 0,
parentId: '', parentId: '100',
ancestors: '', ancestors: '',
parentName: null, parentName: null,
phone: '', phone: '',
tenancyKey: '',
tenancyType: '',
status: '0', status: '0',
}, },
confirmLoading: false, confirmLoading: false,
@@ -209,7 +185,7 @@ const modalStateFrom = Form.useForm(
message: t('views.system.dept.highClass') + t('common.unableNull'), message: t('views.system.dept.highClass') + t('common.unableNull'),
}, },
], ],
tenantName: [ deptName: [
{ {
required: true, required: true,
min: 1, min: 1,
@@ -217,35 +193,45 @@ const modalStateFrom = Form.useForm(
message: t('views.system.dept.className') + t('common.unableNull'), 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) { function fnModalVisibleByVive(deptId: string | number) {
if (!tenantId) { if (!deptId) {
message.error(t('common.getInfoFail'), 2); message.error(t('common.getInfoFail'), 2);
return; return;
} }
if (modalState.confirmLoading) return; if (modalState.confirmLoading) return;
const hide = message.loading(t('common.loading'), 0); const hide = message.loading(t('common.loading'), 0);
modalState.confirmLoading = true; modalState.confirmLoading = true;
getDept(tenantId).then(res => { getDept(deptId).then(res => {
modalState.confirmLoading = false; modalState.confirmLoading = false;
hide(); hide();
if (res.code === RESULT_CODE_SUCCESS && res.data) { if (res.code === RESULT_CODE_SUCCESS && res.data) {
if (res.data.parentId === '0') { if (res.data.parentId === '0') {
modalState.treeData = [ modalState.treeData = [
{ { deptId: '0', parentId: '0', deptName: t('views.system.dept.node') },
tenantId: '0',
parentId: '0',
tenantName: t('views.system.dept.node'),
},
]; ];
} else { } else {
//modalState.treeData = treeDataAll; modalState.treeData = treeDataAll;
} }
modalState.from = Object.assign(modalState.from, res.data); modalState.from = Object.assign(modalState.from, res.data);
modalState.title = t('views.system.dept.classInfo'); 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 * @param parentId 上级部门id
*/ */
function fnModalVisibleByEdit( function fnModalVisibleByEdit(
tenantId?: string | number, deptId?: string | number,
parentId?: string | number parentId?: string | number
) { ) {
if (!tenantId) { if (!deptId) {
modalStateFrom.resetFields(); modalStateFrom.resetFields();
if (parentId) { if (parentId) {
modalState.from.parentId = parentId; modalState.from.parentId = parentId;
@@ -278,7 +264,7 @@ function fnModalVisibleByEdit(
const hide = message.loading(t('common.loading'), 0); const hide = message.loading(t('common.loading'), 0);
modalState.confirmLoading = true; modalState.confirmLoading = true;
// 获取部门信息同时查询部门列表(排除节点) // 获取部门信息同时查询部门列表(排除节点)
Promise.all([getDept(tenantId), listDeptExcludeChild(tenantId)]) Promise.all([getDept(deptId), listDeptExcludeChild(deptId)])
.then(resArr => { .then(resArr => {
if (resArr[0].code === RESULT_CODE_SUCCESS && resArr[0].data) { if (resArr[0].code === RESULT_CODE_SUCCESS && resArr[0].data) {
modalState.from = Object.assign(modalState.from, resArr[0].data); modalState.from = Object.assign(modalState.from, resArr[0].data);
@@ -289,13 +275,13 @@ function fnModalVisibleByEdit(
if (resArr[1].data.length === 0) { if (resArr[1].data.length === 0) {
modalState.treeData = [ modalState.treeData = [
{ {
tenantId: '0', deptId: '0',
parentId: '0', parentId: '0',
tenantName: t('views.system.dept.node'), deptName: t('views.system.dept.node'),
}, },
]; ];
} else { } else {
modalState.treeData = parseDataToTree(resArr[1].data, 'tenantId'); modalState.treeData = parseDataToTree(resArr[1].data, 'deptId');
} }
} }
modalState.title = modalState.title =
@@ -322,8 +308,7 @@ function fnModalOk() {
.then(() => { .then(() => {
modalState.confirmLoading = true; modalState.confirmLoading = true;
const from = toRaw(modalState.from); const from = toRaw(modalState.from);
console.log('from', from); const dept = from.deptId ? updateDept(from) : addDept(from);
const dept = from.tenantId ? updateDept(from) : addDept(from);
const hide = message.loading(t('common.loading'), 0); const hide = message.loading(t('common.loading'), 0);
dept dept
.then(res => { .then(res => {
@@ -334,7 +319,7 @@ function fnModalOk() {
}); });
modalState.visibleByEdit = false; modalState.visibleByEdit = false;
// 新增时清空上级部门树重新获取 // 新增时清空上级部门树重新获取
if (!from.tenantId) { if (!from.deptId) {
treeDataAll = []; treeDataAll = [];
} }
modalStateFrom.resetFields(); 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({ Modal.confirm({
title: t('common.tipTitle'), title: t('common.tipTitle'),
content: t('views.system.dept.delSure', { tenantId: tenantId }), content: t('views.system.dept.delSure', { deptId: deptId }),
onOk() { onOk() {
const hide = message.loading(t('common.loading'), 0); const hide = message.loading(t('common.loading'), 0);
delDept(tenantId).then(res => { delDept(deptId).then(res => {
hide(); hide();
if (res.code === RESULT_CODE_SUCCESS) { if (res.code === RESULT_CODE_SUCCESS) {
message.success({ message.success({
@@ -401,16 +386,13 @@ function fnGetList() {
tableState.loading = true; tableState.loading = true;
listDept(toRaw(queryParams)).then(res => { listDept(toRaw(queryParams)).then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
// 转换树状数据 const treeData = parseDataToTree(res.data, 'deptId');
const treeData = parseDataToTree(res.data, 'tenantId');
// 初始上级部门和展开编号key // 初始上级部门和展开编号key
if (treeDataAll.length <= 0) { if (treeDataAll.length <= 0) {
// 转换树状数据 // 转换树状数据
treeDataAll = treeData; treeDataAll = treeData;
// 展开编号key // 展开编号key
expandedRowKeys = [ expandedRowKeys = [...new Set(res.data.map(item => item.parentId))];
...new Set(res.data.map((item: any) => item.parentId)),
];
fnTableExpandedRowsAll(tableState.expandedRowAll); fnTableExpandedRowsAll(tableState.expandedRowAll);
} }
tableState.data = treeData; tableState.data = treeData;
@@ -444,10 +426,10 @@ onMounted(() => {
<a-col :lg="6" :md="12" :xs="24"> <a-col :lg="6" :md="12" :xs="24">
<a-form-item <a-form-item
:label="t('views.system.dept.className')" :label="t('views.system.dept.className')"
name="tenantName" name="deptName"
> >
<a-input <a-input
v-model:value="queryParams.tenantName" v-model:value="queryParams.deptName"
allow-clear allow-clear
></a-input> ></a-input>
</a-form-item> </a-form-item>
@@ -552,7 +534,7 @@ onMounted(() => {
<!-- 表格列表 --> <!-- 表格列表 -->
<a-table <a-table
class="table" class="table"
row-key="tenantId" row-key="deptId"
:columns="tableColumns" :columns="tableColumns"
:loading="tableState.loading" :loading="tableState.loading"
:data-source="tableState.data" :data-source="tableState.data"
@@ -567,13 +549,13 @@ onMounted(() => {
<template v-if="column.key === 'status'"> <template v-if="column.key === 'status'">
<DictTag :options="dict.sysNormalDisable" :value="record.status" /> <DictTag :options="dict.sysNormalDisable" :value="record.status" />
</template> </template>
<template v-if="column.key === 'tenantId'"> <template v-if="column.key === 'deptId'">
<a-space :size="8" align="center"> <a-space :size="8" align="center">
<a-tooltip> <a-tooltip>
<template #title>{{ t('common.viewText') }}</template> <template #title>{{ t('common.viewText') }}</template>
<a-button <a-button
type="link" type="link"
@click.prevent="fnModalVisibleByVive(record.tenantId)" @click.prevent="fnModalVisibleByVive(record.deptId)"
v-perms:has="['system:dept:query']" v-perms:has="['system:dept:query']"
> >
<template #icon><ProfileOutlined /></template> <template #icon><ProfileOutlined /></template>
@@ -583,7 +565,7 @@ onMounted(() => {
<template #title>{{ t('common.editText') }}</template> <template #title>{{ t('common.editText') }}</template>
<a-button <a-button
type="link" type="link"
@click.prevent="fnModalVisibleByEdit(record.tenantId)" @click.prevent="fnModalVisibleByEdit(record.deptId)"
v-perms:has="['system:dept:edit']" v-perms:has="['system:dept:edit']"
> >
<template #icon><FormOutlined /></template> <template #icon><FormOutlined /></template>
@@ -593,7 +575,7 @@ onMounted(() => {
<template #title>{{ t('common.deleteText') }}</template> <template #title>{{ t('common.deleteText') }}</template>
<a-button <a-button
type="link" type="link"
@click.prevent="fnRecordDelete(record.tenantId)" @click.prevent="fnRecordDelete(record.deptId)"
v-perms:has="['system:dept:remove']" v-perms:has="['system:dept:remove']"
> >
<template #icon><DeleteOutlined /></template> <template #icon><DeleteOutlined /></template>
@@ -606,7 +588,7 @@ onMounted(() => {
<a-button <a-button
type="link" type="link"
@click.prevent=" @click.prevent="
fnModalVisibleByEdit(undefined, record.tenantId) fnModalVisibleByEdit(undefined, record.deptId)
" "
v-perms:has="['system:dept:add']" v-perms:has="['system:dept:add']"
> >
@@ -639,10 +621,10 @@ onMounted(() => {
:tree-data="modalState.treeData" :tree-data="modalState.treeData"
:field-names="{ :field-names="{
children: 'children', children: 'children',
label: 'tenantName', label: 'deptName',
value: 'tenantId', value: 'deptId',
}" }"
tree-node-label-prop="tenantName" tree-node-label-prop="deptName"
> >
<template #suffixIcon></template> <template #suffixIcon></template>
</a-tree-select> </a-tree-select>
@@ -651,9 +633,9 @@ onMounted(() => {
<a-col :lg="12" :md="12" :xs="24"> <a-col :lg="12" :md="12" :xs="24">
<a-form-item <a-form-item
:label="t('views.system.dept.className')" :label="t('views.system.dept.className')"
name="tenantName" name="deptName"
> >
{{ modalState.from.tenantName }} {{ modalState.from.deptName }}
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :lg="12" :md="12" :xs="24"> <a-col :lg="12" :md="12" :xs="24">
@@ -676,23 +658,30 @@ onMounted(() => {
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :lg="12" :md="12" :xs="24"> <a-col :lg="12" :md="12" :xs="24">
<a-form-item <a-form-item :label="t('views.system.dept.classId')" name="deptId">
:label="t('views.system.dept.classId')" {{ modalState.from.deptId }}
name="tenantId"
>
{{ modalState.from.tenantId }}
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :lg="24" :md="24" :xs="24"> <a-col :lg="24" :md="24" :xs="24">
<a-form-item <a-form-item
:label="t('views.system.dept.type')" :label="t('views.system.dept.admin')"
name="type" name="leader"
:label-col="{ span: 3 }" :label-col="{ span: 3 }"
:labelWrap="true" :labelWrap="true"
> >
{{ modalState.from.tenancyType }} {{ modalState.from.leader }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item :label="t('views.system.dept.phone')" name="phone">
{{ modalState.from.phone }}
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item :label="t('views.system.dept.email')" name="email">
{{ modalState.from.email }}
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@@ -735,11 +724,11 @@ onMounted(() => {
:tree-data="modalState.treeData" :tree-data="modalState.treeData"
:field-names="{ :field-names="{
children: 'children', children: 'children',
label: 'tenantName', label: 'deptName',
value: 'tenantId', value: 'deptId',
}" }"
tree-node-label-prop="tenantName" tree-node-label-prop="deptName"
tree-node-filter-prop="tenantName" tree-node-filter-prop="deptName"
style="width: 100%" style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
> >
@@ -748,13 +737,13 @@ onMounted(() => {
<a-form-item <a-form-item
:label="t('views.system.dept.className')" :label="t('views.system.dept.className')"
name="tenantName" name="deptName"
v-bind="modalStateFrom.validateInfos.tenantName" v-bind="modalStateFrom.validateInfos.deptName"
:label-col="{ span: 3 }" :label-col="{ span: 3 }"
:labelWrap="true" :labelWrap="true"
> >
<a-input <a-input
v-model:value="modalState.from.tenantName" v-model:value="modalState.from.deptName"
allow-clear allow-clear
:maxlength="30" :maxlength="30"
></a-input> ></a-input>
@@ -787,29 +776,43 @@ onMounted(() => {
</a-row> </a-row>
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :span="12"> <a-col :span="24">
<a-form-item <a-form-item
:label="t('views.system.dept.type')" :label="t('views.system.dept.admin')"
name="type" name="leader"
v-bind="modalStateFrom.validateInfos.leader"
:label-col="{ span: 3 }"
:labelWrap="true" :labelWrap="true"
> >
<a-select <a-input
v-model:value="modalState.from.tenancyType" v-model:value="modalState.from.leader"
allow-clear allow-clear
:options="modalStateFromOption.tenantType" ></a-input>
>
</a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :lg="24" :md="24" :xs="24"> <a-col :lg="12" :md="12" :xs="24">
<a-form-item <a-form-item
:label="t('views.system.dept.key')" :label="t('views.system.dept.phone')"
name="key" name="phone"
:label-col="{ span: 3 }" v-bind="modalStateFrom.validateInfos.phone"
> >
<a-input <a-input
v-model:value="modalState.from.tenancyKey" v-model:value="modalState.from.phone"
allow-clear allow-clear
:maxlength="11"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
:label="t('views.system.dept.email')"
name="email"
v-bind="modalStateFrom.validateInfos.email"
>
<a-input
v-model:value="modalState.from.email"
allow-clear
:maxlength="40"
></a-input> ></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -819,4 +822,5 @@ onMounted(() => {
</PageContainer> </PageContainer>
</template> </template>
<style lang="less" scoped></style> <style lang="less" scoped>
</style>