| | |
| | | <el-button type="danger" plain @click="handleDelete">删除</el-button> |
| | | </div> |
| | | </div> |
| | | <!-- 油品出库父行的 children 是到货记录,靠 row-key + children 渲染成子行 --> |
| | | <!-- 到货记录不在列表里展开,只在详情弹框展示 --> |
| | | <el-table |
| | | :data="tableData" |
| | | border |
| | | v-loading="tableLoading" |
| | | @selection-change="handleSelectionChange" |
| | | :row-key=" |
| | | (row) => |
| | | row.source |
| | | ? `${row.source}-${row.stockOutRecordId ?? row.id}` |
| | | : `arrival-${row.id}` |
| | | " |
| | | :row-key="deliveryRowKey" |
| | | style="width: 100%" |
| | | height="calc(100vh - 21.5em)" |
| | | > |
| | |
| | | show-overflow-tooltip |
| | | /> |
| | | <el-table-column |
| | | label="审核状态" |
| | | prop="status" |
| | | align="center" |
| | | width="100" |
| | | > |
| | | <template #default="scope"> |
| | | <el-tag :type="getApprovalStatusType(scope.row.status)"> |
| | | {{ getApprovalStatusText(scope.row.status) }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="出库单号" |
| | | prop="outboundBatches" |
| | | show-overflow-tooltip |
| | |
| | | <!-- @click="openForm('edit', scope.row)">发货--> |
| | | <!-- </el-button>--> |
| | | <el-button |
| | | v-if="!isArrivalRow(scope.row)" |
| | | link |
| | | type="primary" |
| | | style="color: #67c23a" |
| | |
| | | <el-descriptions-item label="发货日期">{{ |
| | | detailRow.shippingDate || "--" |
| | | }}</el-descriptions-item> |
| | | <el-descriptions-item label="审核状态">{{ |
| | | getApprovalStatusText(detailRow.status) |
| | | }}</el-descriptions-item> |
| | | <el-descriptions-item label="发货车牌号">{{ |
| | | detailRow.shippingCarNumber || "--" |
| | | }}</el-descriptions-item> |
| | |
| | | const detailDialogVisible = ref(false); |
| | | const detailRow = ref(null); |
| | | const detailProductList = ref([]); |
| | | // 油品出库父行的到货记录(子行) |
| | | // 油品出库父行的到货记录:列表不展开,只在详情弹框里展示 |
| | | const detailArrivalList = ref([]); |
| | | // 父行 row-key -> 该行的到货记录,列表接口的 children 摘下来放这里 |
| | | const arrivalMap = new Map(); |
| | | |
| | | // 到货附件后端存 JSON 字符串,出参可能是数组也可能是串 |
| | | const toAttachmentList = (value) => { |
| | |
| | | const data = reactive({ |
| | | searchForm: { |
| | | shippingNo: "", // 发货单号(两类来源都匹配) |
| | | salesContractNo: "", // 销售合同号(只匹配发货单行) |
| | | salesContractNo: "", // 销售合同号(多台账出库命中任一合同号即返回该行) |
| | | shippingCarNumber: "", // 车牌号 |
| | | }, |
| | | form: { |
| | |
| | | deliveryLedgerListPage({ ...searchForm.value, ...page }) |
| | | .then((res) => { |
| | | tableLoading.value = false; |
| | | tableData.value = res.data.records || []; |
| | | const records = res.data.records || []; |
| | | // 到货记录不做层级展开(el-table 见到 children 就会渲染成子行), |
| | | // 但详情弹框还要展示,先按父行摘出来存着 |
| | | arrivalMap.clear(); |
| | | records.forEach((row) => { |
| | | if (Array.isArray(row.children) && row.children.length) { |
| | | arrivalMap.set(deliveryRowKey(row), row.children); |
| | | } |
| | | delete row.children; |
| | | }); |
| | | tableData.value = records; |
| | | total.value = res.data.total || 0; |
| | | }) |
| | | .catch(() => { |
| | |
| | | // 油品出库行来自 stock_out_record,id 与 shipping_info 会撞号, |
| | | // 发货/删除/详情等接口背后都是 shipping_info,不能用于这类行 |
| | | const isOilOutRow = (row) => row?.source === "oilOut"; |
| | | // 层级展示时到货记录挂在父行的 children 上,子行没有 source |
| | | const isArrivalRow = (row) => !row?.source; |
| | | const sourceLabel = (row) => { |
| | | if (isArrivalRow(row)) return "到货"; |
| | | return isOilOutRow(row) ? "油品出库" : "发货单"; |
| | | }; |
| | | const sourceTagType = (row) => { |
| | | if (isArrivalRow(row)) return "warning"; |
| | | return isOilOutRow(row) ? "success" : "info"; |
| | | }; |
| | | const isRowSelectable = (row) => !isOilOutRow(row) && !isArrivalRow(row); |
| | | // 两个来源的 id 不同域,row-key 必须带上来源;到货记录要能按父行反查回来 |
| | | const deliveryRowKey = (row) => |
| | | `${row?.source ?? "shipping"}-${row?.stockOutRecordId ?? row?.id}`; |
| | | const sourceLabel = (row) => (isOilOutRow(row) ? "油品出库" : "发货单"); |
| | | const sourceTagType = (row) => (isOilOutRow(row) ? "success" : "info"); |
| | | const isRowSelectable = (row) => !isOilOutRow(row); |
| | | |
| | | // 表格选择数据 |
| | | const handleSelectionChange = (selection) => { |
| | |
| | | const openDetail = async (row) => { |
| | | detailRow.value = row || null; |
| | | detailProductList.value = []; |
| | | detailArrivalList.value = Array.isArray(row?.children) ? row.children : []; |
| | | detailArrivalList.value = arrivalMap.get(deliveryRowKey(row)) || []; |
| | | detailDialogVisible.value = true; |
| | | // 油品出库行不走发货单详情接口(id 会撞号),直接用列表行数据展示 |
| | | if (!row?.id || isOilOutRow(row)) return; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 获取审核状态文本 |
| | | const getApprovalStatusText = (status) => { |
| | | if (status === null || status === undefined || status === "") { |
| | | return "待审核"; |
| | | } |
| | | // 如果是数字 |
| | | if (typeof status === "number") { |
| | | const statusMap = { |
| | | 0: "待审核", |
| | | 1: "审核中", |
| | | 2: "审核拒绝", |
| | | 3: "审核通过", |
| | | }; |
| | | return statusMap[status] || "待审核"; |
| | | } |
| | | // 如果是字符串,直接返回或映射 |
| | | const statusStr = String(status).trim(); |
| | | const statusTextMap = { |
| | | 待审核: "待审核", |
| | | 审核中: "审核中", |
| | | 审核拒绝: "审核拒绝", |
| | | 审核通过: "审核通过", |
| | | 已发货: "已发货", |
| | | 0: "待审核", |
| | | 1: "审核中", |
| | | 2: "审核拒绝", |
| | | 3: "审核通过", |
| | | }; |
| | | return statusTextMap[statusStr] || statusStr || "待审核"; |
| | | }; |
| | | |
| | | // 获取审核状态标签类型(颜色) |
| | | const getApprovalStatusType = (status) => { |
| | | if (status === null || status === undefined || status === "") { |
| | | return "info"; |
| | | } |
| | | // 如果是数字 |
| | | if (typeof status === "number") { |
| | | const typeMap = { |
| | | 0: "info", // 待审核 - 灰色 |
| | | 1: "warning", // 审核中 - 黄色 |
| | | 2: "danger", // 审核拒绝 - 红色 |
| | | 3: "success", // 审核通过 - 绿色 |
| | | }; |
| | | return typeMap[status] || "info"; |
| | | } |
| | | // 如果是字符串 |
| | | const statusStr = String(status).trim(); |
| | | const typeTextMap = { |
| | | 待审核: "info", |
| | | 审核中: "warning", |
| | | 审核拒绝: "danger", |
| | | 审核通过: "success", |
| | | 已发货: "success", |
| | | 0: "info", |
| | | 1: "warning", |
| | | 2: "danger", |
| | | 3: "success", |
| | | }; |
| | | return typeTextMap[statusStr] || "info"; |
| | | }; |
| | | |
| | | // 检查审核状态是否为"审核通过" |
| | | const isApproved = (status) => { |