2024-11-13 19:45:44 +08:00
|
|
|
<template>
|
|
|
|
|
<!-- 扫码报工 -->
|
|
|
|
|
<view>
|
|
|
|
|
<uni-card v-if="!formData.workorder">
|
2024-11-15 11:29:58 +08:00
|
|
|
<!-- <text>{{ '线别:' + lineCode }}</text> -->
|
|
|
|
|
<text>{{ '组别' + groupCode }}</text>
|
|
|
|
|
<ScanInput @scanConfirm="scanConfirm" placeholder="请扫报工码开始报工"></ScanInput>
|
2024-11-13 19:45:44 +08:00
|
|
|
</uni-card>
|
2024-11-15 11:29:58 +08:00
|
|
|
<!-- <uni-card v-if="formData.workorder && formData.status === 2">
|
2024-11-13 19:45:44 +08:00
|
|
|
<text>{{ '线别:' + lineCode }}</text>
|
|
|
|
|
<text style="margin-left: 20px">{{ '组别' + groupCode }}</text>
|
2024-11-15 11:29:58 +08:00
|
|
|
<ScanInput @scanConfirm="scanConfirm2" placeholder="请扫报工码结束报工"></ScanInput>
|
|
|
|
|
</uni-card> -->
|
2024-11-13 19:45:44 +08:00
|
|
|
<uni-card v-if="formData.workorder">
|
|
|
|
|
<uni-forms :modelValue="formData" label-width="80px" label-align="right">
|
|
|
|
|
<uni-forms-item label="工单号" name="workorder">
|
|
|
|
|
<span>{{ formData.workorder }}</span>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="产品编号" name="productionCode">
|
|
|
|
|
<span>{{ formData.productionCode }}</span>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="产品名称" name="productionName">
|
|
|
|
|
<span>{{ formData.productionName }}</span>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="规格" name="specification">
|
|
|
|
|
<span>{{ formData.specification }}</span>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="工单状态" name="status">
|
|
|
|
|
<span style="color: grey" v-if="formData.status === 1">未开始</span>
|
|
|
|
|
<span style="color: blue" v-if="formData.status === 2">进行中</span>
|
|
|
|
|
<span style="color: green" v-if="formData.status === 3">已完成</span>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="计划生产" name="deliveryNum">
|
|
|
|
|
<span>{{ formData.deliveryNum }}</span>
|
|
|
|
|
</uni-forms-item>
|
2024-11-15 11:29:58 +08:00
|
|
|
<uni-forms-item v-if="formData.status === 2" label="报工数" name="finishedNum">
|
|
|
|
|
<uni-number-box class="input-item" :width="200" v-model="finishedNum" placeholder="请输入报工数" :max="99999" ></uni-number-box>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item v-if="formData.status === 2" label="">
|
|
|
|
|
<span class="row-box">
|
|
|
|
|
<button @click="addFinishedNum">增加</button>
|
|
|
|
|
<button @click="reduceFinishedNum">减少</button>
|
|
|
|
|
<!-- <button @click="doStartWorkOrder">暂存</button> -->
|
|
|
|
|
</span>
|
2024-11-13 19:45:44 +08:00
|
|
|
</uni-forms-item>
|
|
|
|
|
</uni-forms>
|
|
|
|
|
</uni-card>
|
2024-11-15 11:29:58 +08:00
|
|
|
<view class="bottom-box" v-if="formData.workorder">
|
|
|
|
|
<button v-if="formData.status === 1" :disabled="loading" type="primary" @click="doStartWorkOrder">开始工单</button>
|
|
|
|
|
<button v-if="formData.status === 2" :disabled="loading" type="warn" @click="doFinfishWorkOrder2">完成工单</button>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 报工数自动修改 -->
|
|
|
|
|
<view>
|
|
|
|
|
<!-- 输入框示例 -->
|
|
|
|
|
<uni-popup ref="inputDialog" type="dialog">
|
|
|
|
|
<uni-popup-dialog
|
|
|
|
|
ref="inputClose"
|
|
|
|
|
mode="input"
|
|
|
|
|
:title="numModel === 1?'增加报工数':'减少报工数'"
|
|
|
|
|
:value="0"
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
|
|
|
|
@confirm="dialogInputConfirm"
|
|
|
|
|
></uni-popup-dialog>
|
|
|
|
|
</uni-popup>
|
2024-11-13 19:45:44 +08:00
|
|
|
</view>
|
2024-11-15 11:29:58 +08:00
|
|
|
<!-- 完成工单校验 -->
|
|
|
|
|
<!-- <view>
|
|
|
|
|
<uni-popup ref="inputDialog2" type="dialog">
|
|
|
|
|
<uni-popup-dialog
|
|
|
|
|
ref="inputClose2"
|
|
|
|
|
mode="input"
|
|
|
|
|
title="扫"
|
|
|
|
|
value=""
|
|
|
|
|
placeholder="请扫报工码校验"
|
|
|
|
|
@confirm="dialogInputConfirm2"
|
|
|
|
|
></uni-popup-dialog>
|
|
|
|
|
</uni-popup>
|
|
|
|
|
</view> -->
|
2024-11-13 19:45:44 +08:00
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-11-15 11:29:58 +08:00
|
|
|
import { errorProofingAndReportingWork,updateProReportwork,noErrorProofingAndReportingReport } from '@/api/workorder/proreportwork.js';
|
|
|
|
|
import { GetWorkOrderDetail, startWorkOrder, finishWorkOrder } from '@/api/workorder/proworkorder.js';
|
2024-11-13 19:45:44 +08:00
|
|
|
export default {
|
|
|
|
|
onLoad: function (option) {
|
|
|
|
|
this.lineCode = option.lineCode;
|
|
|
|
|
this.groupCode = option.groupCode;
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
lineCode: '',
|
|
|
|
|
groupCode: '',
|
|
|
|
|
loading: false,
|
|
|
|
|
formData: {
|
|
|
|
|
id: null,
|
|
|
|
|
finishNum: 0
|
2024-11-15 11:29:58 +08:00
|
|
|
},
|
|
|
|
|
finishedNum:0,
|
|
|
|
|
// 按钮模式 1-加 2-减去
|
|
|
|
|
numModel:1,
|
|
|
|
|
inputDialog:null,
|
|
|
|
|
inputClose:null,
|
|
|
|
|
inputDialog2:null,
|
|
|
|
|
inputClose2:null,
|
2024-11-13 19:45:44 +08:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2024-11-15 11:29:58 +08:00
|
|
|
// finishedNumInputChange(e){
|
|
|
|
|
// this.formData.finishedNum = e.detail.value;
|
|
|
|
|
// },
|
|
|
|
|
// 第一次扫工单码结果
|
2024-11-13 19:45:44 +08:00
|
|
|
async scanConfirm(val) {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
if (val === '' || val === null) {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let strArray = val.split('^');
|
|
|
|
|
const params = {
|
|
|
|
|
workorder: strArray[0]
|
|
|
|
|
};
|
|
|
|
|
let res1 = await GetWorkOrderDetail(params);
|
2024-11-15 11:29:58 +08:00
|
|
|
if (res1 === null || res1.code !== 200) {
|
2024-11-13 19:45:44 +08:00
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'error',
|
|
|
|
|
title: '标签异常'
|
|
|
|
|
});
|
|
|
|
|
this.loading = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-11-15 11:29:58 +08:00
|
|
|
if (res1.data.groupCode !== this.groupCode) {
|
2024-11-13 19:45:44 +08:00
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'none',
|
2024-11-15 11:29:58 +08:00
|
|
|
title: '扫码结果异常,该工单不属于此组'
|
2024-11-13 19:45:44 +08:00
|
|
|
});
|
|
|
|
|
this.loading = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.formData = res1.data;
|
2024-11-15 11:29:58 +08:00
|
|
|
this.finishedNum = res1.data.finishNum ?? 0;
|
2024-11-13 19:45:44 +08:00
|
|
|
this.loading = false;
|
|
|
|
|
},
|
2024-11-15 11:29:58 +08:00
|
|
|
// 更新工单信息
|
|
|
|
|
updateWorkOrderDetail(params) {
|
|
|
|
|
GetWorkOrderDetail(params).then((res) => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.formData = res.data;
|
|
|
|
|
|
|
|
|
|
// this.formData.finishedNum = res.data.nu,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 开始工单
|
|
|
|
|
doStartWorkOrder() {
|
|
|
|
|
this.loading = true;
|
2024-11-13 19:45:44 +08:00
|
|
|
const params = {
|
2024-11-15 11:29:58 +08:00
|
|
|
workorder: this.formData.workorder
|
2024-11-13 19:45:44 +08:00
|
|
|
};
|
2024-11-15 11:29:58 +08:00
|
|
|
startWorkOrder(params).then((res) => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'success',
|
|
|
|
|
title: '工单开始成功'
|
|
|
|
|
});
|
|
|
|
|
this.updateWorkOrderDetail(params);
|
|
|
|
|
this.loading = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 报工数增加指定数
|
|
|
|
|
addFinishedNum() {
|
|
|
|
|
this.numModel = 1
|
|
|
|
|
this.$refs.inputDialog.open()
|
|
|
|
|
},
|
|
|
|
|
// 报工数减少指定数
|
|
|
|
|
reduceFinishedNum() {
|
|
|
|
|
this.numModel = 2
|
|
|
|
|
this.$refs.inputDialog.open()
|
|
|
|
|
},
|
|
|
|
|
// 提交1
|
|
|
|
|
dialogInputConfirm(val){
|
|
|
|
|
let oldNum = this.finishedNum ?? 0
|
|
|
|
|
if(this.numModel === 1){
|
|
|
|
|
this.finishedNum = (oldNum * 1) + (val * 1)
|
|
|
|
|
}else{
|
|
|
|
|
this.finishedNum = (oldNum * 1) - (val * 1)
|
|
|
|
|
if(this.finishedNum < 0){
|
|
|
|
|
this.finishedNum = 0
|
|
|
|
|
}
|
2024-11-13 19:45:44 +08:00
|
|
|
}
|
2024-11-15 11:29:58 +08:00
|
|
|
},
|
|
|
|
|
// NODO 打开扫码报工
|
|
|
|
|
openDialog2() {
|
|
|
|
|
this.$refs.inputDialog2.open()
|
|
|
|
|
},
|
|
|
|
|
// NODO 提交2
|
|
|
|
|
dialogInputConfirm2(val){
|
|
|
|
|
const that = this
|
|
|
|
|
if (val === '' || val === null) {
|
2024-11-13 19:45:44 +08:00
|
|
|
uni.showToast({
|
2024-11-15 11:29:58 +08:00
|
|
|
icon: 'error',
|
|
|
|
|
title: '报工号异常'
|
2024-11-13 19:45:44 +08:00
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-11-15 11:29:58 +08:00
|
|
|
let strArray = val.split('^');
|
|
|
|
|
if(strArray[0] != this.formData.workorder){
|
2024-11-13 19:45:44 +08:00
|
|
|
uni.showToast({
|
2024-11-15 11:29:58 +08:00
|
|
|
icon: 'error',
|
|
|
|
|
title: '报工号异常'
|
2024-11-13 19:45:44 +08:00
|
|
|
});
|
2024-11-15 11:29:58 +08:00
|
|
|
this.loading = false;
|
2024-11-13 19:45:44 +08:00
|
|
|
return;
|
|
|
|
|
}
|
2024-11-15 11:29:58 +08:00
|
|
|
this.loading = true;
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title:'报工中……'
|
2024-11-13 19:45:44 +08:00
|
|
|
})
|
2024-11-15 11:29:58 +08:00
|
|
|
// 不防错报工
|
2024-11-13 19:45:44 +08:00
|
|
|
const params = {
|
2024-11-15 11:29:58 +08:00
|
|
|
workorder:this.formData.workorder,
|
|
|
|
|
reportNum:this.finishedNum
|
2024-11-13 19:45:44 +08:00
|
|
|
}
|
2024-11-15 11:29:58 +08:00
|
|
|
|
|
|
|
|
noErrorProofingAndReportingReport(params).then(res=>{
|
2024-11-13 19:45:44 +08:00
|
|
|
if(res.code === 200){
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'success',
|
2024-11-15 11:29:58 +08:00
|
|
|
title: '报工成功',
|
|
|
|
|
duration:2000,
|
|
|
|
|
success() {
|
|
|
|
|
const params2 = {
|
|
|
|
|
workorder: that.formData.workorder
|
|
|
|
|
};
|
|
|
|
|
finishWorkOrder(params2).then((res) => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'success',
|
|
|
|
|
title: '完成工单'
|
|
|
|
|
});
|
|
|
|
|
that.loading = false;
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
uni.navigateBack(-1)
|
|
|
|
|
},2000)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-11-13 19:45:44 +08:00
|
|
|
});
|
|
|
|
|
}
|
2024-11-15 11:29:58 +08:00
|
|
|
}).finally(()=>{
|
|
|
|
|
this.loading = true;
|
|
|
|
|
uni.hideLoading();
|
2024-11-13 19:45:44 +08:00
|
|
|
})
|
|
|
|
|
},
|
2024-11-15 11:29:58 +08:00
|
|
|
// NODO 完成工单
|
2024-11-13 19:45:44 +08:00
|
|
|
doFinfishWorkOrder() {
|
|
|
|
|
const params = {
|
2024-11-15 11:29:58 +08:00
|
|
|
workorder: this.formData.workorder
|
|
|
|
|
};
|
|
|
|
|
finishWorkOrder(params).then((res) => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'success',
|
|
|
|
|
title: '工单完成成功'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.updateWorkOrderDetail(params);
|
|
|
|
|
this.loading = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 不放错 报工 + 完成工单
|
|
|
|
|
doFinfishWorkOrder2(){
|
|
|
|
|
let that = this
|
|
|
|
|
this.loading = true;
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title:'报工中……'
|
|
|
|
|
})
|
|
|
|
|
// 不防错报工
|
|
|
|
|
const params = {
|
|
|
|
|
workorder:this.formData.workorder,
|
|
|
|
|
reportNum:this.finishedNum
|
2024-11-13 19:45:44 +08:00
|
|
|
}
|
2024-11-15 11:29:58 +08:00
|
|
|
|
|
|
|
|
noErrorProofingAndReportingReport(params).then(res=>{
|
2024-11-13 19:45:44 +08:00
|
|
|
if(res.code === 200){
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'success',
|
2024-11-15 11:29:58 +08:00
|
|
|
title: '报工成功',
|
|
|
|
|
duration:2000,
|
|
|
|
|
success() {
|
|
|
|
|
const params2 = {
|
|
|
|
|
workorder: that.formData.workorder
|
|
|
|
|
};
|
|
|
|
|
finishWorkOrder(params2).then((res) => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'success',
|
|
|
|
|
title: '完成工单'
|
|
|
|
|
});
|
|
|
|
|
that.loading = false;
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
uni.navigateBack(-1)
|
|
|
|
|
},2000)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-11-13 19:45:44 +08:00
|
|
|
});
|
|
|
|
|
}
|
2024-11-15 11:29:58 +08:00
|
|
|
}).finally(()=>{
|
|
|
|
|
this.loading = true;
|
|
|
|
|
uni.hideLoading();
|
2024-11-13 19:45:44 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.row-box {
|
|
|
|
|
display: flex;
|
|
|
|
|
}
|
|
|
|
|
span {
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
}
|
2024-11-15 11:29:58 +08:00
|
|
|
.input-item {
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
}
|
2024-11-13 19:45:44 +08:00
|
|
|
</style>
|