Browse Source

专家导入功能

bzkf3 2 years ago
parent
commit
f45a2c199a
2 changed files with 50 additions and 23 deletions
  1. 14 14
      src/router/index.js
  2. 36 9
      src/views/xtgl/zjk/index.vue

+ 14 - 14
src/router/index.js

@@ -249,20 +249,20 @@ export const allRoutes = [
           },
         ],
       },
-      {
-        path: "zdb",
-        // name: 'zdb',
-        component: MainDefaultLayout,
-        meta: { title: "字典表" },
-        children: [
-          {
-            path: "",
-            name: "zdb",
-            component: () => import("@/views/xtgl/zdb/index.vue"),
-            meta: { title: "字典表" },
-          },
-        ],
-      },
+      // {
+      //   path: "zdb",
+      //   // name: 'zdb',
+      //   component: MainDefaultLayout,
+      //   meta: { title: "字典表" },
+      //   children: [
+      //     {
+      //       path: "",
+      //       name: "zdb",
+      //       component: () => import("@/views/xtgl/zdb/index.vue"),
+      //       meta: { title: "字典表" },
+      //     },
+      //   ],
+      // },
     ],
   },
 

+ 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>
@@ -167,6 +172,7 @@ import {
 } from "./api";
 
 const { token } = useUserStore();
+import { request } from "@/utils/request";
 
 export default {
   components: {
@@ -234,6 +240,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,
@@ -258,6 +265,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") {