wuhongyu 5 anos atrás
pai
commit
2e3d9455b5

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 11911
package-lock.json


+ 19 - 0
src/router/index.js

@@ -17,6 +17,25 @@ const routes = [
     meta: { title: '菜单管理' },
     component: () => import('../views/menu/index.vue'),
   },
+  // 用戶管理
+  // 个人与企业
+  {
+    path: '/user/index',
+    meta: { title: '个人&企业用户管理' },
+    component: () => import('../views/user/index.vue'),
+  },
+  // 专家
+  {
+    path: '/user/exportIndex',
+    meta: { title: '专家用户管理' },
+    component: () => import('../views/user/exportIndex.vue'),
+  },
+  // 临时
+  {
+    path: '/user/temporaryIndex',
+    meta: { title: '临时用户管理' },
+    component: () => import('../views/user/temporaryIndex.vue'),
+  },
   // 部门管理
   {
     path: '/department/index',

+ 3 - 0
src/store/index.js

@@ -7,6 +7,8 @@ import codeitem from './codeitem';
 import codeCategory from './codeCategory';
 import liveTechnicalColumn from './liveTechnicalColumn';
 import liveTechnicalNews from './liveTechnicalNews';
+// 个人&企业
+import users from './user';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -17,6 +19,7 @@ export default new Vuex.Store({
     codeCategory, //字典表类别
     liveTechnicalColumn, //技术培训类别
     liveTechnicalNews, //技术培训内容
+    users,
   },
   state: { ...ustate },
   mutations: { ...umutations },

+ 39 - 0
src/store/user.js

@@ -0,0 +1,39 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/market/user`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit = 10, ...info } = {}) {
+    const res = await this.$axios.$get(api.interface, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.interface}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.interface}/${id}`, { ...info });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 8 - 23
src/util/axios-wrapper.js

@@ -37,29 +37,20 @@ export default class AxiosWrapper {
     });
     return uri;
   }
-  //替换路由方法
-  static routerChange(uri, router = {}) {
-    let keys = Object.keys(router);
-    keys.forEach(key => {
-      uri = _.replace(uri, `{${key}}`, router[key]);
-    });
-    return uri;
-  }
 
-  $get(uri, router, query, options) {
-    return this.$request(uri, null, query, options, router);
+  $get(uri, query, options) {
+    return this.$request(uri, null, query, options);
   }
 
-  $post(uri, data = {}, router, query, options) {
-    return this.$request(uri, data, query, options, router);
+  $post(uri, data = {}, query, options) {
+    return this.$request(uri, data, query, options);
   }
 
   $delete(uri, data = {}, router, query, options = {}) {
     options = { ...options, method: 'delete' };
     return this.$request(uri, data, query, options, router);
   }
-
-  async $request(uri, data, query, options, router) {
+  async $request(uri, data, query, options) {
     // TODO: 合并query和options
     if (_.isObject(query) && _.isObject(options)) {
       options = { ...options, params: query, method: 'get' };
@@ -70,11 +61,7 @@ export default class AxiosWrapper {
     }
     if (!options) options = {};
     if (options.params) options.params = trimData(options.params);
-    let url = AxiosWrapper.merge(uri, options.params);
-    //处理url部分需要替换参数的情况
-    if (_.isObject(router)) {
-      url = AxiosWrapper.routerChange(url, router);
-    }
+    const url = AxiosWrapper.merge(uri, options.params);
     currentRequests += 1;
     // Indicator.open({
     //   spinnerType: 'fading-circle',
@@ -84,9 +71,7 @@ export default class AxiosWrapper {
       const axios = Axios.create({
         baseURL: this.baseUrl,
       });
-      if (sessionStorage.getItem('token')) {
-        axios.defaults.headers.common.Authorization = util.token;
-      }
+      axios.defaults.headers.common.Authorization = util.token;
       let res = await axios.request({
         method: isNullOrUndefined(data) ? 'get' : 'post',
         url,
@@ -102,7 +87,7 @@ export default class AxiosWrapper {
       }
       // unwrap data
       if (this.unwrap) {
-        res = _.omit(res, ['errmsg', 'details']);
+        res = _.omit(res, ['details']);
         const keys = Object.keys(res);
         if (keys.length === 1 && keys.includes('data')) {
           res = res.data;

+ 36 - 0
src/views/user/exportIndex.vue

@@ -0,0 +1,36 @@
+<template>
+  <div id="exportIndex">
+    <el-row>
+      <el-col :span="24" class="index">
+        <el-col :span="24" class="top">
+          <topInfo :topTitle="pageTitle"></topInfo>
+        </el-col>
+        <el-col :span="24" class="info">
+          主体
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+<script>
+import topInfo from '@/layout/public/top.vue';
+export default {
+  name: 'exportIndex',
+  props: {},
+  components: {
+    topInfo,
+  },
+  data: () => ({}),
+  created() {},
+  methods: {},
+  computed: {
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+<style lang="less" scoped></style>

+ 89 - 0
src/views/user/index.vue

@@ -0,0 +1,89 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="index">
+        <el-col :span="24" class="top">
+          <topInfo :topTitle="pageTitle"></topInfo>
+        </el-col>
+        <el-col :span="24" class="add" style="text-align:right">
+          <el-button size="mini" type="primary" @click="$router.push({ path: './detail' })" icon="el-icon-plus">添加用户</el-button>
+        </el-col>
+      </el-col>
+      <el-col :span="24" class="info">
+        <data-table :fields="fields" @delete="toDelete" :data="list" :opera="opera" @edit="toEdit" :total="total" @query="search"></data-table>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+<script>
+import topInfo from '@/layout/public/top.vue';
+import dataTable from '@/components/data-table.vue';
+import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: users } = createNamespacedHelpers('users');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    topInfo,
+    dataTable,
+  },
+  data: () => ({
+    opera: [
+      {
+        label: '编辑',
+        icon: 'el-icon-edit',
+        method: 'edit',
+      },
+      {
+        label: '删除',
+        icon: 'el-icon-delete',
+        method: 'delete',
+        confirm: true,
+      },
+    ],
+    fields: [
+      { label: '姓名', prop: 'name', filter: 'input' },
+      { label: '身份证号', prop: 'cardnumber', filter: 'input' },
+      { label: '电话', prop: 'phone', filter: 'input' },
+      { label: '状态', prop: 'status', format: i => (i == '0' ? '待审核' : i == '1' ? '审核成功' : '审核拒绝') },
+    ],
+    list: [],
+    total: 0,
+  }),
+  created() {
+    this.search();
+  },
+  methods: {
+    ...users(['query', 'delete', 'update']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    toEdit({ data }) {
+      this.$router.push({ path: './detail', query: { id: data.id } });
+    },
+    async toDelete({ data }) {
+      const res = await this.delete(data.id);
+      if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) this.search();
+    },
+  },
+  computed: {
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+<style lang="less" scoped>
+.add {
+  height: 40px;
+  line-height: 40px;
+  padding: 0 15px;
+}
+</style>

+ 36 - 0
src/views/user/temporaryIndex.vue

@@ -0,0 +1,36 @@
+<template>
+  <div id="temporaryIndex">
+    <el-row>
+      <el-col :span="24" class="index">
+        <el-col :span="24" class="top">
+          <topInfo :topTitle="pageTitle"></topInfo>
+        </el-col>
+        <el-col :span="24" class="info">
+          主体
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+<script>
+import topInfo from '@/layout/public/top.vue';
+export default {
+  name: 'temporaryIndex',
+  props: {},
+  components: {
+    topInfo,
+  },
+  data: () => ({}),
+  created() {},
+  methods: {},
+  computed: {
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+<style lang="less" scoped></style>