|
|
@ -39,7 +39,7 @@ |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
<script setup> |
|
|
|
import { goHome, showConfirmMsg, getCurrDateTime } from '@/common/basic.js' |
|
|
|
|
|
|
|
import { splitPackageRecordSubmit } from '@/api/request2.js' |
|
|
@ -63,201 +63,179 @@ 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) { |
|
|
|
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 |
|
|
|
}) |
|
|
|
this.getBusinessType() |
|
|
|
}, |
|
|
|
// 返回首页 |
|
|
|
onNavigationBarButtonTap(e) { |
|
|
|
}); |
|
|
|
getBusinessType(); |
|
|
|
}); |
|
|
|
|
|
|
|
onNavigationBarButtonTap((e) => { |
|
|
|
if (e.index === 0) { |
|
|
|
goHome() |
|
|
|
goHome(); |
|
|
|
} |
|
|
|
}, |
|
|
|
// 拦截返回按钮事件 |
|
|
|
onBackPress(e) {}, |
|
|
|
}); |
|
|
|
|
|
|
|
onPullDownRefresh() {}, |
|
|
|
|
|
|
|
mounted() {}, |
|
|
|
methods: { |
|
|
|
getBusinessType() { |
|
|
|
getBusinessType(this.typeCode, (res) => { |
|
|
|
const getBusinessType = () => { |
|
|
|
getBusinessTypeApi(typeCode.value, (res) => { |
|
|
|
if (res.success) { |
|
|
|
this.businessType = res.businessType |
|
|
|
this.fromInventoryStatuses = getDirectoryItemArray(res.fromInventoryStatuses) |
|
|
|
this.fromLocationAreaTypeList = res.fromLocationAreaTypeList |
|
|
|
this.openScanPopup() |
|
|
|
businessType.value = res.businessType; |
|
|
|
fromInventoryStatuses.value = getDirectoryItemArray(res.fromInventoryStatuses); |
|
|
|
fromLocationAreaTypeList.value = res.fromLocationAreaTypeList; |
|
|
|
openScanPopup(); |
|
|
|
} else { |
|
|
|
this.showErrorMessage(res.message) |
|
|
|
showErrorMessage(res.message); |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
openScanPopup() { |
|
|
|
if (this.businessType) { |
|
|
|
if (this.detailSource.length > 0) { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const openScanPopup = () => { |
|
|
|
if (businessType.value) { |
|
|
|
if (detailSource.value.length > 0) { |
|
|
|
showConfirmMsg('拆包信息还没提交,是否要重新扫描?', (res) => { |
|
|
|
if (res) { |
|
|
|
this.clearData() |
|
|
|
this.$refs.scanPopup.openScanPopup(this.businessType) |
|
|
|
clearData(); |
|
|
|
scanPopupRef.value.openScanPopup(businessType.value); |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
} else { |
|
|
|
this.$refs.scanPopup.openScanPopup(this.businessType) |
|
|
|
scanPopupRef.value.openScanPopup(businessType.value); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.getBusinessType() |
|
|
|
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 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 = 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 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) |
|
|
|
this.detailSource.push(itemp) |
|
|
|
this.itemCode = balance.itemCode |
|
|
|
this.fromLocationCode = balance.locationCode |
|
|
|
this.closeScanPopup() |
|
|
|
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) => { |
|
|
|
if (r.packingNumber == pack.packingNumber && r.batch == balance.batch && r.locationCode == balance.locationCode && r.inventoryStatus == balance.inventoryStatus) { |
|
|
|
return r |
|
|
|
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}]重复扫描`); |
|
|
|
} |
|
|
|
}) |
|
|
|
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}]重复扫描`) |
|
|
|
} |
|
|
|
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.calcHandleQty() |
|
|
|
}, |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
calcHandleQty() { |
|
|
|
calcHandleQty(this.detailSource) |
|
|
|
this.$forceUpdate() |
|
|
|
}, |
|
|
|
const removeItem = (index) => { |
|
|
|
detailSource.value.splice(index, 1); |
|
|
|
}; |
|
|
|
|
|
|
|
showErrorMessage(message) { |
|
|
|
this.$refs.comMessage.showErrorMessage(message, (res) => { |
|
|
|
if (res) { |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
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) |
|
|
|
const closeScanPopup = () => { |
|
|
|
if (scanPopupRef.value) { |
|
|
|
scanPopupRef.value.closeScanPopup(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
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() |
|
|
|
const scanPopupGetFocus = () => { |
|
|
|
if (scanPopupRef.value) { |
|
|
|
scanPopupRef.value.getfocus(); |
|
|
|
} |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
commit() { |
|
|
|
if (this.detailSource.length > 0 && this.detailSource[0].subList.length > 0) { |
|
|
|
if (this.splitCount <= 0) { |
|
|
|
this.showErrorMessage('拆出数量必须大于0') |
|
|
|
return |
|
|
|
const commit = () => { |
|
|
|
if (detailSource.value.length > 0 && detailSource.value[0].subList.length > 0) { |
|
|
|
if (splitCount.value <= 0) { |
|
|
|
showErrorMessage('拆出数量必须大于0'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (this.splitCount >= this.detailSource[0].qty) { |
|
|
|
this.showErrorMessage('拆出数量不能大于等于库存数量') |
|
|
|
return |
|
|
|
if (splitCount.value >= detailSource.value[0].qty) { |
|
|
|
showErrorMessage('拆出数量不能大于等于库存数量'); |
|
|
|
return; |
|
|
|
} |
|
|
|
uni.showLoading({ |
|
|
|
title: '提交中....', |
|
|
|
mask: true |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
const params = this.setParams() |
|
|
|
console.log(`提交${JSON.stringify(params)}`) |
|
|
|
const params = setParams(); |
|
|
|
console.log(`提交${JSON.stringify(params)}`); |
|
|
|
splitPackageRecordSubmit(params) |
|
|
|
.then((res) => { |
|
|
|
uni.hideLoading() |
|
|
|
uni.hideLoading(); |
|
|
|
if (res.data) { |
|
|
|
const list = [] |
|
|
|
res.data.forEach((item) => { |
|
|
|
list.push({ |
|
|
|
const list = res.data.map((item) => ({ |
|
|
|
itemCode: item.itemCode, // 物品代码 |
|
|
|
itemName: item.itemName, // 物品名称 |
|
|
|
packName: item.packName, // 包装名称 |
|
|
@ -272,104 +250,99 @@ export default { |
|
|
|
productionLineCode: item.productionLineCode, // 生产线 |
|
|
|
barcodeString: item.barcodeString, // 标签信息 |
|
|
|
barcodeBase64: '' |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.showCommitSuccessMessage('提交成功\n生成拆包记录\n', list) |
|
|
|
})); |
|
|
|
showCommitSuccessMessage('提交成功\n生成拆包记录\n', list); |
|
|
|
} else { |
|
|
|
this.showErrorMessage(`提交失败[${res.msg}]`) |
|
|
|
showErrorMessage(`提交失败[${res.msg}]`); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
uni.hideLoading() |
|
|
|
this.showErrorMessage(error) |
|
|
|
}) |
|
|
|
uni.hideLoading(); |
|
|
|
showErrorMessage(error); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
this.showErrorMessage('没有要提交的数据') |
|
|
|
showErrorMessage('没有要提交的数据'); |
|
|
|
} |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
setParams() { |
|
|
|
const subList = [] |
|
|
|
const creator = this.$store.state.user.id |
|
|
|
this.detailSource.forEach((item) => { |
|
|
|
const setParams = () => { |
|
|
|
const subList = []; |
|
|
|
const creator = store.state.user.id; |
|
|
|
detailSource.value.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 |
|
|
|
this.dataContent.creator = creator |
|
|
|
return this.dataContent |
|
|
|
}, |
|
|
|
|
|
|
|
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() |
|
|
|
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)}` |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
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") |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
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> |
|
|
|