From c40f4c1267dae4fcf27dbbd75ea83014fba87783 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 15 七月 2025 15:28:21 +0800
Subject: [PATCH] 新增联合执法清单

---
 src/views/fysp/check/components/CompProblemAddOrUpd.vue |  750 ++++++++++++++++++++++++++++++---------------------------
 1 files changed, 399 insertions(+), 351 deletions(-)

diff --git a/src/views/fysp/check/components/CompProblemAddOrUpd.vue b/src/views/fysp/check/components/CompProblemAddOrUpd.vue
index 00f7751..dbd66dc 100644
--- a/src/views/fysp/check/components/CompProblemAddOrUpd.vue
+++ b/src/views/fysp/check/components/CompProblemAddOrUpd.vue
@@ -1,154 +1,220 @@
 <template>
-  <div class="main-container">
-    <el-form :model="problem" label-width="auto" style="max-width: 95%">
-      <el-form-item label="闂绫诲瀷" prop="proType">
-        <el-select v-model="proType" @change="onProTypeChange" class="row" :disabled="readonly">
-          <el-option
-            v-for="item in problemTypeOptions"
-            :key="item.typeid"
-            :label="item.typename"
-            :value="item.typename"
-          />
-        </el-select>
-      </el-form-item>
-      <el-form-item label="闂鎻忚堪" prop="description">
-        <el-select
-          v-model="deepCopyProblem.description"
-          @change="onProDesChange"
-          class="row"
-          :disabled="readonly"
+  <CompGenericWrapper type="dialog" append-to-body>
+    <template #content>
+      <div class="main-container">
+        <el-form
+          :rules="rules"
+          :model="deepCopyProblem"
+          label-width="auto"
+          style="max-width: 95%"
+          ref="formRef"
         >
-          <el-option
-            v-for="item in descriptionOptions"
-            :key="item.guid"
-            :label="item.description"
-            :value="item.guid"
-          />
-        </el-select>
-      </el-form-item>
-      <el-form-item label="闂浣嶇疆" prop="locationid">
-        <el-select
-          v-model="deepCopyProblem.locationid"
-          @change="onProLocationChange"
-          class="row"
-          :disabled="readonly"
+          <el-form-item label="闂浣嶇疆" prop="locationid">
+            <el-select
+              v-model="deepCopyProblem.locationid"
+              @change="onProLocationChange"
+              class="row"
+              :disabled="readonly"
+            >
+              <el-option
+                v-for="item in posList"
+                :key="item.index"
+                :label="item.text"
+                :value="item.index"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="闂绫诲瀷" prop="_proType">
+            <el-select
+              v-model="deepCopyProblem._proType"
+              @change="onProTypeChange"
+              class="row"
+              :disabled="readonly"
+            >
+              <el-option
+                v-for="item in problemTypeOptions"
+                :key="item.typeid"
+                :label="item.typename"
+                :value="item.typename"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="闂鎻忚堪" prop="description">
+            <el-select
+              v-model="deepCopyProblem.description"
+              @change="onProDesChange"
+              class="row"
+              :disabled="readonly"
+            >
+              <el-option
+                v-for="item in descriptionOptions"
+                :key="item.guid"
+                :label="item.description"
+                :value="item.description"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="琛ュ厖璇存槑" :disabled="readonly" prop="proRemark">
+            <el-input
+              v-model="proRemark"
+              type="textarea"
+              @change="onProRemarkChange"
+              class="row"
+              placeholder="璇疯緭鍏�"
+              :disabled="readonly"
+            />
+          </el-form-item>
+          <el-form-item label="闂寤鸿" prop="advice">
+            <el-select
+              v-model="deepCopyProblem.advice"
+              class="row"
+              :disabled="readonly"
+              @change="onProAdviseChange"
+            >
+              <el-option
+                v-for="item in adviseOptions"
+                :key="item.adGuid"
+                :label="item.adName"
+                :value="item.adName"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item
+            label="闂寤鸿淇"
+            prop="_adviseEdit"
+            :disabled="false"
+          >
+            <el-input
+              v-model="deepCopyProblem._adviseEdit"
+              type="textarea"
+              @change="onProAdviseEditChange"
+              class="row"
+              placeholder="璇疯緭鍏ラ棶棰樺缓璁慨姝�"
+              :disabled="readonly"
+            />
+          </el-form-item>
+          <el-form-item label="闂鍥剧墖">
+            <el-row>
+              <el-col>
+                <el-button
+                  @click="chosePicFromAnyPic"
+                  v-show="!readonly"
+                  :disabled="fileList.length >= 3"
+                  >浠庡満鏅浘鐗囬�夊彇</el-button
+                >
+                <el-button
+                  @click="chosePicFromDevicePic"
+                  v-show="!readonly"
+                  :disabled="fileList.length >= 3"
+                  >浠庤澶囧浘鐗囬�夊彇</el-button
+                >
+                <el-button
+                  @click="chosePicFromLedgerPic"
+                  v-show="!readonly"
+                  :disabled="fileList.length >= 3"
+                  >浠庡彴璐﹂�夊彇</el-button
+                >
+                <el-button
+                  @click="choseChangePic"
+                  v-show="!readonly"
+                  :disabled="fileList.length >= 3"
+                  >浠庢枃浠跺す閫夊彇</el-button
+                >
+              </el-col>
+              <el-col v-if="!fileList || fileList.length <= 0">
+                <el-empty
+                  style="height: 145px"
+                  class="img-upload"
+                  description="璇锋坊鍔犲浘鐗�"
+                />
+              </el-col>
+              <el-col>
+                <el-upload
+                  v-show="fileList && fileList.length > 0"
+                  class="img-upload"
+                  ref="uploadRef"
+                  v-model:file-list="fileList"
+                  list-type="picture-card"
+                  multiple
+                  :auto-upload="false"
+                  crossorigin="Anonymous"
+                  :before-remove="beforeRemoveFile"
+                  :on-preview="handlePictureCardPreview"
+                  :disabled="readonly"
+                  accept="image/*"
+                >
+                  <template #trigger v-if="fileList.length < 3 && !readonly">
+                    <el-button
+                      v-if="fileList.length < 3"
+                      type="primary"
+                      id="uploadBtnId"
+                      style="display: none"
+                    ></el-button>
+                    <el-icon>
+                      <Plus />
+                    </el-icon>
+                  </template>
+                  <template #tip>
+                    <div style="color: #f56c6c">
+                      鏈�灏戜笂浼犱竴寮犲浘鐗囷紝鏈�澶氶�夋嫨涓夊紶鍥剧墖
+                    </div>
+                  </template>
+                </el-upload>
+              </el-col>
+            </el-row>
+          </el-form-item>
+        </el-form>
+        <el-row justify="end">
+          <el-button type="primary" @click="onSubmit" v-show="!readonly"
+            >淇濆瓨</el-button
+          >
+          <el-button @click="onCancel" v-show="!readonly">鍙栨秷</el-button>
+        </el-row>
+        <ArbitraryPhoto
+          :max-select="maxSelectImgCount - fileList.length"
+          v-model:dialog-visible="anyPhotoDialog"
+          @submit="handleSelectedAnyPhono"
+          :subtask="subtask"
+          :defaultFile="fileList"
+          ref="arbitraryPhotoRef"
         >
-          <el-option
-            v-for="item in posList"
-            :key="item.index"
-            :label="item.text"
-            :value="item.index"
-          />
-        </el-select>
-      </el-form-item>
-      <el-form-item label="闂寤鸿" prop="advise">
-        <el-select v-model="deepCopyProblem.advise" class="row" :disabled="readonly">
-          <el-option
-            v-for="item in adviseOptions"
-            :key="item.adGuid"
-            :label="item.adName"
-            :value="item.adName"
-          />
-        </el-select>
-      </el-form-item>
-      <el-form-item label="琛ュ厖璇存槑" :disabled="readonly" prop="proRemark">
-        <el-input
-          v-model="proRemark"
-          type="textarea"
-          @change="onProRemarkChange"
-          class="row"
-          placeholder="璇疯緭鍏�"
+        </ArbitraryPhoto>
+        <CompLedgerPhoto
+          :max-select="maxSelectImgCount - fileList.length"
+          v-model:dialog-visible="ledgerPicDialog"
+          @submit="handleLedgerPicPhono"
+          :subtask="subtask"
+          :defaultFile="fileList"
+          ref="ledgerPhotoRef"
+        ></CompLedgerPhoto>
+        <CompDevicePhoto
+          :max-select="maxSelectImgCount - fileList.length"
+          v-model:dialog-visible="deiveceImgDialog"
+          @submit="handleSelectedDevicePhono"
+          :subtask="subtask"
+          :defaultFile="fileList"
+          ref="deiveceImgDialogRef"
+        >
+        </CompDevicePhoto>
+        <el-image-viewer
+          v-if="previewDialogVisible"
+          :url-list="fileList.map((item) => item.url)"
+          :initial-index="initialIndex"
+          @close="previewDialogVisible = false"
+          alt="棰勮"
+          class="preview-pic"
         />
-      </el-form-item>
-      <div class="t-card_item">
-        闂鍥剧墖&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-        <div>
-          <el-button @click="chosePicFromAnyPic" v-show="!readonly">浠庝换鎰忓浘鐗囬�夊彇</el-button>
-          <el-button @click="chosePicFromDevicePic" v-show="!readonly">浠庤澶囧浘鐗囬�夊彇</el-button>
-          <el-button @click="chosePicFromLedgerPic" v-show="!readonly">浠庡彴璐﹂�夊彇</el-button>
-          <el-button @click="choseChangePic" v-show="!readonly">浠庢枃浠跺す閫夊彇</el-button>
-        </div>
+        <!-- <el-dialog v-model="previewDialogVisible">
+          
+        </el-dialog> -->
       </div>
-      <el-upload
-        class="img-upload"
-        ref="uploadRef"
-        v-model:file-list="fileList"
-        list-type="picture-card"
-        multiple
-        :auto-upload="false"
-        crossorigin="Anonymous"
-        :before-remove="beforeRemoveFile"
-        :on-preview="handlePictureCardPreview"
-        :disabled="readonly"
-        accept="image/*"
-      >
-        <el-button type="primary" id="uploadBtnId" style="display: none"></el-button>
-        <el-icon>
-          <Plus />
-        </el-icon>
-      </el-upload>
-      <el-form-item>
-        <el-button type="primary" @click="onSubmit" v-show="!readonly">淇濆瓨</el-button>
-        <el-button @click="this.$emit('submited', false)" v-show="!readonly">鍙栨秷</el-button>
-      </el-form-item>
-    </el-form>
-    <el-dialog
-      title="浠绘剰鍥剧墖"
-      width="80%"
-      v-model="anyPhotoDialog"
-      :before-close="beforeAnyPhotoDialogclose"
-      class="dialog_style"
-    >
-      <ArbitraryPhoto
-        v-if="anyPhotoDialog"
-        @selectByAnyPhonoEvent="handleSelectedAnyPhono"
-        :subtask="subtask"
-        :defaultFile="fileList"
-        ref="arbitraryPhotoRef"
-      >
-      </ArbitraryPhoto>
-    </el-dialog>
-    <el-dialog
-      width="80%"
-      v-model="ledgerPicDialog"
-      :before-close="beforeLedgerPicDialogclose"
-      class="dialog_style"
-    >
-      <LedgerPic
-        v-if="ledgerPicDialog"
-        @selectByLedgerPicEvent="handleLedgerPicPhono"
-        :month="month"
-        :subtask="subtask"
-        :defaultFile="fileList"
-        ref="ledgerPicRef"
-      >
-      </LedgerPic>
-    </el-dialog>
-    <el-dialog
-      title="璁惧鍥剧墖"
-      width="80%"
-      v-model="deiveceImgDialog"
-      :before-close="beforeDeiveceImgDialogclose"
-      class="dialog_style"
-    >
-      <CompDevicePhono
-        v-if="deiveceImgDialog"
-        @selectPhonoEvent="handleSelectedDevicePhono"
-        :imgPathsDataSource="deviceImgObjList"
-        :defaultFile="fileList"
-        ref="deiveceImgDialogRef"
-      >
-      </CompDevicePhono>
-    </el-dialog>
-    <el-dialog v-model="previewDialogVisible">
-      <img w-full :src="previewDialogImageUrl" alt="棰勮" class="preview-pic"/>
-    </el-dialog>
-  </div>
+    </template>
+  </CompGenericWrapper>
 </template>
 <script>
 import ArbitraryPhoto from './ArbitraryPhoto.vue';
-import LedgerPic from './CompLedgerPic.vue';
-import CompDevicePhono from './CompDevicePhono.vue';
+import CompLedgerPhoto from './CompLedgerPhoto.vue';
+import CompDevicePhoto from './CompDevicePhoto.vue';
 import problemApi from '@/api/fysp/problemApi.js';
 
 import { $fysp } from '@/api/index.js';
@@ -156,11 +222,13 @@
 import { useCloned } from '@vueuse/core';
 import { ElMessage } from 'element-plus';
 import deviceApi from '@/api/fysp/deviceApi';
+import { useFormConfirm } from '@/composables/formConfirm';
 export default {
+  emits: ['submit', 'cancel'],
   components: {
     ArbitraryPhoto,
-    LedgerPic,
-    CompDevicePhono
+    CompDevicePhoto,
+    CompLedgerPhoto
   },
   props: {
     readonly: {
@@ -191,6 +259,12 @@
   },
   data() {
     return {
+      // fixme 2024.11.20 瀛愮粍浠跺垵濮嬪寲鏃舵満闂
+      initPropsCount: 0,
+      // 鍒濆棰勮鍥剧墖index
+      initialIndex: -1,
+      // 鍥剧墖閫夋嫨鏈�澶ф暟閲�
+      maxSelectImgCount: 3,
       previewDialogVisible: false,
       previewDialogImageUrl: '',
       // 璁惧鍥剧墖鍒楄〃
@@ -215,11 +289,26 @@
       month: -1,
       ledgerPicDialog: false,
       rules: {
-        proType: { required: true, message: '闂绫诲瀷涓嶈兘涓虹┖', trigger: 'change' },
-        description: { required: true, message: '闂鎻忚堪涓嶈兘涓虹┖', trigger: 'change' },
-        locationid: { required: true, message: '闂浣嶇疆涓嶈兘涓虹┖', trigger: 'change' },
-        advise: { required: true, message: '闂寤鸿涓嶈兘涓虹┖', trigger: 'change' },
-        proRemark: { required: true, message: '琛ュ厖璇存槑涓嶈兘涓虹┖', trigger: 'change' }
+        _proType: {
+          required: true,
+          message: '闂绫诲瀷涓嶈兘涓虹┖',
+          trigger: 'change'
+        },
+        description: {
+          required: true,
+          message: '闂鎻忚堪涓嶈兘涓虹┖',
+          trigger: 'change'
+        },
+        locationid: {
+          required: true,
+          message: '闂浣嶇疆涓嶈兘涓虹┖',
+          trigger: 'change'
+        },
+        advice: {
+          required: true,
+          message: '闂寤鸿涓嶈兘涓虹┖',
+          trigger: 'change'
+        }
       },
       deviceTopTypes: [
         { id: 0, label: '鐩戞帶璁惧' },
@@ -231,21 +320,54 @@
   watch: {
     fileList: {
       handler(newFileList, oldFileList) {
-        console.log('newFileList', newFileList);
         // 鍥剧墖鏍¢獙
         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: {
     descriptionOptions() {
       const descriptions = [];
+
       this.problemTypeList.forEach((item) => {
-        if (item.typename == this.proType) {
+        if (item.typename == this.deepCopyProblem._proType) {
           descriptions.push(item);
         }
       });
+
       return descriptions;
     },
     problemTypeOptions() {
@@ -258,114 +380,41 @@
       }, []);
     },
     adviseOptions() {
-      var array = this.suggestions.filter((item) => item.adProblemtypeguid == this.currProTypeGuid);
-      console.log('adName', array);
-
+      let problemGuid = this.currProTypeGuid || this.problem.guid;
+      let array = this.suggestions.filter(
+        (item) => item.adProblemtypeguid == problemGuid
+      );
       return array;
     }
   },
-  mounted() {
-    this.initOptions();
-    this.getDeviceImgList();
-  },
+  mounted() {},
   methods: {
+    onProAdviseChange(value) {
+      this.deepCopyProblem._adviseEdit = this.deepCopyProblem.advice;
+    },
     handlePictureCardPreview(uploadFile) {
+      this.initialIndex = this.fileList.indexOf(uploadFile);
       this.previewDialogVisible = true;
       this.previewDialogImageUrl = uploadFile.url;
     },
     beforeDeiveceImgDialogclose() {
       this.deiveceImgDialog = false;
     },
-    // 鏍囧噯鍖栧睘鎬у悕
-    convertKeys(obj) {
-      // 灏嗕竴涓猨s瀵硅薄涓墍鏈塪i锛寃i锛宲i寮�澶寸殑灞炴�у叏閮ㄦ敼鎴愬幓鎺夎繖浜涘墠缂�骞朵笖閲嶆柊鍙樹负椹煎嘲寮忓懡鍚�
-      const newObj = {};
-      for (const key in obj) {
-        if (obj.hasOwnProperty(key)) {
-          let newKey = key;
-          if (key.startsWith('di')) {
-            newKey = key.substring(2);
-          } else if (key.startsWith('wi')) {
-            newKey = key.substring(2);
-          } else if (key.startsWith('pi')) {
-            newKey = key.substring(2);
-          }
-          newKey = newKey.charAt(0).toLowerCase() + newKey.slice(1);
-          newObj[newKey] = obj[key];
-        }
-      }
-      return newObj;
-    },
-    // 淇濆瓨鐘舵�佷俊鎭�
-    saveStatus(device, status) {
-      var _picUrl = $fysp.imgUrl + status.dlPicUrl;
-      device._picUrl = _picUrl;
-      status._picUrl = _picUrl;
-      if ('_statusList' in device) {
-        device._statusList.push(status);
-      } else {
-        device._statusList = Array.of(status);
-      }
-      // 鎺掑簭
-      device._statusList.sort(function (x, y) {
-        return new Date(x.dlCreateTime) - new Date(y.dlCreateTime); //	闄嶅簭锛屽崌搴忓垯鍙嶄箣
-      });
-    },
-    async getDeviceImgList() {
-      this.deviceImgObjList = [];
-      for (const deviceTopTypeElement of this.deviceTopTypes) {
-        const topTypeId = deviceTopTypeElement.id;
-        await deviceApi.fetchDevices(this.subtask.sceneId, topTypeId).then((result) => {
-          // 鏍囧噯鍖栧睘鎬у悕
-          for (let i = 0; i < result.data.length; i++) {
-            var element = this.convertKeys(result.data[i]);
-            // 鑾峰彇璁惧鐘舵�佷俊鎭�
-            let data = {
-              deviceId: element.id,
-              sceneId: element.sceneGuid,
-              deviceTypeId: topTypeId
-            };
-            deviceApi
-              .fetchDeviceStatus(data)
-              .then((status) => {
-                var statusData = status.data;
-                var imgPaths = [];
-
-                if (statusData) {
-                  if (statusData.length == 0) {
-                    this.deviceImgObjList.push(element);
-                    return;
-                  }
-                  element = this.convertKeys(result.data[i]);
-                  for (let j = 0; j < statusData.length; j++) {
-                    // 澶嶅埗鍑轰竴涓澶囧璞�
-                    var newDevice = useCloned(element).cloned.value;
-                    const statusItem = statusData[j];
-                    // 璁惧瀵硅薄娣诲姞涓�涓睘鎬у垪琛ㄥ睘鎬х敤鏉ヤ繚瀛樿澶囩姸鎬�
-                    this.saveStatus(newDevice, statusItem);
-                    newDevice.dlLocation = statusItem.dlLocation;
-                    newDevice.topTypeId = topTypeId;
-                    console.log('newDevice.topTypeId', newDevice.topTypeId);
-                    console.log('newDevice', newDevice);
-
-                    this.deviceImgObjList.push(newDevice);
-                  }
-                }
-              })
-              .catch((err) => {});
-          }
-        });
-      }
-    },
     initOptions() {
+      if (!this.problem || !this.subtask || !this.topTask) {
+        return;
+      }
       if (this.problem == undefined || this.problem == null) {
-        this.problem = {};
         this.deepCopyProblem = {};
       } else {
         this.deepCopyProblem = useCloned(this.problem).cloned.value;
+        this.currProTypeGuid = this.problem.guid;
+        this.deepCopyProblem.advice = this.deepCopyProblem.advise;
+        this.deepCopyProblem._adviseEdit = this.deepCopyProblem.advice;
       }
 
       this.type = 'guid' in this.deepCopyProblem ? 1 : 0;
+
       // 鑾峰彇闂绫诲瀷
       let data = {
         sceneTypeId: this.subtask.sceneTypeId,
@@ -373,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);
@@ -383,17 +432,20 @@
             currDescription = currProName;
             this.problemTypeList.forEach((item) => {
               if (item.description == currDescription) {
-                this.proType = item.typename;
+                this.deepCopyProblem._proType = item.typename;
               }
             });
             this.deepCopyProblem.description = currDescription;
             this.proRemark = '';
           } else {
-            currDescription = currProName.substring(0, currProName.lastIndexOf('('));
+            currDescription = currProName.substring(
+              0,
+              currProName.lastIndexOf('(')
+            );
 
             this.problemTypeList.forEach((item) => {
               if (item.description === currDescription) {
-                this.proType = item.typename;
+                this.deepCopyProblem._proType = item.typename;
               }
             });
             this.deepCopyProblem.description = currDescription;
@@ -422,10 +474,6 @@
       // 闂寤鸿
       problemApi.getSuggestion().then((res) => {
         this.suggestions = res.data;
-        // 濉厖褰撳墠闂寤鸿
-        this.deepCopyProblem.advise = this.suggestions.filter(
-          (item) => item.adProblemtypeguid == this.deepCopyProblem.guid
-        )[0].adName;
       });
 
       // 闂浣嶇疆
@@ -443,7 +491,7 @@
         this.oldFileList.filter((item) => item.url != file.url);
       }
     },
-    handleLedgerPicPhono() {
+    handleLedgerPicPhono(data) {
       this.beforeLedgerPicDialogclose();
       let isExist = false;
       for (const item of data) {
@@ -461,9 +509,6 @@
         isExist = false;
       }
     },
-    beforeLedgerPicDialogclose() {
-      this.ledgerPicDialog = false;
-    },
     findProTypeByGuid(guid) {
       let result;
       this.problemTypeList.forEach((item) => {
@@ -474,7 +519,7 @@
       return result;
     },
     changeProblemname() {
-      if (this.proRemark == null || this.proRemark == '') {
+      if (!this.proRemark || this.proRemark == null || this.proRemark == '') {
         this.deepCopyProblem.problemname = this.deepCopyProblem.description;
       } else {
         this.deepCopyProblem.problemname =
@@ -484,19 +529,35 @@
     onProRemarkChange(value) {
       this.changeProblemname();
     },
+    onProAdviseEditChange(value) {},
     onProTypeChange(value) {
-      this.deepCopyProblem.description = '';
-      this.deepCopyProblem.advise = '';
+      // 榛樿闂鎻忚堪鍜岄棶棰樺缓璁负绗竴涓�
+      this.currProTypeGuid = this.descriptionOptions[0].guid;
+      this.deepCopyProblem.description = this.descriptionOptions[0].description;
+      this.onProDesChange(this.deepCopyProblem.description);
+      this.deepCopyProblem.advice = this.adviseOptions[0].adName;
+      this.deepCopyProblem._adviseEdit = this.deepCopyProblem.advice;
+    },
+    findProByProDesName(name) {
+      let result;
+      this.problemTypeList.forEach((item) => {
+        if (item.description == name) {
+          result = item;
+        }
+      });
+      return result;
     },
     onProDesChange(value) {
-      let currPro = this.findProTypeByGuid(value);
-      this.deepCopyProblem.advise = '';
-      this.currProTypeGuid = value;
-      this.deepCopyProblem.description = currPro.description;
+      let currPro = this.findProByProDesName(value);
+      this.currProTypeGuid = currPro.guid;
+      // this.deepCopyProblem.description = currPro.description;
       this.changeProblemname();
-      this.deepCopyProblem.advise = '';
-
-      this.deepCopyProblem.advise = this.adviseOptions[0].adName;
+      var adName =
+        this.adviseOptions.length == 0 ? '' : this.adviseOptions[0].adName;
+      this.deepCopyProblem.advice = adName;
+      this.$nextTick(() => {
+        this.deepCopyProblem._adviseEdit = this.deepCopyProblem.advice;
+      });
     },
     onProLocationChange(value) {
       this.posList.forEach((item) => {
@@ -522,70 +583,79 @@
       }
       return true;
     },
-    // TODO
-    validateForm() {},
+    onCancel() {
+      this.$emit('cancel');
+      this.$emit('update:visible', false);
+    },
     onSubmit() {
-      this.validateForm();
-      // 鍥剧墖鏍¢獙
-      if (!this.pictureValidate()) {
-        return;
-      }
-      // 鏁版嵁鍑嗗
-      let deepCopyPro = useCloned(this.deepCopyProblem).cloned.value;
-      let data = new FormData();
-      var picUrls = [];
-      this.fileList.forEach((item) => {
-        if (!('guid' in item)) {
-          // 鏂扮殑
-          let exclude = false;
-          for (let index = 0; index < this.oldFileList.length; index++) {
-            const element = this.oldFileList[index];
-            if (item.url == element.url) {
-              exclude = true;
-              break;
+      this.$refs.formRef.validate((valid) => {
+        if (valid && this.pictureValidate()) {
+          // 鏁版嵁鍑嗗
+          let deepCopyPro = useCloned(this.deepCopyProblem).cloned.value;
+          let data = new FormData();
+          var picUrls = [];
+          this.fileList.forEach((item) => {
+            if (!('guid' in item)) {
+              // 鏂扮殑
+              let exclude = false;
+              for (let index = 0; index < this.oldFileList.length; index++) {
+                const element = this.oldFileList[index];
+                if (item.url == element.url) {
+                  exclude = true;
+                  break;
+                }
+              }
+              if (!exclude) {
+                picUrls.push(item.url);
+              }
+              exclude = false;
+              // picUrls.push(item)
             }
+          });
+          if (this.type == 1) {
+            let deleteImgCopy = this.deleteImg;
+            fileUtil.getImageFiles(picUrls, (files) => {
+              data.append('deleteImg', deleteImgCopy);
+              deepCopyPro.advise = deepCopyPro.advice;
+              delete deepCopyPro['advice'];
+              delete deepCopyPro['mediafileList'];
+              delete deepCopyPro['description'];
+              delete deepCopyPro['_adviseEdit'];
+              delete deepCopyPro['_proType'];
+              delete deepCopyPro['proType'];
+              data.append('problem', JSON.stringify(deepCopyPro));
+              files.forEach((image) => {
+                data.append('images', image);
+              });
+              problemApi.updateProblem(data).then((res) => {
+                this.$emit('submit', false);
+              });
+            });
+          } else {
+            const deepCopySubTask = useCloned(this.subtask).cloned.value;
+            fileUtil.getImageFiles(picUrls, (files) => {
+              deepCopyPro.insGuid = deepCopySubTask.insGuid;
+              delete deepCopyPro['description'];
+              deepCopyPro.proName = deepCopyPro.problemname;
+              delete deepCopyPro['problemname'];
+              deepCopyPro.ptGuid = this.findProTypeByGuid(
+                this.currProTypeGuid
+              ).guid;
+              deepCopyPro.locationId = deepCopyPro.locationid;
+              delete deepCopyPro['locationid'];
+              delete deepCopyPro['_adviseEdit'];
+              delete deepCopyPro['_proType'];
+              data.append('problemVo', JSON.stringify(deepCopyPro));
+              files.forEach((image) => {
+                data.append('images', image);
+              });
+              problemApi.newProblem(data).then((res) => {
+                this.$emit('submit', true);
+              });
+            });
           }
-          if (!exclude) {
-            picUrls.push(item.url);
-          }
-          exclude = false;
-          // picUrls.push(item)
-        } else {
         }
       });
-      if (this.type == 1) {
-        let deleteImgCopy = this.deleteImg;
-        fileUtil.getImageFiles(picUrls, function (files) {
-          data.append('deleteImg', deleteImgCopy);
-          delete deepCopyPro['mediafileList'];
-          delete deepCopyPro['description'];
-          data.append('problem', JSON.stringify(deepCopyPro));
-          files.forEach((image) => {
-            data.append('images', image);
-          });
-          problemApi.updateProblem(data).then((res) => {});
-        });
-      } else {
-        const deepCopySubTask = useCloned(this.subtask).cloned.value;
-        const that = this;
-        fileUtil.getImageFiles(picUrls, function (files) {
-          console.log('deepCopySubTask', deepCopySubTask);
-          deepCopyPro.insGuid = deepCopySubTask.insGuid;
-          delete deepCopyPro['advise'];
-          delete deepCopyPro['description'];
-          deepCopyPro.proName = deepCopyPro.problemname;
-          delete deepCopyPro['problemname'];
-          deepCopyPro.ptGuid = that.findProTypeByGuid(that.currProTypeGuid).guid;
-          deepCopyPro.locationId = deepCopyPro.locationid;
-          delete deepCopyPro['locationid'];
-          data.append('problemVo', JSON.stringify(deepCopyPro));
-          files.forEach((image) => {
-            data.append('images', image);
-          });
-          problemApi.newProblem(data).then((res) => {});
-        });
-      }
-      this.$emit('submited', true);
     },
     handleSelectedAnyPhono(data) {
       this.beforeAnyPhotoDialogclose();
@@ -606,24 +676,6 @@
       }
     },
     handleSelectedDevicePhono(data) {
-      this.beforeDeiveceImgDialogclose();
-      let isExist = false;
-      for (const item of data) {
-        for (const already of this.fileList) {
-          if (item._picUrl == already.url) {
-            isExist = true;
-          }
-        }
-        if (!isExist) {
-          this.fileList.push({
-            url: item._picUrl,
-            name: '1'
-          });
-        }
-        isExist = false;
-      }
-    },
-    handleLedgerPicPhono(data) {
       let isExist = false;
       for (const item of data) {
         for (const already of this.fileList) {
@@ -639,8 +691,6 @@
         }
         isExist = false;
       }
-
-      this.beforeAnyPhotoDialogclose();
     },
     chosePicFromAnyPic() {
       this.anyPhotoDialog = true;
@@ -675,10 +725,6 @@
     },
     beforeLedgerPicDialogclose() {
       this.ledgerPicDialog = false;
-    },
-
-    destoryMyself() {
-      this.$destroy();
     }
   }
 };
@@ -700,14 +746,9 @@
 .img-upload {
   margin-top: 30px;
   margin-bottom: 30px;
-  margin-left: 63px;
 }
 .row {
   width: 100%;
-}
-
-::v-deep .el-dialog__body {
-  width: 95%;
 }
 ::v-deep .el-upload-list--picture-card .el-upload-list__item-thumbnail {
   object-fit: cover !important;
@@ -717,4 +758,11 @@
   width: 100%;
   height: 100%;
 }
+::v-deep .el-upload--picture-card {
+  display: none;
+}
+/* 闅愯棌el-upload涓婁紶鎴愬姛缁勪欢 */
+::v-deep .el-upload-list__item-status-label {
+  display: none !important;
+}
 </style>

--
Gitblit v1.9.3