|
|
@ -1,6 +1,6 @@ |
|
|
|
<template> |
|
|
|
<view> |
|
|
|
<uni-popup ref="popup" @change="change" :mask-click="false"> |
|
|
|
<u-popup v-model="show" @change="change" :mask-close-able="false"> |
|
|
|
<view class="popup_box"> |
|
|
|
<view class="pop_title uni-flex space-between"> |
|
|
|
<view class="" style="font-size: 35rpx;"> |
|
|
@ -19,7 +19,7 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
</u-popup> |
|
|
|
<!-- 模拟扫描功能 --> |
|
|
|
<win-com-scan v-show="false" ref="comscansimulate" @getResult="getScanResult" :headerType="headerType" |
|
|
|
:isShowHistory="false" :clearResult="true"></win-com-scan> |
|
|
@ -27,242 +27,192 @@ |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
<script setup> |
|
|
|
import winComScan from '@/mycomponents/scan/winComScan.vue' |
|
|
|
import { |
|
|
|
getBalanceByFilter |
|
|
|
} from '@/api/request2.js'; |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'winScanParentPackage', |
|
|
|
components: { |
|
|
|
winComScan, |
|
|
|
}, |
|
|
|
props: { |
|
|
|
title: { |
|
|
|
type: String, |
|
|
|
default: '箱标签' |
|
|
|
}, |
|
|
|
isShowHistory: { |
|
|
|
type: Boolean, |
|
|
|
default: true |
|
|
|
}, |
|
|
|
headerType: { |
|
|
|
type: String, |
|
|
|
default: 'HPQ,HMQ' |
|
|
|
} |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
show: false, |
|
|
|
businessType: null |
|
|
|
} |
|
|
|
}, |
|
|
|
created() { |
|
|
|
|
|
|
|
}, |
|
|
|
methods: { |
|
|
|
simulateScan(item) { |
|
|
|
this.$refs.comscansimulate.setItemCodeSimulate(item.copyContent) |
|
|
|
this.$refs.comscansimulate.clickScanMsg(); |
|
|
|
}, |
|
|
|
openScanPopup() { |
|
|
|
this.$refs.popup.open('bottom') |
|
|
|
setTimeout(res => { |
|
|
|
this.getfocus() |
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
openScanPopupByBusinessType(businessType) { |
|
|
|
this.$refs.popup.open('bottom') |
|
|
|
setTimeout(res => { |
|
|
|
this.getfocus() |
|
|
|
this.businessType = businessType; |
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
closeScanPopup() { |
|
|
|
this.losefocus() |
|
|
|
this.$refs.popup.close(); |
|
|
|
this.$emit("close", ''); |
|
|
|
}, |
|
|
|
|
|
|
|
scanClick() { |
|
|
|
if (this.$refs.comscan) { |
|
|
|
this.$refs.comscan.clickScanMsg(); |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
cancelClick() { |
|
|
|
if (this.$refs.comscan) { |
|
|
|
this.$refs.comscan.clearScanValue(); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
getScanResult(result) { |
|
|
|
if (result.success) { |
|
|
|
this.getBalance(result, res => { |
|
|
|
result.balance = res; |
|
|
|
this.$emit("getResult", result); |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.showMessage(result.message) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
getParams(label) { |
|
|
|
let filters = [{ |
|
|
|
column: "itemCode", |
|
|
|
action: "==", |
|
|
|
value: label.itemCode |
|
|
|
}, { |
|
|
|
column: "batch", |
|
|
|
action: "==", |
|
|
|
value: label.batch |
|
|
|
}]; |
|
|
|
if (this.businessType.outInventoryStatuses != null) { |
|
|
|
filters.push({ |
|
|
|
column: "inventoryStatus", |
|
|
|
action: "in", |
|
|
|
value: this.businessType.outInventoryStatuses |
|
|
|
}) |
|
|
|
} |
|
|
|
if (this.businessType.outAreaTypes != null) { |
|
|
|
filters.push({ |
|
|
|
column: "areaType", |
|
|
|
action: "in", |
|
|
|
value: this.businessType.outAreaTypes |
|
|
|
}) |
|
|
|
} |
|
|
|
if (this.businessType.outAreaCodes != null) { |
|
|
|
filters.push({ |
|
|
|
column: "areaCode", |
|
|
|
action: "in", |
|
|
|
value: this.businessType.outAreaCodes |
|
|
|
}) |
|
|
|
} |
|
|
|
return filters; |
|
|
|
}, |
|
|
|
|
|
|
|
getBalance(result, callback) { |
|
|
|
let filters = []; |
|
|
|
let packageInfo = result.package; |
|
|
|
let comfilters = this.getParams(packageInfo); |
|
|
|
let balance = { |
|
|
|
parentBalance: {}, |
|
|
|
childBalance: [] |
|
|
|
}; |
|
|
|
|
|
|
|
let parentPackingNumber = packageInfo.parentNumber; |
|
|
|
let childPackingNumber = packageInfo.number; |
|
|
|
|
|
|
|
//packageInfo.subList子包装数量大于0扫描的就是父包装 |
|
|
|
//1.当扫描箱时,同时查询箱和托的库存 |
|
|
|
if (parentPackingNumber) { |
|
|
|
let packingNumber = parentPackingNumber + "," + childPackingNumber; |
|
|
|
filters.push({ |
|
|
|
column: "packingNumber", |
|
|
|
action: "in", |
|
|
|
value: packingNumber |
|
|
|
}) |
|
|
|
} else { |
|
|
|
filters.push({ |
|
|
|
column: "packingNumber", |
|
|
|
action: "==", |
|
|
|
value: childPackingNumber |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
filters = filters.concat(comfilters); |
|
|
|
var params = { |
|
|
|
filters: filters, |
|
|
|
pageNo: 1, |
|
|
|
pageSize: 100, |
|
|
|
} |
|
|
|
getBalanceByFilter(params).then(res => { |
|
|
|
res.data.list.forEach(r => { |
|
|
|
if (packageInfo.parentNumber) { |
|
|
|
r.parentPackingNumber = parentPackingNumber |
|
|
|
} else { |
|
|
|
r.parentPackingNumber = childPackingNumber |
|
|
|
} |
|
|
|
}) |
|
|
|
//如果扫描的是托标签,按托标签没查找到库存再按托标签下的子标签查询库存 |
|
|
|
if (packageInfo.subList.length > 0) { |
|
|
|
let packparams = ''; |
|
|
|
packageInfo.subList.forEach(pack => { |
|
|
|
packparams = packparams + pack.number + ',' |
|
|
|
}) |
|
|
|
packparams = packparams.trimEnd(','); |
|
|
|
filters = []; |
|
|
|
filters.push({ |
|
|
|
column: "packingNumber", |
|
|
|
action: "in", |
|
|
|
value: packparams |
|
|
|
}) |
|
|
|
filters = filters.concat(comfilters); |
|
|
|
params.filters = filters; |
|
|
|
getBalanceByFilter(params).then(res1 => { |
|
|
|
if (res1.data.list.length == 0) { |
|
|
|
this.showErrorMessage('未查找到该包装的库存余额', res => { |
|
|
|
this.packGetFocus(); |
|
|
|
}) |
|
|
|
} else { |
|
|
|
res1.data.list.forEach(r => r.parentPackingNumber = childPackingNumber) |
|
|
|
|
|
|
|
balance.parentBalance = res.data.list.filter(r => r.packingNumber == |
|
|
|
childPackingNumber) |
|
|
|
balance.childBalance = res1.data.list; |
|
|
|
|
|
|
|
callback(balance); |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
this.showErrorMessage(err.message); |
|
|
|
}) |
|
|
|
} else { |
|
|
|
//扫描的是子包装 |
|
|
|
//扫描的是父包装,(新加的) |
|
|
|
balance.childBalance = res.data.list.filter(r => r.packingNumber == childPackingNumber) |
|
|
|
balance.parentBalance = res.data.list.filter(r => r.packingNumber == parentPackingNumber) |
|
|
|
callback(balance); |
|
|
|
} |
|
|
|
|
|
|
|
}).catch(err => { |
|
|
|
this.showErrorMessage(err.message); |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
getfocus() { |
|
|
|
if (this.$refs.comscan) { |
|
|
|
this.$refs.comscan.getfocus(); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
losefocus() { |
|
|
|
if (this.$refs.comscan) { |
|
|
|
this.$refs.comscan.losefocus(); |
|
|
|
} |
|
|
|
}, |
|
|
|
showMessage(message) { |
|
|
|
this.$refs.comMessage.showMessage(message); |
|
|
|
}, |
|
|
|
change(e) { |
|
|
|
this.show = e.show |
|
|
|
}, |
|
|
|
showErrorMessage(message) { |
|
|
|
this.losefocus() |
|
|
|
this.$refs.comMessage.showErrorMessage(message, res => { |
|
|
|
if (res) { |
|
|
|
this.getfocus(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
import { ref, onMounted } from 'vue'; |
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
title: { |
|
|
|
type: String, |
|
|
|
default: '箱标签' |
|
|
|
}, |
|
|
|
isShowHistory: { |
|
|
|
type: Boolean, |
|
|
|
default: true |
|
|
|
}, |
|
|
|
headerType: { |
|
|
|
type: String, |
|
|
|
default: 'HPQ,HMQ' |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
const show = ref(false); |
|
|
|
const businessType = ref(null); |
|
|
|
|
|
|
|
const comscansimulate = ref(null); |
|
|
|
const comscan = ref(null); |
|
|
|
const comMessage = ref(null); |
|
|
|
|
|
|
|
const simulateScan = (item) => { |
|
|
|
comscansimulate.value.setItemCodeSimulate(item.copyContent); |
|
|
|
comscansimulate.value.clickScanMsg(); |
|
|
|
}; |
|
|
|
|
|
|
|
const openScanPopup = () => { |
|
|
|
show.value = true |
|
|
|
setTimeout(() => { |
|
|
|
getfocus(); |
|
|
|
}, 500); |
|
|
|
}; |
|
|
|
|
|
|
|
const openScanPopupByBusinessType = (businessType) => { |
|
|
|
show.value = true |
|
|
|
setTimeout(() => { |
|
|
|
getfocus(); |
|
|
|
businessType.value = businessType; |
|
|
|
}, 500); |
|
|
|
}; |
|
|
|
|
|
|
|
const closeScanPopup = () => { |
|
|
|
losefocus(); |
|
|
|
show.value = false |
|
|
|
emit("close", ''); |
|
|
|
}; |
|
|
|
|
|
|
|
const scanClick = () => { |
|
|
|
if (comscan.value) { |
|
|
|
comscan.value.clickScanMsg(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const cancelClick = () => { |
|
|
|
if (comscan.value) { |
|
|
|
comscan.value.clearScanValue(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const getScanResult = (result) => { |
|
|
|
if (result.success) { |
|
|
|
getBalance(result, (res) => { |
|
|
|
result.balance = res; |
|
|
|
emit("getResult", result); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
showMessage(result.message); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const getParams = (label) => { |
|
|
|
let filters = [ |
|
|
|
{ column: "itemCode", action: "==", value: label.itemCode }, |
|
|
|
{ column: "batch", action: "==", value: label.batch } |
|
|
|
]; |
|
|
|
|
|
|
|
if (businessType.value?.outInventoryStatuses) { |
|
|
|
filters.push({ column: "inventoryStatus", action: "in", value: businessType.value.outInventoryStatuses }); |
|
|
|
} |
|
|
|
|
|
|
|
if (businessType.value?.outAreaTypes) { |
|
|
|
filters.push({ column: "areaType", action: "in", value: businessType.value.outAreaTypes }); |
|
|
|
} |
|
|
|
|
|
|
|
if (businessType.value?.outAreaCodes) { |
|
|
|
filters.push({ column: "areaCode", action: "in", value: businessType.value.outAreaCodes }); |
|
|
|
} |
|
|
|
|
|
|
|
return filters; |
|
|
|
}; |
|
|
|
|
|
|
|
const getBalance = (result, callback) => { |
|
|
|
let filters = []; |
|
|
|
let packageInfo = result.package; |
|
|
|
let comfilters = getParams(packageInfo); |
|
|
|
let balance = { parentBalance: {}, childBalance: [] }; |
|
|
|
|
|
|
|
let parentPackingNumber = packageInfo.parentNumber; |
|
|
|
let childPackingNumber = packageInfo.number; |
|
|
|
|
|
|
|
if (parentPackingNumber) { |
|
|
|
let packingNumber = parentPackingNumber + "," + childPackingNumber; |
|
|
|
filters.push({ column: "packingNumber", action: "in", value: packingNumber }); |
|
|
|
} else { |
|
|
|
filters.push({ column: "packingNumber", action: "==", value: childPackingNumber }); |
|
|
|
} |
|
|
|
|
|
|
|
filters = filters.concat(comfilters); |
|
|
|
const params = { filters, pageNo: 1, pageSize: 100 }; |
|
|
|
|
|
|
|
getBalanceByFilter(params).then((res) => { |
|
|
|
res.data.list.forEach((r) => { |
|
|
|
if (packageInfo.parentNumber) { |
|
|
|
r.parentPackingNumber = parentPackingNumber; |
|
|
|
} else { |
|
|
|
r.parentPackingNumber = childPackingNumber; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if (packageInfo.subList.length > 0) { |
|
|
|
let packparams = packageInfo.subList.map((pack) => pack.number).join(','); |
|
|
|
filters = [{ column: "packingNumber", action: "in", value: packparams }]; |
|
|
|
filters = filters.concat(comfilters); |
|
|
|
params.filters = filters; |
|
|
|
|
|
|
|
getBalanceByFilter(params).then((res1) => { |
|
|
|
if (res1.data.list.length === 0) { |
|
|
|
showErrorMessage('未查找到该包装的库存余额', () => packGetFocus()); |
|
|
|
} else { |
|
|
|
res1.data.list.forEach((r) => r.parentPackingNumber = childPackingNumber); |
|
|
|
balance.parentBalance = res.data.list.filter((r) => r.packingNumber === childPackingNumber); |
|
|
|
balance.childBalance = res1.data.list; |
|
|
|
callback(balance); |
|
|
|
} |
|
|
|
}).catch((err) => { |
|
|
|
showErrorMessage(err.message); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
balance.childBalance = res.data.list.filter((r) => r.packingNumber === childPackingNumber); |
|
|
|
balance.parentBalance = res.data.list.filter((r) => r.packingNumber === parentPackingNumber); |
|
|
|
callback(balance); |
|
|
|
} |
|
|
|
}).catch((err) => { |
|
|
|
showErrorMessage(err.message); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const getfocus = () => { |
|
|
|
if (comscan.value) { |
|
|
|
comscan.value.getfocus(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const losefocus = () => { |
|
|
|
if (comscan.value) { |
|
|
|
comscan.value.losefocus(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const showMessage = (message) => { |
|
|
|
comMessage.value.showMessage(message); |
|
|
|
}; |
|
|
|
|
|
|
|
const change = (e) => { |
|
|
|
show.value = e.show; |
|
|
|
}; |
|
|
|
|
|
|
|
const showErrorMessage = (message) => { |
|
|
|
losefocus(); |
|
|
|
comMessage.value.showErrorMessage(message, (res) => { |
|
|
|
if (res) { |
|
|
|
getfocus(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const emit = defineEmits(['close', 'getResult']); |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
|