Browse Source

mycomponents/page/container/record 文件迁移Vue2升级Vue3 8/2-10/25

hella_vue3
王志国 3 weeks ago
parent
commit
eba5273896
  1. 413
      src/pages/container/record/containerUnBindRecord.vue

413
src/pages/container/record/containerUnBindRecord.vue

@ -56,111 +56,97 @@ import winScanContainer from '@/mycomponents/scan/winScanContainer.vue'
import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue' import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue'
import comPalletRecord from '@/pages/container/coms/comPalletRecord.vue' import comPalletRecord from '@/pages/container/coms/comPalletRecord.vue'
export default { import { ref, onMounted, nextTick } from 'vue';
components: { import { useStore } from 'vuex';
winScanButton, import { onLoad,onNavigationBarButtonTap } from '@dcloudio/uni-app'
winScanPack,
comBlankView, const id = ref('');
targetContainer, const scanCount = ref(0);
recordComDetailCard, const detailSource = ref([]);
winScanContainer, const businessTypeInfo = ref({});
comPalletRecord const fromLocationInfo = ref({});
}, const containerCode = ref('');
data() {
return { const scanPopup = ref(null);
id: '', const scanContainer = ref(null);
scanCount: 0, const comMessage = ref(null);
detailSource: [], //
businessTypeInfo: {}, const emit = defineEmits(['close', 'getResult']);
fromLocationInfo: {},
containerCode: '' onLoad((option) => {
}
},
onLoad(option) {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: option.title title: option.title
}) });
}, })
//
onNavigationBarButtonTap(e) { onNavigationBarButtonTap((e) => {
if (e.index === 0) { if (e.index === 0) {
goHome() goHome();
} }
}, })
//
onBackPress(e) {},
onPullDownRefresh() {}, onMounted(() => {
showContainerPopup();
});
mounted() { const getScanResult = (result) => {
this.showContainerPopup()
},
methods: {
getScanResult(result) {
try { try {
const { packingNumber } = result.label const { packingNumber, batch, qty, itemCode } = result.label;
const { batch } = result.label const detail = detailSource.value.find((r) => r.itemCode === itemCode);
const { qty } = result.label
const { itemCode } = result.label
const detail = this.detailSource.find((r) => r.itemCode == itemCode)
if (detail == undefined) { if (detail == undefined) {
this.showMessage(`物料号【${itemCode}】不在列表中`) showMessage(`物料号【${itemCode}】不在列表中`);
} else { } else {
const itemDetail = detail.subList.find((r) => r.packingNumber == packingNumber && r.batch == batch) const itemDetail = detail.subList.find((r) => r.packingNumber === packingNumber && r.batch === batch);
if (itemDetail == undefined) { if (itemDetail == undefined) {
this.showMessage(`箱码【${packingNumber}】,批次【${batch}】不在列表中`) showMessage(`箱码【${packingNumber}】,批次【${batch}】不在列表中`);
} else if (itemDetail.scaned) { } else if (itemDetail.scaned) {
this.showMessage(`箱码【${packingNumber}】,批次【${batch}】已经扫描`) showMessage(`箱码【${packingNumber}】,批次【${batch}】已经扫描`);
} else { } else {
itemDetail.scaned = true itemDetail.scaned = true;
itemDetail.record = this.createRecordInfo(itemDetail, result.label) itemDetail.record = createRecordInfo(itemDetail, result.label);
// this.calcHandleQty(); // calcHandleQty();
} }
} }
} catch (e) { } catch (e) {
this.showErrorMessage(e.message) showErrorMessage(e.message);
} }
}, };
createRecordInfo(detail, label) { const createRecordInfo = (detail, label) => {
const record = {} const record = {};
detail.scaned = true Object.assign(record, detail);
// let record = JSON.parse(JSON.stringify(detail)); record.qty = Number(label.qty);
// return record;
Object.assign(record, detail) };
record.qty = Number(label.qty)
return record const calcHandleQty = () => {
}, calcHandleQty(detailSource.value);
scanPopupGetFocus();
calcHandleQty() { };
calcHandleQty(this.detailSource)
this.scanPopupGetFocus() const getDataSource = (subList) => {
this.$forceUpdate() const items = [];
},
getDataSource(subList) {
const items = []
subList.forEach((detail) => { subList.forEach((detail) => {
let item = items.find((r) => r.itemCode == detail.itemCode) let item = items.find((r) => r.itemCode === detail.itemCode);
if (item == undefined) { if (item == undefined) {
item = this.createItemInfo(detail) item = createItemInfo(detail);
const newDetail = this.createDetailInfo(detail) // const newDetail = createDetailInfo(detail);
item.subList.push(newDetail) item.subList.push(newDetail);
items.push(item) items.push(item);
} else { } else {
item.qty = calc.add(item.qty, detail.qty) item.qty = calc.add(item.qty, detail.qty);
const newDetail = this.createDetailInfo(detail) // const newDetail = createDetailInfo(detail);
item.subList.push(newDetail) item.subList.push(newDetail);
} }
}) });
return items return items;
}, };
removeItem(index, item) { const removeItem = (index) => {
this.detailSource.splice(index, 1) detailSource.value.splice(index, 1);
}, };
createItemInfo(res) { const createItemInfo = (res) => {
const item = { const item = {
itemCode: res.itemCode, itemCode: res.itemCode,
itemName: res.itemName, itemName: res.itemName,
@ -170,182 +156,181 @@ export default {
handleQty: 0, handleQty: 0,
uom: res.uom, uom: res.uom,
subList: [] subList: []
} };
return item return item;
}, };
createDetailInfo(data) { const createDetailInfo = (data) => {
data.scaned = false data.scaned = false;
data.packingNumber = data.contentNumber data.packingNumber = data.contentNumber;
data.qty = Number(data.qty) data.qty = Number(data.qty);
data.handleQty = 0 data.handleQty = 0;
const detail = data return data;
return detail };
},
const removePack = () => {
removePack() { for (let i = 0; i < detailSource.value.length; i++) {
for (let i = 0; i < this.detailSource.length; i++) { const item = detailSource.value[i];
const item = this.detailSource[i] if (item.subList.length === 0) {
if (item.subList.length == 0) { detailSource.value.splice(i, 1);
this.detailSource.splice(i, 1)
} }
} }
this.updateData() updateData();
}, };
openScanPopup() { const openScanPopup = () => {
if (this.containerCode == '') { if (containerCode.value === '') {
this.showContainerPopup() showContainerPopup();
return return;
} }
this.$refs.scanPopup.openScanPopup() scanPopup.value.openScanPopup();
}, };
showContainerPopup() {
this.$nextTick(() => { const showContainerPopup = () => {
this.$refs.scanContainer.openScanPopup() nextTick(() => {
}) scanContainer.value.openScanPopup();
}, });
closeScanPopup() { };
this.$refs.scanPopup.closeScanPopup()
}, const closeScanPopup = () => {
scanPopup.value.closeScanPopup();
scanPopupGetFocus() { };
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.getfocus() const scanPopupGetFocus = () => {
if (scanPopup.value != undefined) {
scanPopup.value.getfocus();
} }
}, };
scanPopupLoseFocus() { const scanPopupLoseFocus = () => {
if (this.$refs.scanPopup != undefined) { if (scanPopup.value != undefined) {
this.$refs.scanPopup.losefocus() scanPopup.value.losefocus();
} }
}, };
commit() { const commit = () => {
uni.showLoading({ uni.showLoading({
title: '提交中...', title: '提交中...',
mask: true mask: true
}) });
this.scanCount = getScanCount(this.detailSource[0].subList) scanCount.value = getScanCount(detailSource.value[0].subList);
if (this.scanCount == 0) { if (scanCount.value === 0) {
this.showErrorMessage('扫描数为0,请先扫描要解绑的箱码') showErrorMessage('扫描数为0,请先扫描要解绑的箱码');
return return;
} }
const params = this.getParams() const params = getParams();
console.log(`提交${JSON.stringify(params)}`) console.log(`提交${JSON.stringify(params)}`);
containerUnBindRecordSubmit(params) containerUnBindRecordSubmit(params)
.then((res) => { .then((res) => {
uni.hideLoading() uni.hideLoading();
if (res.data) { if (res.data) {
this.showCommitSuccessMessage(`提交成功\n生成器具绑定记录\n${res.data}`) showCommitSuccessMessage(`提交成功\n生成器具绑定记录\n${res.data}`);
this.clear() clear();
} else { } else {
this.showErrorMessage(`提交失败[${res.msg}]`) showErrorMessage(`提交失败[${res.msg}]`);
} }
}) })
.catch((error) => { .catch((error) => {
uni.hideLoading() uni.hideLoading();
this.showErrorMessage(error) showErrorMessage(error);
}) });
}, };
getParams() { const getParams = () => {
const subList = [] const subList = [];
const creator = this.$store.state.user.id const creator = useStore().state.user.id;
const params = { const params = {
number: this.containerCode, number: containerCode.value,
type: 'bind', type: 'bind',
status: 'USED', status: 'USED',
creator creator
} };
this.detailSource.forEach((item) => { detailSource.value.forEach((item) => {
item.subList.forEach((detail) => { item.subList.forEach((detail) => {
if (detail.scaned) { if (detail.scaned) {
detail.containerContentType = 'PACKAGE' detail.containerContentType = 'PACKAGE';
detail.contentNumber = detail.packingNumber detail.contentNumber = detail.packingNumber;
detail.itemCode = detail.itemCode;
detail.itemCode = detail.itemCode detail.batch = detail.batch;
detail.batch = detail.batch detail.inventoryStatus = detail.inventoryStatus;
detail.inventoryStatus = detail.inventoryStatus detail.qty = detail.handleQty;
detail.qty = detail.handleQty detail.package = null;
detail.package = null subList.push(detail);
subList.push(detail)
} }
}) });
}) });
params.subList = subList params.subList = subList;
return params return params;
}, };
showMessage(message) { const showMessage = (message) => {
setTimeout((r) => { setTimeout(() => {
this.scanPopupLoseFocus() scanPopupLoseFocus();
this.$refs.comMessage.showMessage(message, (res) => { comMessage.value.showMessage(message, (res) => {
if (res) { if (res) {
this.scanPopupGetFocus() scanPopupGetFocus();
} }
}) });
}) });
}, };
showErrorMessage(message) { const showErrorMessage = (message) => {
setTimeout((r) => { setTimeout(() => {
this.scanPopupLoseFocus() scanPopupLoseFocus();
this.$refs.comMessage.showErrorMessage(message, (res) => { comMessage.value.showErrorMessage(message, (res) => {
if (res) { if (res) {
this.scanPopupGetFocus() scanPopupGetFocus();
} }
}) });
}) });
}, };
showScanMessage(message) { const showScanMessage = (message) => {
this.$refs.comMessage.showScanMessage(message) comMessage.value.showScanMessage(message);
}, };
afterCloseMessage() { const afterCloseMessage = () => {
this.scanPopupGetFocus() scanPopupGetFocus();
}, };
closeScanMessage() { const closeScanMessage = () => {
this.scanPopupGetFocus() scanPopupGetFocus();
}, };
getContainer(containerInfo) { const getContainer = (containerInfo) => {
this.containerCode = containerInfo.number containerCode.value = containerInfo.number;
getContainerDetailByNumber(this.containerCode) getContainerDetailByNumber(containerCode.value)
.then((res) => { .then((res) => {
if (res.data != null && res.data.subList.length > 0) { if (res.data != null && res.data.subList.length > 0) {
this.detailSource = this.getDataSource(res.data.subList) detailSource.value = getDataSource(res.data.subList);
} }
}) })
.catch((error) => { .catch((error) => {
this.showErrorMessage(error.message) showErrorMessage(error.message);
}) });
}, };
showCommitSuccessMessage(hint) { const showCommitSuccessMessage = (hint) => {
this.$refs.comMessage.showSuccessMessage(hint, (res) => { comMessage.value.showSuccessMessage(hint, (res) => {
this.containerCode = '' containerCode.value = '';
}) });
}, };
updateData() { const updateData = () => {
this.calcHandleQty() calcHandleQty();
for (let i = 0; i < this.detailSource.length; i++) { for (let i = 0; i < detailSource.value.length; i++) {
const item = this.detailSource[i] const item = detailSource.value[i];
if (item.qty == 0) { if (item.qty === 0) {
this.detailSource.splice(i, 1) detailSource.value.splice(i, 1);
}
} }
},
clear() {}
} }
} };
const clear = () => {};
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>

Loading…
Cancel
Save