From 49b46688641b7a4ba074dedccbcc5547f879ec0a Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: Tue, 02 Jun 2026 14:50:14 +0800
Subject: [PATCH] 修改专业对应部门处室
---
src/views/safetyReview/expertManage/fillForm/index.vue | 15 ++++++-
src/views/safetyReview/baseSet/expertsType/index.vue | 61 ++++++++++++++++++++++++++----
src/views/safetyReview/expertManage/applyRecords/components/expertForm.vue | 16 ++++++-
3 files changed, 78 insertions(+), 14 deletions(-)
diff --git a/src/views/safetyReview/baseSet/expertsType/index.vue b/src/views/safetyReview/baseSet/expertsType/index.vue
index 379022e..3640d22 100644
--- a/src/views/safetyReview/baseSet/expertsType/index.vue
+++ b/src/views/safetyReview/baseSet/expertsType/index.vue
@@ -66,6 +66,15 @@
<el-form-item label="分类名称" prop="classifyName">
<el-input v-model="state.form.classifyName" placeholder="请输入分类名称" />
</el-form-item>
+ <el-form-item label="部门处室" prop="deptId" v-if="state.form.parentId">
+ <el-cascader
+ style="width: 100%"
+ clearable
+ :show-all-levels="false"
+ v-model="state.form.deptId"
+ :options="state.deptList"
+ :props="{ expandTrigger: 'hover', value: 'deptId',label: 'deptName',emitPath: false}"></el-cascader>
+ </el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm(formRef)">确 定</el-button>
@@ -79,28 +88,36 @@
import {getExpertTypes, delExpertType, addType, updateType} from "@/api/form"
import {onMounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus"
+import {listOutDept} from "@/api/system/dept";
import { Plus } from '@element-plus/icons-vue'
const state = reactive({
loading: false,
total: 0,
expertList: [],
+ deptList: [],
title: "",
open: false,
form: {
parentId: null,
id: null,
- classifyName: ''
+ classifyName: '',
+ deptId: null,
+ deptName: ''
},
rules: {
classifyName: [
{ required: true, message: "分类名称不能为空", trigger: "blur" }
+ ],
+ deptId: [
+ { required: true, message: "部门处室不能为空", trigger: "blur" }
]
}
})
const formRef = ref()
-
+const {proxy} = getCurrentInstance()
onMounted(()=>{
getList()
+ getDepList()
})
/** 查询岗位列表 */
const getList = async()=> {
@@ -113,20 +130,28 @@
}
state.loading = false;
}
+ function getDepList() {
+ listOutDept({}).then(response => {
+ state.deptList = proxy.handleTree(response.data, "deptId", 'parentId', 'children');
+ });
+ }
// 取消按钮
const cancel=()=> {
state.open = false;
reset();
}
const handleChange=(value)=> {
- console.log(value);
+ state.form.deptId = null
+ state.form.deptName = ''
}
// 表单重置
const reset=()=> {
state.form = {
parentId: 0,
id: null,
- classifyName: ''
+ classifyName: '',
+ deptId: null,
+ deptName: ''
}
}
@@ -138,11 +163,11 @@
const handleUpdate=(row)=> {
reset();
- console.log(row,'row')
state.form.id = row.id;
state.form.classifyName = row.classifyName;
state.form.parentId = findParentNodeById(state.expertList,row.id)
- console.log(state.form,'form')
+ state.form.deptId = row.deptId
+ state.form.deptName = row.deptName
state.open = true;
state.title = "修改分类";
}
@@ -150,6 +175,9 @@
const submitForm = async(formEl)=> {
await formEl.validate(async (valid, fields) => {
if (valid) {
+ if(state.form.deptId){
+ state.form.deptName = findNameByDeptId(state.deptList,state.form.deptId)
+ }
if (state.title == '修改分类') {
updateType(state.form).then(res => {
if(res.code == 200){
@@ -200,20 +228,35 @@
const findParentNodeById=(data, value)=> {
for (const node of data) {
if (node.id === value) {
- return null; // 已经是根节点,没有父级节点
+ return null;
}
if (node.children) {
for (const child of node.children) {
if (child.id === value) {
- return node.id; // 返回当前节点的ID作为父级ID
+ return node.id;
}
}
const foundNode = findParentNodeById(node.children, value);
if (foundNode !== null) {
- return foundNode; // 返回找到的父级ID
+ return foundNode;
}
}
}
return null;
}
+
+ const findNameByDeptId = (list,id)=>{
+ for(const node of list){
+ if(node.deptId == id){
+ return node.deptName
+ }
+ if(node.children){
+ const foundName = findNameByDeptId(node.children,id)
+ if(foundName){
+ return foundName
+ }
+ }
+ }
+ return null
+ }
</script>
diff --git a/src/views/safetyReview/expertManage/applyRecords/components/expertForm.vue b/src/views/safetyReview/expertManage/applyRecords/components/expertForm.vue
index e6105cc..e65a061 100644
--- a/src/views/safetyReview/expertManage/applyRecords/components/expertForm.vue
+++ b/src/views/safetyReview/expertManage/applyRecords/components/expertForm.vue
@@ -35,7 +35,7 @@
<el-cascader
style="width: 100%"
clearable
- :disabled="state.disable"
+ :disabled="state.findDept || disable"
v-model="state.form.deptId"
:options="state.deptList"
:props="{ expandTrigger: 'hover', value: 'deptId',label: 'deptName',emitPath: false}"></el-cascader>
@@ -548,6 +548,7 @@
const state = reactive({
assessDialog: false,
+ findDept: true,
form: {
id: null,
name: '',
@@ -662,12 +663,21 @@
state.form.bigClassify = null
state.form.smallClassify = null
}
+ const foundType = findNodeById(state.expertsType,value[1])
+ if(foundType.deptId){
+ state.form.deptId = foundType.deptId
+ state.findDept = true
+ }else{
+ ElMessage.warning('该专业未找到对应的业务处室,请手动选择')
+ state.form.deptId = null
+ state.findDept = false
+ }
}
const findNodeById = (data,value)=> {
for (const node of data) {
if (node.id === value) {
- return node.classifyName;
+ return node;
}
if (node.children) {
const foundNode = findNodeById(node.children, value);
@@ -953,7 +963,7 @@
let data = JSON.parse(JSON.stringify(state.form))
data.bigClassify = data.profession[0]
data.smallClassify = data.profession[1]
- data.domain = findNodeById(state.expertsType,data.smallClassify)
+ data.domain = findNodeById(state.expertsType,data.smallClassify)?.classifyName
data.supportDirectionSafety = Array.isArray(data.supportDirectionSafety) ? data.supportDirectionSafety.join(',') : ''
data.supportDirectionPrevention = Array.isArray(data.supportDirectionPrevention) ? data.supportDirectionPrevention.join(',') : ''
data.supportDirectionEmergency = Array.isArray(data.supportDirectionEmergency) ? data.supportDirectionEmergency.join(',') : ''
diff --git a/src/views/safetyReview/expertManage/fillForm/index.vue b/src/views/safetyReview/expertManage/fillForm/index.vue
index 17f0edb..fbcb06c 100644
--- a/src/views/safetyReview/expertManage/fillForm/index.vue
+++ b/src/views/safetyReview/expertManage/fillForm/index.vue
@@ -23,6 +23,7 @@
<el-cascader
style="width: 100%"
clearable
+ :disabled="state.findDept"
v-model="state.form.deptId"
:options="state.deptList"
:props="{ expandTrigger: 'hover', value: 'deptId',label: 'deptName',emitPath: false}"></el-cascader>
@@ -431,6 +432,7 @@
remark: '',
source: 1
},
+ findDept: true,
expertsType: [],
deptList: [],
directionList: [
@@ -510,12 +512,21 @@
state.form.bigClassify = null
state.form.smallClassify = null
}
+ const foundType = findNodeById(state.expertsType,value[1])
+ if(foundType.deptId){
+ state.form.deptId = foundType.deptId
+ state.findDept = true
+ }else{
+ ElMessage.warning('该专业未找到对应的业务处室,请手动选择')
+ state.form.deptId = null
+ state.findDept = false
+ }
}
const findNodeById = (data,value)=> {
for (const node of data) {
if (node.id === value) {
- return node.classifyName;
+ return node;
}
if (node.children) {
const foundNode = findNodeById(node.children, value);
@@ -611,7 +622,7 @@
let data = JSON.parse(JSON.stringify(state.form))
data.bigClassify = data.profession[0]
data.smallClassify = data.profession[1]
- data.domain = findNodeById(state.expertsType,data.smallClassify)
+ data.domain = findNodeById(state.expertsType,data.smallClassify)?.classifyName
data.supportDirectionSafety = Array.isArray(data.supportDirectionSafety)?data.supportDirectionSafety.join(','):''
data.supportDirectionPrevention = Array.isArray(data.supportDirectionPrevention)?data.supportDirectionPrevention.join(','):''
data.supportDirectionEmergency = Array.isArray(data.supportDirectionEmergency)?data.supportDirectionEmergency.join(','):''
--
Gitblit v1.9.2