Browse Source

mycomponents/scan 文件迁移Vue2升级Vue3 8/2-10/25

hella_vue3
王志国 3 weeks ago
parent
commit
be04eb258d
  1. 288
      src/mycomponents/scan/winScanParentPackage.vue

288
src/mycomponents/scan/winScanParentPackage.vue

@ -1,6 +1,6 @@
<template> <template>
<view> <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="popup_box">
<view class="pop_title uni-flex space-between"> <view class="pop_title uni-flex space-between">
<view class="" style="font-size: 35rpx;"> <view class="" style="font-size: 35rpx;">
@ -19,7 +19,7 @@
</view> </view>
</view> </view>
</view> </view>
</uni-popup> </u-popup>
<!-- 模拟扫描功能 --> <!-- 模拟扫描功能 -->
<win-com-scan v-show="false" ref="comscansimulate" @getResult="getScanResult" :headerType="headerType" <win-com-scan v-show="false" ref="comscansimulate" @getResult="getScanResult" :headerType="headerType"
:isShowHistory="false" :clearResult="true"></win-com-scan> :isShowHistory="false" :clearResult="true"></win-com-scan>
@ -27,18 +27,15 @@
</view> </view>
</template> </template>
<script> <script setup>
import winComScan from '@/mycomponents/scan/winComScan.vue' import winComScan from '@/mycomponents/scan/winComScan.vue'
import { import {
getBalanceByFilter getBalanceByFilter
} from '@/api/request2.js'; } from '@/api/request2.js';
export default { import { ref, onMounted } from 'vue';
name: 'winScanParentPackage',
components: { const props = defineProps({
winComScan,
},
props: {
title: { title: {
type: String, type: String,
default: '箱标签' default: '箱标签'
@ -51,218 +48,171 @@
type: String, type: String,
default: 'HPQ,HMQ' default: 'HPQ,HMQ'
} }
}, });
data() {
return {
show: false,
businessType: null
}
},
created() {
}, const show = ref(false);
methods: { const businessType = ref(null);
simulateScan(item) {
this.$refs.comscansimulate.setItemCodeSimulate(item.copyContent)
this.$refs.comscansimulate.clickScanMsg();
},
openScanPopup() {
this.$refs.popup.open('bottom')
setTimeout(res => {
this.getfocus()
}, 500)
},
const comscansimulate = ref(null);
const comscan = ref(null);
const comMessage = ref(null);
openScanPopupByBusinessType(businessType) { const simulateScan = (item) => {
this.$refs.popup.open('bottom') comscansimulate.value.setItemCodeSimulate(item.copyContent);
setTimeout(res => { comscansimulate.value.clickScanMsg();
this.getfocus() };
this.businessType = businessType;
}, 500)
},
const openScanPopup = () => {
show.value = true
setTimeout(() => {
getfocus();
}, 500);
};
closeScanPopup() { const openScanPopupByBusinessType = (businessType) => {
this.losefocus() show.value = true
this.$refs.popup.close(); setTimeout(() => {
this.$emit("close", ''); getfocus();
}, businessType.value = businessType;
}, 500);
};
scanClick() { const closeScanPopup = () => {
if (this.$refs.comscan) { losefocus();
this.$refs.comscan.clickScanMsg(); show.value = false
} emit("close", '');
};
}, const scanClick = () => {
if (comscan.value) {
comscan.value.clickScanMsg();
}
};
cancelClick() { const cancelClick = () => {
if (this.$refs.comscan) { if (comscan.value) {
this.$refs.comscan.clearScanValue(); comscan.value.clearScanValue();
} }
}, };
getScanResult(result) { const getScanResult = (result) => {
if (result.success) { if (result.success) {
this.getBalance(result, res => { getBalance(result, (res) => {
result.balance = res; result.balance = res;
this.$emit("getResult", result); emit("getResult", result);
}) });
} else { } else {
this.showMessage(result.message) showMessage(result.message);
} }
}, };
const getParams = (label) => {
let filters = [
{ column: "itemCode", action: "==", value: label.itemCode },
{ column: "batch", action: "==", value: label.batch }
];
getParams(label) { if (businessType.value?.outInventoryStatuses) {
let filters = [{ filters.push({ column: "inventoryStatus", action: "in", value: businessType.value.outInventoryStatuses });
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({ if (businessType.value?.outAreaTypes) {
column: "areaType", filters.push({ column: "areaType", action: "in", value: businessType.value.outAreaTypes });
action: "in",
value: this.businessType.outAreaTypes
})
} }
if (this.businessType.outAreaCodes != null) {
filters.push({ if (businessType.value?.outAreaCodes) {
column: "areaCode", filters.push({ column: "areaCode", action: "in", value: businessType.value.outAreaCodes });
action: "in",
value: this.businessType.outAreaCodes
})
} }
return filters; return filters;
}, };
getBalance(result, callback) { const getBalance = (result, callback) => {
let filters = []; let filters = [];
let packageInfo = result.package; let packageInfo = result.package;
let comfilters = this.getParams(packageInfo); let comfilters = getParams(packageInfo);
let balance = { let balance = { parentBalance: {}, childBalance: [] };
parentBalance: {},
childBalance: []
};
let parentPackingNumber = packageInfo.parentNumber; let parentPackingNumber = packageInfo.parentNumber;
let childPackingNumber = packageInfo.number; let childPackingNumber = packageInfo.number;
//packageInfo.subList0
//1.
if (parentPackingNumber) { if (parentPackingNumber) {
let packingNumber = parentPackingNumber + "," + childPackingNumber; let packingNumber = parentPackingNumber + "," + childPackingNumber;
filters.push({ filters.push({ column: "packingNumber", action: "in", value: packingNumber });
column: "packingNumber",
action: "in",
value: packingNumber
})
} else { } else {
filters.push({ filters.push({ column: "packingNumber", action: "==", value: childPackingNumber });
column: "packingNumber",
action: "==",
value: childPackingNumber
})
} }
filters = filters.concat(comfilters); filters = filters.concat(comfilters);
var params = { const params = { filters, pageNo: 1, pageSize: 100 };
filters: filters,
pageNo: 1, getBalanceByFilter(params).then((res) => {
pageSize: 100, res.data.list.forEach((r) => {
}
getBalanceByFilter(params).then(res => {
res.data.list.forEach(r => {
if (packageInfo.parentNumber) { if (packageInfo.parentNumber) {
r.parentPackingNumber = parentPackingNumber r.parentPackingNumber = parentPackingNumber;
} else { } else {
r.parentPackingNumber = childPackingNumber r.parentPackingNumber = childPackingNumber;
} }
}) });
//
if (packageInfo.subList.length > 0) { if (packageInfo.subList.length > 0) {
let packparams = ''; let packparams = packageInfo.subList.map((pack) => pack.number).join(',');
packageInfo.subList.forEach(pack => { filters = [{ column: "packingNumber", action: "in", value: packparams }];
packparams = packparams + pack.number + ','
})
packparams = packparams.trimEnd(',');
filters = [];
filters.push({
column: "packingNumber",
action: "in",
value: packparams
})
filters = filters.concat(comfilters); filters = filters.concat(comfilters);
params.filters = filters; 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 == getBalanceByFilter(params).then((res1) => {
childPackingNumber) 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; balance.childBalance = res1.data.list;
callback(balance); callback(balance);
} }
}).catch(err => { }).catch((err) => {
this.showErrorMessage(err.message); showErrorMessage(err.message);
}) });
} else { } else {
// balance.childBalance = res.data.list.filter((r) => r.packingNumber === childPackingNumber);
//() balance.parentBalance = res.data.list.filter((r) => r.packingNumber === parentPackingNumber);
balance.childBalance = res.data.list.filter(r => r.packingNumber == childPackingNumber)
balance.parentBalance = res.data.list.filter(r => r.packingNumber == parentPackingNumber)
callback(balance); callback(balance);
} }
}).catch((err) => {
showErrorMessage(err.message);
});
};
}).catch(err => { const getfocus = () => {
this.showErrorMessage(err.message); if (comscan.value) {
}) comscan.value.getfocus();
},
getfocus() {
if (this.$refs.comscan) {
this.$refs.comscan.getfocus();
} }
}, };
losefocus() { const losefocus = () => {
if (this.$refs.comscan) { if (comscan.value) {
this.$refs.comscan.losefocus(); comscan.value.losefocus();
} }
}, };
showMessage(message) {
this.$refs.comMessage.showMessage(message); const showMessage = (message) => {
}, comMessage.value.showMessage(message);
change(e) { };
this.show = e.show
}, const change = (e) => {
showErrorMessage(message) { show.value = e.show;
this.losefocus() };
this.$refs.comMessage.showErrorMessage(message, res => {
const showErrorMessage = (message) => {
losefocus();
comMessage.value.showErrorMessage(message, (res) => {
if (res) { if (res) {
this.getfocus(); getfocus();
} }
}); });
}, };
}
} const emit = defineEmits(['close', 'getResult']);
</script> </script>
<style lang="scss"> <style lang="scss">

Loading…
Cancel
Save