|
@@ -1,15 +1,24 @@
|
|
|
|
|
+import C from 'highlight.js/lib/languages/1c';
|
|
|
import Vue from 'vue';
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
//改变数量
|
|
//改变数量
|
|
|
export function changeCount(row, countObj, noDiscountSingle, weightType) {
|
|
export function changeCount(row, countObj, noDiscountSingle, weightType) {
|
|
|
- console.log('changeCount~~', row, countObj, noDiscountSingle)
|
|
|
|
|
- const type = countObj.type || 'sale';
|
|
|
|
|
|
|
+ // console.log('changeCount~~', row, countObj, noDiscountSingle);
|
|
|
let total = row[countObj.countKey] || 0;
|
|
let total = row[countObj.countKey] || 0;
|
|
|
let data = row;
|
|
let data = row;
|
|
|
|
|
+ let _endIndex = 0; //计算单重需要
|
|
|
if (row.packageDispositionList) {
|
|
if (row.packageDispositionList) {
|
|
|
let endIndex = row.packageDispositionList.findIndex(
|
|
let endIndex = row.packageDispositionList.findIndex(
|
|
|
(ite) => row[countObj.unitIdKey] == ite.id
|
|
(ite) => row[countObj.unitIdKey] == ite.id
|
|
|
);
|
|
);
|
|
|
|
|
+ _endIndex = endIndex;
|
|
|
|
|
+ let packageData = row.packageDispositionList.find(
|
|
|
|
|
+ (ite) => row[countObj.unitIdKey] == ite.id
|
|
|
|
|
+ );
|
|
|
|
|
+ row[countObj.unitKey] = packageData.conversionUnit;
|
|
|
|
|
+ if (row.weightUnit == row.measuringUnit && row.singleWeight) {
|
|
|
|
|
+ row.packageDispositionList[1].packageCell = row.singleWeight;
|
|
|
|
|
+ }
|
|
|
for (; 0 < endIndex; endIndex--) {
|
|
for (; 0 < endIndex; endIndex--) {
|
|
|
total = Vue.prototype.$math.format(
|
|
total = Vue.prototype.$math.format(
|
|
|
row.packageDispositionList[endIndex].packageCell * total,
|
|
row.packageDispositionList[endIndex].packageCell * total,
|
|
@@ -17,30 +26,31 @@ export function changeCount(row, countObj, noDiscountSingle, weightType) {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
data['totalCount'] = total;
|
|
data['totalCount'] = total;
|
|
|
data['discountSinglePrice'] = !noDiscountSingle
|
|
data['discountSinglePrice'] = !noDiscountSingle
|
|
|
? data.singlePrice
|
|
? data.singlePrice
|
|
|
: data.discountSinglePrice;
|
|
: data.discountSinglePrice;
|
|
|
-
|
|
|
|
|
- if(weightType == 'totalWeight'){
|
|
|
|
|
- console.log('weightType~~', 1)
|
|
|
|
|
- setSingleWeight(data);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (weightType == 'totalWeight') {
|
|
|
|
|
+ console.log('weightType~~', 1);
|
|
|
|
|
+ setSingleWeight(data, countObj, _endIndex);
|
|
|
} else {
|
|
} else {
|
|
|
- console.log('weightType~~', 2)
|
|
|
|
|
- setWeight(data, type);
|
|
|
|
|
|
|
+ console.log('weightType~~', 2);
|
|
|
|
|
+ setWeight(data, countObj);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
data['totalPrice'] = 0;
|
|
data['totalPrice'] = 0;
|
|
|
data['discountTotalPrice'] = 0;
|
|
data['discountTotalPrice'] = 0;
|
|
|
- if (row.pricingWay == 2||row.pricingWay == 3) {
|
|
|
|
|
- let weightKey=countObj.weightKey||'totalWeight'
|
|
|
|
|
|
|
+ if (row.pricingWay == 2 || row.pricingWay == 3) {
|
|
|
|
|
+ let weightKey = countObj.weightKey || 'totalWeight';
|
|
|
if (row[weightKey] && row.singlePrice) {
|
|
if (row[weightKey] && row.singlePrice) {
|
|
|
data['totalPrice'] = (row[weightKey] * row.singlePrice).toFixed(2);
|
|
data['totalPrice'] = (row[weightKey] * row.singlePrice).toFixed(2);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
if (row[countObj.countKey] && row.singlePrice) {
|
|
if (row[countObj.countKey] && row.singlePrice) {
|
|
|
- data['totalPrice'] = (row[countObj.countKey] * row.singlePrice).toFixed(2);
|
|
|
|
|
|
|
+ data['totalPrice'] = (row[countObj.countKey] * row.singlePrice).toFixed(
|
|
|
|
|
+ 2
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
data['discountTotalPrice'] = !noDiscountSingle
|
|
data['discountTotalPrice'] = !noDiscountSingle
|
|
@@ -50,25 +60,57 @@ export function changeCount(row, countObj, noDiscountSingle, weightType) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 计算总重
|
|
// 计算总重
|
|
|
-function setWeight(row, type) {
|
|
|
|
|
- if (row.weightUnit == row.measuringUnit && (type != 'purchase' || (type == 'purchase'&& row.pricingWay == 1))) {
|
|
|
|
|
|
|
+function setWeight(row, countObj) {
|
|
|
|
|
+ if (row.weightUnit == row.measuringUnit) {
|
|
|
row['totalWeight'] = row.totalCount;
|
|
row['totalWeight'] = row.totalCount;
|
|
|
- } else if (row.totalCount && row.singleWeight) {
|
|
|
|
|
- row['totalWeight'] = (row.totalCount * row.singleWeight).toFixed(2);
|
|
|
|
|
|
|
+ } else if (row[countObj.countKey] && row.singleWeight) {
|
|
|
|
|
+ row['totalWeight'] = (row[countObj.countKey] * row.singleWeight).toFixed(2);
|
|
|
} else {
|
|
} else {
|
|
|
row['totalWeight'] = 0;
|
|
row['totalWeight'] = 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ // if (row.weightUnit == row[countObj.unitKey]) {
|
|
|
|
|
+ // row['totalWeight'] = row.totalCount;
|
|
|
|
|
+ // } else if (row[countObj.countKey] && row.singleWeight) {
|
|
|
|
|
+ // row['totalWeight'] = (row[countObj.countKey] * row.singleWeight).toFixed(2);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // row['totalWeight'] = 0;
|
|
|
|
|
+ // }
|
|
|
|
|
+ if (row.weightUnit == row.measuringUnit) {
|
|
|
|
|
+ row['totalCount'] = row.totalWeight;
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log(row['totalCount'], 'dsds');
|
|
|
}
|
|
}
|
|
|
// 计算单重
|
|
// 计算单重
|
|
|
-function setSingleWeight(row) {
|
|
|
|
|
- console.log('setSingleWeight~~', row)
|
|
|
|
|
- if (row.totalWeight && row.totalCount) {
|
|
|
|
|
- console.log('setSingleWeight~~', row.totalWeight, row.totalCount)
|
|
|
|
|
- row['singleWeight'] = (row.totalWeight/row.totalCount).toFixed(2);
|
|
|
|
|
- console.log('singleWeight~~', row['singleWeight'])
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+function setSingleWeight(row, countObj, endIndex) {
|
|
|
|
|
+ console.log('setSingleWeight~~', row);
|
|
|
|
|
+ // if (row.totalWeight && row[countObj.countKey]) {
|
|
|
|
|
+ // row['singleWeight'] = (row.totalWeight / row[countObj.countKey]).toFixed(2);
|
|
|
|
|
+ // console.log('singleWeight~~', row['singleWeight']);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // row['singleWeight'] = 0;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // console.log(endIndex, 'endIndex');
|
|
|
|
|
+ if (row.weightUnit == row.measuringUnit) {
|
|
|
|
|
+ let totalWeight = row['totalWeight'];
|
|
|
|
|
+ for (; 1 < endIndex; endIndex--) {
|
|
|
|
|
+ totalWeight = Vue.prototype.$math.format(
|
|
|
|
|
+ totalWeight / row.packageDispositionList[endIndex].packageCell,
|
|
|
|
|
+ 14
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ // console.log(totalWeight, 'totalWeight');
|
|
|
|
|
+ row['singleWeight'] = Number(totalWeight/row[countObj.countKey]).toFixed(2);
|
|
|
|
|
+ } else if (row.totalWeight && row[countObj.countKey]) {
|
|
|
|
|
+ row['singleWeight'] = (row.totalWeight / totalCount).toFixed(2);
|
|
|
|
|
+ } else {
|
|
|
row['singleWeight'] = 0;
|
|
row['singleWeight'] = 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (row.weightUnit == row.measuringUnit) {
|
|
|
|
|
+ row['totalCount'] = row.totalWeight;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (row.weightUnit == row[countObj.unitKey]) {
|
|
|
|
|
+ row[countObj.countKey] = row.totalWeight;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
export function getAllPrice(arr) {
|
|
export function getAllPrice(arr) {
|
|
|
let sum = 0;
|
|
let sum = 0;
|