You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

308 lines
8.2 KiB

10 months ago
<template>
<view class="page-wraper">
10 months ago
<view class="" v-if='detailSource.length==0'>
10 months ago
<com-blank-view @goScan='goScan(true)'></com-blank-view>
</view>
<view v-else class="page-wraper">
<view class="page-main">
10 months ago
<scroll-view scroll-y="true" class="">
<view v-for="(toLocation, index) in detailSource">
<view class="uni-row uni-flex">
<com-issue-request-info :workShopCode="workShopCode" :dataContent="toLocation">
</com-issue-request-info>
</view>
10 months ago
<com-issue-detail-card ref='comIssueDetailCard' :dataContent="toLocation"
@updateData='updateData'>
</com-issue-detail-card>
</view>
</scroll-view>
<button class="btn_add" @click="goScan(true)">+去添加</button>
10 months ago
</view>
<div class="btn_bottom">
<view class="" style="display: flex;flex-direction: row;">
<view class="">
<button class="btn_commit" hover-class="btn_commit_after" @click="submit()">提交</button>
</view>
</view>
</div>
</view>
</view>
10 months ago
<com-message ref="comMessage"></com-message>
10 months ago
<com-issue-request-popup ref="comIssueRequestPopup" @confirm='requestConfirm'></com-issue-request-popup>
<win-scan-button v-if='detailSource.length>0' @goScan='openScanDetailPopup'></win-scan-button>
10 months ago
<com-scan-issue-pack ref="comScanIssuePack" @closeScan='closeScan' @updateData='updateData'>
</com-scan-issue-pack>
10 months ago
</template>
<script>
import {
10 months ago
issueRecordSubmit,
getBalanceByBatchOffShelf
10 months ago
} from '@/api/request2.js';
import {
goHome,
updateTitle,
getRemoveOption,
getISODateTime,
10 months ago
} from '@/common/basic.js';
import {
getDataSource
} from '@/pages/issue/js/issue.js';
import {
getBusinessType,
} from '@/common/record.js';
10 months ago
import comBlankView from '@/mycomponents/common/comBlankView.vue'
import comIssueRequestPopup from '@/pages/issue/coms/comIssueRequestPopup.vue'
import jobDetailPopup from '@/mycomponents/job/jobDetailPopup.vue'
import comMessage from '@/mycomponents/common/comMessage.vue'
import comIssueRequestCreator from '@/pages/issue/coms/comIssueRequestCreator.vue'
10 months ago
import comIssueRequestInfo from '@/pages/issue/coms/comIssueRequestInfo.vue'
import comIssueDetailCard from '@/pages/issue/coms/comIssueDetailCard.vue'
10 months ago
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import comScanIssuePack from '@/pages/issue/coms/comScanIssuePack.vue'
10 months ago
export default {
9 months ago
name: '',
10 months ago
components: {
comBlankView,
comIssueRequestPopup,
jobDetailPopup,
comMessage,
10 months ago
comIssueRequestCreator,
comIssueRequestInfo,
10 months ago
comIssueDetailCard,
winScanButton,
comScanIssuePack
10 months ago
},
data() {
return {
subList: [], //接口返回的任务subList
10 months ago
detailSource: [], //绑定在页面上的数据源
10 months ago
detailOptions: [],
scanOptions: [],
workShopCode: "",
fromInventoryStatuses: "",
toInventoryStatuses: "",
requestList: [],
10 months ago
}
},
mounted() {
10 months ago
},
onLoad(option) {
var typeCode = "Issue"
getBusinessType(typeCode, res => {
if (res.success) {
this.businessType = res.businessType;
this.fromlocationTypeList = res.fromlocationTypeList;
this.tolocationTypeList = res.tolocationTypeList;
this.fromInventoryStatuses = res.fromInventoryStatuses
this.toInventoryStatuses = res.toInventoryStatuses
this.goScan(true)
} else {
this.showErrorMessage(res.message)
}
});
10 months ago
},
methods: {
9 months ago
closeScan() {
this.resizeCollapse();
},
10 months ago
resizeCollapse() {
this.$nextTick(r => {
this.$refs.comIssueDetailCard.forEach(r => {
r.resizeCollapse();
})
});
},
10 months ago
goScan(editPosition) {
this.$refs.comIssueRequestPopup.openRequestPopup(editPosition);
},
//确定需求信息
requestConfirm(action, item) {
10 months ago
if (item.itemCode == '' || item.itemCode == null) return;
let that = this;
let request = that.requestList.find(r => r.itemCode == item.itemCode);
if (request == undefined) {
that.requestList.push(item);
this.getRecommendInfo(item);
} else {
this.$refs.comMessage.showQuestionMessage('已经存在零件[' + item.itemCode + ']的需求信息,是否要修改?', res => {
if (res) {
that.detailSource.forEach(detail => {
let index = detail.Items.findIndex(r => {
r.itemCode == item.itemCode
})
detail.Items.splice(index, 1);
})
this.getRecommendInfo(item);
}
});
}
},
getRecommendInfo(item) {
10 months ago
let that = this;
uni.showLoading({
title: '加载中...',
mask: true
})
getBalanceByBatchOffShelf(item.itemCode, item.qty).then(res => {
if (res.data == null) {
that.showMessage('未获取到推荐信息');
} else {
10 months ago
if (res.data.length > 0) {
that.workShopCode = item.workshopCode;
10 months ago
res.data.forEach(r => {
10 months ago
r.toLocationCode = item.rawLocationCode;
r.productionLineCode = item.productionLineCode;
r.workStationCode = item.workStationCode;
r.itemCode = item.itemCode;
r.uom = item.uom;
that.subList.push(r);
})
that.detailSource = getDataSource(that.detailSource, that.subList)
//要修改一下数量
that.detailSource.forEach(detail => {
detail.Items.forEach(i => {
let request = that.requestList.find(r => r
.itemCode == i
.itemCode);
i.qty = request.qty;
})
})
10 months ago
that.resizeCollapse();
} else {
that.showMessage('列表数据为0');
10 months ago
}
10 months ago
uni.hideLoading();
}
}).catch(error => {
uni.hideLoading()
that.showErrorMessage(error)
10 months ago
})
10 months ago
},
10 months ago
10 months ago
caclcQty() {
var totalQty = 0;
this.detailSource.subList.forEach(res => {
totalQty += res.qty
})
this.detailSource.totalQty = totalQty;
},
10 months ago
openScanDetailPopup() {
var datacontent = {}
//克隆对象,深度克隆,防止双向绑定同一个变量
// Object.assign(datacontent, this.detailSource);
var dataContent = {
allowModifyPackingNumber: "FALSE",
outInventoryStatuses: this.fromInventoryStatuses
}
this.$refs.comScanIssuePack.openScanPopup(this.detailSource, dataContent);
10 months ago
},
closeScanPopup() {
this.updateCommitBtn();
},
updateData(record) {
let requestLocation = this.detailSource.find(r => r.toLocationCode == record.toLocationCode);
let item = requestLocation.Items.find(r => r.itemCode == record.itemCode);
let itemHandleQty = 0;
if (item != undefined) {
item.Locations.forEach(l => {
let batch = l.Batchs.find(b => (b.packingNumber == record.packingNumber || b
.packingNumber == null || b.packingNumber == '') && b.batch ==
record.batch);
let handleQty = 0;
if (batch != undefined) {
batch.Records.forEach(res => {
handleQty += Number(res.qty)
})
batch.handleQty = handleQty;
itemHandleQty += handleQty;
}
})
}
10 months ago
this.resizeCollapse();
10 months ago
// item.handleQty=itemHandleQty;
// this.closeScan();
10 months ago
},
10 months ago
setParams() {
return this.detailSource
},
submit() {
uni.showLoading({
title: "提交中....",
mask: true
});
9 months ago
var params = this.setParams()
console.log("提交参数", JSON.stringify(params));
issueRecordSubmit(params).then(res => {
uni.hideLoading()
if (res.data) {
this.showCommitSuccessMessage("提交成功<br>生成发料记录" + res.data)
} else {
this.showErrorMessage("提交失败[" + res.msg + "]")
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
10 months ago
10 months ago
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
10 months ago
if (this.fromType == "requestType") {
10 months ago
uni.navigateTo({
url: './issueRequest'
})
}
10 months ago
10 months ago
})
},
10 months ago
showMessage(message) {
this.$refs.comMessage.showMessage(message, res => {
if (res) {
this.afterCloseMessage()
}
});
},
10 months ago
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {}
});
},
showQuestionMessage(message) {
},
// this.$refs.comMessage.showQuestionMessage('是否要清空已扫描的零件和目标库位信息?', res => {
// if (res) {
// that.clearInfo();
// }
// });
10 months ago
}
}
</script>
<style>
</style>