|
|
@@ -9,14 +9,14 @@
|
|
|
@keyup.enter="handleQuery"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="部门编码" prop="deptCode" label-position="top">
|
|
|
+ <!-- <el-form-item label="部门编码" prop="deptCode" label-position="top">
|
|
|
<el-input
|
|
|
v-model="queryParams.deptCode"
|
|
|
placeholder="请输入部门编码"
|
|
|
clearable
|
|
|
@keyup.enter="handleQuery"
|
|
|
/>
|
|
|
- </el-form-item>
|
|
|
+ </el-form-item> -->
|
|
|
<el-form-item label="状态" prop="status" label-position="top">
|
|
|
<el-select v-model="queryParams.status" placeholder="部门状态" clearable>
|
|
|
<el-option
|
|
|
@@ -64,7 +64,7 @@
|
|
|
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
|
|
>
|
|
|
<el-table-column prop="deptName" label="部门名称"></el-table-column>
|
|
|
- <el-table-column prop="deptCode" label="部门编码"></el-table-column>
|
|
|
+ <!-- <el-table-column prop="deptCode" label="部门编码"></el-table-column> -->
|
|
|
<el-table-column prop="level" label="层级" width="100">
|
|
|
<template #default="scope">
|
|
|
<dict-tag :options="dept_level" :value="scope.row.level" />
|
|
|
@@ -112,11 +112,11 @@
|
|
|
<el-input v-model="form.deptName" placeholder="请输入部门名称" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="12">
|
|
|
+ <!-- <el-col :span="12">
|
|
|
<el-form-item label="部门编码" prop="deptCode">
|
|
|
<el-input v-model="form.deptCode" placeholder="请输入部门编码" />
|
|
|
</el-form-item>
|
|
|
- </el-col>
|
|
|
+ </el-col> -->
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="层级" prop="level">
|
|
|
<el-select v-model="form.level" placeholder="请选择层级" :disabled="isLevelDisabled">
|
|
|
@@ -201,7 +201,6 @@ const data = reactive({
|
|
|
rules: {
|
|
|
parentId: [{ required: true, message: "上级部门不能为空", trigger: "blur" }],
|
|
|
deptName: [{ required: true, message: "部门名称不能为空", trigger: "blur" }],
|
|
|
- deptCode: [{ required: true, message: "部门编码不能为空", trigger: "blur" }],
|
|
|
level: [{ required: true, message: "部门层级不能为空", trigger: "blur" }],
|
|
|
orderNum: [{ required: true, message: "显示排序不能为空", trigger: "blur" }],
|
|
|
email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
|
|
|
@@ -317,7 +316,7 @@ function submitForm() {
|
|
|
if (!validateLevelRules()) {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (form.value.deptId != undefined) {
|
|
|
updateDept(form.value).then(response => {
|
|
|
proxy.$modal.msgSuccess("修改成功")
|
|
|
@@ -341,14 +340,14 @@ function validateLevelRules() {
|
|
|
if (form.value.parentId === 0) {
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 获取当前选择的父级部门
|
|
|
const parentDept = findDeptById(form.value.parentId, deptOptions.value);
|
|
|
if (!parentDept) {
|
|
|
proxy.$modal.msgError("未找到父级部门信息");
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 如果当前层级为维保中心(2)
|
|
|
if (form.value.level === "2") {
|
|
|
// 父级不能是维保中心(2)或场站(3)
|
|
|
@@ -356,7 +355,7 @@ function validateLevelRules() {
|
|
|
proxy.$modal.msgError("维保中心不能添加在维保中心或场站下");
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 祖级列表中不能有维保中心(2)或场站(3)
|
|
|
const ancestors = parentDept.ancestors ? parentDept.ancestors.split(",") : [];
|
|
|
const ancestorDepts = findDeptsByIds(ancestors, deptOptions.value);
|
|
|
@@ -367,7 +366,7 @@ function validateLevelRules() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 如果当前层级为场站(3)
|
|
|
if (form.value.level === "3") {
|
|
|
// 父级必须是维保中心(2)
|
|
|
@@ -375,7 +374,7 @@ function validateLevelRules() {
|
|
|
proxy.$modal.msgError("场站只能添加在维保中心下");
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 祖级列表中不能有场站(3)
|
|
|
const ancestors = parentDept.ancestors ? parentDept.ancestors.split(",") : [];
|
|
|
const ancestorDepts = findDeptsByIds(ancestors, deptOptions.value);
|
|
|
@@ -386,7 +385,7 @@ function validateLevelRules() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 编辑时检查子级是否违反层级规则
|
|
|
if (form.value.deptId) {
|
|
|
// 从完整的部门列表中查找当前部门,以获取真实的子级信息
|
|
|
@@ -396,7 +395,7 @@ function validateLevelRules() {
|
|
|
const hasStation = currentDept.children.some(child => child.level === "3");
|
|
|
// 检查子级中是否有维保中心
|
|
|
const hasMaintenanceCenter = currentDept.children.some(child => child.level === "2");
|
|
|
-
|
|
|
+
|
|
|
if (form.value.level === "1") {
|
|
|
// 如果要修改为普通部门
|
|
|
if (hasStation) {
|
|
|
@@ -424,7 +423,7 @@ function validateLevelRules() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -435,7 +434,7 @@ function hasStationChildren(dept) {
|
|
|
if (!dept.children || dept.children.length === 0) {
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
for (const child of dept.children) {
|
|
|
if (child.level === "3") {
|
|
|
return true;
|
|
|
@@ -445,7 +444,7 @@ function hasStationChildren(dept) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -469,14 +468,14 @@ function findDeptById(deptId, depts) {
|
|
|
function findDeptsByIds(deptIds, depts) {
|
|
|
const result = []
|
|
|
const allDepts = flattenDepts(depts)
|
|
|
-
|
|
|
+
|
|
|
for (const deptId of deptIds) {
|
|
|
const dept = allDepts.find(d => d.deptId == deptId)
|
|
|
if (dept) {
|
|
|
result.push(dept)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
@@ -503,4 +502,4 @@ function handleDelete(row) {
|
|
|
}
|
|
|
|
|
|
getList()
|
|
|
-</script>
|
|
|
+</script>
|