| | |
| | | style="width: 300px" |
| | | placeholder="请输入本次生产数量" /> |
| | | </el-form-item> |
| | | <el-form-item label="报废数量"> |
| | | <el-input v-model.number="reportForm.scrapQty" |
| | | type="number" |
| | | min="1" |
| | | style="width: 300px" |
| | | placeholder="请输入报废数量" /> |
| | | </el-form-item> |
| | | <el-form-item label="班组信息"> |
| | | <el-select v-model="reportForm.userId" |
| | | style="width: 300px" |
| | |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | <FilesDia ref="workOrderFilesRef" /> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | productWorkOrderPage, |
| | | updateProductWorkOrder, |
| | | addProductMain, |
| | | downProductWorkOrder, |
| | | } from "@/api/productionManagement/workOrder.js"; |
| | | import { getUserProfile, userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import QRCode from "qrcode"; |
| | | import { getCurrentInstance, reactive, toRefs } from "vue"; |
| | | import FilesDia from "./components/filesDia.vue"; |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | const tableColumn = ref([ |
| | |
| | | { |
| | | name: "流转卡", |
| | | clickFun: row => { |
| | | showTransferCard(row); |
| | | downloadAndPrintWorkOrder(row); |
| | | }, |
| | | }, |
| | | { |
| | | name: "附件", |
| | | clickFun: row => { |
| | | openWorkOrderFiles(row); |
| | | }, |
| | | }, |
| | | { |
| | |
| | | const transferCardQrUrl = ref(""); |
| | | const transferCardRowData = ref(null); |
| | | const reportDialogVisible = ref(false); |
| | | const workOrderFilesRef = ref(null); |
| | | const userOptions = ref([]); |
| | | const reportForm = reactive({ |
| | | planQuantity: 0, |
| | |
| | | }); |
| | | }; |
| | | |
| | | // 下载并打印工单流转卡(文件流) |
| | | const downloadAndPrintWorkOrder = async row => { |
| | | if (!row || !row.id) { |
| | | proxy.$modal.msgError("缺少工单ID,无法下载流转卡"); |
| | | return; |
| | | } |
| | | const fileName = row.workOrderNo |
| | | ? `工单流转卡_${row.workOrderNo}.xlsx` |
| | | : "工单流转卡.xlsx"; |
| | | try { |
| | | // 调用接口,以 responseType: 'blob' 获取文件流 |
| | | const blob = await downProductWorkOrder(row.id); |
| | | |
| | | if (!blob) { |
| | | proxy.$modal.msgError("未获取到流转卡文件"); |
| | | 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.style.bottom = "0"; |
| | | iframe.style.width = "0"; |
| | | iframe.style.height = "0"; |
| | | iframe.style.border = "0"; |
| | | iframe.src = url; |
| | | document.body.appendChild(iframe); |
| | | |
| | | iframe.onload = () => { |
| | | try { |
| | | iframe.contentWindow?.focus(); |
| | | iframe.contentWindow?.print(); |
| | | } catch (e) { |
| | | console.error("自动调用打印失败", e); |
| | | // 退而求其次,打开新窗口由用户手动打印 |
| | | window.open(url); |
| | | } |
| | | }; |
| | | } catch (e) { |
| | | console.error("下载工单流转卡失败", e); |
| | | proxy.$modal.msgError("下载工单流转卡失败"); |
| | | } |
| | | }; |
| | | |
| | | const showTransferCard = async row => { |
| | | transferCardRowData.value = row; |
| | | const qrContent = String(row.id); |
| | |
| | | reportForm.workOrderId = row.id; |
| | | reportForm.reportWork = row.reportWork; |
| | | reportForm.productMainId = row.productMainId; |
| | | reportForm.scrapQty = row.scrapQty; |
| | | // 获取当前登录用户信息,设置为默认选中 |
| | | getUserProfile() |
| | | .then(res => { |
| | |
| | | reportDialogVisible.value = true; |
| | | }; |
| | | |
| | | const openWorkOrderFiles = row => { |
| | | workOrderFilesRef.value?.openDialog(row); |
| | | }; |
| | | |
| | | const handleReport = () => { |
| | | if (reportForm.planQuantity <= 0) { |
| | | ElMessageBox.alert("待生产数量为0,无法报工", "提示", { |