| | |
| | | <el-form ref="formRef" :model="form" :rules="rules" label-position="top"> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="6"> |
| | | <el-form-item label="工资主题" prop="title"> |
| | | <el-form-item label="工资主题" prop="salaryTitle"> |
| | | <el-input |
| | | v-model="form.title" |
| | | v-model="form.salaryTitle" |
| | | placeholder="请输入" |
| | | clearable |
| | | maxlength="20" |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="选择工资月份" prop="payMonth"> |
| | | <el-form-item label="选择工资月份" prop="salaryMonth"> |
| | | <el-date-picker |
| | | v-model="form.payMonth" |
| | | v-model="form.salaryMonth" |
| | | type="month" |
| | | value-format="YYYY-MM" |
| | | format="YYYY-MM" |
| | |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="6"> |
| | | <el-form-item label="支付银行" prop="payBank"> |
| | | <el-select |
| | | v-model="form.payBank" |
| | | placeholder="请选择" |
| | | clearable |
| | | filterable |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="b in bankOptions" |
| | | :key="b" |
| | | :label="b" |
| | | :value="b" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | > |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="员工姓名" prop="staffName" minWidth="100" /> |
| | | <el-table-column label="角色" prop="roleName" minWidth="100" /> |
| | | <el-table-column label="部门" prop="deptName" minWidth="100" /> |
| | | <el-table-column label="基本工资" minWidth="110"> |
| | | <template #default="{ row }"> |
| | |
| | | <el-table-column label="计件工资" minWidth="110"> |
| | | <template #default="{ row }"> |
| | | <el-input |
| | | v-model.number="row.pieceworkSalary" |
| | | v-model.number="row.pieceSalary" |
| | | type="number" |
| | | placeholder="0" |
| | | size="small" |
| | | @input="row.pieceworkSalary = parseNum(row.pieceworkSalary)" |
| | | @input="row.pieceSalary = parseNum(row.pieceSalary)" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | <el-table-column label="社保个人" minWidth="110"> |
| | | <template #default="{ row }"> |
| | | <el-input |
| | | v-model.number="row.socialSecurityIndividuals" |
| | | v-model.number="row.socialPersonal" |
| | | type="number" |
| | | placeholder="0" |
| | | size="small" |
| | | @input="row.socialSecurityIndividuals = parseNum(row.socialSecurityIndividuals)" |
| | | @input="row.socialPersonal = parseNum(row.socialPersonal)" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="公积金个人" minWidth="120"> |
| | | <template #default="{ row }"> |
| | | <el-input |
| | | v-model.number="row.providentFundIndividuals" |
| | | v-model.number="row.fundPersonal" |
| | | type="number" |
| | | placeholder="0" |
| | | size="small" |
| | | @input="row.providentFundIndividuals = parseNum(row.providentFundIndividuals)" |
| | | @input="row.fundPersonal = parseNum(row.fundPersonal)" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | import { ArrowUp } from "@element-plus/icons-vue"; |
| | | import { listDept } from "@/api/system/dept.js"; |
| | | import { staffOnJobList } from "@/api/personnelManagement/monthlyStatistics.js"; |
| | | import { bankList } from "@/api/personnelManagement/bank.js"; |
| | | import { |
| | | monthlyStatisticsAdd, |
| | | monthlyStatisticsUpdate, |
| | | monthlyStatisticsGet, |
| | | } from "@/api/personnelManagement/monthlyStatistics.js"; |
| | | staffSalaryMainAdd, |
| | | staffSalaryMainUpdate, |
| | | staffSalaryMainCalculateSalary, |
| | | } from "@/api/personnelManagement/staffSalaryMain.js"; |
| | | |
| | | const emit = defineEmits(["update:modelValue", "close"]); |
| | | const props = defineProps({ |
| | |
| | | const deptStaffTree = ref([]); |
| | | const employeeList = ref([]); |
| | | const selectedEmployees = ref([]); |
| | | const bankOptions = ref([]); |
| | | const taxTableData = ref([ |
| | | { level: 1, range: "不超过36000元", rate: 3, quickDeduction: 0 }, |
| | | { level: 2, range: "超过36000-144000元", rate: 10, quickDeduction: 2520 }, |
| | |
| | | const data = reactive({ |
| | | form: { |
| | | id: undefined, |
| | | title: "", |
| | | salaryTitle: "", |
| | | deptId: undefined, |
| | | payMonth: "", |
| | | salaryMonth: "", |
| | | remark: "", |
| | | payBank: "", |
| | | }, |
| | | rules: { |
| | | title: [{ required: true, message: "请输入工资主题", trigger: "blur" }], |
| | | salaryTitle: [{ required: true, message: "请输入工资主题", trigger: "blur" }], |
| | | deptId: [{ required: true, message: "请选择部门", trigger: "change" }], |
| | | payMonth: [{ required: true, message: "请选择工资月份", trigger: "change" }], |
| | | salaryMonth: [{ required: true, message: "请选择工资月份", trigger: "change" }], |
| | | }, |
| | | }); |
| | | const { form, rules } = toRefs(data); |
| | | |
| | | const loadBankOptions = () => { |
| | | return bankList().then((res) => { |
| | | const list = Array.isArray(res?.data) ? res.data : []; |
| | | bankOptions.value = list |
| | | .map((b) => (b?.bankName == null ? "" : String(b.bankName).trim())) |
| | | .filter((v) => v !== ""); |
| | | }); |
| | | }; |
| | | |
| | | // 扁平化部门树供下拉使用 |
| | | function flattenDept(tree, list = []) { |
| | |
| | | const openDialog = (type, row) => { |
| | | nextTick(() => { |
| | | loadDeptOptions(); |
| | | loadBankOptions(); |
| | | employeeList.value = []; |
| | | Object.assign(form.value, { |
| | | id: undefined, |
| | | title: "", |
| | | salaryTitle: "", |
| | | deptId: undefined, |
| | | payMonth: "", |
| | | salaryMonth: "", |
| | | remark: "", |
| | | payBank: "", |
| | | }); |
| | | // 编辑:列表页已返回主表字段;这里只做回显(明细由“生成工资表/计算工资”得到) |
| | | if (type === "edit" && row?.id) { |
| | | monthlyStatisticsGet(row.id).then((res) => { |
| | | const d = res.data || {}; |
| | | form.value.id = d.id; |
| | | form.value.title = d.title ?? d.payDateStr ?? ""; |
| | | form.value.deptId = d.deptId; |
| | | form.value.payMonth = d.payMonth ?? d.payDate ?? d.payDateStr ?? ""; |
| | | form.value.remark = d.remark ?? ""; |
| | | employeeList.value = (d.detailList || d.employeeList || []).map((e) => ({ |
| | | ...e, |
| | | basicSalary: parseNum(e.basicSalary), |
| | | pieceworkSalary: parseNum(e.pieceworkSalary), |
| | | hourlySalary: parseNum(e.hourlySalary), |
| | | otherIncome: parseNum(e.otherIncome), |
| | | socialSecurityIndividuals: parseNum(e.socialSecurityIndividuals), |
| | | providentFundIndividuals: parseNum(e.providentFundIndividuals), |
| | | })); |
| | | }); |
| | | form.value.id = row.id; |
| | | form.value.salaryTitle = row.salaryTitle ?? ""; |
| | | // deptIds 后端是字符串(多个用逗号分隔);当前表单仍是单选 deptId |
| | | form.value.deptId = row.deptIds ? Number(String(row.deptIds).split(",")[0]) : undefined; |
| | | form.value.salaryMonth = row.salaryMonth ?? ""; |
| | | form.value.remark = row.remark ?? ""; |
| | | form.value.payBank = row.payBank ?? ""; |
| | | } |
| | | }); |
| | | }; |
| | |
| | | if (existIds.has(id)) return; |
| | | existIds.add(id); |
| | | employeeList.value.push({ |
| | | staffId: id, |
| | | id: id, |
| | | staffOnJobId: id, |
| | | id, |
| | | staffName: node.label, |
| | | roleName: node.roleName ?? node.role ?? "", |
| | | postName: node.postName ?? node.post ?? "", |
| | | deptName: node.deptName ?? "", |
| | | basicSalary: 0, |
| | | pieceworkSalary: 0, |
| | | pieceSalary: 0, |
| | | hourlySalary: 0, |
| | | otherIncome: 0, |
| | | socialSecurityIndividuals: 0, |
| | | providentFundIndividuals: 0, |
| | | socialPersonal: 0, |
| | | fundPersonal: 0, |
| | | otherDeduct: 0, |
| | | salaryTax: 0, |
| | | grossSalary: 0, |
| | | deductSalary: 0, |
| | | netSalary: 0, |
| | | remark: "", |
| | | }); |
| | | }); |
| | | addPersonVisible.value = false; |
| | |
| | | |
| | | const removeEmployee = (row) => { |
| | | employeeList.value = employeeList.value.filter( |
| | | (e) => (e.staffId || e.id) !== (row.staffId || row.id) |
| | | (e) => (e.staffOnJobId || e.id) !== (row.staffOnJobId || row.id) |
| | | ); |
| | | }; |
| | | |
| | |
| | | proxy.$modal.msgWarning("请先勾选要删除的员工"); |
| | | return; |
| | | } |
| | | const ids = new Set(selectedEmployees.value.map((e) => e.staffId || e.id)); |
| | | const ids = new Set(selectedEmployees.value.map((e) => e.staffOnJobId || e.id)); |
| | | employeeList.value = employeeList.value.filter( |
| | | (e) => !ids.has(e.staffId || e.id) |
| | | (e) => !ids.has(e.staffOnJobId || e.id) |
| | | ); |
| | | }; |
| | | |
| | | const handleGenerate = () => { |
| | | proxy.$modal.msgInfo("生成工资表功能需对接后端"); |
| | | if (!form.value.deptId) { |
| | | proxy.$modal.msgWarning("请先选择部门"); |
| | | return; |
| | | } |
| | | if (!form.value.salaryMonth) { |
| | | proxy.$modal.msgWarning("请先选择工资月份"); |
| | | return; |
| | | } |
| | | if (!employeeList.value?.length) { |
| | | proxy.$modal.msgWarning("请先新增人员"); |
| | | return; |
| | | } |
| | | const ids = employeeList.value |
| | | .map((e) => e.staffOnJobId ?? e.staffId ?? e.id) |
| | | .filter(Boolean); |
| | | staffSalaryMainCalculateSalary(ids).then((res) => { |
| | | const list = Array.isArray(res?.data) ? res.data : []; |
| | | if (!list.length) { |
| | | proxy.$modal.msgWarning("未计算到工资数据"); |
| | | return; |
| | | } |
| | | employeeList.value = list.map((e) => ({ |
| | | ...e, |
| | | staffOnJobId: e.staffOnJobId ?? e.staffId ?? e.id, |
| | | staffName: e.staffName, |
| | | postName: e.postName, |
| | | deptName: e.deptName, |
| | | basicSalary: parseNum(e.basicSalary), |
| | | pieceSalary: parseNum(e.pieceSalary), |
| | | hourlySalary: parseNum(e.hourlySalary), |
| | | otherIncome: parseNum(e.otherIncome), |
| | | socialPersonal: parseNum(e.socialPersonal), |
| | | fundPersonal: parseNum(e.fundPersonal), |
| | | otherDeduct: parseNum(e.otherDeduct), |
| | | salaryTax: parseNum(e.salaryTax), |
| | | grossSalary: parseNum(e.grossSalary), |
| | | deductSalary: parseNum(e.deductSalary), |
| | | netSalary: parseNum(e.netSalary), |
| | | remark: e.remark ?? "", |
| | | })); |
| | | proxy.$modal.msgSuccess("生成成功"); |
| | | }); |
| | | }; |
| | | |
| | | const handleExport = () => { |
| | |
| | | if (!valid) return; |
| | | const payload = { |
| | | ...form.value, |
| | | deptIds: form.value.deptId ? String(form.value.deptId) : "", |
| | | detailList: employeeList.value.map((e) => ({ |
| | | staffId: e.staffId ?? e.id, |
| | | staffOnJobId: e.staffOnJobId ?? e.staffId ?? e.id, |
| | | staffName: e.staffName, |
| | | basicSalary: parseNum(e.basicSalary), |
| | | pieceworkSalary: parseNum(e.pieceworkSalary), |
| | | pieceSalary: parseNum(e.pieceSalary), |
| | | hourlySalary: parseNum(e.hourlySalary), |
| | | otherIncome: parseNum(e.otherIncome), |
| | | socialSecurityIndividuals: parseNum(e.socialSecurityIndividuals), |
| | | providentFundIndividuals: parseNum(e.providentFundIndividuals), |
| | | socialPersonal: parseNum(e.socialPersonal), |
| | | fundPersonal: parseNum(e.fundPersonal), |
| | | otherDeduct: parseNum(e.otherDeduct), |
| | | salaryTax: parseNum(e.salaryTax), |
| | | grossSalary: parseNum(e.grossSalary), |
| | | deductSalary: parseNum(e.deductSalary), |
| | | netSalary: parseNum(e.netSalary), |
| | | remark: e.remark ?? "", |
| | | })), |
| | | }; |
| | | if (props.operationType === "add") { |
| | | monthlyStatisticsAdd(payload).then(() => { |
| | | staffSalaryMainAdd({ ...payload, status: 1 }).then(() => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | closeDia(); |
| | | }); |
| | | } else { |
| | | monthlyStatisticsUpdate(payload).then(() => { |
| | | staffSalaryMainUpdate(payload).then(() => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | closeDia(); |
| | | }); |