Browse Source

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

pull/1/head
test 5 months ago
parent
commit
be04eb258d
  1. 416
      src/mycomponents/scan/winScanParentPackage.vue

416
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,242 +27,192 @@
</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, title: {
}, type: String,
props: { default: '箱标签'
title: { },
type: String, isShowHistory: {
default: '箱标签' type: Boolean,
}, default: true
isShowHistory: { },
type: Boolean, headerType: {
default: true type: String,
}, default: 'HPQ,HMQ'
headerType: { }
type: String, });
default: 'HPQ,HMQ'
} const show = ref(false);
}, const businessType = ref(null);
data() {
return { const comscansimulate = ref(null);
show: false, const comscan = ref(null);
businessType: null const comMessage = ref(null);
}
}, const simulateScan = (item) => {
created() { comscansimulate.value.setItemCodeSimulate(item.copyContent);
comscansimulate.value.clickScanMsg();
}, };
methods: {
simulateScan(item) { const openScanPopup = () => {
this.$refs.comscansimulate.setItemCodeSimulate(item.copyContent) show.value = true
this.$refs.comscansimulate.clickScanMsg(); setTimeout(() => {
}, getfocus();
openScanPopup() { }, 500);
this.$refs.popup.open('bottom') };
setTimeout(res => {
this.getfocus() const openScanPopupByBusinessType = (businessType) => {
}, 500) show.value = true
}, setTimeout(() => {
getfocus();
businessType.value = businessType;
openScanPopupByBusinessType(businessType) { }, 500);
this.$refs.popup.open('bottom') };
setTimeout(res => {
this.getfocus() const closeScanPopup = () => {
this.businessType = businessType; losefocus();
}, 500) show.value = false
}, emit("close", '');
};
closeScanPopup() { const scanClick = () => {
this.losefocus() if (comscan.value) {
this.$refs.popup.close(); comscan.value.clickScanMsg();
this.$emit("close", ''); }
}, };
scanClick() { const cancelClick = () => {
if (this.$refs.comscan) { if (comscan.value) {
this.$refs.comscan.clickScanMsg(); comscan.value.clearScanValue();
} }
};
},
const getScanResult = (result) => {
cancelClick() { if (result.success) {
if (this.$refs.comscan) { getBalance(result, (res) => {
this.$refs.comscan.clearScanValue(); result.balance = res;
} emit("getResult", result);
}, });
} else {
getScanResult(result) { showMessage(result.message);
if (result.success) { }
this.getBalance(result, res => { };
result.balance = res;
this.$emit("getResult", result); const getParams = (label) => {
}) let filters = [
} else { { column: "itemCode", action: "==", value: label.itemCode },
this.showMessage(result.message) { column: "batch", action: "==", value: label.batch }
} ];
},
if (businessType.value?.outInventoryStatuses) {
getParams(label) { filters.push({ column: "inventoryStatus", action: "in", value: businessType.value.outInventoryStatuses });
let filters = [{ }
column: "itemCode",
action: "==", if (businessType.value?.outAreaTypes) {
value: label.itemCode filters.push({ column: "areaType", action: "in", value: businessType.value.outAreaTypes });
}, { }
column: "batch",
action: "==", if (businessType.value?.outAreaCodes) {
value: label.batch filters.push({ column: "areaCode", action: "in", value: businessType.value.outAreaCodes });
}]; }
if (this.businessType.outInventoryStatuses != null) {
filters.push({ return filters;
column: "inventoryStatus", };
action: "in",
value: this.businessType.outInventoryStatuses const getBalance = (result, callback) => {
}) let filters = [];
} let packageInfo = result.package;
if (this.businessType.outAreaTypes != null) { let comfilters = getParams(packageInfo);
filters.push({ let balance = { parentBalance: {}, childBalance: [] };
column: "areaType",
action: "in", let parentPackingNumber = packageInfo.parentNumber;
value: this.businessType.outAreaTypes let childPackingNumber = packageInfo.number;
})
} if (parentPackingNumber) {
if (this.businessType.outAreaCodes != null) { let packingNumber = parentPackingNumber + "," + childPackingNumber;
filters.push({ filters.push({ column: "packingNumber", action: "in", value: packingNumber });
column: "areaCode", } else {
action: "in", filters.push({ column: "packingNumber", action: "==", value: childPackingNumber });
value: this.businessType.outAreaCodes }
})
} filters = filters.concat(comfilters);
return filters; const params = { filters, pageNo: 1, pageSize: 100 };
},
getBalanceByFilter(params).then((res) => {
getBalance(result, callback) { res.data.list.forEach((r) => {
let filters = []; if (packageInfo.parentNumber) {
let packageInfo = result.package; r.parentPackingNumber = parentPackingNumber;
let comfilters = this.getParams(packageInfo); } else {
let balance = { r.parentPackingNumber = childPackingNumber;
parentBalance: {}, }
childBalance: [] });
};
if (packageInfo.subList.length > 0) {
let parentPackingNumber = packageInfo.parentNumber; let packparams = packageInfo.subList.map((pack) => pack.number).join(',');
let childPackingNumber = packageInfo.number; filters = [{ column: "packingNumber", action: "in", value: packparams }];
filters = filters.concat(comfilters);
//packageInfo.subList0 params.filters = filters;
//1.
if (parentPackingNumber) { getBalanceByFilter(params).then((res1) => {
let packingNumber = parentPackingNumber + "," + childPackingNumber; if (res1.data.list.length === 0) {
filters.push({ showErrorMessage('未查找到该包装的库存余额', () => packGetFocus());
column: "packingNumber", } else {
action: "in", res1.data.list.forEach((r) => r.parentPackingNumber = childPackingNumber);
value: packingNumber balance.parentBalance = res.data.list.filter((r) => r.packingNumber === childPackingNumber);
}) balance.childBalance = res1.data.list;
} else { callback(balance);
filters.push({ }
column: "packingNumber", }).catch((err) => {
action: "==", showErrorMessage(err.message);
value: childPackingNumber });
}) } else {
} balance.childBalance = res.data.list.filter((r) => r.packingNumber === childPackingNumber);
balance.parentBalance = res.data.list.filter((r) => r.packingNumber === parentPackingNumber);
filters = filters.concat(comfilters); callback(balance);
var params = { }
filters: filters, }).catch((err) => {
pageNo: 1, showErrorMessage(err.message);
pageSize: 100, });
} };
getBalanceByFilter(params).then(res => {
res.data.list.forEach(r => { const getfocus = () => {
if (packageInfo.parentNumber) { if (comscan.value) {
r.parentPackingNumber = parentPackingNumber comscan.value.getfocus();
} else { }
r.parentPackingNumber = childPackingNumber };
}
}) const losefocus = () => {
// if (comscan.value) {
if (packageInfo.subList.length > 0) { comscan.value.losefocus();
let packparams = ''; }
packageInfo.subList.forEach(pack => { };
packparams = packparams + pack.number + ','
}) const showMessage = (message) => {
packparams = packparams.trimEnd(','); comMessage.value.showMessage(message);
filters = []; };
filters.push({
column: "packingNumber", const change = (e) => {
action: "in", show.value = e.show;
value: packparams };
})
filters = filters.concat(comfilters); const showErrorMessage = (message) => {
params.filters = filters; losefocus();
getBalanceByFilter(params).then(res1 => { comMessage.value.showErrorMessage(message, (res) => {
if (res1.data.list.length == 0) { if (res) {
this.showErrorMessage('未查找到该包装的库存余额', res => { getfocus();
this.packGetFocus(); }
}) });
} else { };
res1.data.list.forEach(r => r.parentPackingNumber = childPackingNumber)
const emit = defineEmits(['close', 'getResult']);
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();
}
});
},
}
}
</script> </script>
<style lang="scss"> <style lang="scss">

Loading…
Cancel
Save