Browse Source

Merge branch 'zhuf'

bzkf3 2 years ago
parent
commit
ab30cc536d
1 changed files with 36 additions and 9 deletions
  1. 36 9
      src/views/xtgl/zjk/index.vue

+ 36 - 9
src/views/xtgl/zjk/index.vue

@@ -7,16 +7,21 @@
       <el-col :span="16">
         <el-container>
           <el-main>
-            <div style="margin-bottom: 20px;">
-              <el-button type="primary" @click="showDialog('add')" class="el-icon-plus">新增</el-button>
-              <el-button type="primary" @click="" class="el-icon-plus" v-show="activeName === 'waipin'">导入</el-button>
+            <div style="margin-bottom: 20px;display: flex;justify-content: space-between;align-items: center;">
+              <div style="display: flex;">
+                <el-button type="primary" @click="showDialog('add')" class="el-icon-plus">新增</el-button>
+                <template v-show="activeName === 'waipin'">
+                  <el-upload action="#" :http-request="httpRequest" :show-file-list="false">
+                    <el-button type="primary" @click="" style="margin-left: 10px;">导入</el-button>
+                  </el-upload>
+                  <a :href="user_template_url" style="margin-left: 10px;">
+                    <el-button type="primary">下载模板</el-button>
+                  </a>
+                </template>
+              </div>
 
-              <div style="
-                  position: absolute;
-                  right: 30px;
-                  top: 20px;
-                  display: inline;
-                ">
+
+              <div style="display: flex;">
                 <el-input placeholder="请输入搜索关键字" v-model="searchText" clearable
                   @clear="tableParams.keyword = searchText" style="width: 300px; margin-right: 10px"></el-input>
                 <el-button type="primary" @click="tableParams.keyword = searchText">搜索</el-button>
@@ -169,6 +174,7 @@ import {
 } from "./api";
 
 const { token } = useUserStore();
+import { request } from "@/utils/request";
 
 export default {
   components: {
@@ -236,6 +242,7 @@ export default {
       hdlxCheckedId: [],
       import_url: window.globalVariables.api + "user/org/import",
       import_user_url: window.globalVariables.api + "user/main/import",
+      user_template_url: window.globalVariables.api + "/user/main/index?api=xls",
       import_data: {
         api: "json",
         token: token,
@@ -260,6 +267,26 @@ export default {
     },
   },
   methods: {
+    httpRequest({ file }) {
+      const formData = new FormData();
+      formData.append("api", 'json');
+      formData.append('token', token);
+      formData.append("file", file);
+      return request({
+        url: '/user/main/import_zj',
+        data: formData,
+        timeout: 1000 * 60
+      })
+        .then((res) => {
+          if (res.code === '1') {
+            this.$message.success('导入成功');
+            this.renderTable(this.tableParams);
+          }
+          else {
+            // this.$message.error(data.msg);
+          }
+        })
+    },
     loadingUserRolesData() {
       // user_role().then((res) => {
       //   if (res.code === "1") {