From fcc1ea2bf3ce3efe1f927bd087e4cd6cf2116c32 Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期三, 30 三月 2022 16:21:36 +0800
Subject: [PATCH] Merge remote-tracking branch 'remotes/origin/shf' into master

---
 src/views/contingencyplan/index.vue |   46 ++++++++++++++++++++++++++++------------------
 1 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/src/views/contingencyplan/index.vue b/src/views/contingencyplan/index.vue
index 621c963..9e07de8 100644
--- a/src/views/contingencyplan/index.vue
+++ b/src/views/contingencyplan/index.vue
@@ -62,16 +62,16 @@
           <el-input v-model="form.name"></el-input>
         </el-form-item>
         <el-form-item label="文件类型">
-          <el-radio-group v-model="form.fileType">
+          <el-radio-group v-model="form.fileType" @change="changeFileType">
             <el-radio :label=0 >图片</el-radio>
             <el-radio :label=1 >文件</el-radio>
           </el-radio-group>
         </el-form-item>
         <el-form-item v-if="form.fileType==0" label="图片上传">
-            <upload-img  v-bind:imgList="form.fileList" @uploadImgSuccess="uploadImgSuccess" @removeImgSuccess="removeImgSuccess"></upload-img>
+            <upload-img :imgList="fileList"   @uploadImgSuccess="uploadImgSuccess" @removeImgSuccess="removeImgSuccess"></upload-img>
         </el-form-item>
         <el-form-item label="文件链接" v-if="form.fileType==1">
-            <upload-file v-bind:url="fileUrl" v-bind:name="fileName" @uploadFileSuccess="uploadFileSuccess" ></upload-file>
+            <upload-file v-bind:url="fileUrl" v-bind:name="fileName"  @uploadFileSuccess="uploadFileSuccess" ></upload-file>
         </el-form-item>
         <el-form-item label="备注" prop="remark">
           <el-input v-model="form.remark" :rows="5" type="textarea"></el-input>
@@ -97,9 +97,7 @@
   components: { uploadImg , uploadFile},
   data() {
     return {
-        name:"111",
-        url:"222",
-        path:"emergencyPlan",
+        uploadDisabled:false,
 
       dialogVisible: false,
       title: "",
@@ -121,6 +119,7 @@
       },
         fileName:"",
         fileUrl:"",
+        fileList:[],
       list: [],
       rules: {
         name: [
@@ -136,17 +135,15 @@
     this.emergencyPlan();
   },
   methods: {
+      changeFileType(){
+          this.fileUrl=""
+          this.fileName=""
+          this.fileList=[]
+      },
 
       uploadFileSuccess(res){
           this.fileName=res.fileName
           this.fileUrl=res.fileUrl
-          if (this.fileName=="" || this.fileUrl==""){
-              this.form.fileList=[]
-          }
-          this.form.fileList=[{
-              fileName: this.fileName,
-              fileUrl:this.fileUrl
-          }]
       },
 
       uploadImgSuccess(res){
@@ -154,11 +151,11 @@
               fileUrl : res.fileUrl,
               fileName : res.fileName
           }
-          this.form.fileList.push(file)
+          this.fileList.push(file)
       },
 
       removeImgSuccess(res){
-          this.form.fileList=res.fileList
+          this.fileList=res.fileList
       },
 
     async emergencyPlan() {
@@ -186,14 +183,27 @@
       } else {
         this.title = "编辑";
         this.form = value;
-        this.fileUrl=value.fileList[0].fileUrl;
-        this.fileName=value.fileList[0].fileName
+        if (this.form.fileType==0){
+            this.fileList=value.fileList
+        } else{
+            this.fileUrl=value.fileList[0].fileUrl;
+            this.fileName=value.fileList[0].fileName
+        }
       }
     },
     addemergencyPlan() {
       this.$refs["form"].validate((valid) => {
         if (valid) {
-            console.log(132,this.form)
+            if (this.form.fileType==0){
+                this.form.fileList=this.fileList
+            }
+            if (this.form.fileType==1){
+                let file={
+                    fileUrl:this.fileUrl,
+                    fileName:this.fileName
+                }
+                this.form.fileList=[file]
+            }
           if (this.title === "新增") {
             emergencyPlanAdd(this.form).then((res) => {
               if (res.data.code === "200") {

--
Gitblit v1.9.2