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.

277 lines
7.4 KiB

12 months ago
<template>
<view class="page-wraper">
11 months ago
<view class="" v-if='detailSource.length==0'>
12 months ago
<com-blank-view @goScan='goScan(true)'></com-blank-view>
</view>
<view v-else class="page-wraper">
<view class="page-main">
11 months ago
<scroll-view scroll-y="true" class="">
<view v-for="(toLocation, index) in detailSource">
<com-issue-request-info :workShopCode="workShopCode" :dataContent="toLocation">
</com-issue-request-info>
<com-issue-detail-card ref='comIssueDetailCard' :dataContent="toLocation"
@updateData='updateData'>
</com-issue-detail-card>
</view>
</scroll-view>
<!-- <comIssueRequestCreator ref="issueRequest" :dataContent="detailSource">
</comIssueRequestCreator> -->
<!-- <button class="btn_add" @click="goScan(false)">+去添加</button> -->
12 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>
11 months ago
<comMessage ref="comMessage"></comMessage>
12 months ago
<com-issue-request-popup ref="comIssueRequestPopup" @confirm='requestConfirm'></com-issue-request-popup>
</template>
<script>
import {
issueRequestSubmit,
11 months ago
issueRecordSubmit,
getBalanceByBatchOffShelf
12 months ago
} from '@/api/request2.js';
import {
goHome,
updateTitle,
getRemoveOption,
getISODateTime
} from '@/common/basic.js';
import {
getDataSource
} from '@/pages/issue/js/issue.js';
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'
11 months ago
import comIssueRequestInfo from '@/pages/issue/coms/comIssueRequestInfo.vue'
import comIssueDetailCard from '@/pages/issue/coms/comIssueDetailCard.vue'
12 months ago
export default {
name: 'issueRequestSubmit',
components: {
comBlankView,
comIssueRequestPopup,
jobDetailPopup,
comMessage,
11 months ago
comIssueRequestCreator,
comIssueRequestInfo,
comIssueDetailCard
12 months ago
},
data() {
return {
subList: [], //接口返回的任务subList
11 months ago
detailSource: [], //绑定在页面上的数据源
12 months ago
detailOptions: [],
scanOptions: [],
11 months ago
fromType: "",
workShopCode: ""
12 months ago
}
},
mounted() {
this.goScan(true)
},
onLoad(option) {
this.fromType = option.fromType
11 months ago
if (this.fromType == "requestType") {
12 months ago
updateTitle("发料申请")
11 months ago
} else {
12 months ago
updateTitle("发料记录")
}
},
methods: {
11 months ago
resizeCollapse() {
this.$nextTick(r => {
this.$refs.comIssueDetailCard.forEach(r => {
r.resizeCollapse();
})
});
},
12 months ago
goScan(editPosition) {
this.$refs.comIssueRequestPopup.openRequestPopup(editPosition);
},
//确定需求信息
requestConfirm(action, item) {
11 months ago
if (item.itemCode == '' || item.itemCode == null) return;
let that = this;
uni.showLoading({
title: '加载中...',
mask: true
})
getBalanceByBatchOffShelf(item.itemCode, item.qty).then(res => {
if (res.data == null) {
that.showMessage('未获取到推荐信息');
} else {
if (res.data.length > 0) {
this.workShopCode = item.workshopCode;
res.data.forEach(r => {
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.resizeCollapse();
} else {
that.showMessage('列表数据为0');
12 months ago
}
11 months ago
uni.hideLoading();
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
12 months ago
11 months ago
// if (this.detailSource.subList.length == 0) {
// this.detailSource = {
// workshopCode: item.workshopCode,
// workShopName: item.workShopName,
12 months ago
11 months ago
// totalQty: 0,
// subList: []
// }
// var subItem = {
// productionLineCode: item.productionLineCode,
// productionLineName: item.productionLineName,
// workStationCode: item.workStationCode,
// workStationName: item.workStationName, //工位
// itemCode: item.itemCode,
// itemName: item.itemName,
// qty: item.qty,
// uom: item.uom
// }
// this.detailSource.subList.push(subItem)
// } else {
// var result = this.detailSource.subList.filter(res => {
// if (res.itemCode == item.itemCode &&
// res.productionLineCode == item.productionLineCode &&
// res.workStationCode == item.workStationCode) {
// return res
// }
// })
12 months ago
11 months ago
// //没有添加数据
// if (result.length == 0) {
// var subItem = {
// productionLineCode: item.productionLineCode,
// productionLineName: item.productionLineName,
// workStationCode: item.workStationCode,
// workStationName: item.workStationName, //工位
// itemCode: item.itemCode,
// itemName: item.itemName,
// qty: item.qty,
// uom: item.uom
// }
// this.detailSource.subList.push(subItem)
// } else {
// //有了更新数据
// result[0].qty += item.qty
// }
// }
// this.caclcQty();
// if (this.$refs.issueRequest != undefined) {
// this.$refs.issueRequest.update()
// }
12 months ago
},
11 months ago
12 months ago
caclcQty() {
var totalQty = 0;
this.detailSource.subList.forEach(res => {
totalQty += res.qty
})
this.detailSource.totalQty = totalQty;
},
setParams() {
return this.detailSource
},
submit() {
uni.showLoading({
title: "提交中....",
mask: true
});
11 months ago
if (this.fromType == "requestType") {
12 months ago
var params = this.setParams()
console.log("提交参数", JSON.stringify(params));
issueRequestSubmit(params).then(res => {
uni.hideLoading()
if (res.data) {
this.showCommitSuccessMessage("提交成功<br>生成发料申请" + res.data)
} else {
12 months ago
this.showErrorMessage("提交失败[" + res.msg + "]")
12 months ago
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
11 months ago
} else {
12 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 {
12 months ago
this.showErrorMessage("提交失败[" + res.msg + "]")
12 months ago
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
}
11 months ago
12 months ago
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
11 months ago
if (this.fromType == "requestType") {
12 months ago
uni.navigateTo({
url: './issueRequest'
})
}
11 months ago
12 months ago
})
},
11 months ago
showMessage(message) {
this.$refs.comMessage.showMessage(message, res => {
if (res) {
this.afterCloseMessage()
}
});
},
12 months ago
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {}
});
},
}
}
</script>
<style>
</style>