From 3d6addd2c0817b30bd328605cb048ca9698742a6 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 28 二月 2025 16:50:17 +0800
Subject: [PATCH] 修复新建子任务时,未提前建立日任务的bug

---
 src/views/fysp/check/components/CompProblemAddOrUpd.vue |   81 +++++++++++++++++++++++++++-------------
 1 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/src/views/fysp/check/components/CompProblemAddOrUpd.vue b/src/views/fysp/check/components/CompProblemAddOrUpd.vue
index 6fe60eb..b1e49ff 100644
--- a/src/views/fysp/check/components/CompProblemAddOrUpd.vue
+++ b/src/views/fysp/check/components/CompProblemAddOrUpd.vue
@@ -80,12 +80,6 @@
             </el-select>
           </el-form-item>
           <el-form-item
-            v-show="
-              problem &&
-              problem.guid &&
-              deepCopyProblem.advice &&
-              deepCopyProblem.advice != ''
-            "
             label="闂寤鸿淇"
             prop="_adviseEdit"
             :disabled="false"
@@ -173,9 +167,7 @@
             <el-button type="primary" @click="onSubmit" v-show="!readonly"
               >淇濆瓨</el-button
             >
-            <el-button @click="$emit('submit', false)" v-show="!readonly"
-              >鍙栨秷</el-button
-            >
+            <el-button @click="onCancel" v-show="!readonly">鍙栨秷</el-button>
           </el-form-item>
         </el-form>
         <ArbitraryPhoto
@@ -220,7 +212,6 @@
   </CompGenericWrapper>
 </template>
 <script>
-import CompGenericWrapper from './CompGenericWrapper.vue';
 import ArbitraryPhoto from './ArbitraryPhoto.vue';
 import CompLedgerPhoto from './CompLedgerPhoto.vue';
 import CompDevicePhoto from './CompDevicePhoto.vue';
@@ -233,12 +224,11 @@
 import deviceApi from '@/api/fysp/deviceApi';
 import { useFormConfirm } from '@/composables/formConfirm';
 export default {
-  emits: ['submit'],
+  emits: ['submit', 'cancel'],
   components: {
     ArbitraryPhoto,
     CompDevicePhoto,
-    CompLedgerPhoto,
-    CompGenericWrapper
+    CompLedgerPhoto
   },
   props: {
     readonly: {
@@ -269,6 +259,8 @@
   },
   data() {
     return {
+      // fixme 2024.11.20 瀛愮粍浠跺垵濮嬪寲鏃舵満闂
+      initPropsCount: 0,
       // 鍒濆棰勮鍥剧墖index
       initialIndex: -1,
       // 鍥剧墖閫夋嫨鏈�澶ф暟閲�
@@ -332,6 +324,38 @@
         this.pictureValidate();
       },
       deep: true
+    },
+    initPropsCount: {
+      handler(nv, ov) {
+        if (nv >= 3) {
+          this.initOptions();
+        }
+      },
+      immediate: true
+    },
+    problem: {
+      handler(nv, ov) {
+        if (nv != null && nv != undefined) {
+          this.initPropsCount++;
+        }
+      },
+      immediate: true
+    },
+    topTask: {
+      handler(nv, ov) {
+        if (nv != null && nv != undefined) {
+          this.initPropsCount++;
+        }
+      },
+      immediate: true
+    },
+    subtask: {
+      handler(nv, ov) {
+        if (nv != null && nv != undefined) {
+          this.initPropsCount++;
+        }
+      },
+      immediate: true
     }
   },
   computed: {
@@ -363,15 +387,13 @@
       return array;
     }
   },
-  mounted() {
-    this.initOptions();
-  },
+  mounted() {},
   methods: {
     onProAdviseChange(value) {
       this.deepCopyProblem._adviseEdit = this.deepCopyProblem.advice;
     },
     handlePictureCardPreview(uploadFile) {
-      this.initialIndex = this.fileList.indexOf(uploadFile)
+      this.initialIndex = this.fileList.indexOf(uploadFile);
       this.previewDialogVisible = true;
       this.previewDialogImageUrl = uploadFile.url;
     },
@@ -400,7 +422,7 @@
         districtCode: this.topTask.districtcode
       };
       problemApi.fetchProblemType(data).then((res) => {
-        this.problemTypeList = res.data;
+        this.problemTypeList = res;
 
         if (this.type == 1) {
           let currProName = String(this.problem.problemname);
@@ -561,6 +583,10 @@
       }
       return true;
     },
+    onCancel() {
+      this.$emit('cancel');
+      this.$emit('update:visible', false);
+    },
     onSubmit() {
       this.$refs.formRef.validate((valid) => {
         if (valid && this.pictureValidate()) {
@@ -588,7 +614,7 @@
           });
           if (this.type == 1) {
             let deleteImgCopy = this.deleteImg;
-            fileUtil.getImageFiles(picUrls, function (files) {
+            fileUtil.getImageFiles(picUrls, (files) => {
               data.append('deleteImg', deleteImgCopy);
               deepCopyPro.advise = deepCopyPro.advice;
               delete deepCopyPro['advice'];
@@ -601,19 +627,19 @@
               files.forEach((image) => {
                 data.append('images', image);
               });
-              problemApi.updateProblem(data).then((res) => {});
+              problemApi.updateProblem(data).then((res) => {
+                this.$emit('submit', false);
+              });
             });
-            this.$emit('submit', false);
           } else {
             const deepCopySubTask = useCloned(this.subtask).cloned.value;
-            const that = this;
-            fileUtil.getImageFiles(picUrls, function (files) {
+            fileUtil.getImageFiles(picUrls, (files) => {
               deepCopyPro.insGuid = deepCopySubTask.insGuid;
               delete deepCopyPro['description'];
               deepCopyPro.proName = deepCopyPro.problemname;
               delete deepCopyPro['problemname'];
-              deepCopyPro.ptGuid = that.findProTypeByGuid(
-                that.currProTypeGuid
+              deepCopyPro.ptGuid = this.findProTypeByGuid(
+                this.currProTypeGuid
               ).guid;
               deepCopyPro.locationId = deepCopyPro.locationid;
               delete deepCopyPro['locationid'];
@@ -623,9 +649,10 @@
               files.forEach((image) => {
                 data.append('images', image);
               });
-              problemApi.newProblem(data).then((res) => {});
+              problemApi.newProblem(data).then((res) => {
+                this.$emit('submit', true);
+              });
             });
-            this.$emit('submit', true);
           }
         }
       });

--
Gitblit v1.9.3