Commit 72a0b4c0 authored by mengcheng's avatar mengcheng

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

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