<template>
|
<div class="app-container">
|
<div class="table_list">
|
<el-row :gutter="16"
|
class="content-row">
|
<!-- 左侧台账 + 顶部筛选 -->
|
<el-col :xs="24"
|
:sm="24"
|
:md="24"
|
:lg="8"
|
:xl="8"
|
class="left-col">
|
<div class="left-panel">
|
<el-alert
|
title="工资核算口径:仅统计审核通过的报工数据。"
|
type="info"
|
:closable="false"
|
show-icon
|
/>
|
<div class="left-header">
|
<el-form :model="searchForm"
|
inline>
|
<el-form-item label="报工人员:">
|
<el-input v-model="searchForm.schedulingUserName"
|
placeholder="请输入"
|
clearable
|
style="width: 160px"
|
@change="reloadData" />
|
</el-form-item>
|
<el-form-item label="工单编号:">
|
<el-input v-model="searchForm.workOrderNo"
|
placeholder="请输入"
|
clearable
|
style="width: 160px"
|
@change="reloadData" />
|
</el-form-item>
|
<el-form-item prop="dateType">
|
<el-radio-group v-model="searchForm.dateType"
|
size="small"
|
@change="handleDateTypeChange">
|
<el-radio-button label="day">日</el-radio-button>
|
<el-radio-button label="month">月</el-radio-button>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item label="日期:"
|
prop="dateRange">
|
<el-date-picker v-model="searchForm.dateRange"
|
:type="searchForm.dateType === 'day' ? 'date' : 'daterange'"
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
style="width: 200px"
|
@change="handleDateRangeChange" />
|
</el-form-item>
|
</el-form>
|
</div>
|
<PIMTable rowKey="id"
|
:column="leftTableColumn"
|
:tableData="leftTableData"
|
:tableLoading="tableLoading"
|
:page="page"
|
@row-click="handleLeftRowClick"
|
@pagination="pagination"></PIMTable>
|
</div>
|
</el-col>
|
<!-- 右侧明细 -->
|
<el-col :xs="24"
|
:sm="24"
|
:md="24"
|
:lg="16"
|
:xl="16"
|
class="right-col">
|
<div class="right-panel">
|
<div class="right-toolbar">
|
<el-button type="primary" @click="handleBatchAccounting">批量核算</el-button>
|
</div>
|
<PIMTable rowKey="id"
|
:column="tableColumn"
|
:tableData="tableData"
|
:page="page1"
|
:isSelection="true"
|
@selection-change="handleSelectionChange"
|
:tableLoading="tableLoading1"
|
style="margin-right: 20px;"
|
@pagination="pagination1"></PIMTable>
|
</div>
|
</el-col>
|
</el-row>
|
</div>
|
<el-dialog v-model="adjustDialogVisible"
|
title="单个修正"
|
width="520px">
|
<el-form :model="adjustForm" label-width="120px">
|
<el-form-item label="报工单号">
|
<el-input v-model="adjustForm.reportNo" disabled />
|
</el-form-item>
|
<el-form-item label="报工人员">
|
<el-input v-model="adjustForm.schedulingUserName" disabled />
|
</el-form-item>
|
<el-form-item label="修正金额">
|
<el-input-number v-model="adjustForm.wages" :min="0" :precision="2" style="width: 100%" />
|
</el-form-item>
|
<el-form-item label="修正说明">
|
<el-input v-model="adjustForm.remark" type="textarea" :rows="3" />
|
</el-form-item>
|
</el-form>
|
<template #footer>
|
<el-button @click="adjustDialogVisible = false">取消</el-button>
|
<el-button type="primary" @click="confirmAdjust">确认</el-button>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup>
|
import { onMounted, ref, reactive, toRefs, getCurrentInstance } from "vue";
|
import { ElMessageBox } from "element-plus";
|
import dayjs from "dayjs";
|
import {
|
salesLedgerProductionAccountingListProductionDetails,
|
salesLedgerProductionAccountingList,
|
productionAccountingBatchAccounting,
|
productionAccountingSingleAdjust,
|
} from "@/api/productionManagement/productionCosting.js";
|
const { proxy } = getCurrentInstance();
|
|
const formatTag = (val, map) => {
|
const item = map[String(val)];
|
if (!item) return "-";
|
return item.label;
|
};
|
|
const tableColumn = ref([
|
{
|
label: "报工单号",
|
prop: "reportNo",
|
minWidth: 140,
|
},
|
{
|
label: "生产日期",
|
prop: "schedulingDate",
|
minWidth: 100,
|
},
|
{
|
label: "生产人",
|
prop: "schedulingUserName",
|
minWidth: 100,
|
},
|
{
|
label: "审核状态",
|
prop: "auditStatus",
|
minWidth: 100,
|
dataType: "tag",
|
formatData: val => formatTag(val, {
|
0: { label: "待审核" },
|
1: { label: "审核通过" },
|
2: { label: "审核不通过" },
|
}),
|
formatType: val => {
|
const typeMap = {
|
0: "warning",
|
1: "success",
|
2: "danger",
|
};
|
return typeMap[String(val)] || "info";
|
},
|
},
|
{
|
label: "报工类型",
|
prop: "reportType",
|
minWidth: 100,
|
dataType: "tag",
|
formatData: val => formatTag(val, {
|
0: { label: "合格" },
|
1: { label: "轻微返工" },
|
2: { label: "严重返工" },
|
3: { label: "报废" },
|
}),
|
formatType: val => {
|
const typeMap = {
|
0: "success",
|
1: "warning",
|
2: "danger",
|
3: "info",
|
};
|
return typeMap[String(val)] || "info";
|
},
|
},
|
{
|
label: "销售合同号",
|
prop: "salesContractNo",
|
minWidth: 140,
|
},
|
{
|
label: "产品大类",
|
prop: "productName",
|
minWidth: 100,
|
},
|
{
|
label: "产品标准数量",
|
prop: "productStandardQuantity",
|
minWidth: 120,
|
},
|
{
|
label: "规格型号",
|
prop: "productModelName",
|
minWidth: 100,
|
},
|
{
|
label: "单位",
|
prop: "unit",
|
minWidth: 100,
|
},
|
{
|
label: "工序",
|
prop: "process",
|
minWidth: 100,
|
},
|
{
|
label: "标准数量",
|
prop: "standardQuantity",
|
minWidth: 100,
|
},
|
{
|
label: "工单编号",
|
prop: "workOrderNo",
|
minWidth: 140,
|
},
|
{
|
label: "补修理工时",
|
prop: "repairWorkHour",
|
minWidth: 120,
|
},
|
{
|
label: "生产数量",
|
prop: "quantity",
|
minWidth: 100,
|
},
|
{
|
label: "折算工时",
|
prop: "convertedWorkHours",
|
minWidth: 100,
|
},
|
]);
|
|
// 左侧汇总台账列(生产人、产量、工资、合格率)
|
const leftTableColumn = ref([
|
{
|
label: "生产人",
|
prop: "schedulingUserName",
|
minWidth: 100,
|
},
|
{
|
label: "产量",
|
prop: "finishedNum",
|
minWidth: 100,
|
},
|
{
|
label: "折算工时合计",
|
prop: "workHours",
|
minWidth: 100,
|
},
|
{
|
label: "合格率",
|
prop: "outputRate",
|
minWidth: 100,
|
formatData: val => {
|
if (val == null || val === "") return "-";
|
return parseFloat(val).toFixed(2) + "%";
|
},
|
},
|
]);
|
|
const tableData = ref([]);
|
const tableLoading = ref(false);
|
const tableLoading1 = ref(false);
|
const leftTableData = ref([]);
|
const selectedRows = ref([]);
|
const adjustDialogVisible = ref(false);
|
const adjustForm = reactive({
|
id: null,
|
reportNo: "",
|
schedulingUserName: "",
|
wages: 0,
|
remark: "",
|
});
|
// 日 / 月 切换(默认按日)
|
const page = reactive({
|
current: 1,
|
size: 100,
|
total: 0,
|
});
|
|
const page1 = reactive({
|
current: 1,
|
size: 100,
|
total: 0,
|
});
|
|
const data = reactive({
|
searchForm: {
|
schedulingUserName: "",
|
workOrderNo: "",
|
salesContractNo: "",
|
dateType: "day",
|
dateRange: dayjs().format("YYYY-MM-DD"),
|
entryDate: dayjs().format("YYYY-MM-DD"),
|
entryDateStart: undefined,
|
entryDateEnd: undefined,
|
},
|
});
|
const { searchForm } = toRefs(data);
|
|
const pagination = obj => {
|
page.current = obj.page;
|
page.size = obj.limit;
|
getList();
|
};
|
|
const pagination1 = obj => {
|
page1.current = obj.page;
|
page1.size = obj.limit;
|
getList1();
|
};
|
|
const handleSelectionChange = selection => {
|
selectedRows.value = selection || [];
|
};
|
|
const handleDateRangeChange = value => {
|
if (value) {
|
if (searchForm.value.dateType === "day") {
|
searchForm.value.entryDate = value;
|
} else {
|
searchForm.value.entryDateStart = dayjs(value[0]).format("YYYY-MM-DD");
|
searchForm.value.entryDateEnd = dayjs(value[1]).format("YYYY-MM-DD");
|
}
|
} else {
|
searchForm.value.entryDate = undefined;
|
searchForm.value.entryDateStart = undefined;
|
searchForm.value.entryDateEnd = undefined;
|
}
|
reloadData();
|
};
|
|
const getList = () => {
|
tableLoading.value = true;
|
const params = { ...searchForm.value, ...page };
|
|
salesLedgerProductionAccountingList(params)
|
.then(res => {
|
const records = res.data.records || [];
|
leftTableData.value = records;
|
page.total = res.data.total || 0;
|
})
|
.finally(() => {
|
tableLoading.value = false;
|
});
|
};
|
|
const getList1 = () => {
|
tableLoading1.value = true;
|
const params = { ...page1, ...searchForm.value };
|
salesLedgerProductionAccountingListProductionDetails(params)
|
.then(res => {
|
tableData.value = res.data.records || [];
|
page1.total = res.data.total || 0;
|
})
|
.finally(() => {
|
tableLoading1.value = false;
|
});
|
};
|
|
// 构建左侧汇总台账(按生产人汇总产量、工资等)
|
const buildLeftTableData = records => {
|
const map = {};
|
records.forEach(item => {
|
const key = item.schedulingUserName || "未知";
|
if (!map[key]) {
|
map[key] = {
|
id: key,
|
schedulingUserName: key,
|
finishedNum: 0,
|
wages: 0,
|
qualifiedRate: item.qualifiedRate ?? null,
|
};
|
}
|
map[key].finishedNum += Number(item.finishedNum || 0);
|
map[key].wages += Number(item.wages || 0);
|
if (item.qualifiedRate != null) {
|
map[key].qualifiedRate = item.qualifiedRate;
|
}
|
});
|
leftTableData.value = Object.values(map);
|
};
|
|
// 左侧日/月切换
|
const handleDateTypeChange = value => {
|
// 这里只作为筛选条件的一部分,直接重新查询列表
|
if (value === "day") {
|
searchForm.value.entryDate = dayjs().format("YYYY-MM-DD");
|
searchForm.value.dateRange = searchForm.value.entryDate;
|
} else {
|
searchForm.value.entryDateStart = dayjs()
|
.startOf("month")
|
.format("YYYY-MM-DD");
|
searchForm.value.entryDateEnd = dayjs().endOf("month").format("YYYY-MM-DD");
|
searchForm.value.dateRange = [
|
searchForm.value.entryDateStart,
|
searchForm.value.entryDateEnd,
|
];
|
}
|
|
reloadData();
|
};
|
|
const reloadData = () => {
|
page.current = 1;
|
page1.current = 1;
|
getList();
|
tableData.value = [];
|
};
|
|
// 点击左侧行,刷右侧明细(按生产人过滤)
|
const handleLeftRowClick = row => {
|
searchForm.value.schedulingUserName = row.schedulingUserName || "";
|
handleQuery();
|
};
|
|
// 查询列表
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
page1.current = 1;
|
getList1();
|
};
|
|
// 导出
|
const handleOut = () => {
|
ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
|
confirmButtonText: "确认",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
proxy.download(
|
"/productionAccount/exportSalarySlip",
|
{ ...searchForm.value },
|
"生产工资条.xlsx"
|
);
|
})
|
.catch(() => {
|
proxy.$modal.msg("已取消");
|
});
|
};
|
|
const handleBatchAccounting = () => {
|
ElMessageBox.confirm("确定要按当前筛选条件执行批量核算吗?", "批量核算", {
|
confirmButtonText: "确认",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
const { dateRange, ...batchPayload } = searchForm.value;
|
return productionAccountingBatchAccounting(batchPayload);
|
})
|
.then(() => {
|
proxy.$modal.msgSuccess("批量核算成功");
|
reloadData();
|
})
|
.catch(() => {
|
proxy.$modal.msg("已取消");
|
});
|
};
|
|
const handleSingleAdjust = () => {
|
if (!selectedRows.value.length) {
|
proxy.$modal.msgWarning("请先勾选一条记录");
|
return;
|
}
|
if (selectedRows.value.length > 1) {
|
proxy.$modal.msgWarning("单个修正只能选择一条记录");
|
return;
|
}
|
const row = selectedRows.value[0];
|
adjustForm.id = row.id;
|
adjustForm.reportNo = row.reportNo || "";
|
adjustForm.schedulingUserName = row.schedulingUserName || "";
|
adjustForm.wages = Number(row.wages || 0);
|
adjustForm.remark = "";
|
adjustDialogVisible.value = true;
|
};
|
|
const confirmAdjust = () => {
|
const selectedRow = selectedRows.value[0];
|
if (!selectedRow || !selectedRow.userId) {
|
proxy.$modal.msgWarning("当前记录缺少报工人员信息,无法修正");
|
return;
|
}
|
if (!adjustForm.wages && adjustForm.wages !== 0) {
|
proxy.$modal.msgWarning("请输入修正金额");
|
return;
|
}
|
productionAccountingSingleAdjust({
|
productionProductMainId: adjustForm.id,
|
schedulingUserId: selectedRow.userId,
|
schedulingUserName: adjustForm.schedulingUserName,
|
adjustAmount: adjustForm.wages,
|
adjustRemark: adjustForm.remark,
|
adjustUser: proxy.$store?.state?.user?.userId || undefined,
|
}).then(() => {
|
proxy.$modal.msgSuccess("修正成功");
|
adjustDialogVisible.value = false;
|
reloadData();
|
}).catch(() => {});
|
};
|
|
const handleRowAdjust = row => {
|
selectedRows.value = [row];
|
handleSingleAdjust();
|
};
|
|
onMounted(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
.content-row {
|
width: 100%;
|
}
|
|
.content-row .left-col,
|
.content-row .right-col {
|
margin-bottom: 16px;
|
}
|
|
.left-panel,
|
.right-panel {
|
display: flex;
|
flex-direction: column;
|
gap: 10px;
|
min-width: 0;
|
}
|
|
.right-toolbar {
|
display: flex;
|
justify-content: flex-end;
|
gap: 10px;
|
}
|
|
.left-header {
|
display: flex;
|
align-items: center;
|
gap: 12px;
|
}
|
|
.left-title {
|
font-size: 16px;
|
color: #ffffff;
|
}
|
|
.header-filters {
|
display: flex;
|
align-items: center;
|
flex: 1;
|
justify-content: flex-end;
|
gap: 8px;
|
}
|
|
.search_title {
|
color: #ffffff;
|
}
|
|
.ml10 {
|
margin-left: 10px;
|
}
|
</style>
|