Forráskód Böngészése

修改批量上传机构id

秦鹏 3 éve
szülő
commit
cc9689f0c1
2 módosított fájl, 31 hozzáadás és 4 törlés
  1. 14 1
      src/components/Upload.vue
  2. 17 3
      src/views/teacher-devEntering/index.vue

+ 14 - 1
src/components/Upload.vue

@@ -17,6 +17,7 @@
       :file-list="targetFileList"
       :before-remove="beforeRemove"
       :limit="filleNumber"
+      :before-upload="handlebeforeUplaod"
     >
       <el-button type="primary" v-if="type == '批量上传'">批量上传</el-button>
       <el-button v-else>上传文件</el-button>
@@ -26,7 +27,7 @@
 
 <script>
 import Cookies from "js-cookie";
-import { getToken,removeToken } from "../utils/auth";
+import { getToken, removeToken } from "../utils/auth";
 export default {
   components: {},
   props: ["fileList", "changeFillId", "type", "accept", "filleNumber"],
@@ -35,6 +36,7 @@ export default {
       targetFileList: null,
       targetAccept: null,
       fileTypeName: "",
+      loading: null,
     };
   },
   computed: {
@@ -61,19 +63,30 @@ export default {
   },
   //方法集合
   methods: {
+    handlebeforeUplaod(file) {
+      this.loading = this.$loading({
+        lock: true,
+        text: "Loading",
+        spinner: "el-icon-loading",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
+    },
     handleSuccess(response, file, fileList) {
       // console.log(response);
       // console.log(file);
       // console.log(fileList);
       if (response.status == 1) {
         this.$message.success("用户导入成功");
+        this.loading.close();
         this.changeFillId(response.file_info_list[0], fileList, this.type);
       } else if (response.status == -1) {
+        this.loading.close();
         removeToken();
         this.$message.warning(response.error);
         this.$router.push("/login");
       } else {
         this.targetFileList = [];
+        this.loading.close();
         // this.$message.warning(response.msg);
       }
     },

+ 17 - 3
src/views/teacher-devEntering/index.vue

@@ -106,7 +106,7 @@ import Header from "@/components/Header";
 import Nav from "@/components/teacher-devEntering/Nav";
 import Upload from "@/components/Upload";
 import { getToken } from "@/utils/auth";
-
+import { usertenant } from "@/api/api";
 import {
   VerifyLogin,
   materiallist,
@@ -146,6 +146,7 @@ export default {
       keyWord: "",
       pageNum: 1,
       pageSize: 10,
+      institutionList: null,
     };
   },
   methods: {
@@ -170,14 +171,14 @@ export default {
       attachmentinsert({
         attachmentList: attachmentList,
         type: "3",
-        tenantId: "2021052017-HFTZIRVKWOWPAUU",
+        tenantId: this.institutionList[0].tenantId,
       })
         .then((res) => {
           materialinsert({
             name: name,
             price: "-1",
             teacherList: [""],
-            tenantId: "2021052017-HFTZIRVKWOWPAUU",
+            tenantId: this.institutionList[0].tenantId,
             tagList: tag,
             attachmentIdList: res.data.attachmentIdList,
           })
@@ -352,6 +353,19 @@ export default {
         });
     },
   },
+  created() {
+    // 获取当前可编辑机构
+    usertenant({})
+      .then((res) => {
+        if (res.status == 1) {
+          this.institutionList = res.data.tenantIdAndNameListEditable;
+          this.loading = false;
+        }
+      })
+      .catch((res) => {
+        this.loading = false;
+      });
+  },
   mounted() {
     this.getdata();
     // this.loading = true;