| | |
| | | :page="page" |
| | | @row-click="handleLeftRowClick" |
| | | @pagination="pagination" |
| | | ></PIMTable> |
| | | > |
| | | <template #workDuration="{ row }"> |
| | | <el-button v-if="Number(row.totalWorkMinutes) > 0" |
| | | type="primary" |
| | | text |
| | | @click.stop="openWorkDurationDialog(row)"> |
| | | {{ row.totalWorkMinutes }} |
| | | </el-button> |
| | | <span v-else>-</span> |
| | | </template> |
| | | </PIMTable> |
| | | </div> |
| | | </el-col> |
| | | |
| | |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | <el-dialog v-model="workDurationDialogVisible" |
| | | :title="`工时明细${currentSchedulingUserName ? ` - ${currentSchedulingUserName}` : ''}`" |
| | | width="600px"> |
| | | <el-table :data="workDurationDetailList" |
| | | border |
| | | style="width: 100%; margin-bottom: 16px;"> |
| | | <el-table-column type="index" |
| | | label="序号" |
| | | width="80"/> |
| | | <el-table-column prop="deviceName" |
| | | label="机台" |
| | | min-width="220"/> |
| | | <el-table-column prop="workMinutes" |
| | | label="工作时间(分钟)" |
| | | min-width="160"/> |
| | | </el-table> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | import {onMounted, ref} from "vue"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import dayjs from "dayjs"; |
| | | import {salesLedgerProductionAccountingListProductionDetails, salesLedgerProductionAccountingList} from "@/api/productionManagement/productionCosting.js"; |
| | | import { |
| | | salesLedgerProductionAccountingListProductionDetails, |
| | | salesLedgerProductionAccountingList |
| | | } from "@/api/productionManagement/productionCosting.js"; |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | const tableColumn = ref([ |
| | |
| | | prop: "wages", |
| | | minWidth: 100, |
| | | }, |
| | | { |
| | | label: "机台", |
| | | prop: "deviceName", |
| | | minWidth: 100, |
| | | }, |
| | | { |
| | | label: "工时(分钟)", |
| | | prop: "workMinutes", |
| | | width: 110, |
| | | }, |
| | | ]); |
| | | |
| | | // 左侧汇总台账列(生产人、产量、工资、合格率) |
| | |
| | | return parseFloat(val).toFixed(2) |
| | | }, |
| | | }, |
| | | { |
| | | label: "工时(分钟)", |
| | | prop: "totalWorkMinutes", |
| | | minWidth: 120, |
| | | dataType: "slot", |
| | | slot: "workDuration", |
| | | }, |
| | | ]); |
| | | |
| | | const tableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | const tableLoading1 = ref(false); |
| | | const leftTableData = ref([]); |
| | | const workDurationDialogVisible = ref(false); |
| | | const workDurationDetailList = ref([]); |
| | | const currentSchedulingUserName = ref(""); |
| | | // 日 / 月 切换(默认按日) |
| | | const page = reactive({ |
| | | current: 1, |
| | |
| | | |
| | | salesLedgerProductionAccountingList(params).then((res) => { |
| | | const records = res.data.records || []; |
| | | leftTableData.value = records; |
| | | leftTableData.value = records.map(item => { |
| | | const workDurationDetailListValue = buildWorkDurationDetailList(item.deviceWorkInfoPairList); |
| | | const totalWorkMinutes = workDurationDetailListValue.reduce( |
| | | (sum, detail) => sum + Number(detail.workMinutes || 0), |
| | | 0 |
| | | ); |
| | | return { |
| | | ...item, |
| | | workDurationDetailList: workDurationDetailListValue, |
| | | totalWorkMinutes, |
| | | }; |
| | | }); |
| | | page.total = res.data.total || 0; |
| | | }).finally(() => { |
| | | tableLoading.value = false; |
| | | }) |
| | | |
| | | |
| | | |
| | | }; |
| | |
| | | tableLoading1.value = true; |
| | | const params = { ...page1, ...searchForm.value }; |
| | | salesLedgerProductionAccountingListProductionDetails(params).then((res) => { |
| | | tableData.value = res.data.records || [];; |
| | | tableData.value = res.data.records || []; |
| | | ; |
| | | page1.total = res.data.total || 0; |
| | | }).finally(() => { |
| | | tableLoading1.value = false; |
| | |
| | | tableData.value = [] |
| | | } |
| | | |
| | | const buildWorkDurationDetailList = (deviceWorkInfoPairList) => { |
| | | if (!deviceWorkInfoPairList) { |
| | | return []; |
| | | } |
| | | let listData = deviceWorkInfoPairList; |
| | | if (typeof deviceWorkInfoPairList === "string") { |
| | | try { |
| | | listData = JSON.parse(deviceWorkInfoPairList); |
| | | } catch { |
| | | return []; |
| | | } |
| | | } |
| | | if (!Array.isArray(listData)) { |
| | | return []; |
| | | } |
| | | const details = []; |
| | | listData.forEach(item => { |
| | | if (!item || typeof item !== "object") { |
| | | return; |
| | | } |
| | | Object.entries(item).forEach(([deviceName, workMinutes]) => { |
| | | const numericMinutes = Number(workMinutes); |
| | | if (deviceName) { |
| | | details.push({ |
| | | deviceName, |
| | | workMinutes: Number.isFinite(numericMinutes) ? numericMinutes : 0, |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | return details; |
| | | }; |
| | | |
| | | const openWorkDurationDialog = row => { |
| | | currentSchedulingUserName.value = row?.schedulingUserName || ""; |
| | | const details = Array.isArray(row?.workDurationDetailList) |
| | | ? row.workDurationDetailList |
| | | : buildWorkDurationDetailList(row?.deviceWorkInfoPairList); |
| | | workDurationDetailList.value = details; |
| | | workDurationDialogVisible.value = true; |
| | | }; |
| | | |
| | | // 点击左侧行,刷右侧明细(按生产人过滤) |
| | | const handleLeftRowClick = (row) => { |
| | | searchForm.value.schedulingUserName = row.schedulingUserName || ""; |