guhongwei 5 years ago
parent
commit
b91d2dc10e

+ 2 - 2
src/layout/layout-part/newmenu.vue

@@ -35,7 +35,7 @@
 import {
   index,
   menu,
-  department,
+  // department,
   permission,
   adminUser,
   business,
@@ -71,7 +71,7 @@ export default {
         this.menu.push(
           index,
           menu,
-          department,
+          // department,
           permission,
           adminUser,
           business,

+ 28 - 15
src/router/index.js

@@ -23,6 +23,34 @@ const routes = [
     meta: { title: '部门管理' },
     component: () => import('../views/department/index.vue'),
   },
+  // 权限管理
+  {
+    path: '/permission/index',
+    meta: { title: '权限管理' },
+    component: () => import('../views/permission/index.vue'),
+  },
+  // 机构管理员
+  {
+    path: '/adminUser/index',
+    meta: { title: '机构管理员' },
+    component: () => import('../views/adminUser/index.vue'),
+  },
+  {
+    path: '/adminUser/detail',
+    meta: { title: '机构管理员信息管理' },
+    component: () => import('../views/adminUser/detail.vue'),
+  },
+  // 业务管理员
+  {
+    path: '/business/index',
+    meta: { title: '业务管理员' },
+    component: () => import('../views/business/index.vue'),
+  },
+  {
+    path: '/business/detail',
+    meta: { title: '业务员管理员信息管理' },
+    component: () => import('../views/adminUser/detail.vue'),
+  },
   // 用戶管理
   // 个人&企业&专家
   {
@@ -62,12 +90,6 @@ const routes = [
     path: '/duijiehui/duijiehuistatus',
     component: () => import('../views/duijiehui/duijiehuistatus.vue'),
   },
-  // 部门管理
-  {
-    path: '/department/index',
-    meta: { title: '部门管理' },
-    component: () => import('../views/department/index.vue'),
-  },
   //产品供求审核管理
   {
     path: '/enterpriseProduct/index',
@@ -85,20 +107,12 @@ const routes = [
     path: '/enterpriseTrans/detail',
     component: () => import('../views/enterpriseTrans/detail.vue'),
   },
-
-  //科技超市交易审核管理
-  {
-    path: '/enterpriseTrans/jiaoyidetail',
-    component: () => import('../views/enterpriseTrans/jiaoyidetail.vue'),
-  },
-
   //技术培训
   {
     path: '/technical/index',
     meta: { title: '技术培训' },
     component: () => import('../views/technical/index.vue'),
   },
-
   // 技术培训-栏目列表
   {
     path: '/technical/columnDetail',
@@ -109,7 +123,6 @@ const routes = [
     path: '/technical/messageInfoDetail',
     component: () => import('../views/technical/messageInfoDetail.vue'),
   },
-
   //字典管理
   {
     path: '/dictionary/index',

+ 2 - 0
src/store/index.js

@@ -13,6 +13,7 @@ import codeCategory from './codeCategory';
 import exportuser from './exportuser';
 //菜单分配权限
 import role from './user/role';
+import authUser from './user/auth-user';
 // 个人&企业
 import users from './user';
 // 对接会
@@ -39,6 +40,7 @@ export default new Vuex.Store({
     place, //地址
     apply, //对接会
     role, //菜单分配权限
+    authUser, //管理员
   },
   state: { ...ustate },
   mutations: { ...umutations },

+ 91 - 0
src/views/adminUser/detail.vue

@@ -0,0 +1,91 @@
+<template>
+  <div id="detail">
+    <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="main">
+          <data-form :fields="fields" :data="form" :rules="{}" @save="drawerSave" :isNew="drawerIsNew"></data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import dataForm from '@/components/form.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: users } = createNamespacedHelpers('users');
+export default {
+  name: 'detail',
+  props: {},
+  components: {
+    topInfo,
+    dataForm,
+  },
+  data: function() {
+    return {
+      drawerIsNew: true,
+      form: {},
+      fields: [
+        { label: '姓名', prop: 'name', model: 'name' },
+        { label: '机构名称', prop: 'deptname', model: 'deptname' },
+        { label: '手机号', prop: 'phone', model: 'phone' },
+        { label: '密码', prop: 'password', model: 'password', type: 'password' },
+      ],
+    };
+  },
+  created() {},
+  methods: {
+    ...users(['fetch', 'create', 'update']),
+    async search() {
+      const res = await this.fetch(this.id);
+      if (this.$checkRes(res)) this.$set(this, `form`, res.data);
+    },
+    // 创建&修改
+    async drawerSave({ data, isNew }) {
+      let res;
+      let msg;
+      if (this.isNew) {
+        data.pid = this.user.uid;
+        data.role = '4';
+        res = await this.create(data);
+        msg = '创建成功';
+      } else {
+        res = await this.update(data);
+        msg = '修改成功';
+      }
+      this.$router.push({ path: '/adminUser/index' });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+    isNew() {
+      return this.$route.query.id ? false : true;
+    },
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    isNew: {
+      handler(val) {
+        if (!val) {
+          this.search();
+        }
+      },
+      immediate: true,
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 94 - 0
src/views/adminUser/index.vue

@@ -0,0 +1,94 @@
+<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 :span="24" class="main">
+          <data-table :fields="fields" @delete="toDelete" :data="list" :opera="opera" @edit="toEdit" :total="total" @query="search"></data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import dataTable from '@/components/data-table.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: users } = createNamespacedHelpers('users');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    topInfo,
+    dataTable,
+  },
+  data: function() {
+    return {
+      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: 'deptname', filter: 'input' },
+        { label: '电话', prop: 'phone', filter: 'input' },
+      ],
+      list: [],
+      total: 0,
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...users(['query', 'fetch', 'create', 'update', 'delete']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, pid: this.user.uid, ...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: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.add {
+  padding: 0 20px;
+}
+.main {
+  padding: 0 20px;
+}
+</style>

+ 91 - 0
src/views/business/detial.vue

@@ -0,0 +1,91 @@
+<template>
+  <div id="detail">
+    <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="main">
+          <data-form :fields="fields" :data="form" :rules="{}" @save="drawerSave" :isNew="drawerIsNew"></data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import dataForm from '@/components/form.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: users } = createNamespacedHelpers('users');
+export default {
+  name: 'detail',
+  props: {},
+  components: {
+    topInfo,
+    dataForm,
+  },
+  data: function() {
+    return {
+      drawerIsNew: true,
+      form: {},
+      fields: [
+        { label: '姓名', prop: 'name', model: 'name' },
+        { label: '机构名称', prop: 'deptname', model: 'deptname' },
+        { label: '手机号', prop: 'phone', model: 'phone' },
+        { label: '密码', prop: 'password', model: 'password', type: 'password' },
+      ],
+    };
+  },
+  created() {},
+  methods: {
+    ...users(['fetch', 'create', 'update']),
+    async search() {
+      const res = await this.fetch(this.id);
+      if (this.$checkRes(res)) this.$set(this, `form`, res.data);
+    },
+    // 创建&修改
+    async drawerSave({ data, isNew }) {
+      let res;
+      let msg;
+      if (this.isNew) {
+        data.pid = this.user.uid;
+        data.role = '4';
+        res = await this.create(data);
+        msg = '创建成功';
+      } else {
+        res = await this.update(data);
+        msg = '修改成功';
+      }
+      this.$router.push({ path: '/business/index' });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+    isNew() {
+      return this.$route.query.id ? false : true;
+    },
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    isNew: {
+      handler(val) {
+        if (!val) {
+          this.search();
+        }
+      },
+      immediate: true,
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 94 - 0
src/views/business/index.vue

@@ -0,0 +1,94 @@
+<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 :span="24" class="main">
+          <data-table :fields="fields" @delete="toDelete" :data="list" :opera="opera" @edit="toEdit" :total="total" @query="search"></data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import dataTable from '@/components/data-table.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: users } = createNamespacedHelpers('users');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    topInfo,
+    dataTable,
+  },
+  data: function() {
+    return {
+      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: 'deptname', filter: 'input' },
+        { label: '电话', prop: 'phone', filter: 'input' },
+      ],
+      list: [],
+      total: 0,
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...users(['query', 'fetch', 'create', 'update', 'delete']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, pid: this.user.uid, ...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: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.add {
+  padding: 0 20px;
+}
+.main {
+  padding: 0 20px;
+}
+</style>

+ 1 - 1
src/views/menu/index.vue

@@ -84,7 +84,7 @@ export default {
     async search({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.query({ ...info, category: this.category });
       if (this.$checkRes(res)) {
-        this.$set(this, `list`, res.data);
+        this.$set(this, `list`, res.data.reverse());
         this.$set(this, `total`, res.total);
       }
     },

+ 150 - 0
src/views/permission/index.vue

@@ -0,0 +1,150 @@
+<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="main">
+          <data-table
+            :fields="fields"
+            @delete="toDelete"
+            :data="list"
+            :opera="opera"
+            @edit="toEdit"
+            :total="total"
+            @query="search"
+            :usePage="true"
+          ></data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+    <el-drawer title="权限分配" :visible.sync="drawer" direction="rtl" @closed="handleClose" :destroy-on-close="false">
+      <data-form :fields="formFields" :data="form" :rules="{}" @save="drawerSave" :isNew="drawerIsNew">
+        <template #custom="{item, form}">
+          <el-checkbox-group v-model="form.menus">
+            <el-checkbox v-for="(i, index) in menuList" :key="index" :label="i._id">{{ i.role_name }}</el-checkbox>
+          </el-checkbox-group>
+        </template>
+      </data-form>
+    </el-drawer>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import dataForm from '@/components/form.vue';
+import dataTable from '@/components/data-table.vue';
+import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: authUser } = createNamespacedHelpers('authUser');
+const { mapActions: role } = createNamespacedHelpers('role');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    topInfo, //头部标题
+    dataTable,
+    dataForm,
+  },
+  data: function() {
+    return {
+      drawer: false,
+      form: {},
+      drawerIsNew: true,
+      opera: [
+        {
+          label: '编辑',
+          icon: 'el-icon-edit',
+          method: 'edit',
+        },
+        {
+          label: '删除',
+          icon: 'el-icon-delete',
+          method: 'delete',
+          confirm: true,
+        },
+      ],
+      fields: [
+        { label: '用户名', prop: 'name' },
+        { label: '机构名称', prop: 'deptname' },
+      ],
+      formFields: [
+        { label: '用户名', model: 'name', type: 'text' },
+        { label: '机构名称', model: 'deptname', type: 'text' },
+        { label: '权限', model: 'menus', custom: true },
+      ],
+      list: [],
+      menuList: [],
+      total: 0,
+    };
+  },
+  created() {
+    this.search();
+    this.getOtherList();
+  },
+  methods: {
+    ...authUser(['fetch', 'query', 'update']),
+    ...role({ getRoleList: 'query' }),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, role: '4', pid: this.user.uid, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    async drawerSave({ data, isNew }) {
+      let res;
+      let msg;
+      let duplicate = JSON.parse(JSON.stringify(data));
+      if (isNew) {
+        res = await this.create(duplicate);
+        msg = '创建成功';
+      } else {
+        res = await this.update(duplicate);
+        msg = '修改成功';
+      }
+      if (this.$checkRes(res, msg, res.errmsg)) {
+        this.handleClose();
+        this.search();
+      }
+    },
+    async toEdit({ data }) {
+      const res = await this.fetch({ id: data.id });
+      if (this.$checkRes(res)) {
+        let menus = res.data.menus;
+        this.$set(this, 'form', { ...data, menus: menus.map(i => i.id) });
+      }
+      this.drawer = true;
+      this.drawerIsNew = false;
+    },
+    async toDelete({ data }) {
+      const res = await this.delete(data.id);
+      if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) this.search();
+    },
+    handleClose() {
+      this.drawer = false;
+      this.form = { menus: [] };
+      this.drawerIsNew = true;
+    },
+    async getOtherList() {
+      const res = await this.getRoleList();
+      if (this.$checkRes(res)) this.$set(this, `menuList`, res.data.reverse());
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  padding: 15px 20px;
+}
+</style>