From e2f0865c2a1167d36208a8c41eb5f18c684c786b Mon Sep 17 00:00:00 2001
From: zhaoxiaoqiang <287285524@qq.com>
Date: Thu, 07 Sep 2023 09:50:56 +0800
Subject: [PATCH] 编辑权益项目

---
 src/views/qyp-project-management/index.vue |   64 +++++++++++++++++++------------
 1 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/src/views/qyp-project-management/index.vue b/src/views/qyp-project-management/index.vue
index c13b62b..0a84a5c 100644
--- a/src/views/qyp-project-management/index.vue
+++ b/src/views/qyp-project-management/index.vue
@@ -91,19 +91,19 @@
               </el-radio-group>
             </el-form-item>
             <el-form-item label="项目背景图" v-if="addProd" ref="backFilePath" prop="backFilePath">
-               <uploadImg  v-if="addProd" @sendList="imgSet($event,'backFilePath')" :disabled="disabled"  :defaultList="ruleForm.backFilePath"></uploadImg>
+               <uploadImg  v-if="addProd" @sendList="imgSet($event,'backFilePath')" :disabled="disabled"  :defaultList="backFilePath"></uploadImg>
             </el-form-item>
             <el-form-item label="项目宣传标语" ref="logoFilePath" prop="logoFilePath">
-              <uploadImg v-if="addProd" @sendList="imgSet($event,'logoFilePath')" :disabled="disabled"  :defaultList="ruleForm.logoFilePath"></uploadImg>
+              <uploadImg v-if="addProd" @sendList="imgSet($event,'logoFilePath')" :disabled="disabled"  :defaultList="logoFilePath"></uploadImg>
             </el-form-item>
             <el-form-item label="项目优惠券图片" ref="titleFilePath" prop="titleFilePath">
-              <uploadImg v-if="addProd"  @sendList="imgSet($event,'titleFilePath')" :disabled="disabled" :defaultList="ruleForm.titleFilePath"></uploadImg>
+              <uploadImg v-if="addProd"  @sendList="imgSet($event,'titleFilePath')" :disabled="disabled" :defaultList="titleFilePath"></uploadImg>
             </el-form-item>
             <el-form-item label="会员权益" ref="qyFilePath">
-              <uploadImg v-if="addProd" @sendList="imgSet($event,'qyFilePath')"     :disabled="disabled" :defaultList="ruleForm.qyFilePath"></uploadImg>
+              <uploadImg v-if="addProd" @sendList="imgSet($event,'qyFilePath')"     :disabled="disabled" :defaultList="qyFilePath"></uploadImg>
             </el-form-item>
             <el-form-item label="活动规则" prop="ruleContent">
-              <tinymce v-model="ruleForm.ruleContent" :disabled="disabled" :height="300" />
+              <tinymce v-if="addProd" v-model="ruleForm.ruleContent" :disabled="disabled" :height="300" />
             </el-form-item>
             <el-form-item style="text-align:right;" v-if="!disabled">
               <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
@@ -179,7 +179,8 @@
             {
               lable: "项目链接",
               prop: "projUrl",
-              align: "center"
+              align: "center",
+              width: "300",
             },
             {
               lable: "创建时间",
@@ -197,6 +198,7 @@
               lable: "项目描述",
               prop: "projDesc",
               align: "center",
+              width: "240",
             },
             {
               lable: "",
@@ -264,8 +266,7 @@
             backFilePath:[],
             logoFilePath:[],
             titleFilePath:[],
-            qyFilePath:[],
-            ruleFilePath:[]
+            qyFilePath:[]
           },
           rules: {
               projName: [
@@ -295,14 +296,19 @@
               qyFilePath: [
                 { required: true,  trigger: 'change' ,validator: qyFilePathImage }
               ],
-              ruleFilePath: [
-                { required: true,  trigger: 'change',validator: ruleFilePathImage  }
-              ],
+              // ruleFilePath: [
+              //   { required: true,  trigger: 'change',validator: ruleFilePathImage  }
+              // ],
               ruleContent:[
                 { required: true, message: '请输入活动规则',  trigger: 'blur', }
               ]
           },
-          title:"新增项目"
+          title:"新增项目",
+          backFilePath:[],
+          logoFilePath:[],
+          titleFilePath:[],
+          qyFilePath:[],
+          ruleFilePath:[]
       }
     },
     watch:{
@@ -315,12 +321,16 @@
               projUrl:"",
               projDesc:"",
               status:"",
+              ruleContent:'',
               backFilePath:[],
               logoFilePath:[],
               titleFilePath:[],
               qyFilePath:[],
-              ruleFilePath:[]
             };
+            this.backFilePath = [];
+            this.logoFilePath = [];
+            this.titleFilePath = [];
+            this.qyFilePath = [];
             this.$refs['ruleForm'].resetFields();
           }
         },
@@ -354,6 +364,7 @@
       },
       addProduct(){
         this.title = '新增项目';
+        this.ruleForm.ruleContent = '';
         this.addProd = true;
         this.disabled = false;
       },
@@ -394,13 +405,13 @@
       submitForm(formName) {
         this.$refs[formName].validate((valid) => {
           if (valid) {
-            let {backFilePath,logoFilePath,titleFilePath,qyFilePath,ruleFilePath,projId} = this.ruleForm;
+            let {backFilePath,logoFilePath,titleFilePath,qyFilePath,projId} = this.ruleForm;
             let method = {projectUpdata,projectAdd};
             let data  = {};
             if(projId){
-              data = {...this.ruleForm,backFilePath:backFilePath[0],logoFilePath:logoFilePath[0],titleFilePath:titleFilePath[0],qyFilePath:qyFilePath[0],ruleFilePath:ruleFilePath[0]}
+              data = {...this.ruleForm};
             }else{
-              data = {...this.ruleForm,backFilePath:backFilePath[0],logoFilePath:logoFilePath[0],titleFilePath:titleFilePath[0],qyFilePath:qyFilePath[0],ruleFilePath:ruleFilePath[0]}
+              data = {...this.ruleForm,backFilePath:backFilePath[0],logoFilePath:logoFilePath[0],titleFilePath:titleFilePath[0],qyFilePath:qyFilePath[0]}
             }
             method[projId?"projectUpdata":"projectAdd"](data).then(res=>{
               this.$message.success("创建成功");
@@ -426,12 +437,11 @@
       },
       getProductDetail(projId,type){
         projectDtl({projId:projId}).then(({body})=>{
-          let {backFilePath,logoFilePath,titleFilePath,qyFilePath,ruleFilePath} = body;
-          body.backFilePath = this.setDefaultImg(backFilePath,'backFilePath');
-          body.logoFilePath = this.setDefaultImg(logoFilePath,'logoFilePath');
-          body.titleFilePath = this.setDefaultImg(titleFilePath,"titleFilePath");
-          body.qyFilePath =qyFilePath? this.setDefaultImg(qyFilePath,"qyFilePath"):[];
-          body.ruleFilePath = this.setDefaultImg(ruleFilePath,"ruleFilePath");
+          let {backFilePath,logoFilePath,titleFilePath,qyFilePath} = body;
+          this.backFilePath = this.setDefaultImg(backFilePath,'backFilePath');
+          this.logoFilePath = this.setDefaultImg(logoFilePath,'backFilePath');
+          this.titleFilePath = this.setDefaultImg(titleFilePath,'titleFilePath');
+          this.qyFilePath = this.setDefaultImg(qyFilePath,'backFilePath');
           this.ruleForm = body;
           this.$nextTick(()=>{ 
             this.addProd = true; 
@@ -439,9 +449,13 @@
         })
       },
       setDefaultImg(url,type){
-        let backArr = [url].map((n,index)=>{
-          return {url:n,filePath:n,uid:type+index,fileId:type+index,fileName:n,name:n};
-        });
+        let backArr = [];
+        if(url){
+          backArr = [url].map((n,index)=>{
+            return {url:n,filePath:n,uid:type+index,fileId:type+index,fileName:n,name:n};
+          });
+        }
+      
         return backArr
       }
     }

--
Gitblit v1.8.0