guhongwei 3 years ago
parent
commit
dd05e748e4

+ 4 - 4
src/layout/login/register-1.vue

@@ -20,10 +20,10 @@
           <van-field v-model="form.addr" name="addr" label="联系地址" placeholder="联系地址" />
           <van-field v-model="form.office_phone" name="office_phone" label="办公电话" placeholder="办公电话" />
           <van-field readonly clickable name="juris" :value="form.juris" label="所属辖区" placeholder="点击选择" @click="showPicker = true" />
-          <van-field v-model="form.school" name="院校" label="院校" placeholder="院校" />
-          <van-field v-model="form.major" name="专业" label="专业" placeholder="专业" />
-          <van-field v-model="form.card" name="身份证号" label="身份证号" placeholder="身份证号" :rules="[{ required: true, message: '身份证号' }]" />
-          <van-field v-model="form.zwzc" name="职务职称" label="职务职称" placeholder="职务职称" />
+          <van-field v-model="form.school" name="school" label="院校" placeholder="院校" />
+          <van-field v-model="form.major" name="major" label="专业" placeholder="专业" />
+          <van-field v-model="form.card" name="card" label="身份证号" placeholder="身份证号" :rules="[{ required: true, message: '身份证号' }]" />
+          <van-field v-model="form.zwzc" name="zwzc" label="职务职称" placeholder="职务职称" />
           <van-popup v-model="showPicker" position="bottom">
             <van-picker show-toolbar :columns="jurisList" @confirm="confirm" @cancel="showPicker = false" />
           </van-popup>

+ 5 - 0
src/router/index.js

@@ -145,6 +145,11 @@ const account = [
     meta: { title: '平台用户-信息维护' },
     component: () => import('../views/account/adminCenter/users/detail.vue'),
   },
+  {
+    path: '/account/adminCenter/users/import_user',
+    meta: { title: '平台用户-批量注册用户' },
+    component: () => import('../views/account/adminCenter/users/import_user.vue'),
+  },
 ];
 const patent = [
   {

+ 99 - 0
src/views/account/adminCenter/users/import_user.vue

@@ -0,0 +1,99 @@
+<template>
+  <div id="index">
+    <admin-frame topType="2" @back="back" :rightArrow="false" :usePage="false" :useNav="false">
+      <template v-slot:info>
+        <van-col span="24" class="one">
+          <van-button type="info" size="small" @click="getTemplate()">数据模板下载</van-button>
+          <importForm-1 :form="form" @onSubmit="onSubmit"></importForm-1>
+        </van-col>
+        <van-col span="24" class="two">
+          <van-col span="24" class="list" v-for="(item, index) in list" :key="index">
+            <van-col span="24" class="name">
+              {{ item.errmsg || item.message }}
+            </van-col>
+          </van-col>
+        </van-col>
+      </template>
+    </admin-frame>
+  </div>
+</template>
+
+<script>
+import importForm1 from './parts/importForm-1.vue';
+import adminFrame from '@frame/src/components/mobile-frame/mobile-main.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: personal } = createNamespacedHelpers('personal');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    adminFrame,
+    importForm1,
+  },
+  data: function () {
+    return {
+      // 详细信息
+      form: {},
+      // 数据提示
+      list: [],
+    };
+  },
+  async created() {},
+  methods: {
+    ...personal(['import']),
+    async onSubmit(data) {
+      var p1 = data.file.map((item) => ({ uri: item.url }))[0];
+      let res = await this.import(p1);
+      if (this.$checkRes(res)) {
+        this.$toast({ type: `success`, message: `操作完成` });
+        this.$set(this, `list`, res.data);
+      } else {
+        this.$toast({ type: `success`, message: `${res.errmsg}` });
+      }
+    },
+    // 数据模板下载
+    getTemplate() {
+      window.location.href = `${process.env.VUE_APP_HOST}/${process.env.VUE_APP_ROUTER}/用户批量注册数据模板.xlsx`;
+    },
+    // 返回
+    back() {
+      this.$router.push({ path: `/account/adminCenter/users/index` });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.one {
+  background-color: #ffffff;
+  text-align: center;
+  padding: 10px 0;
+  margin: 0 0 10px 0;
+  .van-button {
+    margin: 0 10px;
+  }
+}
+.two {
+  .list {
+    background-color: #ffffff;
+    margin: 0 0 10px 0;
+    padding: 10px;
+    .name {
+      font-size: 16px;
+    }
+  }
+}
+</style>

+ 8 - 30
src/views/account/adminCenter/users/index.vue

@@ -11,24 +11,20 @@
           </van-tab>
         </van-tabs> -->
         <van-col span="24" class="one">
-          <van-button type="info" size="small" @click="getTemplate()">数据模板下载</van-button>
           <van-button type="info" size="small" @click="toImport()">批量注册用户</van-button>
+          <van-button type="info" size="small" @click="tpExport()">批量导出用户</van-button>
         </van-col>
         <van-col span="24" class="two">
           <personal-1 :list="personalList" @detail="perDetail"></personal-1>
         </van-col>
       </template>
     </admin-frame>
-    <van-dialog class="dialog" v-model="dialog.show" :title="dialog.title" :show-confirm-button="false" show-cancel-button>
-      <importForm-1 :form="form" v-if="dialog.type == '1'" @onSubmit="onSubmit"></importForm-1>
-    </van-dialog>
   </div>
 </template>
 
 <script>
 import personal1 from './parts/personal-1.vue';
 import company1 from './parts/company-1.vue';
-import importForm1 from './parts/importForm-1.vue';
 import adminFrame from '@frame/src/components/mobile-frame/mobile-main.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: personal } = createNamespacedHelpers('personal');
@@ -39,7 +35,6 @@ export default {
   components: {
     adminFrame,
     personal1,
-    importForm1,
   },
   data: function () {
     return {
@@ -48,17 +43,13 @@ export default {
       companyList: [],
       total: 0,
       limit: 5,
-      // 弹框
-      dialog: { show: false, title: '批量注册', type: '1' },
-      // 详细信息
-      form: {},
     };
   },
   async created() {
     await this.search();
   },
   methods: {
-    ...personal(['query', 'import']),
+    ...personal(['query', 'export']),
     ...organization({ orgQuery: 'query' }),
     // 查询列表
     async search({ skip = 0, limit = this.limit, ...info } = {}) {
@@ -94,23 +85,16 @@ export default {
     },
     // 批量注册用户
     toImport() {
-      this.dialog = { show: true, title: '批量注册', type: '1' };
+      this.$router.push({ path: `/account/adminCenter/users/import_user` });
     },
-    async onSubmit(data) {
-      var p1 = data.file.map((item) => ({ uri: item.url }))[0];
-      let res = await this.import(p1);
+    // 导出用户
+    async tpExport() {
+      let res = await this.export();
       if (this.$checkRes(res)) {
-        this.$toast({ type: `success`, message: `操作完成` });
-        this.search();
-        this.dialog = { show: false, title: '批量注册', type: '1' };
-      } else {
-        this.$toast({ type: `success`, message: `${res.errmsg}` });
+        window.location.href = `${process.env.VUE_APP_HOST}/${res.data}`;
       }
     },
-    // 数据模板下载
-    getTemplate() {
-      window.location.href = `${process.env.VUE_APP_HOST}/${process.env.VUE_APP_ROUTER}/用户批量注册数据模板.xlsx`;
-    },
+
     // 返回
     back() {
       this.$router.push({ path: `/account/index` });
@@ -141,10 +125,4 @@ export default {
     margin: 0 10px;
   }
 }
-.dialog {
-  /deep/.van-dialog__content {
-    max-height: 350px;
-    overflow-y: auto;
-  }
-}
 </style>

+ 7 - 6
src/views/register.vue

@@ -38,12 +38,13 @@ export default {
     ...personal({ personalCreate: 'create' }),
     ...organization({ organizationCreate: 'create' }),
     async onSubmit(data) {
-      let res = await this.personalCreate(data);
-      if (this.$checkRes(res)) {
-        this.$toast({ type: 'success', message: '注册成功,待管理员审核通过,方可登录' });
-      } else {
-        this.$toast({ type: 'fail', message: res.errmsg });
-      }
+      console.log(data);
+      // let res = await this.personalCreate(data);
+      // if (this.$checkRes(res)) {
+      //   this.$toast({ type: 'success', message: '注册成功,待管理员审核通过,方可登录' });
+      // } else {
+      //   this.$toast({ type: 'fail', message: res.errmsg });
+      // }
     },
     async orgSubmit(data) {
       let newData = { ...data, ...this.perForm };