Browse Source

pages/package/record 文件迁移Vue2升级Vue3 8/2-10/25

hella_vue3
王志国 3 weeks ago
parent
commit
694688ab65
  1. 571
      src/pages/package/record/splitPackageRecord.vue

571
src/pages/package/record/splitPackageRecord.vue

@ -39,7 +39,7 @@
</view> </view>
</template> </template>
<script> <script setup>
import { goHome, showConfirmMsg, getCurrDateTime } from '@/common/basic.js' import { goHome, showConfirmMsg, getCurrDateTime } from '@/common/basic.js'
import { splitPackageRecordSubmit } from '@/api/request2.js' import { splitPackageRecordSubmit } from '@/api/request2.js'
@ -63,313 +63,286 @@ import winComScanBalance from '@/mycomponents/scan/winComScanBalance.vue'
import uom from '@/mycomponents/qty/uom.vue' import uom from '@/mycomponents/qty/uom.vue'
import numberBox from '@/mycomponents/qty/numberBox.vue' import numberBox from '@/mycomponents/qty/numberBox.vue'
export default { import { ref, onMounted, nextTick } from 'vue';
components: { import { onLoad, onNavigationBarButtonTap, onBackPress, onPullDownRefresh } from '@dcloudio/uni-app';
winScanButton,
winScanPack, const id = ref('');
requiredLocation, const detailSource = ref([]); //
comBlankView, const fromLocationCode = ref('');
winScanLocation, const toLocationCode = ref('');
winScanPackAndLocation, const fromLocationAreaTypeList = ref([]);
recommendBalance, const inInventoryStatus = ref(''); //
recordComDetailCard, const outInventoryStatus = ref(''); //
comPackageRecord, const businessType = ref({});
winComScanBalance, const dataContent = ref({});
uom, const currentItemCode = ref('');
numberBox const toPackingNumber = ref('');
}, const itemCode = ref('');
data() { const splitCount = ref(1);
return { const typeCode = ref('SplitPackage');
id: '', const fromInventoryStatuses = ref(null)
detailSource: [], // const scanPopupRef = ref(null);
fromLocationCode: '', const comMessageRef = ref(null);
toLocationCode: '', const fromPackUnit = ref('');
fromLocationAreaTypeList: [], const fromPack = ref({})
inInventoryStatus: '', // onLoad((option) => {
outInventoryStatus: '', // uni.setNavigationBarTitle({
businessType: {}, title: option.title
dataContent: {}, });
currentItemCode: '', getBusinessType();
toPackingNumber: '', });
itemCode: '',
splitCount: 1, onNavigationBarButtonTap((e) => {
typeCode: 'SplitPackage' if (e.index === 0) {
} goHome();
}, }
onLoad(option) { });
uni.setNavigationBarTitle({
title: option.title
}) const getBusinessType = () => {
this.getBusinessType() getBusinessTypeApi(typeCode.value, (res) => {
}, if (res.success) {
// businessType.value = res.businessType;
onNavigationBarButtonTap(e) { fromInventoryStatuses.value = getDirectoryItemArray(res.fromInventoryStatuses);
if (e.index === 0) { fromLocationAreaTypeList.value = res.fromLocationAreaTypeList;
goHome() openScanPopup();
} else {
showErrorMessage(res.message);
} }
}, });
// };
onBackPress(e) {},
onPullDownRefresh() {},
mounted() {},
methods: {
getBusinessType() {
getBusinessType(this.typeCode, (res) => {
if (res.success) {
this.businessType = res.businessType
this.fromInventoryStatuses = getDirectoryItemArray(res.fromInventoryStatuses)
this.fromLocationAreaTypeList = res.fromLocationAreaTypeList
this.openScanPopup()
} else {
this.showErrorMessage(res.message)
}
})
},
openScanPopup() {
if (this.businessType) {
if (this.detailSource.length > 0) {
showConfirmMsg('拆包信息还没提交,是否要重新扫描?', (res) => {
if (res) {
this.clearData()
this.$refs.scanPopup.openScanPopup(this.businessType)
}
})
} else {
this.$refs.scanPopup.openScanPopup(this.businessType)
}
} else {
this.getBusinessType()
}
},
getScanResult(result) {
this.setData(result)
},
setData(result) {
const { balance } = result
const { label } = result
const pack = result.package
this.fromPackUnit = pack.packUnit
this.fromPack = pack
if (this.fromLocationCode && this.fromLocationCode != balance.locationCode) {
this.showErrorMessage(`箱码[${balance.packingNumber}批次[${balance.batch}]在库位[${this.fromLocationCode}]没有库存余额`)
return
}
const item = this.detailSource.find((res) => {
if (res.itemCode == balance.itemCode) {
return res
}
})
if (item == undefined) {
if (this.itemCode != '' && this.itemCode != balance.itemCode) {
this.showErrorMessage(`请扫描物料为【${this.itemCode}】的箱码`)
return
}
const itemp = createItemInfo(balance, pack)
itemp.handleQty = 0
const newDetail = createDetailInfo(balance, pack) //
newDetail.handleQty = 0
newDetail.scaned = false
itemp.subList.push(newDetail)
this.detailSource.push(itemp)
this.itemCode = balance.itemCode
this.fromLocationCode = balance.locationCode
this.closeScanPopup()
} else {
const detail = item.subList.find((r) => {
if (r.packingNumber == pack.packingNumber && r.batch == balance.batch && r.locationCode == balance.locationCode && r.inventoryStatus == balance.inventoryStatus) {
return r
}
})
if (detail == undefined) {
const newDetail = createDetailInfo(balance, pack)
newDetail.handleQty = 0
item.subList.push(newDetail)
this.closeScanPopup()
} else if (detail.scaned == true) {
this.showErrorMessage(`箱码[${detail.packingNumber}批次[${balance.batch}]重复扫描`)
}
}
this.calcHandleQty()
},
calcHandleQty() {
calcHandleQty(this.detailSource)
this.$forceUpdate()
},
showErrorMessage(message) { const openScanPopup = () => {
this.$refs.comMessage.showErrorMessage(message, (res) => { if (businessType.value) {
if (detailSource.value.length > 0) {
showConfirmMsg('拆包信息还没提交,是否要重新扫描?', (res) => {
if (res) { if (res) {
clearData();
scanPopupRef.value.openScanPopup(businessType.value);
} }
}) });
}, } else {
scanPopupRef.value.openScanPopup(businessType.value);
updateData() { }
this.calcHandleQty() } else {
for (let i = 0; i < this.detailSource.length; i++) { getBusinessType();
const item = this.detailSource[i] }
if (item.qty == 0) { };
this.detailSource.splice(i, 1)
} const getScanResult = (result) => {
} setData(result);
}, };
removeItem(index, item) {
this.detailSource.splice(index, 1) const setData = (result) => {
}, const { balance } = result;
const { label } = result;
closeScanPopup() { const pack = result.package;
if (this.$refs.scanPopup != undefined) { fromPackUnit.value = pack.packUnit;
this.$refs.scanPopup.closeScanPopup() fromPack.value = pack;
}
}, if (fromLocationCode.value && fromLocationCode.value !== balance.locationCode) {
showErrorMessage(`箱码[${balance.packingNumber}批次[${balance.batch}]在库位[${fromLocationCode.value}]没有库存余额`);
scanPopupGetFocus() { return;
if (this.$refs.scanPopup != undefined) { }
this.$refs.scanPopup.getfocus()
} const item = detailSource.value.find((res) => res.itemCode === balance.itemCode);
}, if (!item) {
if (itemCode.value !== '' && itemCode.value !== balance.itemCode) {
commit() { showErrorMessage(`请扫描物料为【${itemCode.value}】的箱码`);
if (this.detailSource.length > 0 && this.detailSource[0].subList.length > 0) { return;
if (this.splitCount <= 0) { }
this.showErrorMessage('拆出数量必须大于0') const itemp = createItemInfo(balance, pack);
return itemp.handleQty = 0;
} const newDetail = createDetailInfo(balance, pack);
if (this.splitCount >= this.detailSource[0].qty) { newDetail.handleQty = 0;
this.showErrorMessage('拆出数量不能大于等于库存数量') newDetail.scaned = false;
return itemp.subList.push(newDetail);
} detailSource.value.push(itemp);
uni.showLoading({ itemCode.value = balance.itemCode;
title: '提交中....', fromLocationCode.value = balance.locationCode;
mask: true closeScanPopup();
}) } else {
const detail = item.subList.find((r) => r.packingNumber === pack.packingNumber && r.batch === balance.batch && r.locationCode === balance.locationCode && r.inventoryStatus === balance.inventoryStatus);
const params = this.setParams() if (!detail) {
console.log(`提交${JSON.stringify(params)}`) const newDetail = createDetailInfo(balance, pack);
splitPackageRecordSubmit(params) newDetail.handleQty = 0;
.then((res) => { item.subList.push(newDetail);
uni.hideLoading() closeScanPopup();
if (res.data) { } else if (detail.scaned) {
const list = [] showErrorMessage(`箱码[${detail.packingNumber}批次[${balance.batch}]重复扫描`);
res.data.forEach((item) => { }
list.push({ }
itemCode: item.itemCode, // calcHandleQtyFun();
itemName: item.itemName, // };
packName: item.packName, //
packageCode: item.toPackingNumber, // const calcHandleQtyFun = () => {
batch: item.toBatch, // calcHandleQty(detailSource.value);
parentNumber: item.parentNumber, // nextTick(() => {
itemType: item.itemType, // //
asnNumber: item.asnNumber, // ASN });
supplierCode: item.supplierCode, // };
qty: item.qty, //
printTimes: getCurrDateTime(), // const showErrorMessage = (message) => {
productionLineCode: item.productionLineCode, // 线 comMessageRef.value.showErrorMessage(message, (res) => {
barcodeString: item.barcodeString, // if (res) {}
barcodeBase64: '' });
}) };
})
this.showCommitSuccessMessage('提交成功\n生成拆包记录\n', list) const updateData = () => {
} else { calcHandleQtyFun();
this.showErrorMessage(`提交失败[${res.msg}]`) for (let i = 0; i < detailSource.value.length; i++) {
} const item = detailSource.value[i];
}) if (item.qty === 0) {
.catch((error) => { detailSource.value.splice(i, 1);
uni.hideLoading() }
this.showErrorMessage(error) }
}) };
} else {
this.showErrorMessage('没有要提交的数据')
}
},
setParams() {
const subList = []
const creator = this.$store.state.user.id
this.detailSource.forEach((item) => {
item.subList.forEach((detail) => {
const subItem = {}
Object.assign(subItem, detail)
subItem.itemCode = subItem.itemCode
subItem.itemName = detail.package.itemName
subItem.itemDesc1 = detail.package.itemDesc1
subItem.itemDesc2 = detail.package.itemDesc2
subItem.fromInventoryStatus = subItem.inventoryStatus
subItem.toInventoryStatus = subItem.inventoryStatus
subItem.fromQty = subItem.qty
subItem.toQty = this.splitCount
subItem.fromPackingNumber = subItem.packingNumber
subItem.toPackingNumber = subItem.packingNumber
subItem.fromBatch = subItem.batch
subItem.toBatch = subItem.batch
subItem.locationCode = detail.locationCode
subItem.package = ''
subItem.Records = ''
subList.push(subItem)
})
})
this.dataContent.subList = subList const removeItem = (index) => {
this.dataContent.creator = creator detailSource.value.splice(index, 1);
return this.dataContent };
},
showMessage(message) { const closeScanPopup = () => {
this.$refs.comMessage.showMessage(message, (res) => { if (scanPopupRef.value) {
if (res) { scanPopupRef.value.closeScanPopup();
} }
}) };
},
const scanPopupGetFocus = () => {
showScanMessage(message) { if (scanPopupRef.value) {
this.$refs.comMessage.showScanMessage(message) scanPopupRef.value.getfocus();
}, }
};
afterCloseMessage() {
this.scanPopupGetFocus() const commit = () => {
}, if (detailSource.value.length > 0 && detailSource.value[0].subList.length > 0) {
if (splitCount.value <= 0) {
closeScanMessage() { showErrorMessage('拆出数量必须大于0');
this.scanPopupGetFocus() return;
}, }
if (splitCount.value >= detailSource.value[0].qty) {
showCommitSuccessMessage(hint, pointData) { showErrorMessage('拆出数量不能大于等于库存数量');
this.$refs.comMessage.showSuccessMessage(hint, (res) => { return;
this.clearData() }
if (pointData.length > 0) { uni.showLoading({
uni.navigateTo({ title: '提交中....',
url: `/pages/point/index?points=${JSON.stringify(pointData)}` mask: true
}) });
const params = setParams();
console.log(`提交${JSON.stringify(params)}`);
splitPackageRecordSubmit(params)
.then((res) => {
uni.hideLoading();
if (res.data) {
const list = res.data.map((item) => ({
itemCode: item.itemCode, //
itemName: item.itemName, //
packName: item.packName, //
packageCode: item.toPackingNumber, //
batch: item.toBatch, //
parentNumber: item.parentNumber, //
itemType: item.itemType, //
asnNumber: item.asnNumber, // ASN
supplierCode: item.supplierCode, //
qty: item.qty, //
printTimes: getCurrDateTime(), //
productionLineCode: item.productionLineCode, // 线
barcodeString: item.barcodeString, //
barcodeBase64: ''
}));
showCommitSuccessMessage('提交成功\n生成拆包记录\n', list);
} else {
showErrorMessage(`提交失败[${res.msg}]`);
} }
}) })
}, .catch((error) => {
uni.hideLoading();
clearData() { showErrorMessage(error);
this.detailSource = [] });
this.fromLocationCode = '' } else {
this.currentItemCode = '' showErrorMessage('没有要提交的数据');
this.dataContent = {}
this.itemCode = ''
this.splitCount = 1
},
calcQty(val) {
this.splitCount = val
// if(val<=0){
// this.showErrorMessage("0")
// }
}
} }
} };
const setParams = () => {
const subList = [];
const creator = store.state.user.id;
detailSource.value.forEach((item) => {
item.subList.forEach((detail) => {
const subItem = { ...detail };
subItem.itemCode = subItem.itemCode;
subItem.itemName = detail.package.itemName;
subItem.itemDesc1 = detail.package.itemDesc1;
subItem.itemDesc2 = detail.package.itemDesc2;
subItem.fromInventoryStatus = subItem.inventoryStatus;
subItem.toInventoryStatus = subItem.inventoryStatus;
subItem.fromQty = subItem.qty;
subItem.toQty = splitCount.value;
subItem.fromPackingNumber = subItem.packingNumber;
subItem.toPackingNumber = subItem.packingNumber;
subItem.fromBatch = subItem.batch;
subItem.toBatch = subItem.batch;
subItem.locationCode = detail.locationCode;
subItem.package = '';
subItem.Records = '';
subList.push(subItem);
});
});
dataContent.value.subList = subList;
dataContent.value.creator = creator;
return dataContent.value;
};
const showMessage = (message) => {
comMessageRef.value.showMessage(message, (res) => {
if (res) {}
});
};
const showScanMessage = (message) => {
comMessageRef.value.showScanMessage(message);
};
const afterCloseMessage = () => {
scanPopupGetFocus();
};
const closeScanMessage = () => {
scanPopupGetFocus();
};
const showCommitSuccessMessage = (hint, pointData) => {
comMessageRef.value.showSuccessMessage(hint, (res) => {
clearData();
if (pointData.length > 0) {
uni.navigateTo({
url: `/pages/point/index?points=${JSON.stringify(pointData)}`
});
}
});
};
const clearData = () => {
detailSource.value = [];
fromLocationCode.value = '';
currentItemCode.value = '';
dataContent.value = {};
itemCode.value = '';
splitCount.value = 1;
};
const calcQty = (val) => {
splitCount.value = val;
// if (val <= 0) {
// showErrorMessage("0");
// }
};
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>

Loading…
Cancel
Save