|
|
@@ -195,7 +195,13 @@
|
|
|
<view class="label">包装数量:</view>
|
|
|
</u-col>
|
|
|
<u-col span="9">
|
|
|
- <view class="value">{{ row.packingQuantityDisplay || "—" }}</view>
|
|
|
+ <view class="value">{{
|
|
|
+ formatValueWithUnit(
|
|
|
+ row.packingQuantityDisplay,
|
|
|
+ row.packingQuantity,
|
|
|
+ row.packingUnit,
|
|
|
+ )
|
|
|
+ }}</view>
|
|
|
</u-col>
|
|
|
</u-row>
|
|
|
<u-row>
|
|
|
@@ -203,7 +209,13 @@
|
|
|
<view class="label">计量数量:</view>
|
|
|
</u-col>
|
|
|
<u-col span="9">
|
|
|
- <view class="value">{{ row.measureQuantityDisplay || "—" }}</view>
|
|
|
+ <view class="value">{{
|
|
|
+ formatValueWithUnit(
|
|
|
+ row.measureQuantityDisplay,
|
|
|
+ row.measureQuantity,
|
|
|
+ row.measureUnit,
|
|
|
+ )
|
|
|
+ }}</view>
|
|
|
</u-col>
|
|
|
</u-row>
|
|
|
<u-row>
|
|
|
@@ -211,7 +223,9 @@
|
|
|
<view class="label">重量:</view>
|
|
|
</u-col>
|
|
|
<u-col span="9">
|
|
|
- <view class="value">{{ row.weightDisplay || "—" }}</view>
|
|
|
+ <view class="value">{{
|
|
|
+ formatValueWithUnit(row.weightDisplay, row.weight, row.weightUnit)
|
|
|
+ }}</view>
|
|
|
</u-col>
|
|
|
</u-row>
|
|
|
<u-row>
|
|
|
@@ -319,7 +333,13 @@
|
|
|
<view class="label">包装数量:</view>
|
|
|
</u-col>
|
|
|
<u-col span="9">
|
|
|
- <view class="value">{{ row.packingQuantityDisplay || "—" }}</view>
|
|
|
+ <view class="value">{{
|
|
|
+ formatValueWithUnit(
|
|
|
+ row.packingQuantityDisplay,
|
|
|
+ row.packingQuantity,
|
|
|
+ row.packingUnit,
|
|
|
+ )
|
|
|
+ }}</view>
|
|
|
</u-col>
|
|
|
</u-row>
|
|
|
<u-row>
|
|
|
@@ -327,7 +347,13 @@
|
|
|
<view class="label">计量数量:</view>
|
|
|
</u-col>
|
|
|
<u-col span="9">
|
|
|
- <view class="value">{{ row.measureQuantityDisplay || "—" }}</view>
|
|
|
+ <view class="value">{{
|
|
|
+ formatValueWithUnit(
|
|
|
+ row.measureQuantityDisplay,
|
|
|
+ row.measureQuantity,
|
|
|
+ row.measureUnit,
|
|
|
+ )
|
|
|
+ }}</view>
|
|
|
</u-col>
|
|
|
</u-row>
|
|
|
<u-row>
|
|
|
@@ -335,7 +361,9 @@
|
|
|
<view class="label">重量:</view>
|
|
|
</u-col>
|
|
|
<u-col span="9">
|
|
|
- <view class="value">{{ row.weightDisplay || "—" }}</view>
|
|
|
+ <view class="value">{{
|
|
|
+ formatValueWithUnit(row.weightDisplay, row.weight, row.weightUnit)
|
|
|
+ }}</view>
|
|
|
</u-col>
|
|
|
</u-row>
|
|
|
<u-row>
|
|
|
@@ -571,6 +599,12 @@ export default {
|
|
|
this.updateStickyPlaceholderHeight();
|
|
|
},
|
|
|
methods: {
|
|
|
+ padNumber(n) {
|
|
|
+ return n < 10 ? `0${n}` : String(n);
|
|
|
+ },
|
|
|
+ arrayIncludes(list, value) {
|
|
|
+ return Array.isArray(list) && list.indexOf(value) !== -1;
|
|
|
+ },
|
|
|
initStickyTop() {
|
|
|
try {
|
|
|
const systemInfo = uni.getSystemInfoSync();
|
|
|
@@ -603,6 +637,16 @@ export default {
|
|
|
return val || "—";
|
|
|
},
|
|
|
|
|
|
+ formatValueWithUnit(displayValue, value, unit) {
|
|
|
+ if (displayValue || displayValue === 0 || displayValue === "0") {
|
|
|
+ return String(displayValue);
|
|
|
+ }
|
|
|
+ if (value === null || value === undefined || value === "") {
|
|
|
+ return "—";
|
|
|
+ }
|
|
|
+ return `${value}${unit || ""}`;
|
|
|
+ },
|
|
|
+
|
|
|
async loadAssetTypeMapping() {
|
|
|
try {
|
|
|
const data = await allCategoryLevel();
|
|
|
@@ -678,7 +722,7 @@ export default {
|
|
|
|
|
|
getNowFormatDate() {
|
|
|
const now = new Date();
|
|
|
- const pad = (n) => String(n).padStart(2, "0");
|
|
|
+ const pad = (n) => this.padNumber(n);
|
|
|
this.formData.storageTime = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
|
|
|
},
|
|
|
|
|
|
@@ -864,7 +908,7 @@ export default {
|
|
|
brandNum: item.brandNum || "",
|
|
|
batchNo: this.isDetail
|
|
|
? detail.batchNo || batchNo
|
|
|
- : [1, 3, 6].includes(this.bizType)
|
|
|
+ : this.arrayIncludes([1, 3, 6], this.bizType)
|
|
|
? detailList[0]?.batchNo || batchNo
|
|
|
: batchNo,
|
|
|
packingQuantity,
|
|
|
@@ -905,6 +949,7 @@ export default {
|
|
|
});
|
|
|
|
|
|
await this.buildPackingList(batchNo);
|
|
|
+ console.log("this.productList", this.productList);
|
|
|
this.formData.outInDetailList = this.productList;
|
|
|
} catch (e) {
|
|
|
console.warn("初始化产品数据失败", e);
|
|
|
@@ -960,9 +1005,9 @@ export default {
|
|
|
];
|
|
|
});
|
|
|
|
|
|
- this.packingList = this.productList.flatMap(
|
|
|
- (p) => p.outInDetailRecordRequestList,
|
|
|
- );
|
|
|
+ this.packingList = this.productList.reduce((list, product) => {
|
|
|
+ return list.concat(product.outInDetailRecordRequestList || []);
|
|
|
+ }, []);
|
|
|
this.formData.outInDetailList = this.productList;
|
|
|
},
|
|
|
|
|
|
@@ -1008,14 +1053,14 @@ export default {
|
|
|
|
|
|
_getNowDateStr() {
|
|
|
const now = new Date();
|
|
|
- const pad = (n) => String(n).padStart(2, "0");
|
|
|
+ const pad = (n) => this.padNumber(n);
|
|
|
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
|
|
|
},
|
|
|
|
|
|
_isNonSplitUnit(unit) {
|
|
|
if (!unit) return false;
|
|
|
const u = unit.toUpperCase();
|
|
|
- return ["KG", "G", "L", "ML"].includes(u) || unit === "立方";
|
|
|
+ return this.arrayIncludes(["KG", "G", "L", "ML"], u) || unit === "立方";
|
|
|
},
|
|
|
|
|
|
async buildPackingList(batchNo) {
|
|
|
@@ -1220,9 +1265,24 @@ export default {
|
|
|
modelKey: product.modelKey || "",
|
|
|
colorKey: product.colorKey || "",
|
|
|
packingUnit: packingUnit,
|
|
|
+ packingQuantityDisplay: this.formatValueWithUnit(
|
|
|
+ "",
|
|
|
+ packingQuantity,
|
|
|
+ packingUnit,
|
|
|
+ ),
|
|
|
measureQuantity: measureQuantity,
|
|
|
measureUnit: measureUnit,
|
|
|
+ measureQuantityDisplay: this.formatValueWithUnit(
|
|
|
+ "",
|
|
|
+ measureQuantity,
|
|
|
+ measureUnit,
|
|
|
+ ),
|
|
|
weight: weight,
|
|
|
+ weightDisplay: this.formatValueWithUnit(
|
|
|
+ "",
|
|
|
+ weight,
|
|
|
+ product.weightUnit || "",
|
|
|
+ ),
|
|
|
packingSpecificationOption:
|
|
|
product.packingSpecificationOption || [],
|
|
|
weightUnit: product.weightUnit || "",
|
|
|
@@ -1254,8 +1314,18 @@ export default {
|
|
|
if (remainder > 0 && packingEntries.length > 0) {
|
|
|
const lastEntry = packingEntries[packingEntries.length - 1];
|
|
|
lastEntry.measureQuantity = remainder;
|
|
|
+ lastEntry.measureQuantityDisplay = this.formatValueWithUnit(
|
|
|
+ "",
|
|
|
+ remainder,
|
|
|
+ lastEntry.measureUnit,
|
|
|
+ );
|
|
|
if (product.singleWeight) {
|
|
|
lastEntry.weight = product.singleWeight * remainder;
|
|
|
+ lastEntry.weightDisplay = this.formatValueWithUnit(
|
|
|
+ "",
|
|
|
+ lastEntry.weight,
|
|
|
+ lastEntry.weightUnit,
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1341,12 +1411,27 @@ export default {
|
|
|
"",
|
|
|
packingQuantity: 1,
|
|
|
packingUnit: item.packingUnit || "",
|
|
|
+ packingQuantityDisplay: this.formatValueWithUnit(
|
|
|
+ "",
|
|
|
+ 1,
|
|
|
+ item.packingUnit || "",
|
|
|
+ ),
|
|
|
measureQuantity: item.quantity || item.measureQuantity || 0,
|
|
|
measureUnit: item.measuringUnit || item.measureUnit || "",
|
|
|
+ measureQuantityDisplay: this.formatValueWithUnit(
|
|
|
+ "",
|
|
|
+ item.quantity || item.measureQuantity || 0,
|
|
|
+ item.measuringUnit || item.measureUnit || "",
|
|
|
+ ),
|
|
|
supplierCode: item.supplierCode || "",
|
|
|
supplierId: item.supplierId || "",
|
|
|
supplierName: item.supplierName || "",
|
|
|
weight: item.packingWeight || 0,
|
|
|
+ weightDisplay: this.formatValueWithUnit(
|
|
|
+ "",
|
|
|
+ item.packingWeight || 0,
|
|
|
+ item.weightUnit || product0.weightUnit || "",
|
|
|
+ ),
|
|
|
singleWeight: item.singleWeight || 0,
|
|
|
pricingWay: item.pricingWay || "",
|
|
|
weightUnit: item.weightUnit || product0.weightUnit || "",
|
|
|
@@ -1391,7 +1476,7 @@ export default {
|
|
|
const _packingList = this.packingList.map((packingItem) => {
|
|
|
let _workOrderId = null;
|
|
|
let _taskId = null;
|
|
|
- if ([1].includes(this.bizType)) {
|
|
|
+ if (this.arrayIncludes([1], this.bizType)) {
|
|
|
_workOrderId = detailList[0]?.workOrderId;
|
|
|
_taskId = detailList[0]?.taskId;
|
|
|
}
|
|
|
@@ -1443,7 +1528,7 @@ export default {
|
|
|
const ids = item.warehouseIds || [];
|
|
|
const names = item.warehouseNames || [];
|
|
|
ids.forEach((id, idx) => {
|
|
|
- if (id && !warehouseId.includes(id)) {
|
|
|
+ if (id && warehouseId.indexOf(id) === -1) {
|
|
|
warehouseId.push(id);
|
|
|
warehouseName.push(names[idx] || "");
|
|
|
}
|