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.

442 lines
12 KiB

1 year ago
<template>
<view class="" v-if="jobContent!=null">
<view class="pda-list">
<view class="pda-list-cell">
<view class="pda-list-cell-left">
<view class="uni-label">类型</view>
</view>
<view class="pda-list-cell-db">
{{getInspectName(jobContent.inspectType) }}
</view>
</view>
<view class="pda-list-cell">
<view class="pda-list-cell-left">
<view class="uni-label">零件号</view>
</view>
<view class="pda-list-cell-db">
<view class="uni-flex space-between">
<input class="display-input" type="text" :disabled="true" v-model="jobContent.itemCode" />
</view>
</view>
</view>
<view class="pda-list-cell">
<view class="pda-list-cell-left">
<view class="uni-label">批次</view>
</view>
<view class="pda-list-cell-db">
<input class="display-input" type="text" :disabled="true" v-model="jobContent.batch" />
</view>
</view>
<view class="pda-list-cell" style="margin-top: 10rpx;margin-bottom: 10rpx;">
<view class="pda-list-cell-left">
<view class="uni-label">收货数量</view>
</view>
<view class="pda-list-cell-db">
<text>{{jobContent.receiveQty}} {{getUnitInfo(jobContent.uom)}}</text>
</view>
</view>
<view class="pda-list-cell">
<view class="pda-list-cell-left">
<view class="uni-label">检验数量</view>
</view>
<view class="pda-list-cell-db">
<text>{{jobContent.sampleQty}} {{getUnitInfo(jobContent.uom)}}</text>
</view>
</view>
<view class="pda-list-cell">
<view class="pda-list-cell-left">
<view class="uni-label">不合格数量</view>
</view>
<view class="pda-list-cell-db" >
<uni-easyinput :inputBorder="true" type="number" placeholder="请输入数字"
v-model="jobContent.failedQty" @blur="failedQtyConfirm" class="count-input">
</uni-easyinput>
</view>
</view>
<view class="pda-list-cell">
<view class="pda-list-cell-left">
<view class="uni-label">报废数量</view>
</view>
<view class="pda-list-cell-db" >
<uni-easyinput placeholder="请输入数字" type="number" v-model="jobContent.crackQty" @blur=""
class="count-input">
</uni-easyinput>
</view>
</view>
<view class="pda-list-cell" >
<view class="pda-list-cell-left">
<view class="uni-label">下一步动作</view>
</view>
<view class="pda-list-cell-db" >
<uni-data-picker class='uni-data-picker' placeholder="请选择下一步动作" popup-title="下一步动作"
@change="nextStepChange" :localdata="nextActionList" v-model="nextAction">
</uni-data-picker>
</view>
</view>
<view class="pda-list-cell">
<view class="pda-list-cell-left">
<view class="uni-label">最终不合格</view>
</view>
<view class="pda-list-cell-db" >
<uni-easyinput placeholder="待计算" type="number" :disabled="true"
v-model="jobContent.notPassedQty" class="count-input">
</uni-easyinput>
</view>
</view>
<view class="pda-list-cell">
<view class="pda-list-cell-left">
<view class="uni-label">备注</view>
</view>
<view class="pda-list-cell-db">
<uni-easyinput placeholder="请输入备注" type="text" autoHeight v-model="jobContent.remark"
class="count-input">
</uni-easyinput>
</view>
</view>
</view>
<view class="" v-if="false">
<uni-collapse>
<uni-collapse-item title="库位列表" style='font-size: 40rpx;' :open='true'>
<view style="">
<scroll-view scroll-y="true" class="scroll-detail">
<view class=""
style="font-size: 35rpx;display: flex;flex-direction: row;align-items: center;width: 100%;"
v-for="(item, index) in detailList" :key="item.id">
1 year ago
<text style="font-size: 35rpx;margin-right: 20rpx;">{{index+1}}.</text>
<view class="">
<view class="">
箱码:{{item.packingNumber}}
</view>
<view class="">
库位:{{item.fromLocationCode}}
</view>
<u-line />
</view>
</view>
</scroll-view>
</view>
</uni-collapse-item>
</uni-collapse>
</view>
<view class="bottom" style="padding-bottom: 20rpx;">
<button :disabled="submitting" type="primary" class="save-button" @click="commit">提交</button>
1 year ago
</view>
<comMessage ref="comMessage"></comMessage>
</view>
</template>
<script>
import comMessage from '@/mycomponents/common/comMessage.vue'
1 year ago
import {
getInspectJobDetail,
takeInspectJob,
cancleTakeInspectJob,
inspectJobSubmit
1 year ago
} from '@/api/request2.js';
1 year ago
import {
getInspectFailedReasonList,
getNextActionList,
getInspectType,
getUnitInfo
} from '@/common/directory.js';
export default {
components: {
comMessage
},
data() {
return {
id: '',
status: "",
itemDetail: {},
inspectType: '', //免检 全检 抽检
failedReasonIndex: 0,
failedReasonArray: [],
nextStep: '',
submitting: false,
received: false,
locations: [],
value: ['0'],
jobContent: {}, //任务内容
detailList: [], //接口返回的任务details
1 year ago
detailSource: [], //绑定在页面上的数据源
nextActionList: [],
nextAction: null,
}
},
onLoad(option) {
this.id = option.id;
this.status = option.status;
this.nextActionList = getNextActionList();
if (this.id != undefined) {
// //新建的任务自动接收
if (option.status == "1") {
this.receive((callback => {
this.received = true;
this.getDetail();
}));
} else {
this.getDetail();
}
1 year ago
}
},
onBackPress(e) {
//已经接收但是没提交任务
if (e.from == 'backbutton') {
if (this.received) {
//取消承接任务
cancleTakeInspectJob(this.id).then(res => {
uni.navigateBack();
}).catch(error => {
uni.navigateBack();
})
} else {
uni.navigateBack();
}
1 year ago
return true;
}
},
methods: {
//接收
receive(callback) {
uni.showLoading({
title: "加载中....",
mask: true
});
if (this.id != null) {
takeInspectJob(this.id).then(res => {
uni.hideLoading();
callback();
}).catch(error => {
uni.hideLoading();
this.showErrorMessage(error)
})
}
},
1 year ago
getDetail() {
var that = this;
uni.showLoading({
title: "加载中....",
mask: true
});
getInspectJobDetail(that.id).then(res => {
uni.hideLoading();
if (res.data == null) {
that.showMessage('未获取到详情');
} else {
if (res.data.subList.length > 0) {
that.jobContent = res.data;
that.detailList = res.data.subList;
1 year ago
that.inspectType =that.jobContent.inspectType;
that.jobContent.goodQty = null, //合格数量
that.jobContent.failedQty = null,//不合格数量
that.jobContent.crackQty = null,//报废数量
that.jobContent.notPassedQty = null; //最终不合格数量
} else {
that.showMessage('列表数据为0');
}
}
}).catch(error => {
uni.hideLoading()
this.showMessage(error)
})
},
showMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
// this.afterCloseMessage()
}
});
},
//不合格数量确认事件
failedQtyConfirm(value) {
// if (value.detail.value > this.jobContent.receiveQty) {
// this.jobContent.failedQty = null
// this.showMessage("不合格数[" + value.detail.value + "]不能大于收货数量[" + this.jobContent.receiveQty + "]")
// return
// }
// if (value.detail.value+ this.jobContent.crackQty> this.jobContent.receiveQty) {
// this.jobContent.failedQty = null
// this.showMessage("不合格数[" + value.detail.value +"+报废数量["+this.jobContent.crackQty+ "]不能大于收货数量[" + this.jobContent.receiveQty + "]")
// return
// }
this.calcNotPassQty()
},
getInspectName(value) {
return getInspectType(value)
},
getUnitInfo(value) {
return getUnitInfo(value).label
},
nextStepChange(e){
this.nextAction = e.detail.value[0].value;
this.calcNotPassQty();
},
calcNotPassQty(){
var failedQty = Number(this.jobContent.failedQty == null ? 0 : this.jobContent.failedQty)
//检验类型:全检(全部合格)
if (this.inspectType == 'FUll' ) {
//最终不合格数量等于不合格数量
this.jobContent.notPassedQty = failedQty
}else if(this.inspectType == 'SAMPLING'){
//检验类型:抽检
//下一步动作
//全检、部分合格
if (this.nextAction == "FULL_INSPECT"||this.nextAction == "PARTIAL_OK") {
// 最终不合格数量=不合格数量
this.jobContent.notPassedQty = failedQty
}else if(this.nextAction=="ALL_NOK"){
//最终不合格数量=收货数量-报废数量
this.jobContent.notPassedQty = Number(this.jobContent.receiveQty)-Number(this.jobContent.crackQty==null?0:this.jobContent.crackQty)
}
}
},
commit() {
1 year ago
if (this.jobContent.failedQty == null) {
this.showMessage("请输入不合格数量")
return
}
if (this.jobContent.crackQty == null) {
this.showMessage("请输入不报废数量")
return
}
var receiveQty = Number(this.jobContent.receiveQty)
var failedQty = Number(this.jobContent.failedQty);
var crackQty = Number(this.jobContent.crackQty);
if (crackQty + failedQty > receiveQty) {
var total = crackQty + failedQty;
this.showMessage("不合格数[" + failedQty + "]+报废数量[" + crackQty + "]等于[" + total + "]大于收货数量[" +
receiveQty + "]")
return
}
//不合格数量==0、(全部合格)、明细全部合格
if (failedQty == 0) {
//直接提交
this.jobContent.subList.forEach(res=>{
res.handleQty = res.qty
1 year ago
res.failedQty = 0;
res.notPassedQty = 0;
res.crackQty = 0;
res.goodQty = this.jobContent.receiveQty;
res.toInventoryStatus = res.inventoryStatus
1 year ago
res.failedReason ="";
res.photos = ""
res.inspectResult =""
res.inspectUser =this.$store.state.user.id
1 year ago
})
this.submitJob(this.jobContent)
1 year ago
} else {
//不合格数量>0
//下一步动作
if (this.nextAction == null) {
this.showMessage("请选择下一步动作")
return
}
//全不合格
if (this.nextAction == "ALL_NOK") {
//提交
this.jobContent.subList.forEach(res=>{
res.handleQty = res.qty
1 year ago
res.failedQty = this.jobContent.receiveQty;
res.notPassedQty = this.jobContent.receiveQty;
res.crackQty = 0;
res.goodQty = 0;
res.toInventoryStatus = "NOK"
1 year ago
res.failedReason ="";
res.photos = ""
res.inspectResult =""
re.inspectUser =this.$store.state.user.id
1 year ago
})
this.submitJob(this.jobContent)
1 year ago
//部分合格
} else if (this.nextAction == "PARTIAL_OK") {
//进入下一页面
uni.navigateTo({
url: './inspectDetail?id=' + this.id + '&status=' + this.status
});
//全检===全部合格
} else if (this.nextAction == "FULL_INSPECT") {
//提交
this.jobContent.subList.forEach(res=>{
res.handleQty = res.qty
res.failedQty = 0;
1 year ago
res.notPassedQty = 0;
res.crackQty = 0;
res.goodQty = this.jobContent.receiveQty;
1 year ago
res.toInventoryStatus = res.inventoryStatus
1 year ago
res.failedReason ="";
res.photos = ""
res.inspectResult =""
res.inspectUser =this.$store.state.user.id
1 year ago
})
this.submitJob(this.jobContent)
1 year ago
}
}
},
submitJob(params){
uni.showLoading({
title: "提交中....",
mask: true
});
console.log("提交参数", JSON.stringify(params));
inspectJobSubmit(params).then(res=>{
if (res.data) {
this.showCommitSuccessMessage("提交成功<br>生成到货检验记录" + res.data, )
} else {
this.showErrorMessage("提交失败"+res.msg)
}
}).catch(error=>{
uni.hideLoading()
this.showErrorMessage(error)
})
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
setTimeout(() => {
uni.navigateTo({
url: './inspectJob'
})
}, 3000)
})
},
1 year ago
}
}
</script>
<style>
</style>