xiebeibei преди 4 години
родител
ревизия
eff324df79
променени са 2 файла, в които са добавени 24 реда и са изтрити 1 реда
  1. 6 0
      src/api/editer.js
  2. 18 1
      src/components/edit/attr_select.vue

+ 6 - 0
src/api/editer.js

@@ -19,4 +19,10 @@ export function saveGroup(postParams) {
 //查询系统图展示所需数据
 export function readGroup(postParams) {
     return httputils.fetchJson(`${testApi}/graph/read`, postParams)
+}
+//上传图片
+export function uploadImg({
+    postParams
+}) {
+    return httputils.postJson(`${testApi}/Picture/create`, postParams)
 }

+ 18 - 1
src/components/edit/attr_select.vue

@@ -72,7 +72,8 @@
           <a-upload-dragger
             name="file"
             :multiple="true"
-            action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
+            :customRequest="customRequest"
+            action="https://jsonplaceholder.typicode.com/posts/"
             @change="changeImage"
           >
             <p class="icon-image">
@@ -192,6 +193,7 @@ import Swatches from "vue-swatches";
 import bus from "@/bus";
 import "vue-swatches/dist/vue-swatches.css";
 import { ItemColor } from "@saga-web/big/lib";
+import { uploadImg } from "@/api/editer.js";
 export default {
   name: "attr_select",
   props: ["type", "focusItemList"],
@@ -286,8 +288,23 @@ export default {
     changebackColor(color){
       bus.$emit("changebackColor", color);
     },
+    customRequest(info){
+      let formData = new FormData()
+      formData.append('file', info.file)
+      let postParams = formData;
+      uploadImg({ postParams }).then(res => {
+        if (res.Result == 'success') {
+          console.log(res);
+          // this.$set(this.ruleForm, 'Url', res.EntityList[0])
+          this.$message.success(`${info.file.name} file uploaded successfully.`);
+        }else{
+          this.$message.error(`${info.file.name} file upload failed.`);
+        }
+      })
+    },
     changeImage(info) {
       const status = info.file.status;
+      console.log(status);
       if (status !== "uploading") {
         console.log(info.file, info.fileList);
       }