Commit 2faf0283 by chenwq1

fix:更新

1 parent 7666f4b2
......@@ -31,6 +31,7 @@ import TestingScore from "@/views/detection/order/components/TestingScore.vue";
import { DetectionController } from "@/api/DetectionController";
import { CheckCircleFilled } from '@ant-design/icons-vue'
import { TrackHelper } from "@/common/TrackHelper";
import { Modal } from "ant-design-vue";
@Component({
......@@ -205,6 +206,28 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
}
handleNodeList(item: any) {
if (item.id == this.activeNodeId) return;
if (this.hasCurrentTabRequiredUnfilled()) {
Modal.confirm({
title: '提示',
content: '当前一级类目下,存在必填检测项未完成,强制离开将丢失数据,请完成检查后切换tab或离开标签页。',
okText: '强制离开',
cancelText: '继续填写',
onOk: () => {
this.switchNode(item);
},
});
return;
}
this.switchNode(item);
}
hasCurrentTabRequiredUnfilled(): boolean {
const ref: any = Number(this.activeNodeId) === -1 ? this.$refs.testingScoreRef : this.$refs.customizeFormRef;
return !!ref?.hasRequiredUnfilled?.();
}
switchNode(item: any) {
this.activeNodeId = item.id;
if (Number(item.id) > 0) {
this.getInspectionNodeData(this.activeNodeId);
......
......@@ -176,6 +176,45 @@ export default class CustomizeForm extends Vue {
return changedIds.map((id) => this.leafIdToName[id] || String(id));
}
hasRequiredUnfilled(): boolean {
const walk = (nodes: any[] = []): boolean => {
return (nodes || []).some((node) => {
if (node?.childrenNodes && node.childrenNodes.length) {
return walk(node.childrenNodes);
}
return this.isRequiredUnfilled(node);
});
};
return walk(this.columnsList || []);
}
isRequiredUnfilled(item: any): boolean {
if (!item || item.allowNoStructure == 1 && item.resultStatus) return false;
const required = item.required === 1 || (item.interactionType === 'image_upload_and_button_select' && this.hasValue(item.value));
if (!required) return false;
if (item.interactionType === 'image_upload' || item.interactionType === 'video_upload' || item.interactionType === 'button_select') {
return !this.hasJsonArrayValue(item.value);
}
if (item.interactionType === 'image_upload_and_button_select') {
return !this.hasValue(item.value) || !this.hasJsonArrayValue(item.uploadValue);
}
return !this.hasValue(item.value);
}
hasValue(value: any): boolean {
return value != null && value !== '';
}
hasJsonArrayValue(value: any): boolean {
if (!this.hasValue(value)) return false;
try {
const list = typeof value === 'string' ? JSON.parse(value || '[]') : value;
return Array.isArray(list) && list.length > 0;
} catch (e) {
return false;
}
}
sendSaveTrack(modifiedFields: string[]) {
const ctx = TrackHelper.getEditContext();
TrackHelper.send(this.axios, {
......
......@@ -236,6 +236,17 @@ export default class TestingScore extends Vue {
return changed.filter((k) => !ignoreKeys.has(k));
}
hasRequiredUnfilled(): boolean {
return !this.postData.exteriorScore
|| !this.postData.exteriorComment
|| !this.postData.skeletonLevel
|| !this.postData.skeletonComment
|| !this.postData.interiorLevel
|| !this.postData.interiorComment
|| !this.postData.overallScore
|| !this.postData.overallComment;
}
sendSaveTrack(modifiedFields: string[]) {
const ctx = TrackHelper.getEditContext();
TrackHelper.send(this.axios, {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!