|
|
@@ -190,7 +190,7 @@
|
|
|
value: 1
|
|
|
},
|
|
|
{
|
|
|
- label: '缺陷',
|
|
|
+ label: '异常',
|
|
|
value: -1
|
|
|
}
|
|
|
],
|
|
|
@@ -209,46 +209,86 @@
|
|
|
console.log(this.time);
|
|
|
if (this.time.length > 0) {
|
|
|
this.butLoading = true;
|
|
|
- this.infoData.acceptTime = this.time[0];
|
|
|
- this.infoData.finishTime = this.time[1];
|
|
|
- this.infoData.deviceList = this.infoData.planDeviceList;
|
|
|
- console.log(this.infoData);
|
|
|
- let deviceList = this.infoData.deviceList
|
|
|
+ try {
|
|
|
+ await this.getInfo();
|
|
|
+ } catch (err) {
|
|
|
+ this.butLoading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const body = {
|
|
|
+ ...this.infoData,
|
|
|
+ acceptTime: this.time[0],
|
|
|
+ finishTime: this.time[1],
|
|
|
+ workOrderId: this.getReportWorkOrderId(),
|
|
|
+ deviceList: this.infoData.planDeviceList || []
|
|
|
+ };
|
|
|
+ if (!body.workOrderId) {
|
|
|
+ this.butLoading = false;
|
|
|
+ return this.$message.error('未获取到工单信息,请刷新后再试');
|
|
|
+ }
|
|
|
+ console.log(body);
|
|
|
+ let deviceList = body.deviceList
|
|
|
.map((item) => {
|
|
|
return item.workItems;
|
|
|
})
|
|
|
.flat();
|
|
|
let boolen = deviceList.every((item) => item.status > -1);
|
|
|
- this.infoData.isAbnormal = boolen ? 1 : 0;
|
|
|
- report(this.infoData).then((res) => {
|
|
|
- if (res.code == 0) {
|
|
|
- this.$message.success('报工成功');
|
|
|
- this.visible = false;
|
|
|
- this.$emit('refresh');
|
|
|
- }
|
|
|
- this.butLoading = false;
|
|
|
- }).catch((err) => {
|
|
|
- this.butLoading = false;
|
|
|
- });
|
|
|
+ body.isAbnormal = boolen ? 1 : 0;
|
|
|
+ report(body)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.code == 0) {
|
|
|
+ this.$message.success('报工成功');
|
|
|
+ this.visible = false;
|
|
|
+ this.$emit('refresh');
|
|
|
+ }
|
|
|
+ this.butLoading = false;
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ this.butLoading = false;
|
|
|
+ });
|
|
|
} else {
|
|
|
this.$message.error('请选择实际起始时间');
|
|
|
}
|
|
|
},
|
|
|
// 表格数据
|
|
|
+ getReportWorkOrderId() {
|
|
|
+ const infoWorkOrderId =
|
|
|
+ this.infoData.eamWorkOrderId ||
|
|
|
+ this.infoData.workOrderId ||
|
|
|
+ this.infoData.workOrderMaintenanceId ||
|
|
|
+ this.infoData.eamWorkorderId ||
|
|
|
+ '';
|
|
|
+ if (infoWorkOrderId) {
|
|
|
+ return infoWorkOrderId;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.workOrderId && typeof this.workOrderId === 'object') {
|
|
|
+ return (
|
|
|
+ this.workOrderId.eamWorkOrderId ||
|
|
|
+ this.workOrderId.workOrderId ||
|
|
|
+ this.workOrderId.workOrderMaintenanceId ||
|
|
|
+ this.workOrderId.eamWorkorderId ||
|
|
|
+ this.workOrderId.id ||
|
|
|
+ ''
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return this.workOrderId || '';
|
|
|
+ },
|
|
|
async getInfo() {
|
|
|
this.loading = true;
|
|
|
- let res = await getById(this.planId);
|
|
|
- console.log(res);
|
|
|
- this.infoData = res.data;
|
|
|
- this.infoData.workOrderId = this.workOrderId;
|
|
|
- this.loading = false;
|
|
|
+ try {
|
|
|
+ let res = await getById(this.planId);
|
|
|
+ console.log(res);
|
|
|
+ this.infoData = res.data;
|
|
|
+ this.infoData.workOrderId = this.getReportWorkOrderId();
|
|
|
+ } finally {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
- .page {
|
|
|
- }
|
|
|
.page-title {
|
|
|
background: #fff;
|
|
|
font-size: 18px;
|