租户管理异常(数据库需要把key字段改名)
This commit is contained in:
@@ -37,18 +37,6 @@ export function getDept(deptId: string | number) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门详细
|
||||
* @param deptId 部门ID
|
||||
* @returns object
|
||||
*/
|
||||
export function getTenant(deptId: string | number) {
|
||||
return request({
|
||||
url: `/system/tenant/${deptId}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
* @param data 部门对象
|
||||
|
||||
99
src/api/system/tenant.ts
Normal file
99
src/api/system/tenant.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import { request } from '@/plugins/http-fetch';
|
||||
|
||||
/**
|
||||
* 查询部门列表
|
||||
* @param query 查询参数
|
||||
* @returns object
|
||||
*/
|
||||
export function listDept(query: Record<string, any>) {
|
||||
return request({
|
||||
url: '/system/tenant/list',
|
||||
method: 'get',
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门列表(排除节点)
|
||||
* @param deptId 部门ID
|
||||
* @returns object
|
||||
*/
|
||||
export function listDeptExcludeChild(deptId: string | number) {
|
||||
return request({
|
||||
url: `/system/tenant/list/exclude/${deptId}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门详细
|
||||
* @param deptId 部门ID
|
||||
* @returns object
|
||||
*/
|
||||
export function getDept(deptId: string | number) {
|
||||
return request({
|
||||
url: `/system/tenant/${deptId}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
* @param data 部门对象
|
||||
* @returns object
|
||||
*/
|
||||
export function addDept(data: Record<string, any>) {
|
||||
return request({
|
||||
url: '/system/tenant',
|
||||
method: 'post',
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
* @param data 部门对象
|
||||
* @returns object
|
||||
*/
|
||||
export function updateDept(data: Record<string, any>) {
|
||||
return request({
|
||||
url: '/system/tenant',
|
||||
method: 'put',
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
* @param deptId 部门ID
|
||||
* @returns object
|
||||
*/
|
||||
export function delDept(deptId: string | number) {
|
||||
return request({
|
||||
url: `/system/tenant/${deptId}`,
|
||||
method: 'delete',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门下拉树结构
|
||||
* @returns object
|
||||
*/
|
||||
export function deptTreeSelect() {
|
||||
return request({
|
||||
url: '/system/tenant/treeSelect',
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门树结构列表(指定角色)
|
||||
* @param roleId 角色ID
|
||||
* @returns object
|
||||
*/
|
||||
export function roleDeptTreeSelect(roleId: string | number) {
|
||||
return request({
|
||||
url: `/system/tenant/roleDeptTreeSelect/${roleId}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
@@ -8,12 +8,11 @@ import { ColumnsType } from 'ant-design-vue/lib/table';
|
||||
import {
|
||||
listDept,
|
||||
getDept,
|
||||
getTenant,
|
||||
delDept,
|
||||
addDept,
|
||||
updateDept,
|
||||
listDeptExcludeChild,
|
||||
} from '@/api/system/dept';
|
||||
} from '@/api/system/tenant';
|
||||
import { parseDateToStr } from '@/utils/date-utils';
|
||||
import { regExpMobile, regExpEmail } from '@/utils/regular-utils';
|
||||
import useDictStore from '@/store/modules/dict';
|
||||
@@ -34,7 +33,7 @@ let dict: {
|
||||
/**查询参数 */
|
||||
let queryParams = reactive({
|
||||
/**部门名称 */
|
||||
deptName: '',
|
||||
tenantName: '',
|
||||
/**部门状态 */
|
||||
status: undefined,
|
||||
});
|
||||
@@ -42,14 +41,14 @@ let queryParams = reactive({
|
||||
/**查询参数重置 */
|
||||
function fnQueryReset() {
|
||||
queryParams = Object.assign(queryParams, {
|
||||
deptName: '',
|
||||
tenantName: '',
|
||||
status: undefined,
|
||||
});
|
||||
fnGetList();
|
||||
}
|
||||
|
||||
/**表格全展开行key */
|
||||
let expandedRowKeys: string[] = [];
|
||||
let expandedRowKeys: any[] = [];
|
||||
|
||||
/**表格状态类型 */
|
||||
type TabeStateType = {
|
||||
@@ -81,13 +80,13 @@ let tableState: TabeStateType = reactive({
|
||||
let tableColumns: ColumnsType = [
|
||||
{
|
||||
title: t('views.system.dept.className'),
|
||||
dataIndex: 'deptName',
|
||||
dataIndex: 'tenantName',
|
||||
align: 'left',
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
title: t('views.system.dept.classId'),
|
||||
dataIndex: 'deptId',
|
||||
dataIndex: 'tenantId',
|
||||
align: 'left',
|
||||
width: 150,
|
||||
},
|
||||
@@ -110,6 +109,18 @@ let tableColumns: ColumnsType = [
|
||||
key: 'type',
|
||||
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.createTime'),
|
||||
@@ -123,7 +134,7 @@ let tableColumns: ColumnsType = [
|
||||
},
|
||||
{
|
||||
title: t('common.operate'),
|
||||
key: 'deptId',
|
||||
key: 'tenantId',
|
||||
align: 'left',
|
||||
},
|
||||
];
|
||||
@@ -133,8 +144,8 @@ const modalStateFromOption = reactive({
|
||||
{ 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) {
|
||||
@@ -176,8 +187,8 @@ let modalState: ModalStateType = reactive({
|
||||
visibleByEdit: false,
|
||||
title: '部门',
|
||||
from: {
|
||||
deptId: undefined,
|
||||
deptName: '',
|
||||
tenantId: undefined,
|
||||
tenantName: '',
|
||||
email: '',
|
||||
leader: '',
|
||||
orderNum: 0,
|
||||
@@ -203,7 +214,7 @@ const modalStateFrom = Form.useForm(
|
||||
message: t('views.system.dept.highClass') + t('common.unableNull'),
|
||||
},
|
||||
],
|
||||
deptName: [
|
||||
tenantName: [
|
||||
{
|
||||
required: true,
|
||||
min: 1,
|
||||
@@ -216,26 +227,30 @@ const modalStateFrom = Form.useForm(
|
||||
|
||||
/**
|
||||
* 对话框弹出显示为 查看
|
||||
* @param deptId 部门编号id
|
||||
* @param tenantId 部门编号id
|
||||
*/
|
||||
function fnModalVisibleByVive(deptId: string | number) {
|
||||
if (!deptId) {
|
||||
function fnModalVisibleByVive(tenantId: string | number) {
|
||||
if (!tenantId) {
|
||||
message.error(t('common.getInfoFail'), 2);
|
||||
return;
|
||||
}
|
||||
if (modalState.confirmLoading) return;
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
modalState.confirmLoading = true;
|
||||
getTenant(deptId).then(res => {
|
||||
getDept(tenantId).then(res => {
|
||||
modalState.confirmLoading = false;
|
||||
hide();
|
||||
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
||||
if (res.data.parentId === '0') {
|
||||
modalState.treeData = [
|
||||
{ deptId: '0', parentId: '0', deptName: t('views.system.dept.node') },
|
||||
{
|
||||
tenantId: '0',
|
||||
parentId: '0',
|
||||
tenantName: 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');
|
||||
@@ -248,14 +263,14 @@ function fnModalVisibleByVive(deptId: string | number) {
|
||||
|
||||
/**
|
||||
* 对话框弹出显示为 新增或者修改
|
||||
* @param deptId 部门编号id, 不传为新增
|
||||
* @param tenantId 部门编号id, 不传为新增
|
||||
* @param parentId 上级部门id
|
||||
*/
|
||||
function fnModalVisibleByEdit(
|
||||
deptId?: string | number,
|
||||
tenantId?: string | number,
|
||||
parentId?: string | number
|
||||
) {
|
||||
if (!deptId) {
|
||||
if (!tenantId) {
|
||||
modalStateFrom.resetFields();
|
||||
if (parentId) {
|
||||
modalState.from.parentId = parentId;
|
||||
@@ -268,7 +283,7 @@ function fnModalVisibleByEdit(
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
modalState.confirmLoading = true;
|
||||
// 获取部门信息同时查询部门列表(排除节点)
|
||||
Promise.all([getTenant(deptId), listDeptExcludeChild(deptId)])
|
||||
Promise.all([getDept(tenantId), listDeptExcludeChild(tenantId)])
|
||||
.then(resArr => {
|
||||
if (resArr[0].code === RESULT_CODE_SUCCESS && resArr[0].data) {
|
||||
modalState.from = Object.assign(modalState.from, resArr[0].data);
|
||||
@@ -279,13 +294,17 @@ function fnModalVisibleByEdit(
|
||||
if (resArr[1].data.length === 0) {
|
||||
modalState.treeData = [
|
||||
{
|
||||
deptId: '0',
|
||||
tenantId: '0',
|
||||
parentId: '0',
|
||||
deptName: t('views.system.dept.node'),
|
||||
tenantName: t('views.system.dept.node'),
|
||||
},
|
||||
];
|
||||
} else {
|
||||
modalState.treeData = parseDataToTree(resArr[1].data, 'deptId');
|
||||
const a = resArr[1].data.map(s=>{
|
||||
delete s.key
|
||||
return s
|
||||
})
|
||||
modalState.treeData = parseDataToTree(a, 'tenantId');
|
||||
}
|
||||
}
|
||||
modalState.title =
|
||||
@@ -312,7 +331,8 @@ function fnModalOk() {
|
||||
.then(() => {
|
||||
modalState.confirmLoading = true;
|
||||
const from = toRaw(modalState.from);
|
||||
const dept = from.deptId ? updateDept(from) : addDept(from);
|
||||
console.log('from', from);
|
||||
const dept = from.tenantId ? updateDept(from) : addDept(from);
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
dept
|
||||
.then(res => {
|
||||
@@ -323,7 +343,7 @@ function fnModalOk() {
|
||||
});
|
||||
modalState.visibleByEdit = false;
|
||||
// 新增时清空上级部门树重新获取
|
||||
if (!from.deptId) {
|
||||
if (!from.tenantId) {
|
||||
treeDataAll = [];
|
||||
}
|
||||
modalStateFrom.resetFields();
|
||||
@@ -357,15 +377,15 @@ function fnModalCancel() {
|
||||
|
||||
/**
|
||||
* 部门删除
|
||||
* @param deptId 部门编号id
|
||||
* @param tenantId 部门编号id
|
||||
*/
|
||||
function fnRecordDelete(deptId: string | number) {
|
||||
function fnRecordDelete(tenantId: string | number) {
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.system.dept.delSure', { deptId: deptId }),
|
||||
content: t('views.system.dept.delSure', { tenantId: tenantId }),
|
||||
onOk() {
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
delDept(deptId).then(res => {
|
||||
delDept(tenantId).then(res => {
|
||||
hide();
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
@@ -390,13 +410,20 @@ 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, 'deptId');
|
||||
var a: any = res.data.map(item => {
|
||||
delete item.key;
|
||||
return item;
|
||||
});
|
||||
|
||||
// 转换树状数据
|
||||
const treeData = parseDataToTree(a, 'tenantId');
|
||||
console.log(treeData);
|
||||
// 初始上级部门和展开编号key
|
||||
if (treeDataAll.length <= 0) {
|
||||
// 转换树状数据
|
||||
treeDataAll = treeData;
|
||||
// 展开编号key
|
||||
expandedRowKeys = [...new Set(res.data.map(item => item.parentId))];
|
||||
expandedRowKeys = [...new Set(a.map((item:any) => item.parentId))];
|
||||
fnTableExpandedRowsAll(tableState.expandedRowAll);
|
||||
}
|
||||
tableState.data = treeData;
|
||||
@@ -430,10 +457,10 @@ onMounted(() => {
|
||||
<a-col :lg="6" :md="12" :xs="24">
|
||||
<a-form-item
|
||||
:label="t('views.system.dept.className')"
|
||||
name="deptName"
|
||||
name="tenantName"
|
||||
>
|
||||
<a-input
|
||||
v-model:value="queryParams.deptName"
|
||||
v-model:value="queryParams.tenantName"
|
||||
allow-clear
|
||||
></a-input>
|
||||
</a-form-item>
|
||||
@@ -538,7 +565,7 @@ onMounted(() => {
|
||||
<!-- 表格列表 -->
|
||||
<a-table
|
||||
class="table"
|
||||
row-key="deptId"
|
||||
row-key="tenantId"
|
||||
:columns="tableColumns"
|
||||
:loading="tableState.loading"
|
||||
:data-source="tableState.data"
|
||||
@@ -553,13 +580,13 @@ onMounted(() => {
|
||||
<template v-if="column.key === 'status'">
|
||||
<DictTag :options="dict.sysNormalDisable" :value="record.status" />
|
||||
</template>
|
||||
<template v-if="column.key === 'deptId'">
|
||||
<template v-if="column.key === 'tenantId'">
|
||||
<a-space :size="8" align="center">
|
||||
<a-tooltip>
|
||||
<template #title>{{ t('common.viewText') }}</template>
|
||||
<a-button
|
||||
type="link"
|
||||
@click.prevent="fnModalVisibleByVive(record.deptId)"
|
||||
@click.prevent="fnModalVisibleByVive(record.tenantId)"
|
||||
v-perms:has="['system:dept:query']"
|
||||
>
|
||||
<template #icon><ProfileOutlined /></template>
|
||||
@@ -569,7 +596,7 @@ onMounted(() => {
|
||||
<template #title>{{ t('common.editText') }}</template>
|
||||
<a-button
|
||||
type="link"
|
||||
@click.prevent="fnModalVisibleByEdit(record.deptId)"
|
||||
@click.prevent="fnModalVisibleByEdit(record.tenantId)"
|
||||
v-perms:has="['system:dept:edit']"
|
||||
>
|
||||
<template #icon><FormOutlined /></template>
|
||||
@@ -579,7 +606,7 @@ onMounted(() => {
|
||||
<template #title>{{ t('common.deleteText') }}</template>
|
||||
<a-button
|
||||
type="link"
|
||||
@click.prevent="fnRecordDelete(record.deptId)"
|
||||
@click.prevent="fnRecordDelete(record.tenantId)"
|
||||
v-perms:has="['system:dept:remove']"
|
||||
>
|
||||
<template #icon><DeleteOutlined /></template>
|
||||
@@ -592,7 +619,7 @@ onMounted(() => {
|
||||
<a-button
|
||||
type="link"
|
||||
@click.prevent="
|
||||
fnModalVisibleByEdit(undefined, record.deptId)
|
||||
fnModalVisibleByEdit(undefined, record.tenantId)
|
||||
"
|
||||
v-perms:has="['system:dept:add']"
|
||||
>
|
||||
@@ -625,10 +652,10 @@ onMounted(() => {
|
||||
:tree-data="modalState.treeData"
|
||||
:field-names="{
|
||||
children: 'children',
|
||||
label: 'deptName',
|
||||
value: 'deptId',
|
||||
label: 'tenantName',
|
||||
value: 'tenantId',
|
||||
}"
|
||||
tree-node-label-prop="deptName"
|
||||
tree-node-label-prop="tenantName"
|
||||
>
|
||||
<template #suffixIcon></template>
|
||||
</a-tree-select>
|
||||
@@ -637,9 +664,9 @@ onMounted(() => {
|
||||
<a-col :lg="12" :md="12" :xs="24">
|
||||
<a-form-item
|
||||
:label="t('views.system.dept.className')"
|
||||
name="deptName"
|
||||
name="tenantName"
|
||||
>
|
||||
{{ modalState.from.deptName }}
|
||||
{{ modalState.from.tenantName }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="12" :md="12" :xs="24">
|
||||
@@ -662,8 +689,11 @@ onMounted(() => {
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="12" :md="12" :xs="24">
|
||||
<a-form-item :label="t('views.system.dept.classId')" name="deptId">
|
||||
{{ modalState.from.deptId }}
|
||||
<a-form-item
|
||||
:label="t('views.system.dept.classId')"
|
||||
name="tenantId"
|
||||
>
|
||||
{{ modalState.from.tenantId }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
@@ -718,11 +748,11 @@ onMounted(() => {
|
||||
:tree-data="modalState.treeData"
|
||||
:field-names="{
|
||||
children: 'children',
|
||||
label: 'deptName',
|
||||
value: 'deptId',
|
||||
label: 'tenantName',
|
||||
value: 'tenantId',
|
||||
}"
|
||||
tree-node-label-prop="deptName"
|
||||
tree-node-filter-prop="deptName"
|
||||
tree-node-label-prop="tenantName"
|
||||
tree-node-filter-prop="tenantName"
|
||||
style="width: 100%"
|
||||
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
||||
>
|
||||
@@ -731,13 +761,13 @@ onMounted(() => {
|
||||
|
||||
<a-form-item
|
||||
:label="t('views.system.dept.className')"
|
||||
name="deptName"
|
||||
v-bind="modalStateFrom.validateInfos.deptName"
|
||||
name="tenantName"
|
||||
v-bind="modalStateFrom.validateInfos.tenantName"
|
||||
:label-col="{ span: 3 }"
|
||||
:labelWrap="true"
|
||||
>
|
||||
<a-input
|
||||
v-model:value="modalState.from.deptName"
|
||||
v-model:value="modalState.from.tenantName"
|
||||
allow-clear
|
||||
:maxlength="30"
|
||||
></a-input>
|
||||
|
||||
Reference in New Issue
Block a user