lijuncheng
9 months ago
5 changed files with 271 additions and 97 deletions
@ -1,83 +1,100 @@ |
|||
import { |
|||
calc |
|||
} from '@/common/calc' |
|||
calc |
|||
} from '@/common/calc' |
|||
|
|||
import { Decimal } from 'decimal.js';//引入
|
|||
export function getDataSource(subList) { |
|||
let items = []; |
|||
subList.forEach(detail => { |
|||
var item = items.find(r => |
|||
r.itemCode == detail.itemCode) |
|||
if (item == undefined) { |
|||
item = createItemInfo(detail); |
|||
let newDetail = createDetailInfo(detail); //
|
|||
item.subList.push(newDetail); |
|||
items.push(item) |
|||
} else { |
|||
item.qty = calc.add(item.qty, detail.qty) |
|||
let newDetail = createDetailInfo(detail); //
|
|||
item.subList.push(newDetail); |
|||
} |
|||
}) |
|||
return items; |
|||
} |
|||
import { |
|||
Decimal |
|||
} from 'decimal.js'; //引入
|
|||
export function getDataSource(dataList) { |
|||
let items = []; |
|||
|
|||
export function createItemInfo(detail) { |
|||
let item = { |
|||
itemCode: detail.itemCode, |
|||
itemName: detail.itemName, |
|||
stdPackQty: Number(detail.stdPackQty) || undefined, |
|||
stdPackUnit: detail.stdPackUnit, |
|||
qty: Number(detail.qty), |
|||
handleQty: 0, |
|||
uom: detail.uom, |
|||
subList: [] |
|||
let parentList = dataList.filter(r => r.parentPackingNumber == null || r |
|||
.parentPackingNumber == ''); |
|||
let childList = dataList.filter(r => r.parentPackingNumber != '' && r.parentPackingNumber != null); |
|||
|
|||
parentList.forEach(detail => { |
|||
var item = items.find(r => |
|||
r.itemCode == detail.itemCode) |
|||
if (item == undefined) { |
|||
item = createItemInfo(detail); |
|||
let newDetail = createDetailInfo(detail); //
|
|||
item.subList.push(newDetail); |
|||
items.push(item) |
|||
} else { |
|||
item.qty = calc.add(item.qty, detail.qty) |
|||
let newDetail = createDetailInfo(detail); //
|
|||
item.subList.push(newDetail); |
|||
} |
|||
return item; |
|||
} |
|||
}) |
|||
|
|||
if (childList.length > 0) { |
|||
items.forEach(r => |
|||
r.subList.forEach(s => { |
|||
s.packList = childList.filter(c => c.parentPackingNumber == s.packingNumber) |
|||
}) |
|||
|
|||
export function createDetailInfo(data) { |
|||
data.scaned = false; |
|||
// data.record = {};
|
|||
let detail = data; |
|||
return detail; |
|||
) |
|||
} |
|||
|
|||
//根据明细创建记录
|
|||
export function createRecordInfo(detail, balance) { |
|||
var record = {} |
|||
// let record = JSON.parse(JSON.stringify(detail));
|
|||
//克隆对象,深度克隆,防止双向绑定同一个变量
|
|||
Object.assign(record, detail) |
|||
detail.scaned = true; |
|||
detail.balance = balance; |
|||
detail.recommendInventoryStatus = detail.inventoryStatus; |
|||
detail.inventoryStatus = balance.inventoryStatus; |
|||
record.qty = Number(balance.qty); |
|||
return record; |
|||
return items; |
|||
} |
|||
|
|||
export function createItemInfo(detail) { |
|||
let item = { |
|||
itemCode: detail.itemCode, |
|||
itemName: detail.itemName, |
|||
stdPackQty: Number(detail.stdPackQty) || undefined, |
|||
stdPackUnit: detail.stdPackUnit, |
|||
qty: Number(detail.qty), |
|||
handleQty: 0, |
|||
uom: detail.uom, |
|||
subList: [] |
|||
} |
|||
return item; |
|||
} |
|||
|
|||
export function createDetailInfo(data) { |
|||
data.scaned = false; |
|||
let detail = data; |
|||
detail.packList = []; |
|||
return detail; |
|||
} |
|||
|
|||
//根据明细创建记录
|
|||
export function createRecordInfo(detail, balance) { |
|||
var record = {} |
|||
// let record = JSON.parse(JSON.stringify(detail));
|
|||
//克隆对象,深度克隆,防止双向绑定同一个变量
|
|||
Object.assign(record, detail) |
|||
detail.scaned = true; |
|||
detail.balance = balance; |
|||
detail.recommendInventoryStatus = detail.inventoryStatus; |
|||
detail.inventoryStatus = balance.inventoryStatus; |
|||
record.qty = Number(balance.qty); |
|||
return record; |
|||
} |
|||
|
|||
//计算实际数量
|
|||
export function calcHandleQty(detailSource) { |
|||
for (let item of detailSource) { |
|||
item.handleQty = new Decimal(0).toNumber(); |
|||
item.qty = new Decimal(0).toNumber(); |
|||
for (let detail of item.subList) { |
|||
if (detail != undefined && detail.scaned) { |
|||
item.handleQty = calc.add(item.handleQty,detail.handleQty); |
|||
item.qty = calc.add(item.qty,detail.qty); |
|||
} |
|||
//计算实际数量
|
|||
export function calcHandleQty(detailSource) { |
|||
for (let item of detailSource) { |
|||
item.handleQty = new Decimal(0).toNumber(); |
|||
item.qty = new Decimal(0).toNumber(); |
|||
for (let detail of item.subList) { |
|||
if (detail != undefined && detail.scaned) { |
|||
item.handleQty = calc.add(item.handleQty, detail.handleQty); |
|||
item.qty = calc.add(item.qty, detail.qty); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
export function getScanCount(subList) { |
|||
let items = subList.filter(r => { |
|||
if (r.scaned) { |
|||
return r; |
|||
} |
|||
}) |
|||
let scanCount = items != null ? items.length : 0; |
|||
return scanCount; |
|||
} |
|||
export function getScanCount(subList) { |
|||
let items = subList.filter(r => { |
|||
if (r.scaned) { |
|||
return r; |
|||
} |
|||
}) |
|||
let scanCount = items != null ? items.length : 0; |
|||
return scanCount; |
|||
} |
@ -0,0 +1,146 @@ |
|||
<template> |
|||
<view class="" v-for="(item,index) in dataContent" :key="item.id"> |
|||
<uni-collapse ref="collapse" @change=""> |
|||
<uni-collapse-item :open="true"> |
|||
<template v-slot:title> |
|||
<recommend :detail="item" :isShowLocation="false" :isShowFromLocation="false"></recommend> |
|||
</template> |
|||
<view v-for="(pack,index) in item.packList" :key="pack.id" style="margin-left: 20px;"> |
|||
<recommend :detail="pack" :isShowLocation="false" :isShowFromLocation="false" |
|||
:isShowToLocation="false" :isShowBatch="false"></recommend> |
|||
</view> |
|||
</uni-collapse-item> |
|||
</uni-collapse> |
|||
</view> |
|||
</template> |
|||
|
|||
|
|||
<script> |
|||
import container from '@/mycomponents/container/container.vue' |
|||
import pack from '@/mycomponents/balance/pack.vue' |
|||
import location from '@/mycomponents/balance/location.vue' |
|||
import toLocation from '@/mycomponents/balance/toLocation.vue' |
|||
import batch from '@/mycomponents/balance/batch.vue' |
|||
import recommendQty from '@/mycomponents/qty/recommendQty.vue' |
|||
import compareQty from '@/mycomponents/qty/compareQty.vue' |
|||
import config from '@/static/config.js' |
|||
import recommend from '@/mycomponents/recommend/recommend.vue' |
|||
|
|||
export default { |
|||
components: { |
|||
container, |
|||
pack, |
|||
location, |
|||
toLocation, |
|||
batch, |
|||
recommendQty, |
|||
compareQty, |
|||
recommend |
|||
}, |
|||
|
|||
data() { |
|||
return { |
|||
|
|||
} |
|||
}, |
|||
props: { |
|||
dataContent: { |
|||
type: Object, |
|||
default: {} |
|||
}, |
|||
isShowContainer: { |
|||
type: Boolean, |
|||
default: true |
|||
}, |
|||
isShowPack: { |
|||
type: Boolean, |
|||
default: true |
|||
}, |
|||
isShowBatch: { |
|||
type: Boolean, |
|||
default: true |
|||
}, |
|||
isShowFromLocation: { |
|||
type: Boolean, |
|||
default: true |
|||
}, |
|||
isShowToLocation: { |
|||
type: Boolean, |
|||
default: false |
|||
}, |
|||
isShowStatus: { |
|||
type: Boolean, |
|||
default: true |
|||
}, |
|||
|
|||
locationTitle: { |
|||
type: String, |
|||
default: '库位' |
|||
}, |
|||
|
|||
}, |
|||
watch: { |
|||
|
|||
}, |
|||
methods: { |
|||
copy() { |
|||
// HPQ;V1.0;ICE115F11161AG;PP20230427000026;B20230427002;Q100 |
|||
var content = "HPQ;V1.0;I" + this.detail.itemCode + ";P" + this.detail.packingNumber + ";B" + this.detail |
|||
.batch + ";Q" + this.detail.qty |
|||
// #ifdef H5 |
|||
this.$copyText(content).then( |
|||
res => { |
|||
uni.showToast({ |
|||
title: '复制采购标签成功', |
|||
icon: 'none' |
|||
}) |
|||
} |
|||
) |
|||
// #endif |
|||
// #ifndef H5 |
|||
uni.setClipboardData({ |
|||
data: content, |
|||
success: () => { |
|||
uni.showToast({ |
|||
title: '复制采购标签成功' |
|||
}) |
|||
} |
|||
}) |
|||
// #endif |
|||
}, |
|||
copyPro() { |
|||
// HPQ;V1.0;ICE115F11161AG;PP20230427000026;B20230427002;Q100 |
|||
var content = "HMQ;V1.0;I" + this.detail.itemCode + ";P" + this.detail.packingNumber + ";B" + this.detail |
|||
.batch + ";Q" + this.detail.qty |
|||
// #ifdef H5 |
|||
this.$copyText(content).then( |
|||
res => { |
|||
uni.showToast({ |
|||
title: '复制制品标签成功', |
|||
icon: 'none' |
|||
}) |
|||
} |
|||
) |
|||
// #endif |
|||
// #ifndef H5 |
|||
uni.setClipboardData({ |
|||
data: content, |
|||
success: () => { |
|||
uni.showToast({ |
|||
title: '复制制品标签成功' |
|||
}) |
|||
} |
|||
}) |
|||
// #endif |
|||
}, |
|||
isDevlement() { |
|||
return config.isDevelopment; |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
|
|||
|
|||
<style> |
|||
</style> |
Loading…
Reference in new issue