Browse Source

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

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

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

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

Loading…
Cancel
Save