<template>
|
<FormDialog
|
v-model="dialogVisible"
|
title="工资审核"
|
width="900px"
|
@close="handleClose"
|
>
|
<!-- 工资表基础信息 -->
|
<el-card shadow="never" style="margin-bottom: 16px;">
|
<template #header>
|
<span>工资表信息</span>
|
</template>
|
<el-descriptions :column="3" border>
|
<el-descriptions-item label="工资主题">{{ auditData?.salaryTitle || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="工资月份">{{ auditData?.salaryMonth || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="工资总额">¥ {{ formatMoney(auditData?.totalSalary) }}</el-descriptions-item>
|
<el-descriptions-item label="支付银行">{{ auditData?.payBank || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="审核人">{{ auditData?.auditUserName || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="备注">{{ auditData?.remark || '-' }}</el-descriptions-item>
|
</el-descriptions>
|
</el-card>
|
|
<!-- 员工工资明细 -->
|
<el-card shadow="never" style="margin-bottom: 16px;">
|
<template #header>
|
<span>员工工资明细</span>
|
</template>
|
<div v-if="!employeeList || employeeList.length === 0" style="text-align: center; padding: 20px; color: #909399;">
|
<div>暂无员工工资明细数据</div>
|
<div style="font-size: 12px; margin-top: 5px;">员工明细数据需要在工资表生成或编辑时才会保存</div>
|
</div>
|
<div v-else>
|
<el-table :data="employeeList" border max-height="300" style="width: 100%">
|
<el-table-column prop="staffName" label="员工姓名" width="100" />
|
<el-table-column prop="deptName" label="部门" width="120" />
|
<el-table-column prop="basicSalary" label="基本工资" width="100" align="right">
|
<template #default="{ row }">¥ {{ formatMoney(row.basicSalary) }}</template>
|
</el-table-column>
|
<el-table-column prop="pieceSalary" label="计件工资" width="100" align="right">
|
<template #default="{ row }">¥ {{ formatMoney(row.pieceSalary) }}</template>
|
</el-table-column>
|
<el-table-column prop="hourlySalary" label="计时工资" width="100" align="right">
|
<template #default="{ row }">¥ {{ formatMoney(row.hourlySalary) }}</template>
|
</el-table-column>
|
<el-table-column prop="otherIncome" label="其他收入" width="100" align="right">
|
<template #default="{ row }">¥ {{ formatMoney(row.otherIncome) }}</template>
|
</el-table-column>
|
<el-table-column prop="socialPersonal" label="社保个人" width="100" align="right">
|
<template #default="{ row }">¥ {{ formatMoney(row.socialPersonal) }}</template>
|
</el-table-column>
|
<el-table-column prop="fundPersonal" label="公积金个人" width="120" align="right">
|
<template #default="{ row }">¥ {{ formatMoney(row.fundPersonal) }}</template>
|
</el-table-column>
|
<el-table-column prop="salaryTax" label="工资个税" width="100" align="right">
|
<template #default="{ row }">¥ {{ formatMoney(row.salaryTax) }}</template>
|
</el-table-column>
|
<el-table-column prop="netSalary" label="实发工资" width="100" align="right" fixed="right">
|
<template #default="{ row }">¥ {{ formatMoney(row.netSalary) }}</template>
|
</el-table-column>
|
</el-table>
|
<div style="margin-top: 10px; text-align: right; font-weight: bold;">
|
工资总额:¥ {{ formatMoney(totalSalary) }}
|
</div>
|
</div>
|
</el-card>
|
|
<!-- 审核操作 -->
|
<el-form label-position="top">
|
<el-form-item label="审核结果" required>
|
<el-radio-group v-model="auditResult">
|
<el-radio :value="4">通过</el-radio>
|
<el-radio :value="2">不通过</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-form>
|
|
<template #footer>
|
<el-button type="primary" :loading="loading" @click="handleConfirm">
|
确定
|
</el-button>
|
<el-button @click="handleClose">取消</el-button>
|
</template>
|
</FormDialog>
|
</template>
|
|
<script setup>
|
import { ref, computed, reactive, toRefs, getCurrentInstance, watch } from "vue";
|
import { ElMessage } from "element-plus";
|
import Cookies from "js-cookie";
|
import FormDialog from "@/components/Dialog/FormDialog.vue";
|
import { staffSalaryMainUpdate } from "@/api/personnelManagement/staffSalaryMain.js";
|
|
const emit = defineEmits(["update:modelValue", "close", "success"]);
|
|
const props = defineProps({
|
modelValue: { type: Boolean, default: false },
|
row: { type: Object, default: () => ({}) },
|
});
|
|
const { proxy } = getCurrentInstance();
|
|
const dialogVisible = computed({
|
get: () => props.modelValue,
|
set: (val) => emit("update:modelValue", val),
|
});
|
|
const loading = ref(false);
|
const auditResult = ref(4); // 默认通过
|
const auditData = ref({});
|
const employeeList = ref([]);
|
|
// 监听row数据变化
|
watch(() => props.row, (newRow) => {
|
if (newRow && Object.keys(newRow).length > 0) {
|
loadAuditData(newRow);
|
}
|
}, { immediate: true });
|
|
// 格式化金额
|
const formatMoney = (value) => {
|
const num = Number(value) || 0;
|
return num.toFixed(2);
|
};
|
|
// 计算工资总额
|
const totalSalary = computed(() => {
|
return employeeList.value.reduce((sum, e) => {
|
const salary = Number(e.netSalary) || 0;
|
return sum + salary;
|
}, 0);
|
});
|
|
// 加载审核数据
|
const loadAuditData = (row) => {
|
auditData.value = row || {};
|
auditResult.value = 4; // 默认选择通过
|
|
// 加载员工工资明细数据
|
if (row?.staffSalaryDetailList && Array.isArray(row.staffSalaryDetailList)) {
|
employeeList.value = row.staffSalaryDetailList.map((e) => ({
|
staffName: e.staffName ?? "",
|
deptName: e.deptName ?? "",
|
basicSalary: Number(e.basicSalary) || 0,
|
pieceSalary: Number(e.pieceSalary) || 0,
|
hourlySalary: Number(e.hourlySalary) || 0,
|
otherIncome: Number(e.otherIncome) || 0,
|
socialPersonal: Number(e.socialPersonal) || 0,
|
fundPersonal: Number(e.fundPersonal) || 0,
|
salaryTax: Number(e.salaryTax) || 0,
|
netSalary: Number(e.netSalary) || 0,
|
}));
|
} else {
|
console.log('没有找到员工明细数据');
|
employeeList.value = [];
|
}
|
};
|
|
// 打开弹窗
|
const openDialog = (row) => {
|
loadAuditData(row);
|
dialogVisible.value = true;
|
};
|
|
// 关闭弹窗
|
const handleClose = () => {
|
dialogVisible.value = false;
|
emit("close");
|
};
|
|
// 确认审核
|
const handleConfirm = () => {
|
try {
|
const row = auditData.value;
|
if (!row?.id) {
|
ElMessage.warning("数据异常,请重试");
|
return;
|
}
|
|
const username = Cookies.get("username") || "";
|
const userIdRaw = Cookies.get("userId");
|
const auditUserId = userIdRaw ? Number(userIdRaw) : undefined;
|
|
// 构建审核数据
|
const submitData = {
|
id: row.id,
|
status: Number(auditResult.value) === 2 ? 2 : 4, // 2=不通过 4=通过(待发放)
|
auditUserId,
|
auditUserName: username,
|
};
|
loading.value = true;
|
staffSalaryMainUpdate(submitData)
|
.then(() => {
|
ElMessage.success("审核成功");
|
dialogVisible.value = false;
|
emit("success");
|
})
|
.catch((error) => {
|
console.error('审核失败:', error)
|
})
|
.finally(() => {
|
loading.value = false;
|
});
|
} catch (error) {
|
console.error('审核处理异常:', error);
|
loading.value = false;
|
}
|
};
|
|
defineExpose({ openDialog });
|
</script>
|
|
<style scoped>
|
:deep(.el-descriptions__label) {
|
width: 100px;
|
}
|
</style>
|