Przeglądaj źródła

工程押金增加下载模板,批量导入功能

chen 3 lat temu
rodzic
commit
4187714d58

+ 38 - 1
src/views/basic_data/dealer/dealer_deposit.vue

@@ -72,7 +72,18 @@
           >
         </div>
         <div class="fr">
-          <el-button type="primary" size="small" @click="addFn">新增</el-button>
+          <el-button type="primary" size="small" @click="downLoadFn"
+            >模板</el-button
+          >
+          <el-upload
+            class="import-btn"
+            action=""
+            :http-request="handleImport"
+            :file-list="importFileList"
+            :show-file-list="false"
+          >
+            <el-button type="primary" size="small">批量导入</el-button>
+          </el-upload>
         </div>
       </div>
 
@@ -346,6 +357,7 @@ import {
 } from "@/api/basic_data/dealer";
 // import { number } from "echarts";
 import DealerDepositHistory from "./components/dealer_deposit_history";
+import { downloadFiles, handleImport } from "@/utils/util";
 
 export default {
   components: {
@@ -353,6 +365,7 @@ export default {
   },
   data() {
     return {
+      importFileList: [],
       historyId: "",
       showHistory: true,
       marks: {
@@ -483,7 +496,27 @@ export default {
     //     this.$message.warning("已选定额押金,如需选择押金比例,请把定额押金归零");
     //   }
     // },
+    // 导入
+    async handleImport(param) {
+      const file = param.file;
+
+      const formData = new FormData();
+      formData.append("file", file);
 
+      let result = await handleImport("/customer/deposit/import", formData);
+
+      console.log(result);
+      this.importFileList = [];
+      if (result.code == 200) {
+        this.$message.success("导入成功");
+      } else {
+        this.$message.error(result.message);
+      }
+    },
+    //下载模板
+    async downLoadFn() {
+      downloadFiles("/customer/deposit/downModel");
+    },
     //记录
     logFn(id) {
       this.historyId = id;
@@ -665,6 +698,10 @@ export default {
     margin-right: 12px;
   }
 }
+.import-btn {
+  display: inline-block;
+  margin-left: 10px;
+}
 // .main {
 //   padding: 12px;
 // }

+ 1 - 1
src/views/finance/rebate_form.vue

@@ -384,7 +384,7 @@ export default {
       console.log(result);
       this.importFileList = [];
       if (result.code == 200) {
-        this.$message.success(result.message);
+        this.$message.success("导入成功");
       } else {
         this.$message.error(result.message);
       }