guhongwei 3 năm trước cách đây
mục cha
commit
7b451744ed
1 tập tin đã thay đổi với 33 bổ sung16 xóa
  1. 33 16
      src/views/admin/live/achieve/pw.vue

+ 33 - 16
src/views/admin/live/achieve/pw.vue

@@ -18,7 +18,7 @@
         </el-form-item>
         <el-form-item label="图片">
           <upload
-            :limit="1"
+            :limit="6"
             :data="form.img_url"
             type="img_url"
             listType=""
@@ -73,7 +73,10 @@ export default {
         },
       ],
       fields: [{ label: '信息', prop: 'content', model: 'content' }],
-      form: {},
+      form: {
+        img_url: [],
+        file_url: [],
+      },
     };
   },
   created() {
@@ -90,18 +93,27 @@ export default {
       }
     },
     async vSubmit() {
-      let dup = _.cloneDeep(this.form);
-      let res;
-      if (!dup.id) {
-        dup.user_id = this.user.user_id;
-        dup.dock_id = this.user._id;
-        res = await this.create(dup);
+      let data = this.form;
+      if (data.id) {
+        let res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '修改信息成功',
+            type: 'success',
+          });
+          this.dialog = false;
+        }
       } else {
-        res = await this.update(dup);
-      }
-      if (this.$checkRes(res, '保存成功', res.errmsg || '保存失败')) {
-        this.search();
-        this.dialog = false;
+        data.user_id = this.user.user_id;
+        data.dock_id = this.user._id;
+        let res = await this.create(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '创建信息成功',
+            type: 'success',
+          });
+          this.dialog = false;
+        }
       }
     },
     async toDelete({ data }) {
@@ -112,15 +124,20 @@ export default {
       }
     },
     toAdd({ data = {} } = {}) {
+      data.img_url = [];
+      data.file_url = [];
       this.dialog = true;
       this.$set(this, `form`, data);
     },
     uploadSuccess({ type, data }) {
-      const { uri } = data;
-      this.$set(this.form, type, uri);
+      let arr = _.cloneDeep(this.form[type]);
+      let file = { name: data.name, url: data.uri };
+      arr.push(file);
+      this.$set(this.form, type, arr);
     },
     uploadDelete({ file, type }) {
-      delete this.form[type];
+      const index = this.form[type].findIndex(f => _.isEqual(f, file));
+      this.form[type].splice(index, 1);
     },
   },
   computed: {