| | |
| | | <el-dialog :title="modalOptions.title" v-model="visible" @close="close" width="60%"> |
| | | <el-form :model="form" label-width="100px" :rules="formRules" ref="formRef"> |
| | | <el-form-item label="岗位名称" prop="deptPositionId"> |
| | | <el-select v-model="form.deptPositionId" placeholder="请选择" clearable @change="handlePositionChange"> |
| | | <el-option :label="item.name" :value="item.id" v-for="(item,index) in positionOptions" :key="item.id" /> |
| | | </el-select> |
| | | <el-tree-select |
| | | v-model="form.deptPositionId" |
| | | :data="deptPositionTree" |
| | | :props="{ value: 'id', label: 'label', children: 'children' }" |
| | | placeholder="请选择部门或岗位" |
| | | clearable |
| | | check-strictly |
| | | :render-after-expand="false" |
| | | check-on-click-node |
| | | @change="handlePositionChange" |
| | | > |
| | | <template #default="{ data }"> |
| | | <span> |
| | | <el-tag size="small" :type="data.type===1 ? 'success' : 'warning'" effect="plain" style="margin-right:4px;"> |
| | | {{ data.type === 1 ? '部门' : '岗位' }} |
| | | </el-tag> |
| | | {{ data.label }} |
| | | </span> |
| | | </template> |
| | | </el-tree-select> |
| | | </el-form-item> |
| | | <el-form-item label="劳保类型" prop="dictType"> |
| | | <el-select v-model="form.dictType" placeholder="请选择" clearable> |
| | |
| | | import useUserStore from "@/store/modules/user"; |
| | | import {staffOnJobListPage} from "@/api/personnelManagement/employeeRecord.js"; |
| | | import { getDept } from "@/api/collaborativeApproval/approvalProcess.js"; |
| | | import { deptPositionListPage, getDeptPositionByDeptIdLabor } from "@/api/lavorissce/issue"; |
| | | import { getDeptPositionTree, getDeptPositionByDeptIdLabor } from "@/api/lavorissce/issue"; |
| | | import { deepCopySameProperties } from '@/utils/util' |
| | | import { ElMessage } from "element-plus"; |
| | | |
| | |
| | | |
| | | const productOptions = ref([]); |
| | | const personList = ref([]); |
| | | const positionOptions = ref([]); |
| | | const deptPositionTree = ref([]); |
| | | const laborSuppliesOptions = ref([]); |
| | | |
| | | const formRules = { |
| | |
| | | await nextTick() |
| | | deepCopySameProperties(row, form) |
| | | } |
| | | async function loadPositions() { |
| | | const res = await deptPositionListPage({pageNum: -1, pageSize:-1}) |
| | | positionOptions.value = res?.data?.records || res?.data || [] |
| | | // 将部门岗位数据转换为树形结构 |
| | | function mapDeptToTree(d) { |
| | | const node = { |
| | | id: d.id, |
| | | label: d.name, |
| | | type: d.type, |
| | | children: [], |
| | | } |
| | | const kids = Array.isArray(d.children) ? d.children : [] |
| | | for (const c of kids) { |
| | | if (c.type === 1) { |
| | | node.children.push(mapDeptToTree(c)) |
| | | } else if (c.type === 2) { |
| | | node.children.push({ |
| | | id: c.id, |
| | | label: c.name, |
| | | type: c.type, |
| | | }) |
| | | } |
| | | } |
| | | return node |
| | | } |
| | | |
| | | async function loadDeptPositionTree() { |
| | | try { |
| | | const res = await getDeptPositionTree() |
| | | const data = res?.data || res || [] |
| | | deptPositionTree.value = data.map(d => mapDeptToTree(d)) |
| | | } catch (e) { |
| | | console.error('加载部门岗位树失败:', e) |
| | | deptPositionTree.value = [] |
| | | } |
| | | } |
| | | |
| | | async function handlePositionChange(deptPositionId) { |
| | | console.log('选择的岗位ID:', deptPositionId) |
| | | if (!deptPositionId) { |
| | | laborSuppliesOptions.value = [] |
| | | form.dictId = undefined |
| | |
| | | } |
| | | |
| | | onMounted(() => { |
| | | loadPositions() |
| | | loadDeptPositionTree() |
| | | getPersonList() |
| | | }) |
| | | |