Browse Source

修改数量精度问题

wms3.0_pda
lijuncheng 10 months ago
parent
commit
c28ff0b1b3
  1. 4
      common/basic.js
  2. 17
      common/calc.js
  3. 3
      common/detail.js
  4. 3
      common/record.js
  5. 5
      pages/count/job/countDetail.vue

4
common/basic.js

@ -3,6 +3,8 @@ export {
maxPageSize maxPageSize
} }
import { calc } from '@/common/calc'
let jobStatusList = []; let jobStatusList = [];
let itemStatusList = []; let itemStatusList = [];
let locationTypeList = []; let locationTypeList = [];
@ -943,7 +945,7 @@ export function getDataSource(subList) {
item.subList.push(newDetail); item.subList.push(newDetail);
items.push(item) items.push(item)
} else { } else {
item.qty += Number(detail.qty) item.qty = calc.add(item.qty,detail.qty)
let newDetail = createDetailInfo(detail); // let newDetail = createDetailInfo(detail); //
item.subList.push(newDetail); item.subList.push(newDetail);
} }

17
common/calc.js

@ -0,0 +1,17 @@
/* 解决js计算精度问题 */
import { Decimal } from 'decimal.js';//引入
class Calc {
add(num1,num2) {
return new Decimal(num1).add(new Decimal(num2))
}
sub(num1,num2) {
return new Decimal(num1).sub(new Decimal(num2))
}
mul(num1,num2) {
return new Decimal(num1).mul(new Decimal(num2))
}
div(num1,num2) {
return new Decimal(num1).div(new Decimal(num2))
}
}
export const calc = new Calc();

3
common/detail.js

@ -1,3 +1,4 @@
import { calc } from '@/common/calc'
export function getDataSource(subList) { export function getDataSource(subList) {
let items = []; let items = [];
subList.forEach(detail => { subList.forEach(detail => {
@ -9,7 +10,7 @@ export function getDataSource(subList) {
item.subList.push(newDetail); item.subList.push(newDetail);
items.push(item) items.push(item)
} else { } else {
item.qty +=Number(detail.qty) item.qty = calc.add(item.qty,detail.qty)
let newDetail = createDetailInfo(detail); // let newDetail = createDetailInfo(detail); //
item.subList.push(newDetail); item.subList.push(newDetail);
} }

3
common/record.js

@ -5,6 +5,7 @@ import {
import { import {
getDirectoryItemArray, getDirectoryItemArray,
} from '@/common/directory.js'; } from '@/common/directory.js';
import { calc } from '@/common/calc'
export function createItemInfo(balance, pack) { export function createItemInfo(balance, pack) {
let item = { let item = {
@ -40,7 +41,7 @@ export function calcHandleQty(detailSource) {
item.qty = 0; item.qty = 0;
for (let detail of item.subList) { for (let detail of item.subList) {
if (detail != undefined && detail.scaned) { if (detail != undefined && detail.scaned) {
item.qty = item.qty + Number(detail.qty) item.qty = calc.add(item.qty,detail.qty);
} }
} }
} }

5
pages/count/job/countDetail.vue

@ -23,6 +23,7 @@
</view> </view>
<u-line color="#D8D8D8" style="margin-bottom: 15rpx;"></u-line> <u-line color="#D8D8D8" style="margin-bottom: 15rpx;"></u-line>
<view class="page-main"> <view class="page-main">
{{detailSource[0].qty}}
<scroll-view scroll-y="true" class="page-main-scroll"> <scroll-view scroll-y="true" class="page-main-scroll">
<view class="detail-list" v-for="(item, index) in detailSource" :key="item.id"> <view class="detail-list" v-for="(item, index) in detailSource" :key="item.id">
<view class=""> <view class="">
@ -72,6 +73,7 @@
import { import {
getCountStageName getCountStageName
} from '@/common/directory.js'; } from '@/common/directory.js';
import { calc } from '@/common/calc'
import winScanButton from '@/mycomponents/scan/winScanButton.vue' import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import winScanPack from '@/mycomponents/scan/winScanPack.vue' import winScanPack from '@/mycomponents/scan/winScanPack.vue'
@ -202,7 +204,7 @@
item.subList.push(newDetail); item.subList.push(newDetail);
items.push(item) items.push(item)
} else { } else {
item.qty += detail.qty item.qty = calc.add(item.qty,detail.qty)
let newDetail = this.createDetailInfo(detail); // let newDetail = this.createDetailInfo(detail); //
item.subList.push(newDetail); item.subList.push(newDetail);
} }
@ -250,6 +252,7 @@
item.handleQty = 0; item.handleQty = 0;
for (let detail of item.subList) { for (let detail of item.subList) {
if (detail != undefined && detail.scaned) { if (detail != undefined && detail.scaned) {
console.log("数量",Number(detail.qty))
item.handleQty += Number(detail.qty) item.handleQty += Number(detail.qty)
} }
} }

Loading…
Cancel
Save