| | |
| | | <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> |
| | |
| | | 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()=> { |
| | |
| | | } |
| | | 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: '' |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | 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 = "修改分类"; |
| | | } |
| | |
| | | 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){ |
| | |
| | | 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> |
| | |
| | | <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> |
| | |
| | | |
| | | const state = reactive({ |
| | | assessDialog: false, |
| | | findDept: true, |
| | | form: { |
| | | id: null, |
| | | name: '', |
| | |
| | | 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); |
| | |
| | | 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(',') : '' |
| | |
| | | <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> |
| | |
| | | remark: '', |
| | | source: 1 |
| | | }, |
| | | findDept: true, |
| | | expertsType: [], |
| | | deptList: [], |
| | | directionList: [ |
| | |
| | | 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); |
| | |
| | | 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(','):'' |