| | |
| | | <div class="search_form mb20"> |
| | | <div class="search-row"> |
| | | <div class="search-item"> |
| | | <span class="search_title">工单编号:</span> |
| | | <el-input v-model="searchForm.workOrderNo" |
| | | style="width: 240px" |
| | | placeholder="请输入" |
| | | @change="handleQuery" |
| | | clearable |
| | | prefix-icon="Search" /> |
| | | </div> |
| | | <div class="search-item"> |
| | | <span class="search_title">生产订单号:</span> |
| | | <el-input v-model="searchForm.npsNo" |
| | | style="width: 240px" |
| | |
| | | </div> |
| | | </div> |
| | | <div class="table_list"> |
| | | <PIMTable rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :page="page" |
| | | :tableLoading="tableLoading" |
| | | @pagination="pagination"> |
| | | <template #completionStatus="{ row }"> |
| | | <el-progress :percentage="toProgressPercentage(row?.completionStatus)" |
| | | :color="progressColor(toProgressPercentage(row?.completionStatus))" |
| | | :status="toProgressPercentage(row?.completionStatus) >= 100 ? 'success' : ''" /> |
| | | </template> |
| | | </PIMTable> |
| | | <el-table :data="tableData" |
| | | border |
| | | v-loading="tableLoading" |
| | | :expand-row-keys="expandedRowKeys" |
| | | :row-key="(row) => row.productionOrderId" |
| | | @expand-change="expandChange" |
| | | height="calc(100vh - 22em)"> |
| | | <!-- 展开行列 --> |
| | | <el-table-column type="expand" |
| | | width="60" |
| | | fixed="left"> |
| | | <template #default="props"> |
| | | <el-table :data="props.row.children || []" |
| | | border |
| | | :row-class-name="({ row }) => getChildRowClassName(row)" |
| | | v-loading="childLoading[props.row.productionOrderId]" |
| | | style="margin: 10px 0;"> |
| | | <el-table-column align="center" |
| | | label="序号" |
| | | type="index" |
| | | width="60" /> |
| | | <el-table-column label="工单编号" |
| | | prop="workOrderNo" |
| | | width="140"> |
| | | <template #default="scope"> |
| | | <span :class="{ 'rework-text': scope.row.workOrderNo?.startsWith('FG') }"> |
| | | {{ scope.row.workOrderNo }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="工序名称" |
| | | prop="operationName" |
| | | width="100" /> |
| | | <el-table-column label="工序类型" |
| | | width="80" |
| | | align="center"> |
| | | <template #default="scope"> |
| | | <span>{{ scope.row.type === 0 ? '计时' : '计件' }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="计划数量" |
| | | prop="planQuantity" |
| | | width="100" /> |
| | | <el-table-column label="完成数量" |
| | | prop="completeQuantity" |
| | | width="100" /> |
| | | <el-table-column label="完成进度" |
| | | width="140"> |
| | | <template #default="scope"> |
| | | <el-progress :percentage="toProgressPercentage(scope.row?.completionStatus)" |
| | | :color="progressColor(toProgressPercentage(scope.row?.completionStatus))" |
| | | :status="toProgressPercentage(scope.row?.completionStatus) >= 100 ? 'success' : ''" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="报废数量" |
| | | prop="scrapQty" |
| | | width="80"> |
| | | <template #default="scope"> |
| | | <span :class="{ 'scrap-text': scope.row.scrapQty > 0 }"> |
| | | {{ scope.row.scrapQty || 0 }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="报工人员" |
| | | prop="userNames" |
| | | width="150" |
| | | show-overflow-tooltip /> |
| | | <el-table-column label="计划开始时间" |
| | | prop="planStartTime" |
| | | width="120" /> |
| | | <el-table-column label="计划结束时间" |
| | | prop="planEndTime" |
| | | width="120" /> |
| | | <el-table-column label="实际开始时间" |
| | | prop="actualStartTime" |
| | | width="120" /> |
| | | <el-table-column label="实际结束时间" |
| | | prop="actualEndTime" |
| | | width="120" /> |
| | | <el-table-column label="状态" |
| | | width="100" |
| | | align="center"> |
| | | <template #default="scope"> |
| | | <el-tag :type="getStatusTagType(scope.row.status)"> |
| | | {{ getStatusText(scope.row.status) }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" |
| | | width="200" |
| | | align="center" |
| | | fixed="right"> |
| | | <template #default="scope"> |
| | | <el-button link |
| | | type="primary" |
| | | @click="downloadAndPrintWorkOrder(scope.row)"> |
| | | 流转卡 |
| | | </el-button> |
| | | <el-button link |
| | | type="primary" |
| | | @click="openWorkOrderFiles(scope.row)"> |
| | | 附件 |
| | | </el-button> |
| | | <el-button link |
| | | type="primary" |
| | | v-if="!scope.row.endOrder" |
| | | :disabled="isReportDisabled(scope.row)" |
| | | @click="showReportDialog(scope.row)"> |
| | | 报工 |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </template> |
| | | </el-table-column> |
| | | <!-- 主表列 --> |
| | | <el-table-column align="center" |
| | | label="序号" |
| | | type="index" |
| | | width="60" /> |
| | | <el-table-column label="生产订单号" |
| | | prop="npsNo" |
| | | width="150" /> |
| | | <el-table-column label="产品名称" |
| | | prop="productName" |
| | | width="140" /> |
| | | <el-table-column label="规格" |
| | | prop="model" |
| | | width="150" /> |
| | | <el-table-column label="单位" |
| | | prop="unit" |
| | | width="80" /> |
| | | <el-table-column label="工序名称" |
| | | prop="operationName" |
| | | width="200" |
| | | show-overflow-tooltip /> |
| | | <el-table-column label="工单数量" |
| | | prop="productionTaskCount" |
| | | width="80"> |
| | | <template #default="scope"> |
| | | <span>共{{ scope.row.productionTaskCount || 0 }}个</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="计划数量" |
| | | prop="planQuantity" |
| | | width="100" /> |
| | | <el-table-column label="完成数量" |
| | | prop="completeQuantity" |
| | | width="100" /> |
| | | <el-table-column label="完成进度" |
| | | width="140"> |
| | | <template #default="scope"> |
| | | <el-progress :percentage="toProgressPercentage(scope.row?.completionStatus)" |
| | | :color="progressColor(toProgressPercentage(scope.row?.completionStatus))" |
| | | :status="toProgressPercentage(scope.row?.completionStatus) >= 100 ? 'success' : ''" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="报废数量" |
| | | prop="scrapQty" |
| | | width="80"> |
| | | <template #default="scope"> |
| | | <span :class="{ 'scrap-text': scope.row.scrapQty > 0 }"> |
| | | {{ scope.row.scrapQty || 0 }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="状态" |
| | | width="100" |
| | | align="center"> |
| | | <template #default="scope"> |
| | | <el-tag :type="getStatusTagType(scope.row.status)"> |
| | | {{ getStatusText(scope.row.status) }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="计划开始时间" |
| | | prop="planStartTime" |
| | | width="120" /> |
| | | <el-table-column label="计划结束时间" |
| | | prop="planEndTime" |
| | | width="120" /> |
| | | <el-table-column label="实际开始时间" |
| | | prop="actualStartTime" |
| | | width="120" /> |
| | | <el-table-column label="实际结束时间" |
| | | prop="actualEndTime" |
| | | width="120" /> |
| | | </el-table> |
| | | <PaginationComp v-show="page.total > 0" |
| | | :total="page.total" |
| | | :page="page.current" |
| | | :limit="page.size" |
| | | @pagination="pagination" /> |
| | | </div> |
| | | <!-- 流转卡弹窗 --> |
| | | <el-dialog v-model="transferCardVisible" |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { onMounted, ref, nextTick } from "vue"; |
| | | import { onMounted, ref, nextTick, reactive, toRefs, getCurrentInstance } from "vue"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import dayjs from "dayjs"; |
| | | import { |
| | | productWorkOrderPage, |
| | | getWorkOrderListByOrderId, |
| | | addProductMain, |
| | | downProductWorkOrder, |
| | | } from "@/api/productionManagement/workOrder.js"; |
| | |
| | | import { getUserProfile, userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import { getDicts } from "@/api/system/dict/data"; |
| | | import QRCode from "qrcode"; |
| | | import { getCurrentInstance, reactive, toRefs } from "vue"; |
| | | import PaginationComp from "@/components/PIMTable/Pagination.vue"; |
| | | import MaterialDialog from "./components/MaterialDialog.vue"; |
| | | const FileList = defineAsyncComponent(() => |
| | | import("@/components/Dialog/FileList.vue") |
| | |
| | | const { proxy } = getCurrentInstance(); |
| | | const userStore = useUserStore(); |
| | | |
| | | const tableColumn = ref([ |
| | | { |
| | | label: "工单类型", |
| | | prop: "workOrderType", |
| | | width: "80", |
| | | }, |
| | | { |
| | | label: "工单编号", |
| | | prop: "workOrderNo", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "生产订单号", |
| | | prop: "npsNo", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "产品名称", |
| | | prop: "productName", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "规格", |
| | | prop: "model", |
| | | }, |
| | | { |
| | | label: "单位", |
| | | prop: "unit", |
| | | }, |
| | | { |
| | | label: "工序名称", |
| | | prop: "operationName", |
| | | width: "100", |
| | | }, |
| | | { |
| | | label: "需求数量", |
| | | prop: "planQuantity", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "完成数量", |
| | | prop: "completeQuantity", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "完成进度", |
| | | prop: "completionStatus", |
| | | dataType: "slot", |
| | | slot: "completionStatus", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "计划开始时间", |
| | | prop: "planStartTime", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "计划结束时间", |
| | | prop: "planEndTime", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "实际开始时间", |
| | | prop: "actualStartTime", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "实际结束时间", |
| | | prop: "actualEndTime", |
| | | width: "140", |
| | | }, |
| | | { |
| | | label: "操作", |
| | | width: "260", |
| | | align: "center", |
| | | dataType: "action", |
| | | fixed: "right", |
| | | operation: [ |
| | | { |
| | | name: "流转卡", |
| | | clickFun: row => { |
| | | downloadAndPrintWorkOrder(row); |
| | | }, |
| | | }, |
| | | { |
| | | name: "附件", |
| | | clickFun: row => { |
| | | openWorkOrderFiles(row); |
| | | }, |
| | | }, |
| | | // { |
| | | // name: "物料", |
| | | // clickFun: row => { |
| | | // openMaterialDialog(row); |
| | | // }, |
| | | // }, |
| | | { |
| | | name: "报工", |
| | | clickFun: row => { |
| | | showReportDialog(row); |
| | | }, |
| | | showHide: row => !row.endOrder, |
| | | disabled: row => { |
| | | if (row.planQuantity <= 0) return true; |
| | | if (!row.userIds) return false; |
| | | try { |
| | | const userIds = |
| | | typeof row.userIds === "string" |
| | | ? JSON.parse(row.userIds) |
| | | : row.userIds; |
| | | if (Array.isArray(userIds)) { |
| | | return !userIds.some(id => String(id) === String(userStore.id)); |
| | | } |
| | | return true; |
| | | } catch (e) { |
| | | return true; |
| | | } |
| | | }, |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | // 状态枚举映射 |
| | | const statusMap = { |
| | | 1: '待确认', |
| | | 2: '待生产', |
| | | 3: '生产中', |
| | | 4: '已生产', |
| | | }; |
| | | |
| | | const getStatusText = (status) => statusMap[status] || '未知'; |
| | | |
| | | const getStatusTagType = (status) => { |
| | | switch (status) { |
| | | case 1: return 'info'; |
| | | case 2: return 'warning'; |
| | | case 3: return 'primary'; |
| | | case 4: return 'success'; |
| | | default: return 'info'; |
| | | } |
| | | }; |
| | | |
| | | const tableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | const expandedRowKeys = ref([]); |
| | | const childLoading = ref({}); |
| | | |
| | | const transferCardVisible = ref(false); |
| | | const transferCardData = ref([]); |
| | | const transferCardQrUrl = ref(""); |
| | |
| | | paramGroups: {}, |
| | | }); |
| | | |
| | | const params = ref({}); |
| | | const params = ref([]); |
| | | const dictOptions = ref({}); |
| | | const paramLoading = ref(false); |
| | | |
| | |
| | | return; |
| | | } |
| | | const num = Number(value); |
| | | // 整数且大于等于1 |
| | | if (isNaN(num) || !Number.isInteger(num) || num < 0) { |
| | | callback(new Error("生产合格数量必须大于等于0")); |
| | | return; |
| | |
| | | return; |
| | | } |
| | | const num = Number(value); |
| | | // 整数且大于等于0 |
| | | if (isNaN(num) || !Number.isInteger(num) || num < 0) { |
| | | callback(new Error("报废数量必须大于等于0")); |
| | | return; |
| | |
| | | scrapQty: [{ validator: validateScrapQty, trigger: "blur" }], |
| | | }; |
| | | |
| | | // 处理生产合格数量输入,限制必须大于等于0 |
| | | // 处理生产合格数量输入 |
| | | const handleQuantityInput = value => { |
| | | if (value === "" || value === null || value === undefined) { |
| | | reportForm.quantity = null; |
| | |
| | | if (isNaN(num)) { |
| | | return; |
| | | } |
| | | // 如果小于1,清除 |
| | | if (num < 0) { |
| | | reportForm.quantity = null; |
| | | return; |
| | | } |
| | | // 如果是小数取整数部分 |
| | | if (!Number.isInteger(num)) { |
| | | const intValue = Math.floor(num); |
| | | // 如果取整后小于1,清除 |
| | | if (intValue < 0) { |
| | | reportForm.quantity = null; |
| | | return; |
| | |
| | | return; |
| | | } |
| | | const num = Number(value); |
| | | // 如果是NaN,保持原值 |
| | | if (isNaN(num)) { |
| | | return; |
| | | } |
| | | // 如果是负数,清除输入 |
| | | if (num < 0) { |
| | | reportForm.scrapQty = null; |
| | | return; |
| | | } |
| | | // 如果是小数,取整数部分 |
| | | if (!Number.isInteger(num)) { |
| | | reportForm.scrapQty = Math.floor(num); |
| | | return; |
| | | } |
| | | // 有效的非负整数(包括0) |
| | | reportForm.scrapQty = num; |
| | | }; |
| | | |
| | |
| | | |
| | | const data = reactive({ |
| | | searchForm: { |
| | | workOrderNo: "", |
| | | npsNo: "", |
| | | }, |
| | | }); |
| | | const { searchForm } = toRefs(data); |
| | | |
| | | const toProgressPercentage = val => { |
| | | const n = Number(val); |
| | | if (!Number.isFinite(n)) return 0; |
| | |
| | | if (n >= 100) return 100; |
| | | return Math.round(n); |
| | | }; |
| | | |
| | | const progressColor = percentage => { |
| | | const p = toProgressPercentage(percentage); |
| | | if (p < 30) return "#f56c6c"; |
| | |
| | | }; |
| | | |
| | | // 查询列表 |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | page.current = 1; |
| | | getList(); |
| | |
| | | |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | expandedRowKeys.value = []; |
| | | const params = { ...searchForm.value, ...page }; |
| | | productWorkOrderPage(params) |
| | | .then(res => { |
| | | tableLoading.value = false; |
| | | tableData.value = res.data.records; |
| | | tableData.value = res.data.records.map(item => ({ |
| | | ...item, |
| | | children: [], |
| | | })); |
| | | page.total = res.data.total; |
| | | }) |
| | | .catch(() => { |
| | |
| | | }); |
| | | }; |
| | | |
| | | // 下载并打印工单流转卡(文件流) |
| | | // 展开行懒加载 |
| | | const expandChange = (row, expandedRows) => { |
| | | if (expandedRows.length > 0) { |
| | | expandedRowKeys.value = []; |
| | | const orderId = row.productionOrderId; |
| | | |
| | | // 检查是否已有数据 |
| | | if (row.children && row.children.length > 0) { |
| | | expandedRowKeys.value.push(orderId); |
| | | return; |
| | | } |
| | | |
| | | childLoading.value[orderId] = true; |
| | | |
| | | getWorkOrderListByOrderId(orderId) |
| | | .then(res => { |
| | | childLoading.value[orderId] = false; |
| | | const index = tableData.value.findIndex( |
| | | item => item.productionOrderId === orderId |
| | | ); |
| | | if (index > -1) { |
| | | tableData.value[index].children = res.data || []; |
| | | } |
| | | expandedRowKeys.value.push(orderId); |
| | | }) |
| | | .catch(error => { |
| | | childLoading.value[orderId] = false; |
| | | console.error('加载工单明细失败:', error); |
| | | }); |
| | | } else { |
| | | expandedRowKeys.value = []; |
| | | } |
| | | }; |
| | | |
| | | // 子表行样式(返工返修红色标记) |
| | | const getChildRowClassName = (row) => { |
| | | if (row.workOrderNo?.startsWith('FG')) { |
| | | return 'row-rework'; |
| | | } |
| | | return ''; |
| | | }; |
| | | |
| | | // 报工按钮禁用逻辑 |
| | | const isReportDisabled = (row) => { |
| | | if (row.planQuantity <= 0) return true; |
| | | if (!row.userIds) return false; |
| | | try { |
| | | const userIds = |
| | | typeof row.userIds === "string" |
| | | ? JSON.parse(row.userIds) |
| | | : row.userIds; |
| | | if (Array.isArray(userIds)) { |
| | | return !userIds.some(id => String(id) === String(userStore.id)); |
| | | } |
| | | return true; |
| | | } catch (e) { |
| | | return true; |
| | | } |
| | | }; |
| | | |
| | | // 下载并打印工单流转卡 |
| | | const downloadAndPrintWorkOrder = async row => { |
| | | if (!row || !row.id) { |
| | | proxy.$modal.msgError("缺少工单ID,无法下载流转卡"); |
| | |
| | | ? `工单流转卡_${row.workOrderNo}.xlsx` |
| | | : "工单流转卡.xlsx"; |
| | | try { |
| | | // 调用接口,以 responseType: 'blob' 获取文件流 |
| | | const blob = await downProductWorkOrder(row.id); |
| | | |
| | | if (!blob) { |
| | |
| | | return; |
| | | } |
| | | |
| | | // 创建 Blob URL |
| | | const fileBlob = |
| | | blob instanceof Blob |
| | | ? blob |
| | | : new Blob([blob], { type: blob.type || "application/octet-stream" }); |
| | | const url = window.URL.createObjectURL(fileBlob); |
| | | |
| | | // 创建隐藏 iframe,用于触发浏览器打印 |
| | | const iframe = document.createElement("iframe"); |
| | | iframe.style.position = "fixed"; |
| | | iframe.style.right = "0"; |
| | |
| | | iframe.contentWindow?.print(); |
| | | } catch (e) { |
| | | console.error("自动调用打印失败", e); |
| | | // 退而求其次,打开新窗口由用户手动打印 |
| | | window.open(url); |
| | | } |
| | | }; |
| | |
| | | return; |
| | | } |
| | | |
| | | // 验证生产合格数量 |
| | | if ( |
| | | reportForm.quantity === null || |
| | | reportForm.quantity === undefined || |
| | |
| | | return; |
| | | } |
| | | |
| | | // if (quantity > reportForm.planQuantity) { |
| | | // ElMessageBox.alert("本次生产数量不能超过待生产数量", "提示", { |
| | | // confirmButtonText: "确定", |
| | | // }); |
| | | // return; |
| | | // } |
| | | |
| | | // 验证报废数量 |
| | | const scrapQty = Number(reportForm.scrapQty); |
| | | if (!isNaN(scrapQty) && scrapQty < 0) { |
| | | ElMessageBox.alert("报废数量不能小于0", "提示", { |
| | |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | // if (!isNaN(scrapQty) && scrapQty > quantity) { |
| | | // ElMessageBox.alert("报废数量不能大于本次生产数量", "提示", { |
| | | // confirmButtonText: "确定", |
| | | // }); |
| | | // return; |
| | | // } |
| | | |
| | | const productionOperationParamList = params.value.map(param => ({ |
| | | ...param, |
| | |
| | | onMounted(() => { |
| | | userStore.getInfo(); |
| | | getList(); |
| | | // 获取用户列表 |
| | | userListNoPageByTenantId().then(res => { |
| | | if (res.code === 200) { |
| | | userOptions.value = res.data; |
| | |
| | | font-size: 12px; |
| | | min-width: 30px; |
| | | } |
| | | |
| | | // 返工返修工单红色标记 |
| | | .row-rework { |
| | | background-color: #fef0f0 !important; |
| | | |
| | | :deep(.el-table__cell) { |
| | | background-color: #fef0f0 !important; |
| | | } |
| | | } |
| | | |
| | | .rework-text { |
| | | color: #f56c6c; |
| | | font-weight: bold; |
| | | } |
| | | |
| | | // 报废数量红色标记 |
| | | .scrap-text { |
| | | color: #f56c6c; |
| | | } |
| | | |
| | | // 子表格样式 |
| | | :deep(.el-table__expanded-cell) { |
| | | padding: 10px 30px !important; |
| | | background-color: #fafafa; |
| | | } |
| | | </style> |
| | | |
| | | <style lang="scss"> |