| | |
| | | <template> |
| | | <el-dialog |
| | | <FormDialog |
| | | v-model="dialogVisible" |
| | | :title="operationType === 'add' ? '新建工资表' : '编辑工资表'" |
| | | width="90%" |
| | | :close-on-click-modal="false" |
| | | destroy-on-close |
| | | @close="closeDia" |
| | | @confirm="submitForm" |
| | | @cancel="closeDia" |
| | | > |
| | | <div class="form-dia-body"> |
| | | <!-- 基础资料 --> |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="选择部门" prop="deptId"> |
| | | <el-form-item label="选择部门" prop="deptIds"> |
| | | <el-select |
| | | v-model="form.deptId" |
| | | v-model="form.deptIds" |
| | | placeholder="请选择" |
| | | clearable |
| | | multiple |
| | | collapse-tags |
| | | collapse-tags-tooltip |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="closeDia">取消</el-button> |
| | | <el-button type="primary" @click="submitForm">确定</el-button> |
| | | </div> |
| | | </template> |
| | | |
| | | |
| | | <!-- 新增人员弹窗 --> |
| | | <el-dialog |
| | |
| | | /> |
| | | </el-table> |
| | | </el-dialog> |
| | | </el-dialog> |
| | | </FormDialog> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive, toRefs, computed, getCurrentInstance, nextTick } 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"; |
| | |
| | | form: { |
| | | id: undefined, |
| | | salaryTitle: "", |
| | | deptId: undefined, |
| | | deptIds: [], |
| | | salaryMonth: "", |
| | | remark: "", |
| | | payBank: "", |
| | | }, |
| | | rules: { |
| | | salaryTitle: [{ required: true, message: "请输入工资主题", trigger: "blur" }], |
| | | deptId: [{ required: true, message: "请选择部门", trigger: "change" }], |
| | | deptIds: [{ required: true, message: "请选择部门", trigger: "change" }], |
| | | salaryMonth: [{ required: true, message: "请选择工资月份", trigger: "change" }], |
| | | }, |
| | | }); |
| | |
| | | Object.assign(form.value, { |
| | | id: undefined, |
| | | salaryTitle: "", |
| | | deptId: undefined, |
| | | deptIds: [], |
| | | salaryMonth: "", |
| | | remark: "", |
| | | payBank: "", |
| | |
| | | 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.deptIds = row.deptIds |
| | | ? String(row.deptIds).split(",").map((id) => Number(id.trim())).filter(Boolean) |
| | | : []; |
| | | form.value.salaryMonth = row.salaryMonth ?? ""; |
| | | form.value.remark = row.remark ?? ""; |
| | | form.value.payBank = row.payBank ?? ""; |
| | |
| | | }; |
| | | |
| | | const handleGenerate = () => { |
| | | if (!form.value.deptId) { |
| | | if (!form.value.deptIds?.length) { |
| | | proxy.$modal.msgWarning("请先选择部门"); |
| | | return; |
| | | } |
| | |
| | | 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 payload = { |
| | | ids: form.value.deptIds, |
| | | date: form.value.salaryMonth, |
| | | }; |
| | | staffSalaryMainCalculateSalary(payload).then((res) => { |
| | | const list = Array.isArray(res?.data) ? res.data : []; |
| | | if (!list.length) { |
| | | proxy.$modal.msgWarning("未计算到工资数据"); |
| | |
| | | formRef.value?.validate((valid) => { |
| | | if (!valid) return; |
| | | const payload = { |
| | | ...form.value, |
| | | deptIds: form.value.deptId ? String(form.value.deptId) : "", |
| | | detailList: employeeList.value.map((e) => ({ |
| | | id: form.value.id, |
| | | salaryTitle: form.value.salaryTitle, |
| | | deptIds: form.value.deptIds?.length ? form.value.deptIds.join(",") : "", |
| | | salaryMonth: form.value.salaryMonth, |
| | | remark: form.value.remark, |
| | | payBank: form.value.payBank, |
| | | staffSalaryDetailList: employeeList.value.map((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), |