| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="选择工资月份" |
| | | prop="salaryMonth"> |
| | | <el-date-picker v-model="form.salaryMonth" |
| | | type="month" |
| | | value-format="YYYY-MM" |
| | | format="YYYY-MM" |
| | | placeholder="请选择工资月份" |
| | | style="width: 100%" |
| | | clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="选择部门" |
| | | prop="deptIds"> |
| | | <el-select v-model="form.deptIds" |
| | |
| | | <el-option v-for="item in deptOptions" |
| | | :key="item.deptId" |
| | | :label="item.deptName" |
| | | :value="item.deptId" /> |
| | | :value="item.deptId" |
| | | :disabled="isDeptDisabled(item.deptId)" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="选择工资月份" |
| | | prop="salaryMonth"> |
| | | <el-date-picker v-model="form.salaryMonth" |
| | | type="month" |
| | | value-format="YYYY-MM" |
| | | format="YYYY-MM" |
| | | placeholder="请选择工资月份" |
| | | style="width: 100%" |
| | | clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | |
| | | computed, |
| | | getCurrentInstance, |
| | | nextTick, |
| | | watch, |
| | | } from "vue"; |
| | | import { ArrowUp } from "@element-plus/icons-vue"; |
| | | import FormDialog from "@/components/Dialog/FormDialog.vue"; |
| | | import { listDept } from "@/api/system/dept.js"; |
| | | import { staffOnJobList } from "@/api/personnelManagement/monthlyStatistics.js"; |
| | | import { bankList } from "@/api/personnelManagement/bank.js"; |
| | | import { |
| | | staffSalaryMainAdd, |
| | | staffSalaryMainUpdate, |
| | | staffSalaryMainCalculateSalary, |
| | | staffSalaryMainCalculateByEmployeeId, |
| | | } from "@/api/personnelManagement/staffSalaryMain.js"; |
| | | import { bankList } from "@/api/personnelManagement/bank.js"; |
| | | import { |
| | | staffSalaryMainAdd, |
| | | staffSalaryMainUpdate, |
| | | staffSalaryMainCalculateSalary, |
| | | staffSalaryMainCalculateByEmployeeId, |
| | | staffSalaryMainAvailableDepts, |
| | | } from "@/api/personnelManagement/staffSalaryMain.js"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | |
| | | const emit = defineEmits(["update:modelValue", "close"]); |
| | |
| | | const addPersonVisible = ref(false); |
| | | const taxDialogVisible = ref(false); |
| | | const deptOptions = ref([]); |
| | | const availableDeptIds = ref(new Set()); |
| | | const deptStaffTree = ref([]); |
| | | const employeeList = ref([]); |
| | | const selectedEmployees = ref([]); |
| | |
| | | return list; |
| | | } |
| | | |
| | | const loadDeptOptions = () => { |
| | | // 加载所有部门 |
| | | const loadAllDeptOptions = () => { |
| | | listDept().then(res => { |
| | | const tree = res.data ?? []; |
| | | deptOptions.value = flattenDept(tree); |
| | | }); |
| | | }; |
| | | |
| | | // 加载可用部门列表(用于判断部门是否可选) |
| | | const loadAvailableDepts = (salaryMonth) => { |
| | | if (!salaryMonth) { |
| | | availableDeptIds.value = new Set(); |
| | | return; |
| | | } |
| | | staffSalaryMainAvailableDepts(salaryMonth).then(res => { |
| | | const availableDepts = Array.isArray(res.data) ? res.data : []; |
| | | availableDeptIds.value = new Set(availableDepts.map(d => d.deptId)); |
| | | }); |
| | | }; |
| | | |
| | | // 判断部门是否禁用 |
| | | const isDeptDisabled = (deptId) => { |
| | | // 如果没有选择月份,所有部门都可选 |
| | | if (!form.value.salaryMonth) return false; |
| | | // 如果已选择月份,只有在可用部门列表中的部门才可选 |
| | | return !availableDeptIds.value.has(deptId); |
| | | }; |
| | | |
| | | // 构建 部门-人员 树(用于新增人员弹窗) |
| | |
| | | const openDialog = (type, row) => { |
| | | nextTick(() => { |
| | | resetRecalcState(); |
| | | loadDeptOptions(); |
| | | loadBankOptions(); |
| | | loadUserList(); |
| | | loadAllDeptOptions(); |
| | | employeeList.value = []; |
| | | Object.assign(form.value, { |
| | | id: undefined, |
| | |
| | | employeeList.value = row.staffSalaryDetailList.map(e => normalizeEmployeeRow(e)); |
| | | } |
| | | } |
| | | // 编辑状态且有月份时,加载可用部门列表 |
| | | if (type === "edit" && form.value.salaryMonth) { |
| | | loadAvailableDepts(form.value.salaryMonth); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | // 监听工资月份变化,清空部门选择并加载可用部门列表 |
| | | watch(() => form.value.salaryMonth, (newMonth, oldMonth) => { |
| | | // 切换月份时清空已选择的部门 |
| | | if (newMonth !== oldMonth) { |
| | | form.value.deptIds = []; |
| | | } |
| | | loadAvailableDepts(newMonth); |
| | | }); |
| | | |
| | | const openAddPerson = () => { |
| | | loadDeptStaffTree(); |
| | |
| | | font-weight: bold; |
| | | font-size: 18px; |
| | | } |
| | | </style> |
| | | </style> |