Commit 72a0b4c0 authored by mengcheng's avatar mengcheng

优化物料查询,优化代码逻辑

parent 7a0103b3
......@@ -130,7 +130,7 @@ export default {
//获取工作站清单
getWorkstationList(item) {
this.currentFlag = item.index;
this.activeProcess = this.processList[item.index].processCode;
this.activeProcess = this.processList[item.index]?.processCode;
this.$u.api.getWorkstationList({
processCode: this.activeProcess
}).then(res => {
......
......@@ -359,7 +359,6 @@ export default {
tableSelectData: [],
feedbackForms: [],
materialUsageRecordList: [],
materialusagerecordLoading: false,
issusLineList: [],
issusLineColumn: [
{
......@@ -421,9 +420,6 @@ export default {
if (this.vuex_workstation != null) {
this.getTaskList();
}
// if (this.vuex_task != null) {
// this.shiftTask(this.vuex_task.taskId);
// }
},
destroyed() {
uni.$off('switchWorkstation');
......@@ -433,7 +429,7 @@ export default {
changeWorkstation() {
uni.$emit('changeWorkstation');
},
commonClick(oper) {
async commonClick(oper) {
if (['Refresh', 'MaterialUsageRecord'].indexOf(oper) === -1 && this.tableSelectData.length === 0) {
this.$u.toast('请选择工作任务!');
return
......@@ -443,23 +439,20 @@ export default {
this.getTaskList();
break;
case 'StartTask':
this.tableSelectData.forEach((item) => {
this.changeStatus(item.taskId, 'START')
})
await Promise.all(this.tableSelectData.map(async item => {
await this.changeStatus(item.taskId, 'START');
}));
this.getTaskList()
break;
case 'StopTask':
this.stopReason = ''
this.stopReasonVisible = true
break;
case 'FinshTask':
this.tableSelectData.forEach((item) => {
this.changeStatus(item.taskId, 'FINISHED')
})
setTimeout(() => {
await Promise.all(this.tableSelectData.map(async item => {
await this.changeStatus(item.taskId, 'FINISHED');
}));
this.getTaskList()
}, 666)
break;
case 'Prod':
this.doFeedback()
......@@ -482,7 +475,7 @@ export default {
},
getIssusLinebyWorkorderCodes() {
this.issusLineList = []
this.$u.api.getIssusLinebyWorkorderCodes({workorderCodes: ['MO202401180001']}).then(res => {
this.$u.api.getIssusLinebyWorkorderCodes({workorderCodes: this.curTaskInfo.workorderCodes?.split(',')}).then(res => {
if (res.code === 200) {
this.issusLineList = res.rows;
}
......@@ -502,22 +495,21 @@ export default {
knifeTemp() {
this.$u.toast('刀具校验通过!');
},
stopReasonSubmit() {
this.tableSelectData.forEach((item) => {
this.changeStatus(item.taskId, 'PAUSE')
})
async stopReasonSubmit() {
await Promise.all(this.tableSelectData.map(async item => {
await this.changeStatus(item.taskId, 'PAUSE');
}));
this.getTaskList()
},
stopReasonChange(e) {
this.stopReason += e;
},
getTaskList() {
async getTaskList() {
this.form = {}
this.tableData = []
this.$u.api.getTaskList({
const res = await this.$u.api.getTaskList({
workstationId: this.vuex_workstation.workstationId,
// status: 'ISSUEGENERATED'
}).then(res => {
})
if (res.code === 200) {
this.tableData = res.rows.filter(t => !['PREPARE', 'FINISHED'].includes(t.status));
this.curTaskInfo = {}
......@@ -526,10 +518,8 @@ export default {
this.curTaskInfo = this.tableData[0]
// this.getMaterialUsageRecordList();
this.getIssusLinebyWorkorderCodes();
} else {
}
}
});
},
typeChange(index) {
this.currentType = index;
......@@ -537,21 +527,16 @@ export default {
},
getMaterialUsageRecordList() {
this.materialUsageRecordList = []
this.materialusagerecordLoading = true
this.$u.api.materialusagerecordList({
const res = this.$u.api.materialusagerecordList({
workstationId: this.vuex_workstation.workstationId,
depletionMethod: this.currentType + 1,
taskId: this.curTaskInfo.taskId
}).then(res => {
this.materialusagerecordLoading = false
})
if (res.code === 200) {
this.materialUsageRecordList = res.rows;
}
});
},
addMaterialUsageRecord() {
console.log(this.materialRecordInfo.materialBatchNumber)
console.log(this.curTaskInfo.itemCode)
if (this.materialRecordInfo.materialBatchNumber !== this.curTaskInfo.itemCode && this.currentType === 0) {
this.$u.toast('物料不在生产目录中!');
return
......@@ -566,60 +551,42 @@ export default {
this.materialRecordInfo.taskId = this.curTaskInfo.taskId;
this.materialRecordInfo.depletionMethod = this.currentType + 1;
this.materialRecordInfo.workstationId = this.vuex_workstation.workstationId;
this.$u.api.addMaterialusagerecord(this.materialRecordInfo).then(res => {
const res = this.$u.api.addMaterialusagerecord(this.materialRecordInfo)
if (res.code === 200) {
this.materialRecordInfo.quantity = 0;
this.materialRecordInfo.materialBatchNumber = '';
this.$u.toast('上报成功');
this.getIssusLinebyWorkorderCodes();
// this.getMaterialUsageRecordList()
}
});
},
shiftTask(tid) {
this.$u.api.getTaskInfo({
async shiftTask(tid) {
const res = await this.$u.api.getTaskInfo({
taskId: tid,
}).then(res => {
})
if (res.code === 200) {
this.form = res.data;
this.$u.vuex('vuex_task', res.data);
this.form.progress = Math.round((this.form.quantityProduced / this.form.quantity) * 100, 0);
}
});
},
changeStatus(taskId, status) {
// this.form.status = status;
this.$u.api.changeStatus({
async changeStatus(taskId, status) {
const res = await this.$u.api.changeStatus({
taskId: taskId,
status: status,
attr1: this.stopReason
}).then(res => {
})
if (res.code === 200) {
this.$u.toast('变更成功');
uni.$emit('taskStatusChanged'); //任务状态变更
this.getTaskList()
}
});
},
// reset() {
// this.feedbackForm = {
// workstationId: 0,
// userName: this.vuex_user.userName,
// taskId: this.form.taskId,
// feedbackChannel: 'PAD',
// quantity: 0,
// quantityQualify: 0,
// quantityUnqualify: 0
// }
// },
quantityChanged() {
this.feedbackForm.quantity = this.feedbackForm.quantityQualify + this.feedbackForm.quantityUnqualify;
},
doFeedback() {
// this.reset();
this.feedbackForms = []
this.tableSelectData.forEach((item) => {
const feedback = {
this.feedbackForms.push({
...item,
workstationId: item.workstationId,
userName: this.vuex_user.userName,
......@@ -629,28 +596,27 @@ export default {
quantityQualify: 0,
quantityUnqualify: 0,
nickName: this.vuex_user.nickName
}
this.feedbackForms.push(feedback)
})
})
this.open = true;
},
cancel() {
this.open = false;
},
feedback() {
// this.$refs.feedbackForm.validate(valid => {
// // if (valid) {
// // console.log('验证通过');
// // } else {
// // console.log('验证失败');
// // }
// });
this.feedbackForms.forEach((item) => {
async feedback() {
for (const item of this.feedbackForms) {
if (['NORMARL', 'PAUSE'].includes(item.status) && item.quantityUnqualify === 0) {
this.$u.toast('请切换任务状态为开始作业后再进行报工!');
return;
}
if (item.quantityQualify === 0 && item.quantityUnqualify === 0) {
this.$u.toast('请填写合格/不合格产品数量!');
return
return;
}
this.$u.api.feedback({
}
for (const item of this.feedbackForms) {
const res = await this.$u.api.feedback({
taskId: item.taskId,
taskCode: item.taskCode,
quantityFeedback: item.quantity,
......@@ -670,14 +636,13 @@ export default {
workstationCode: item.workstationCode,
workstationName: item.workstationName,
startTime: item.startTime
}).then(res => {
});
this.getTaskList();
if (res.code === 200) {
this.$u.toast('上报成功');
}
});
})
this.getTaskList()
this.open = false;
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment