| | |
| | | <el-dropdown-menu> |
| | | <el-dropdown-item command="finishedProcessCard">生产流程卡(成品)</el-dropdown-item> |
| | | <el-dropdown-item command="salesOrder">销售订单</el-dropdown-item> |
| | | <el-dropdown-item command="salesDeliveryNote">销售发货单</el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </template> |
| | | </el-dropdown> |
| | |
| | | saleProcessBind, |
| | | getSaleProcessBindInfo, |
| | | getProcessCard, |
| | | getSalesInvoices, |
| | | } from "@/api/salesManagement/salesLedger.js"; |
| | | import { modelList, productTreeList } from "@/api/basicData/product.js"; |
| | | import useFormData from "@/hooks/useFormData.js"; |
| | |
| | | import { getCurrentDate } from "@/utils/index.js"; |
| | | import { printFinishedProcessCard } from "./components/processCardPrint.js"; |
| | | import { printSalesOrder } from "./components/salesOrderPrint.js"; |
| | | import { printSalesDeliveryNote } from "./components/salesDeliveryPrint.js"; |
| | | // import { salesLedgerProductSetProcessFlowConfig } from "@/api/salesManagement/salesProcessFlowConfig.js"; |
| | | |
| | | const userStore = useUserStore(); |
| | |
| | | }; |
| | | |
| | | const handlePrintCommand = async (command) => { |
| | | if (command !== "finishedProcessCard" && command !== "salesOrder") return; |
| | | if (selectedRows.value.length !== 1) { |
| | | if (command !== "finishedProcessCard" && command !== "salesOrder" && command !== "salesDeliveryNote") return; |
| | | if (command === "salesDeliveryNote") { |
| | | if (selectedRows.value.length === 0) { |
| | | proxy.$modal.msgWarning("请至少选择一条销售台账数据进行打印"); |
| | | return; |
| | | } |
| | | const customerNames = Array.from( |
| | | new Set(selectedRows.value.map((item) => String(item?.customerName ?? "").trim())) |
| | | ); |
| | | if (customerNames.length > 1) { |
| | | proxy.$modal.msgWarning("仅支持相同客户名称的销售台账合并发货打印"); |
| | | return; |
| | | } |
| | | } else if (selectedRows.value.length !== 1) { |
| | | proxy.$modal.msgWarning("请选择一条销售台账数据进行打印"); |
| | | return; |
| | | } |
| | | |
| | | const selectedRow = selectedRows.value[0]; |
| | | const selectedId = selectedRow?.id; |
| | | if (command === "salesDeliveryNote") { |
| | | const selectedIds = selectedRows.value |
| | | .map((item) => item?.id) |
| | | .filter((id) => id !== null && id !== undefined && id !== ""); |
| | | if (selectedIds.length !== selectedRows.value.length) { |
| | | proxy.$modal.msgWarning("当前选择数据存在缺少ID的记录,无法打印"); |
| | | return; |
| | | } |
| | | const loadingText = |
| | | command === "salesOrder" |
| | | ? "正在获取销售订单数据,请稍候..." |
| | | : command === "salesDeliveryNote" |
| | | ? "正在获取销售发货单数据,请稍候..." |
| | | : "正在获取生产流程卡数据,请稍候..."; |
| | | proxy.$modal.loading(loadingText); |
| | | try { |
| | | const res = await getSalesInvoices(selectedIds); |
| | | const salesInvoiceData = res?.data ?? {}; |
| | | printSalesDeliveryNote(salesInvoiceData, selectedRow); |
| | | } catch (error) { |
| | | console.error("打印销售发货单失败:", error); |
| | | proxy.$modal.msgError("打印失败,请稍后重试"); |
| | | } finally { |
| | | proxy.$modal.closeLoading(); |
| | | } |
| | | return; |
| | | } |
| | | if (!selectedId) { |
| | | proxy.$modal.msgWarning("当前选择数据缺少ID,无法打印"); |
| | | return; |
| | |
| | | const loadingText = |
| | | command === "salesOrder" |
| | | ? "正在获取销售订单数据,请稍候..." |
| | | : command === "salesDeliveryNote" |
| | | ? "正在获取销售发货单数据,请稍候..." |
| | | : "正在获取生产流程卡数据,请稍候..."; |
| | | proxy.$modal.loading(loadingText); |
| | | try { |
| | | if (command === "salesOrder") { |
| | | const res = await getProcessCard(selectedId); |
| | | const processCardData = res?.data ?? {}; |
| | | if (command === "salesOrder") { |
| | | printSalesOrder(processCardData); |
| | | } else { |
| | | const res = await getProcessCard(selectedId); |
| | | const processCardData = res?.data ?? {}; |
| | | printFinishedProcessCard(processCardData); |
| | | } |
| | | } catch (error) { |
| | | console.error(command === "salesOrder" ? "打印销售订单失败:" : "打印生产流程卡失败:", error); |
| | | console.error( |
| | | command === "salesOrder" |
| | | ? "打印销售订单失败:" |
| | | : command === "salesDeliveryNote" |
| | | ? "打印销售发货单失败:" |
| | | : "打印生产流程卡失败:", |
| | | error |
| | | ); |
| | | proxy.$modal.msgError("打印失败,请稍后重试"); |
| | | } finally { |
| | | proxy.$modal.closeLoading(); |