From f19e5267cc23b1c714dc746239864f33ed715dd9 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 05 十二月 2025 17:55:02 +0800
Subject: [PATCH] 完成地图制作任务功能初版

---
 src/views/fysp/check/components/CompProblemAddOrUpd.vue |  127 ++++++++++++++++++++++++++++--------------
 1 files changed, 84 insertions(+), 43 deletions(-)

diff --git a/src/views/fysp/check/components/CompProblemAddOrUpd.vue b/src/views/fysp/check/components/CompProblemAddOrUpd.vue
index 6fe60eb..8221a0e 100644
--- a/src/views/fysp/check/components/CompProblemAddOrUpd.vue
+++ b/src/views/fysp/check/components/CompProblemAddOrUpd.vue
@@ -1,5 +1,5 @@
 <template>
-  <CompGenericWrapper type="dialog">
+  <CompGenericWrapper type="dialog" append-to-body>
     <template #content>
       <div class="main-container">
         <el-form
@@ -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"
@@ -169,15 +163,17 @@
               </el-col>
             </el-row>
           </el-form-item>
-          <el-form-item>
-            <el-button type="primary" @click="onSubmit" v-show="!readonly"
-              >淇濆瓨</el-button
-            >
-            <el-button @click="$emit('submit', false)" v-show="!readonly"
-              >鍙栨秷</el-button
-            >
-          </el-form-item>
         </el-form>
+        <el-row justify="end">
+          <el-button
+            type="primary"
+            @click="onSubmit"
+            v-show="!readonly"
+            :loading="loading"
+            >淇濆瓨</el-button
+          >
+          <el-button @click="onCancel" v-show="!readonly">鍙栨秷</el-button>
+        </el-row>
         <ArbitraryPhoto
           :max-select="maxSelectImgCount - fileList.length"
           v-model:dialog-visible="anyPhotoDialog"
@@ -220,7 +216,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 +228,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 +263,8 @@
   },
   data() {
     return {
+      // fixme 2024.11.20 瀛愮粍浠跺垵濮嬪寲鏃舵満闂
+      initPropsCount: 0,
       // 鍒濆棰勮鍥剧墖index
       initialIndex: -1,
       // 鍥剧墖閫夋嫨鏈�澶ф暟閲�
@@ -322,7 +318,8 @@
         { id: 0, label: '鐩戞帶璁惧' },
         { id: 1, label: '娌荤悊璁惧' },
         { id: 2, label: '鐢熶骇璁惧' }
-      ]
+      ],
+      loading: false
     };
   },
   watch: {
@@ -332,6 +329,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 +392,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 +427,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);
@@ -510,9 +537,7 @@
     onProAdviseEditChange(value) {},
     onProTypeChange(value) {
       // 榛樿闂鎻忚堪鍜岄棶棰樺缓璁负绗竴涓�
-      this.currProTypeGuid = this.descriptionOptions[0].guid;
-      this.deepCopyProblem.description = this.descriptionOptions[0].description;
-      this.onProDesChange(this.deepCopyProblem.description);
+      this.onProDesChange(this.descriptionOptions[0].description);
       this.deepCopyProblem.advice = this.adviseOptions[0].adName;
       this.deepCopyProblem._adviseEdit = this.deepCopyProblem.advice;
     },
@@ -528,7 +553,8 @@
     onProDesChange(value) {
       let currPro = this.findProByProDesName(value);
       this.currProTypeGuid = currPro.guid;
-      // this.deepCopyProblem.description = currPro.description;
+      this.deepCopyProblem.description = currPro.description;
+      this.deepCopyProblem.ptguid = this.currProTypeGuid;
       this.changeProblemname();
       var adName =
         this.adviseOptions.length == 0 ? '' : this.adviseOptions[0].adName;
@@ -561,7 +587,12 @@
       }
       return true;
     },
+    onCancel() {
+      this.$emit('cancel');
+      this.$emit('update:visible', false);
+    },
     onSubmit() {
+      this.loading = true;
       this.$refs.formRef.validate((valid) => {
         if (valid && this.pictureValidate()) {
           // 鏁版嵁鍑嗗
@@ -588,9 +619,9 @@
           });
           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;
+              deepCopyPro.advise = deepCopyPro._adviseEdit;
               delete deepCopyPro['advice'];
               delete deepCopyPro['mediafileList'];
               delete deepCopyPro['description'];
@@ -601,20 +632,24 @@
               files.forEach((image) => {
                 data.append('images', image);
               });
-              problemApi.updateProblem(data).then((res) => {});
+              problemApi
+                .updateProblem(data)
+                .then((res) => {
+                  this.$emit('submit', false);
+                })
+                .finally(() => {
+                  this.loading = 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
-              ).guid;
+              deepCopyPro.ptGuid = this.currProTypeGuid;
+              delete deepCopyPro['ptguid'];
               deepCopyPro.locationId = deepCopyPro.locationid;
               delete deepCopyPro['locationid'];
               delete deepCopyPro['_adviseEdit'];
@@ -623,9 +658,15 @@
               files.forEach((image) => {
                 data.append('images', image);
               });
-              problemApi.newProblem(data).then((res) => {});
+              problemApi
+                .newProblem(data)
+                .then((res) => {
+                  this.$emit('submit', true);
+                })
+                .finally(() => {
+                  this.loading = false;
+                });
             });
-            this.$emit('submit', true);
           }
         }
       });
@@ -723,7 +764,7 @@
 .row {
   width: 100%;
 }
-::v-deep .el-upload-list--picture-card .el-upload-list__item-thumbnail {
+:deep(.el-upload-list--picture-card .el-upload-list__item-thumbnail) {
   object-fit: cover !important;
 }
 .preview-pic {
@@ -731,11 +772,11 @@
   width: 100%;
   height: 100%;
 }
-::v-deep .el-upload--picture-card {
+:deep(.el-upload--picture-card) {
   display: none;
 }
 /* 闅愯棌el-upload涓婁紶鎴愬姛缁勪欢 */
-::v-deep .el-upload-list__item-status-label {
+:deep(.el-upload-list__item-status-label) {
   display: none !important;
 }
 </style>

--
Gitblit v1.9.3