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

Loading…
Cancel
Save