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

Loading…
Cancel
Save