| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- import Vue from 'vue';
- //改变数量
- export function changeCount(row, countObj, noDiscountSingle) {
- console.log(row, countObj, noDiscountSingle);
- let total = row[countObj.countKey] || 0;
- let data = row;
- if (row.packageDispositionList) {
- let endIndex = row.packageDispositionList.findIndex(
- (ite) => row[countObj.unitIdKey] == ite.id
- );
- for (; 0 < endIndex; endIndex--) {
- total = Vue.prototype.$math.format(
- row.packageDispositionList[endIndex].packageCell * total,
- 14
- );
- }
- }
- data['totalCount'] = total;
- data['discountSinglePrice'] = !noDiscountSingle
- ? data.singlePrice
- : data.discountSinglePrice;
- setWeight(data);
- if (row[countObj.countKey] && row.singlePrice) {
- data['totalPrice'] = row[countObj.countKey] * row.singlePrice;
- data['discountTotalPrice'] = !noDiscountSingle
- ? data.totalPrice
- : data.discountTotalPrice;
- } else {
- data['totalPrice'] = 0;
- data['discountTotalPrice'] = 0;
- }
- // getNotaxSinglePrice(data);
- return data;
- // if (row) {
- // singleWeightChange(row, index);
- // }
- // return getNumTotalPrice(arr, noDiscountSingle);
- }
- function setWeight(row) {
- if (row.weightUnit == row.measuringUnit) {
- row['totalWeight'] = row.totalCount;
- } else if (row.totalCount && row.singleWeight) {
- row['totalWeight'] = row.totalCount * row.singleWeight;
- } else {
- row['totalWeight'] = 0;
- }
- }
- export function getAllPrice(arr) {
- let sum = 0;
- arr.forEach((item) => {
- if (item.totalPrice) {
- sum += Number(item.totalPrice);
- }
- });
- return isNaN(sum) ? 0 : sum.toFixed(2);
- }
- // //计算不含税单价
- // function getNotaxSinglePrice(row) {
- // if (row.singlePrice && row.taxRate) {
- // row['notaxSinglePrice'] = parseFloat(
- // (row.singlePrice / (1 + row.taxRate / 100)).toFixed(2)
- // );
- // } else {
- // row['notaxSinglePrice'] = '';
- // }
- // }
- // //计算总金额
- // function getNumTotalPrice(arr, noDiscountSingle) {
- // let sum = 0;
- // arr.forEach((r, index) => {
- // // if (r.singlePrice) {
- // // r.notaxSinglePrice=r.taxRate?r.singlePrice/(1-(r.taxRate/100)):r.singlePrice
- // // }
- // if (r.singlePrice && r.totalCount) {
- // Vue.set(
- // arr[index],
- // 'discountSinglePrice',
- // !noDiscountSingle ? r.singlePrice : r.discountSinglePrice
- // );
- // Vue.set(arr[index], 'totalPrice', getAllPrice(r));
- // Vue.set(
- // arr[index],
- // 'discountTotalPrice',
- // !noDiscountSingle ? r.totalPrice : r.discountTotalPrice
- // );
- // sum += Number(r.totalPrice);
- // } else {
- // Vue.set(arr[index], 'totalPrice', 0);
- // Vue.set(arr[index], 'discountTotalPrice',0);
- // }
- // });
- // return { allPrice: isNaN(sum) ? 0 : sum.toFixed(2), arr };
- // }
- // //获取合计
- // function getAllPrice(row) {
- // let num = 0;
- // if (row.pricingWay == 1) {
- // //按数量计价计算总金额
- // num = Number(row.singlePrice) * Number(row.totalCount);
- // }
- // if (row.pricingWay == 2) {
- // //按重量计价计算总金额
- // num =
- // Number(row.singlePrice) *
- // Number(row.totalCount) *
- // Number(row.singleWeight);
- // }
- // return isNaN(num) ? '' : num.toFixed(2);
- // }
- // function singleWeightChange(row) {
- // console.log(row, 'row');
- // if (row && row.singleWeight && row.totalCount) {
- // row.totalWeight = (row.singleWeight * row.totalCount).toFixed(2) || 0;
- // } else {
- // row.totalWeight = '';
- // }
- // }
|