Ver Fonte

编辑bug

xiaohaizhao há 7 meses atrás
pai
commit
dcb6a2ade4

+ 9 - 4
src/WebsiteManagement/marketproductMag/compents/upload.vue

@@ -165,13 +165,12 @@ export default {
         document: ".txt,.doc,.docx,.xls,.xlsx,.ppt,.pptx",
         pdf: ".pdf",
       };
-      return this.classType.map((v) => (obj[v] ? obj[v] : v)).join(",")
+      return this.classType.map((v) => (obj[v] ? obj[v] : v)).join(",");
     },
   },
   methods: {
     handleChange(file, filelist) {
-      if (!this.filelist.some((v) => v.uid == file.uid))
-        this.filelist.push(file);
+      this.$set(this.filelist, this.filelist.length, file);
       this.loading = true;
       let filename = file.raw.name,
         filetype = file.name.substr(file.raw.name.lastIndexOf(".") + 1);
@@ -201,6 +200,7 @@ export default {
     async upoladFileToServer(url, file, ext, obsfilename) {
       let that = this,
         item = this.filelist.find((v) => v.uid === file.uid);
+        console.log("itemitem",item)
       let config = {
         headers:
           ext === "pdf"
@@ -231,22 +231,27 @@ export default {
           },
         })
         .then((res) => {
-          console.log("res", res);
+          console.log("res", res, file);
           if (res.code == 0) return this.failUpload(res, file);
           let data = JSON.parse(res.attinfos).data,
             index = this.filelist.findIndex((v) => v.uid == file.uid),
             attachmentid = res.data.attachmentids[0],
             item = data.find((v) => v.attachmentid == attachmentid);
+          console.log(item);
+          console.log("this.filelist",this.filelist)
           delete file.row;
           this.$set(
             this.filelist,
             index,
             Object.assign(this.filelist[index], item)
           );
+          console.log("this.filelist",this.filelist)
           this.loading = this.filelist.some((v) => v.row);
+          this.filelist = this.filelist;
         });
     },
     failUpload(res, file) {
+      console.log("失败",res)
       Message.error(file.name + res.msg);
       this.filelist = this.filelist.filter((v) => v.uid !== file.uid);
       this.loading = this.filelist.some((v) => v.row);

+ 48 - 29
src/WebsiteManagement/marketproductMag/modules/edit.vue

@@ -82,7 +82,24 @@
             </el-col>
             <el-col :span="24">
               <el-form-item :label="$t('分类')" prop="classmx">
-                <el-cascader ref="selectdep" size="small" style="width: 100%" :placeholder='$t("分类")' v-model="form.classmx" :options="classData" filterable :props="{emitPath:false,expandTrigger:'hover',checkStrictly:false,label:'remarks',value:'value',children:'subvalues'}"  clearable></el-cascader>
+                <el-cascader
+                  ref="selectdep"
+                  size="small"
+                  style="width: 100%"
+                  :placeholder="$t('分类')"
+                  v-model="form.classmx"
+                  :options="classData"
+                  filterable
+                  :props="{
+                    emitPath: false,
+                    expandTrigger: 'hover',
+                    checkStrictly: false,
+                    label: 'remarks',
+                    value: 'value',
+                    children: 'subvalues',
+                  }"
+                  clearable
+                ></el-cascader>
               </el-form-item>
             </el-col>
             <el-col :span="24">
@@ -170,13 +187,15 @@ export default {
         technicalparam: "",
         contentstr: "",
         isonsale: "1",
-        classmx:''
+        classmx: "",
       },
       rules: {
         itemname: [
           { required: true, message: this.$t("请选择商品"), trigger: "change" },
         ],
-        classmx: [{ required: true,  message: this.$t( "请选择分类"), trigger: "change" }],
+        classmx: [
+          { required: true, message: this.$t("请选择分类"), trigger: "change" },
+        ],
       },
     };
   },
@@ -187,22 +206,22 @@ export default {
       this.$refs.materialdescription.innerHTML = this.form.materialdescription;
     if (this.$refs.contentstr)
       this.$refs.contentstr.innerHTML = this.form.contentstr;
-
-    this.$refs.upload.filelist = this.fileType
-      .fileList(this.data.attinfos)
-      .map((v) => {
-        v.progress = 100;
-        v.type = v.postfix;
-        v.uid = v.attachmentid;
-        return v;
-      });
+    if (!this.$refs.upload.filelist.length)
+      this.$refs.upload.filelist = this.fileType
+        .fileList(this.data.attinfos)
+        .map((v) => {
+          v.progress = 100;
+          v.type = v.postfix;
+          v.uid = v.attachmentid;
+          return v;
+        });
   },
   methods: {
     oploadIng(e) {
       this.disabled = e;
     },
     async editBtn() {
-      this.queryClass()
+      this.queryClass();
       const res = await this.$api.requested({
         id: "20240920101403",
         content: {
@@ -263,25 +282,25 @@ export default {
     },
     async queryClass() {
       const res = await this.$store.dispatch(
-          "optiontypeselect",
-          "marketproductclass"
+        "optiontypeselect",
+        "marketproductclass"
       );
-      this.classData = []
-      this.classData = res.data.map(item => {
+      this.classData = [];
+      this.classData = res.data.map((item) => {
         return {
-          value:item.value,
-          remarks:item.remarks,
-          subvalues:[]
-        }
-      })
-      res.data.forEach((item,index)=>{
-        this.classData[index].subvalues = item.subvalues.map(k=>{
+          value: item.value,
+          remarks: item.remarks,
+          subvalues: [],
+        };
+      });
+      res.data.forEach((item, index) => {
+        this.classData[index].subvalues = item.subvalues.map((k) => {
           return {
-            value:k,
-            remarks:k,
-          }
-        })
-      })
+            value: k,
+            remarks: k,
+          };
+        });
+      });
     },
     onClose() {
       this.loading = false;