From 78caa769e452f63288743b8997f7b4c21bb06ce5 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 06 十一月 2026 19:00:38 +0800
Subject: [PATCH] feat(crm,mes): 扩展客户字段与重构批次号生成逻辑
---
src/views/mobile/sales.vue | 129 +++++++++++++++++++++++++++++++++++-------
1 files changed, 106 insertions(+), 23 deletions(-)
diff --git a/src/views/mobile/sales.vue b/src/views/mobile/sales.vue
index a806d2d..4fd2a57 100644
--- a/src/views/mobile/sales.vue
+++ b/src/views/mobile/sales.vue
@@ -2,30 +2,47 @@
import { computed, onMounted, ref } from 'vue';
import { onBeforeRouteLeave } from 'vue-router';
import { useUserStore } from '@vben/stores';
-import { getProductSalesPage, getProductSales, previewProductSalesScan, scanProductSales, checkProductSalesQuantity, stockProductSales, shippingProductSales, finishProductSales, type MesWmProductSalesApi } from '#/api/mes/wm/productsales';
+import { getProductSalesPage, getProductSales, getProductSalesShipments, closeProductSalesRemaining, cancelProductSalesShipment, previewProductSalesScan, scanProductSales, checkProductSalesQuantity, stockProductSales, shippingProductSales, finishProductSales, type MesWmProductSalesApi } from '#/api/mes/wm/productsales';
import { getProductSalesLinePage, type MesWmProductSalesLineApi } from '#/api/mes/wm/productsales/line';
-import { getProductSalesDetailListByLineId, type MesWmProductSalesDetailApi } from '#/api/mes/wm/productsales/detail';
+import { getProductSalesDetailListByLineId, createMobileManualDetail, deleteProductSalesDetail, type MesWmProductSalesDetailApi } from '#/api/mes/wm/productsales/detail';
import { can, extractCode } from '#/mobile/access';
import { errorText } from '#/mobile/api';
import Scanner from './scanner.vue';
+import { speakDuplicateScan } from '#/mobile/scanVoice';
import PickingBags from '../wls/productsales/modules/picking-bags.vue';
+import { formatPickingRemark } from '../wls/productsales/data';
+import { getPickingStocks, type MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
type Sales = MesWmProductSalesApi.ProductSales;
type Preview = MesWmProductSalesApi.ProductSalesScanResponse;
type Line = MesWmProductSalesLineApi.ProductSalesLine;
type Detail = MesWmProductSalesDetailApi.ProductSalesDetail;
-type Action = 'scan' | 'stock' | 'shipping' | 'finish';
-type Pending = { salesId: number; action: Action; before: number; preview?: Preview; carrier?: string; shippingNumber?: string };
-const statusNames: Record<number, string> = { 0: '鑽夌', 1: '寰呮娴�', 2: '寰呮嫞璐�', 10: '寰呭~鍐欒繍鍗�', 3: '寰呮墽琛屽嚭搴�', 4: '宸插畬鎴�', 5: '宸插彇娑�' };
+type Action = 'scan' | 'manual' | 'stock' | 'shipping' | 'finish' | 'close' | 'cancelShipment' | 'delete';
+type Pending = { salesId: number; action: Action; before: number; preview?: Preview; carrier?: string; shippingNumber?: string; lineId?: number; materialStockId?: number; manual?: boolean; detail?: Detail; detailId?: number };
+const statusNames: Record<number, string> = { 0: '鑽夌', 1: '寰呮娴�', 2: '寰呮嫞璐�', 10: '寰呭~鍐欒繍鍗�', 3: '寰呮墽琛屽嚭搴�', 4: '宸插畬鎴�', 5: '宸插彇娑�', 8: '宸插叧闂�' };
+function statusLabel(order: Sales) { return `${order.partiallyShipped ? '閮ㄥ垎鍙戣揣 / ' : ''}${statusNames[order.status!] || '鏈煡鐘舵��'}`; }
const busy = ref(false), error = ref(''), notice = ref(''), code = ref(''), status = ref('');
const rows = ref<Sales[]>([]), page = ref(0), total = ref(0), sales = ref<Sales>();
const lines = ref<Line[]>([]), details = ref<Detail[]>([]), preview = ref<Preview>(), pending = ref<Pending>();
+const shipments = ref<MesWmProductSalesApi.Shipment[]>([]);
+const shipmentNames: Record<number, string> = { 0: '鎷h揣涓�', 10: '寰呭~鍐欒繍鍗�', 20: '寰呮墽琛屽嚭搴�', 30: '宸插嚭搴�', 40: '宸插彇娑�' };
const carrier = ref(''), shippingNumber = ref('');
const scanType = ref<'BAG' | 'PALLET' | 'BATCH'>('BAG'), selectedBagIds = ref<number[]>([]);
+const manualLine = ref<Line>(), manualStock = ref<MesWmMaterialStockApi.MaterialStock>();
+const manualStocks = ref<MesWmMaterialStockApi.MaterialStock[]>([]), stocksLoaded = ref(false);
+const manualQuantity = ref<number>();
const storageKey = 'mom-mobile-sales-' + useUserStore().userInfo?.id;
let filters: { code?: string; status?: number } = {};
const picking = computed(() => sales.value?.status === 2 && can('mes:wm-product-sales:stock'));
function clearPending() { pending.value = undefined; sessionStorage.removeItem(storageKey); }
+function requestId() {
+ if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();
+ if (!globalThis.crypto?.getRandomValues) throw new Error('褰撳墠鐜鏃犳硶鐢熸垚瀹夊叏鐨勮姹傛爣璇�');
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
+ bytes[6] = (bytes[6]! & 15) | 64; bytes[8] = (bytes[8]! & 63) | 128;
+ const hex = Array.from(bytes, b => b.toString(16).padStart(2, '0')).join('');
+ return `${hex.slice(0,8)}-${hex.slice(8,12)}-${hex.slice(12,16)}-${hex.slice(16,20)}-${hex.slice(20)}`;
+}
async function load(reset = true) {
if (busy.value || pending.value) return;
busy.value = true; error.value = '';
@@ -44,51 +61,100 @@
if (all.length >= data.total || !data.list.length) break;
}
const picked = (await Promise.all(all.filter(l => l.id != null).map(l => getProductSalesDetailListByLineId(l.id!)))).flat();
+ shipments.value = await getProductSalesShipments(id);
sales.value = order; lines.value = all; details.value = picked;
- carrier.value = order.carrier || ''; shippingNumber.value = order.shippingNumber || '';
+ const current = shipments.value.find(s => s.status === 10);
+ carrier.value = current ? current.carrier || '' : order.carrier || '';
+ shippingNumber.value = current ? current.shippingNumber || '' : order.shippingNumber || '';
}
async function open(id?: number) {
if (!id || busy.value || pending.value) return;
- busy.value = true; error.value = ''; notice.value = ''; preview.value = undefined;
+ busy.value = true; error.value = ''; notice.value = ''; preview.value = undefined; manualLine.value = undefined; manualStock.value = undefined; manualStocks.value = []; stocksLoaded.value = false;
try { await readOrder(id); } catch (e) { error.value = errorText(e); } finally { busy.value = false; }
}
function pickedQuantity(lineId?: number) { return details.value.filter(d => d.lineId === lineId).reduce((sum, d) => sum + Number(d.quantity || 0), 0); }
+function shippedQuantity(lineId?: number) { const line = lines.value.find(l => l.id === lineId); if (line?.shippedQuantity != null) return Number(line.shippedQuantity); const done = new Set(shipments.value.filter(s => s.status === 30).map(s => s.id)); return details.value.filter(d => d.lineId === lineId && d.shipmentId && done.has(d.shipmentId)).reduce((sum, d) => sum + Number(d.quantity || 0), 0); }
async function identify(raw: string) {
if (busy.value || !picking.value || pending.value) return;
- busy.value = true; error.value = ''; notice.value = ''; preview.value = undefined;
+ busy.value = true; error.value = ''; notice.value = ''; preview.value = undefined; manualLine.value = undefined; manualStock.value = undefined; manualStocks.value = []; stocksLoaded.value = false;
try {
selectedBagIds.value = [];
const data = await previewProductSalesScan(extractCode(raw), scanType.value, sales.value?.id);
+ if (data.scanType === 'BAG' && data.codeId && details.value.some(d => d.bagCodeId === data.codeId)) { speakDuplicateScan('outbound'); throw new Error('璇ヨ鐮佸凡鍦ㄦ嫞璐ф竻鍗曚腑锛岃鍕块噸澶嶆壂鎻�'); }
if (!data.codeId || !data.scanQuantity || data.scanQuantity <= 0) throw new Error('鏃犳硶纭鎵爜鏁伴噺锛岃鏍稿鐮佸��');
const line = lines.value.find(l => l.itemId === data.itemId);
if (!line) throw new Error('鎵爜鍝佺涓嶅湪褰撳墠鍑哄簱鍗曚腑');
data.itemName = line.itemName; preview.value = data;
if (data.scanType === 'BAG') selectedBagIds.value = data.bags?.filter(b => b.selectable).map(b => b.id) || [];
- } catch (e) { error.value = errorText(e); } finally { busy.value = false; }
+ } catch (e) { error.value = errorText(e); if (/宸叉壂鎻忓嚭搴�/.test(error.value)) speakDuplicateScan('outbound'); } finally { busy.value = false; }
+}
+async function chooseManualLine(line: Line) {
+ if (!line.id || !picking.value || busy.value || pending.value) return;
+ busy.value = true; error.value = ''; notice.value = ''; preview.value = undefined;
+ selectedBagIds.value = []; manualLine.value = line; manualStock.value = undefined; stocksLoaded.value = false;
+ try { manualStocks.value = await getPickingStocks(line.id); stocksLoaded.value = true; }
+ catch (e) { error.value = errorText(e); } finally { busy.value = false; }
+}
+async function chooseManualStock(stock: MesWmMaterialStockApi.MaterialStock) {
+ if (!stock.id || !manualLine.value || !sales.value?.id || busy.value) return;
+ if (!stock.bagCount) { manualStock.value = stock; manualQuantity.value = undefined; preview.value = undefined; return; }
+ if (!stock.batchCode) { error.value = '璇ュ簱瀛樼己灏戞壒娆″彿锛屾棤娉曢�夋嫨琚嬬爜'; return; }
+ busy.value = true; error.value = ''; preview.value = undefined; selectedBagIds.value = [];
+ try {
+ const data = await previewProductSalesScan(stock.batchCode, 'BATCH', sales.value.id);
+ if (data.itemId !== manualLine.value.itemId) throw new Error('搴撳瓨鎵规鐨勫搧绉嶄笌鍑哄簱鍗曡涓嶄竴鑷�');
+ const bags = (data.bags || []).filter(b => b.materialStockId === stock.id);
+ if (!bags.length) throw new Error('璇ュ簱瀛樻病鏈夊彲璇嗗埆鐨勮鐮侊紝璇峰湪 PC 绔鐞嗘棤琚嬬爜鍘嗗彶搴撳瓨');
+ manualStock.value = stock; data.bags = bags; data.itemName = manualLine.value.itemName;
+ data.scanQuantity = bags.filter(b => b.selectable).length; preview.value = data;
+ } catch (e) { manualStock.value = undefined; error.value = errorText(e); } finally { busy.value = false; }
+}
+async function removePendingDetail(detail: Detail) {
+ if (!detail.id || detail.shipmentId || !sales.value?.id || !picking.value || busy.value || pending.value || !can('mes:wm-product-sales:delete')) return;
+ if (!window.confirm('纭绉婚櫎杩欐潯灏氭湭鍙戣揣鐨勬嫞璐ф槑缁嗭紵')) return;
+ busy.value = true; error.value = ''; notice.value = '';
+ const operation: Pending = { salesId: sales.value.id, before: sales.value.status!, action: 'delete', detailId: detail.id };
+ pending.value = operation; sessionStorage.setItem(storageKey, JSON.stringify(operation));
+ try { await deleteProductSalesDetail(detail.id); clearPending(); await readOrder(operation.salesId); notice.value = '鎷h揣鏄庣粏宸茬Щ闄ゃ��'; }
+ catch (e) { error.value = '鎿嶄綔缁撴灉寰呯‘璁わ紝璇峰厛鏍稿疄锛�' + errorText(e); } finally { busy.value = false; }
}
async function execute(action: Action) {
const order = sales.value;
if (!order?.id || busy.value || pending.value) return;
- const permission = action === 'scan' ? 'stock' : action;
+ const permission = action === 'scan' || action === 'manual' ? 'stock' : action === 'close' || action === 'cancelShipment' ? 'cancel' : action;
if (!can('mes:wm-product-sales:' + permission)) return;
if (action === 'scan' && (!picking.value || !preview.value)) return;
if (action === 'scan' && !selectedBagIds.value.length) { error.value = '璇烽�夋嫨鏈鎷h揣瀵瑰簲鐨勮鐮�'; return; }
+ if (action === 'manual' && (!picking.value || !manualLine.value?.id || !manualStock.value?.id || !manualQuantity.value || manualQuantity.value <= 0 || manualQuantity.value > Number(manualStock.value.availableQuantity ?? manualStock.value.quantity ?? 0))) { error.value = '璇疯緭鍏ヤ笉瓒呰繃鍙敤搴撳瓨鐨勬湁鏁堟暟閲�'; return; }
if (action === 'stock' && order.status !== 2 || action === 'shipping' && order.status !== 10 || action === 'finish' && order.status !== 3) return;
if (action === 'shipping' && (!carrier.value.trim() || !shippingNumber.value.trim())) { error.value = '璇峰~鍐欐壙杩愬晢鍜岃繍杈撳崟鍙�'; return; }
- const message = action === 'scan' ? `纭灏嗘墍閫� ${selectedBagIds.value.length} 琚嬪姞鍏ユ湰鍗曟嫞璐у苟鍏宠仈杩芥函琚嬬爜锛焋 : action === 'stock' ? '纭瀹屾垚鎷h揣锛熺郴缁熷皢鏍稿鍚勫搧绉嶆暟閲忋��' : action === 'shipping' ? '纭淇濆瓨杩愬崟骞惰繘鍏ュ緟鎵ц鍑哄簱锛�' : '纭鎵ц鍑哄簱锛熸湰鍗曞皢鎵e噺搴撳瓨骞舵爣璁板凡瀹屾垚銆�';
+ const closeReason = action === 'close' ? window.prompt('璇疯緭鍏ュ叧闂墿浣欐暟閲忕殑鍘熷洜锛堟渶澶�500瀛楋級') : undefined;
+ if (action === 'close' && closeReason === null) return;
+ if (action === 'close' && (!closeReason?.trim() || closeReason.trim().length > 500)) { error.value = '璇峰~鍐欎笉瓒呰繃500瀛楃殑鍏抽棴鍘熷洜'; return; }
+ const message = action === 'cancelShipment' ? '纭鍙栨秷鏈鍙戣揣骞堕噴鏀惧簱瀛樺崰鐢紵鎷h揣鏄庣粏浼氫繚鐣欎緵璋冩暣銆�' : action === 'close' ? '纭鍏抽棴鍓╀綑鏈彂鏁伴噺锛熷凡鍑哄簱璁板綍灏嗕繚鐣欍��' : action === 'manual' ? `纭鎸夋暟閲忔嫞璐� ${manualQuantity.value}锛熻鍘嗗彶搴撳瓨娌℃湁琚嬬爜鏄庣粏锛屾棤娉曢�愯杩芥函銆俙 : action === 'scan' ? `纭灏嗘墍閫� ${selectedBagIds.value.length} 琚嬪姞鍏ユ湰鍗曟嫞璐у苟鍏宠仈杩芥函琚嬬爜锛焋 : action === 'stock' ? '纭瀹屾垚鏈鍙戣揣鎷h揣锛熺郴缁熷皢鏍稿绱鏁伴噺銆�' : action === 'shipping' ? '纭淇濆瓨鏈杩愬崟骞惰繘鍏ュ緟鎵ц鍑哄簱锛�' : '纭鎵ц鏈鍑哄簱锛熺郴缁熷皢鎵e噺鏈搴撳瓨銆�';
if (!window.confirm(message)) return;
busy.value = true; error.value = ''; notice.value = '';
try {
- if (action === 'stock' && !await checkProductSalesQuantity(order.id)) throw new Error('鎷h揣鏁伴噺涓庡嚭搴撴暟閲忎笉涓�鑷达紝璇锋牳瀵规瘡涓搧绉�');
- const operation: Pending = { salesId: order.id, action, before: order.status!, preview: action === 'scan' ? { ...preview.value, selectedBagIds: [...selectedBagIds.value], scanQuantity: selectedBagIds.value.length } : undefined, carrier: carrier.value.trim(), shippingNumber: shippingNumber.value.trim() };
+ if (action === 'stock' && !await checkProductSalesQuantity(order.id)) throw new Error('璇峰厛鎷i�夋湰娆℃槑缁嗭紝涓旂疮璁℃暟閲忎笉鑳借秴杩囪鍒掓暟閲�');
+ const operation: Pending = { salesId: order.id, action, before: order.status!, preview: action === 'scan' ? { ...preview.value, selectedBagIds: [...selectedBagIds.value], scanQuantity: selectedBagIds.value.length } : undefined, carrier: carrier.value.trim(), shippingNumber: shippingNumber.value.trim(), lineId: manualStock.value ? manualLine.value?.id : undefined, materialStockId: manualStock.value?.id, manual: !!manualStock.value };
+ if (action === 'manual') {
+ operation.detail = { salesId: order.id, lineId: manualLine.value!.id, itemId: manualLine.value!.itemId,
+ materialStockId: manualStock.value!.id, batchId: manualStock.value!.batchId, batchCode: manualStock.value!.batchCode,
+ warehouseId: manualStock.value!.warehouseId,
+ quantity: manualQuantity.value, remark: `绉诲姩绔棤琚嬬爜鎷h揣 #${requestId()}` };
+ }
pending.value = operation; sessionStorage.setItem(storageKey, JSON.stringify(operation));
if (action === 'scan') {
- const result = await scanProductSales({ salesId: order.id, scanContent: operation.preview!.scanContent!, scanType: operation.preview!.scanType as 'BAG' | 'PALLET' | 'BATCH', bagIds: operation.preview!.selectedBagIds, quantity: operation.preview!.scanQuantity });
+ const result = await scanProductSales({ salesId: order.id, scanContent: operation.preview!.scanContent!, scanType: operation.preview!.scanType as 'BAG' | 'PALLET' | 'BATCH', bagIds: operation.preview!.selectedBagIds, quantity: operation.preview!.scanQuantity, lineId: operation.lineId, materialStockId: operation.materialStockId, manual: operation.manual });
+ if (result.alreadyScanned) speakDuplicateScan('outbound');
notice.value = result.alreadyScanned ? '璇ョ爜宸插湪鎷h揣娓呭崟涓紝鏈鏈噸澶嶆坊鍔犮��' : `宸插姞鍏ユ嫞璐э細${result.outboundQuantity || operation.preview!.scanQuantity} 琚嬨�俙;
- } else if (action === 'stock') { await stockProductSales(order.id); notice.value = '鎷h揣瀹屾垚锛岃濉啓杩愬崟銆�'; }
+ } else if (action === 'manual') { await createMobileManualDetail(operation.detail!); notice.value = '鏁伴噺鎷h揣宸插姞鍏ワ紱璇ユ槑缁嗘棤琚嬬爜杩芥函銆�'; }
+ else if (action === 'stock') { await stockProductSales(order.id); notice.value = '鎷h揣瀹屾垚锛岃濉啓杩愬崟銆�'; }
else if (action === 'shipping') { await shippingProductSales({ id: order.id, carrier: operation.carrier, shippingNumber: operation.shippingNumber }); notice.value = '杩愬崟宸蹭繚瀛橈紝璇锋牳瀵瑰悗鎵ц鍑哄簱銆�'; }
- else { await finishProductSales(order.id); notice.value = '鍑哄簱瀹屾垚锛屽簱瀛樺凡鏇存柊銆�'; }
- clearPending(); preview.value = undefined;
+ else if (action === 'close') { await closeProductSalesRemaining(order.id, closeReason!.trim()); notice.value = '鍓╀綑鏁伴噺宸插叧闂��'; }
+ else if (action === 'cancelShipment') { await cancelProductSalesShipment(order.id); notice.value = '鏈鍙戣揣宸插彇娑堬紝搴撳瓨鍗犵敤宸查噴鏀俱��'; }
+ else { await finishProductSales(order.id); notice.value = '鏈鍑哄簱瀹屾垚锛屽簱瀛樺凡鏇存柊銆�'; }
+ clearPending(); preview.value = undefined; manualStock.value = undefined; manualLine.value = undefined; manualStocks.value = []; stocksLoaded.value = false;
await readOrder(order.id);
} catch (e) { error.value = (pending.value ? '鎿嶄綔缁撴灉寰呯‘璁わ紝璇峰厛鏍稿疄锛�' : '') + errorText(e); } finally { busy.value = false; }
}
@@ -99,7 +165,7 @@
const operation = pending.value;
await readOrder(operation.salesId);
const requestedIds = operation.preview?.selectedBagIds;
- const found = operation.action === 'scan' ? requestedIds?.length ? requestedIds.every(id => details.value.some(d => d.bagCodeId === id)) : details.value.some(d => operation.preview?.scanType === 'PALLET' ? d.palletCodeId === operation.preview.codeId : d.bagCodeId === operation.preview?.codeId) : sales.value?.status !== operation.before;
+ const found = operation.action === 'delete' ? !details.value.some(d => d.id === operation.detailId) : operation.action === 'manual' ? details.value.some(d => d.remark === operation.detail?.remark) : operation.action === 'scan' ? requestedIds?.length ? requestedIds.every(id => details.value.some(d => d.bagCodeId === id)) : details.value.some(d => operation.preview?.scanType === 'PALLET' ? d.palletCodeId === operation.preview.codeId : d.bagCodeId === operation.preview?.codeId) : sales.value?.status !== operation.before;
if (operation.action === 'scan' && !found && requestedIds?.some(id => details.value.some(d => d.bagCodeId === id))) { error.value = '鎵�閫夎鐮佷粎閮ㄥ垎瀛樺湪浜庢嫞璐ф槑缁嗭紝璇疯仈绯昏礋璐d汉鏍稿锛屼笉鑳借嚜鍔ㄩ噸璇曘��'; return; }
if (found) {
notice.value = operation.action === 'scan' ? '宸叉牳瀹烇細璇ョ爜宸插湪鎷h揣娓呭崟涓��' : '褰撳墠鍗曟嵁鐘舵�侊細' + statusNames[sales.value!.status!] + '銆傝鏍稿鏄庣粏鍜岃繍鍗曞悗缁х画銆�';
@@ -119,15 +185,32 @@
<p v-if="error" class="m-error" role="alert">{{error}}</p>
<section v-if="pending" class="m-panel"><h2 class="m-title">鍑哄簱鎿嶄綔缁撴灉寰呯‘璁�</h2><p>鍗曟嵁缂栧彿 {{pending.salesId}}锛岃鍏堟牳瀹炲啀缁х画鎿嶄綔銆�</p><button class="m-primary" :disabled="busy" @click="verify">鏍稿疄鎿嶄綔缁撴灉</button></section>
<template v-if="sales">
- <button v-if="!pending" class="m-secondary" :disabled="busy" @click="sales = undefined; preview = undefined; load()">杩斿洖鍑哄簱鍗曞垪琛�</button>
- <section class="m-panel" style="margin-top:16px"><h2 class="m-title">{{sales.code}}</h2><strong class="m-status">{{statusNames[sales.status!] || '鏈煡鐘舵��'}}</strong><dl><div class="m-row"><dt>瀹㈡埛</dt><dd>{{sales.clientName || '鈥�'}}</dd></div><div class="m-row"><dt>鏀惰揣浜�</dt><dd>{{sales.contactName || '鈥�'}} {{sales.contactTelephone}}</dd></div><div class="m-row"><dt>鏀惰揣鍦板潃</dt><dd>{{sales.contactAddress || '鈥�'}}</dd></div><div v-if="sales.shippingNumber" class="m-row"><dt>杩愬崟</dt><dd>{{sales.carrier}} 路 {{sales.shippingNumber}}</dd></div></dl><button v-if="!pending" class="m-secondary" :disabled="busy" @click="open(sales.id)">鍒锋柊鍗曟嵁</button></section>
+ <button v-if="!pending" class="m-secondary" :disabled="busy" @click="sales = undefined; preview = undefined; manualLine = undefined; manualStock = undefined; manualStocks = []; stocksLoaded = false; load()">杩斿洖鍑哄簱鍗曞垪琛�</button>
+ <section class="m-panel" style="margin-top:16px"><h2 class="m-title">{{sales.code}}</h2><strong class="m-status">{{statusLabel(sales)}}</strong><dl><div class="m-row"><dt>瀹㈡埛</dt><dd>{{sales.clientName || '鈥�'}}</dd></div><div class="m-row"><dt>鏀惰揣浜�</dt><dd>{{sales.contactName || '鈥�'}} {{sales.contactTelephone}}</dd></div><div class="m-row"><dt>鏀惰揣鍦板潃</dt><dd>{{sales.contactAddress || '鈥�'}}</dd></div><div v-if="sales.shippingNumber" class="m-row"><dt>鏈�杩戣繍鍗�</dt><dd>{{sales.carrier}} 路 {{sales.shippingNumber}}</dd></div></dl><button v-if="!pending" class="m-secondary" :disabled="busy" @click="open(sales.id)">鍒锋柊鍗曟嵁</button></section>
<h2 class="m-section-title">鍑哄簱鍝佺涓庢嫞璐ц繘搴�</h2>
+ <section v-if="shipments.length" class="m-panel"><h2 class="m-title">鍙戣揣璁板綍</h2><div v-for="shipment in shipments" :key="shipment.id" class="m-record"><strong>绗� {{shipments.indexOf(shipment) + 1}} 娆� 路 {{shipmentNames[shipment.status] || '鏈煡鐘舵��'}}</strong><p v-if="shipment.shippingNumber">{{shipment.carrier || '鏈綍鍏ユ壙杩愬晢'}} 路 {{shipment.shippingNumber}}</p><p v-if="shipment.outboundTime">鍑哄簱鏃堕棿锛歿{shipment.outboundTime}}</p></div></section>
<p v-if="!lines.length" class="m-empty">璇ュ崟鏆傛棤鍝佺鏄庣粏</p>
- <article v-for="line in lines" :key="line.id" class="m-panel"><h3 class="m-title">{{line.itemName || line.itemCode}}</h3><p>璁″垝 {{line.quantity || 0}} {{line.unitMeasureName || '琚�'}} 路 宸叉嫞 {{pickedQuantity(line.id)}} {{line.unitMeasureName || '琚�'}}</p><details><summary>鏌ョ湅鎷h揣鏄庣粏</summary><div v-for="detail in details.filter(d => d.lineId === line.id)" :key="detail.id" class="m-record"><p>{{detail.batchCode || '鏈綍鍏ユ壒娆�'}} 路 {{detail.quantity}} {{line.unitMeasureName || '琚�'}}</p><p class="m-muted">{{detail.warehouseName || '鈥�'}} / {{detail.locationName || '鈥�'}} / {{detail.areaName || '鈥�'}}</p><p class="m-muted">{{detail.bagCodeId ? '琚嬬爜缂栧彿 ' + detail.bagCodeId : '鎵樼洏缂栧彿 ' + detail.palletCodeId}}</p><p v-if="detail.remark" class="m-muted" style="overflow-wrap:anywhere">{{detail.remark}}</p></div></details></article>
+ <article v-for="line in lines" :key="line.id" class="m-panel"><h3 class="m-title">{{line.itemName || line.itemCode}}</h3><p>璁″垝 {{line.quantity || 0}} 路 宸插彂 {{shippedQuantity(line.id)}} 路 宸叉嫞鍚堣 {{pickedQuantity(line.id)}} {{line.unitMeasureName || '琚�'}}</p><details><summary>鏌ョ湅鎷h揣鏄庣粏</summary><div v-for="detail in details.filter(d => d.lineId === line.id)" :key="detail.id" class="m-record"><p>{{detail.batchCode || '鏈綍鍏ユ壒娆�'}} 路 {{detail.quantity}} {{line.unitMeasureName || '琚�'}}</p><p class="m-muted">{{detail.warehouseName || '鈥�'}}</p><p class="m-muted">{{detail.bagCodeId ? '琚嬬爜缂栧彿 ' + detail.bagCodeId : detail.palletCodeId ? '鎵樼洏缂栧彿 ' + detail.palletCodeId : '鏃犺鐮佹槑缁�'}}</p><p v-if="detail.remark" class="m-muted" style="overflow-wrap:anywhere">{{formatPickingRemark(detail.remark)}}</p><button v-if="picking && !detail.shipmentId && !pending && can('mes:wm-product-sales:delete')" class="m-secondary" :disabled="busy || !!preview" @click="removePendingDetail(detail)">绉婚櫎鏈彂鏄庣粏</button></div></details><button v-if="picking && !pending" class="m-secondary" :disabled="busy || !!preview" @click="chooseManualLine(line)">鎵嬪伐閫夋嫨搴撳瓨琚嬬爜</button></article>
+ <section v-if="manualLine && !pending" class="m-panel">
+ <h2 class="m-title">閫夋嫨 {{manualLine.itemName || manualLine.itemCode}} 鐨勫簱瀛�</h2>
+ <p v-if="stocksLoaded && !manualStocks.length" class="m-empty">娌℃湁鍙�夌殑鍚堟牸搴撳瓨</p>
+ <button v-for="stock in manualStocks" :key="stock.id" class="m-order-button" :disabled="busy || !!preview" @click="chooseManualStock(stock)">
+ <strong>鎵规 {{stock.batchCode || '鏈綍鍏�'}}</strong><span>{{stock.warehouseName}}</span><small>鍙敤 {{stock.availableQuantity ?? stock.quantity ?? 0}} 路 鍦ㄥ簱琚嬬爜 {{stock.bagCount ?? 0}}</small>
+ </button>
+ <div v-if="manualStock && !manualStock.bagCount && !preview" class="m-record">
+ <p>璇ュ簱瀛樻殏鏃犲湪搴撹鐮佹槑缁嗭紝鎸夋暟閲忔嫞璐ф棤娉曢�愯杩芥函銆�</p>
+ <label class="m-field"><span>鏈鎷h揣鏁伴噺</span><input v-model.number="manualQuantity" type="number" min="0.000001" step="any" :max="manualStock.availableQuantity ?? manualStock.quantity ?? 0" :disabled="busy" /></label>
+ <button class="m-primary" :disabled="busy || !manualQuantity" @click="execute('manual')">纭鏁伴噺鎷h揣</button>
+ </div>
+ <button class="m-detail-toggle" :disabled="busy || !!preview" @click="manualLine = undefined; manualStocks = []; stocksLoaded = false">鍏抽棴搴撳瓨閫夋嫨</button>
+ </section>
<template v-if="!pending">
- <template v-if="picking"><h2 class="m-section-title">鎵爜鎷h揣</h2><label class="m-field"><span>鎷h揣鎵爜绫诲瀷</span><select v-model="scanType" :disabled="busy" @change="preview = undefined; selectedBagIds = []"><option value="BAG">琚嬬爜</option><option value="PALLET">鎵樼洏鐮�</option><option value="BATCH">鐢熶骇鎵规鐮�</option></select></label><p class="m-muted">鏀寔涓氬姟鐮佷笌杩芥函鐮併�傛墭鐩樸�佹壒娆¤瘑鍒悗閫夋嫨瀹為檯鎷h揣琚嬬爜锛屾暟閲忔寜鎵�閫夎鏁拌鍏ャ��</p><Scanner :disabled="busy" @code="identify" /><section v-if="preview" class="m-panel"><h3 class="m-title">鏍稿鎷h揣瀵硅薄</h3><p>{{preview.itemName}}</p><p style="overflow-wrap:anywhere">{{preview.scanContent}}</p><p>鎵规 {{preview.batchCode}} 路 鍙嫞 {{preview.scanQuantity}} 琚�</p><PickingBags v-if="preview.scanType !== 'BAG'" v-model="selectedBagIds" :bags="preview.bags || []" :disabled="busy" /><p v-else>琚嬬爜 {{preview.bags?.[0]?.code}}</p><p role="status">鏈鎷h揣 {{selectedBagIds.length}} 琚�</p><button class="m-primary" :disabled="busy || !selectedBagIds.length" @click="execute('scan')">纭鍔犲叆鎷h揣</button><button class="m-detail-toggle" :disabled="busy" @click="preview = undefined">鍙栨秷鏈鎵爜</button></section></template>
+ <template v-if="picking"><h2 class="m-section-title">鎵爜鎷h揣</h2><label class="m-field"><span>鎷h揣鎵爜绫诲瀷</span><select v-model="scanType" :disabled="busy" @change="preview = undefined; selectedBagIds = []"><option value="BAG">琚嬬爜</option><option value="PALLET">鎵樼洏鐮�</option><option value="BATCH">鐢熶骇鎵规鐮�</option></select></label><p class="m-muted">鏀寔杩芥函鐮併�傛墭鐩樸�佹壒娆¤瘑鍒悗閫夋嫨瀹為檯鎷h揣琚嬬爜锛屾暟閲忔寜鎵�閫夎鏁拌鍏ャ��</p><Scanner voice-operation="outbound" duplicate-voice :disabled="busy" @code="identify" /><section v-if="preview" class="m-panel"><h3 class="m-title">鏍稿鎷h揣瀵硅薄</h3><p>{{preview.itemName}}</p><p style="overflow-wrap:anywhere">{{preview.scanContent}}</p><p>鎵规 {{preview.batchCode}} 路 鍙嫞 {{preview.scanQuantity}} 琚�</p><PickingBags v-if="preview.scanType !== 'BAG'" v-model="selectedBagIds" :bags="preview.bags || []" :disabled="busy" /><p v-else>琚嬬爜 {{preview.bags?.[0]?.code}}</p><p role="status">鏈鎷h揣 {{selectedBagIds.length}} 琚�</p><button class="m-primary" :disabled="busy || !selectedBagIds.length" @click="execute('scan')">纭鍔犲叆鎷h揣</button><button class="m-detail-toggle" :disabled="busy" @click="preview = undefined">鍙栨秷鏈鎵爜</button></section></template>
<form v-if="sales.status === 10 && can('mes:wm-product-sales:shipping')" class="m-panel" @submit.prevent="execute('shipping')"><h2 class="m-title">濉啓杩愬崟</h2><label class="m-field"><span>鎵胯繍鍟�</span><input v-model="carrier" :disabled="busy" maxlength="100" required /></label><label class="m-field"><span>杩愯緭鍗曞彿</span><input v-model="shippingNumber" :disabled="busy" maxlength="100" required /></label><button class="m-primary" :disabled="busy">淇濆瓨杩愬崟</button></form>
<div v-if="!preview" class="m-action-bar"><button v-if="picking" class="m-primary" :disabled="busy || !lines.length" @click="execute('stock')">瀹屾垚鎷h揣骞舵牳瀵规暟閲�</button><button v-if="sales.status === 3 && can('mes:wm-product-sales:finish')" class="m-primary" :disabled="busy" @click="execute('finish')">纭鎵ц鍑哄簱</button></div>
+ <button v-if="picking && shipments.some(s => s.status === 30) && can('mes:wm-product-sales:cancel')" class="m-secondary" :disabled="busy || !!preview" @click="execute('close')">鍏抽棴鍓╀綑鏁伴噺</button>
+ <button v-if="(sales.status === 10 || sales.status === 3) && can('mes:wm-product-sales:cancel')" class="m-secondary" :disabled="busy" @click="execute('cancelShipment')">鍙栨秷鏈鍙戣揣</button>
+ <p v-if="sales.status === 8" class="m-warning">鍓╀綑鏁伴噺宸插叧闂細{{sales.closeReason || '鏈褰曞師鍥�'}}</p>
<p v-if="sales.status === 0 || sales.status === 1" class="m-warning">{{sales.status === 0 ? '璇ュ崟涓鸿崏绋匡紝璇峰湪 PC 绔淮鎶ゅ搧绉嶅苟鎻愪氦鍚庤繘琛岀Щ鍔ㄦ嫞璐с��' : '璇ュ崟寰呮娴嬶紝妫�娴嬪畬鎴愬悗鎵嶈兘鎷h揣銆�'}}</p>
<p v-if="sales.status === 4" class="m-success">璇ュ崟宸插畬鎴愬嚭搴撱��</p>
</template>
@@ -135,7 +218,7 @@
<template v-else-if="!pending">
<form class="m-panel" @submit.prevent="load()"><label class="m-field"><span>鍑哄簱鍗曞彿</span><input v-model="code" :disabled="busy" placeholder="杈撳叆鍑哄簱鍗曞彿" /></label><label class="m-field"><span>鍗曟嵁鐘舵��</span><select v-model="status" :disabled="busy"><option value="">鍏ㄩ儴鐘舵��</option><option v-for="(name, value) in statusNames" :key="value" :value="String(value)">{{name}}</option></select></label><button class="m-secondary" :disabled="busy">{{busy ? '姝e湪鏌ヨ鈥�' : '鏌ヨ鍑哄簱鍗�'}}</button></form>
<p class="m-muted" role="status">鍏� {{total}} 寮犲嚭搴撳崟</p><p v-if="!rows.length && !busy && !error" class="m-empty">鏆傛棤鍖归厤鐨勫嚭搴撳崟</p>
- <button v-for="row in rows" :key="row.id" class="m-order-button" :disabled="busy" @click="open(row.id)"><strong>{{row.code}}</strong><span>{{statusNames[row.status!] || '鏈煡鐘舵��'}}</span><small>{{row.clientName || '鏈綍鍏ュ鎴�'}}</small></button>
+ <button v-for="row in rows" :key="row.id" class="m-order-button" :disabled="busy" @click="open(row.id)"><strong>{{row.code}}</strong><span>{{statusLabel(row)}}</span><small>{{row.clientName || '鏈綍鍏ュ鎴�'}}</small></button>
<button v-if="rows.length < total" class="m-secondary" :disabled="busy" @click="load(false)">{{busy ? '姝e湪鍔犺浇鈥�' : '鍔犺浇鏇村'}}</button>
</template>
</template>
--
Gitblit v1.9.3