Browse Source

Merge branch 'master' of http://git.cc-lotus.info/user-juris/userjuris-cms

lrf402788946 4 years ago
parent
commit
9da39e5442
3 changed files with 230 additions and 21 deletions
  1. 5 5
      src/router/index.js
  2. 115 8
      src/views/permission/index.vue
  3. 110 8
      src/views/vip/index.vue

+ 5 - 5
src/router/index.js

@@ -40,11 +40,11 @@ export default new Router({
           component: () => import('../views/business/index.vue'),
           meta: { title: '业务管理员' },
         },
-        {
-          path: '/vip',
-          component: () => import('../views/vip/index.vue'),
-          meta: { title: 'VIP用户' },
-        },
+        // {
+        //   path: '/vip',
+        //   component: () => import('../views/vip/index.vue'),
+        //   meta: { title: 'VIP用户' },
+        // },
         {
           path: '/user',
           component: () => import('../views/user/index.vue'),

+ 115 - 8
src/views/permission/index.vue

@@ -1,32 +1,139 @@
 <template>
   <div id="index">
     <el-row>
-      <el-col :span="24">
-        <p>index</p>
+      <el-col :span="24" class="main">
+        <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
+        <el-col :span="24" class="container info">
+          <el-col :span="24" class="list">
+            <data-table :fields="fields" :opera="opera" :data="list" :total="total" @edit="toEdit" @query="search"></data-table>
+          </el-col>
+        </el-col>
       </el-col>
     </el-row>
+    <el-dialog title="增加权限" :visible.sync="dialog" width="50%" @close="toClose" :destroy-on-close="true">
+      <data-form :data="form" :fields="formFields" @save="turnSave">
+        <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-dialog>
   </div>
 </template>
 
 <script>
+import breadcrumb from '@c/common/breadcrumb.vue';
+import dataTable from '@/components/frame/filter-page-table.vue';
+import dataForm from '@/components/frame/form.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: authUser } = createNamespacedHelpers('authUser');
+const { mapActions: role } = createNamespacedHelpers('role');
+const { mapActions: loginMenu } = createNamespacedHelpers('login');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
   },
   name: 'index',
   props: {},
-  components: {},
+  components: {
+    breadcrumb,
+    dataTable,
+    dataForm,
+  },
   data: function() {
-    return {};
+    return {
+      opera: [
+        {
+          label: '修改',
+          method: 'edit',
+        },
+      ],
+      fields: [
+        { label: '用户名', prop: 'name' },
+        { label: '机构名称', prop: 'deptname' },
+      ],
+      list: [],
+      total: 0,
+      dialog: false,
+      formFields: [
+        { label: '用户名', model: 'name', type: 'text' },
+        { label: '机构名称', model: 'deptname', type: 'text' },
+        { label: '权限', model: 'menus', custom: true },
+      ],
+      form: {},
+      menuList: [],
+    };
+  },
+  async created() {
+    await this.search();
+    await this.getOtherList();
+  },
+  methods: {
+    ...authUser(['fetch', 'query', 'update']),
+    ...role({ getRoleList: 'query' }),
+    ...loginMenu(['toGetMenu']),
+    // 查询列表
+    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);
+      }
+    },
+    // 修改
+    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.dialog = true;
+    },
+    // 保存
+    async turnSave({ data }) {
+      let res;
+      let msg;
+      if (data.id) {
+        res = await this.update(data);
+        msg = '修改成功';
+      } else {
+        res = await this.create(data);
+        msg = '创建成功';
+      }
+      if (this.$checkRes(res, msg, res.errmsg)) {
+        this.toClose();
+        this.search();
+      }
+    },
+    // 取消增加
+    toClose() {
+      this.dialog = false;
+      this.form = { menus: [] };
+    },
+    async getOtherList() {
+      if (this.user.role == '0') {
+        const res = await this.getRoleList({ id: this.user.uid });
+        if (this.$checkRes(res)) this.$set(this, `menuList`, res.data.reverse());
+      } else if (this.user.role == '1') {
+        const res = await this.toGetMenu({ id: this.user.uid });
+        if (this.$checkRes(res)) this.$set(this, `menuList`, res.data.menus.reverse());
+      }
+    },
   },
-  created() {},
-  methods: {},
   computed: {
     ...mapState(['user']),
   },
-  watch: {},
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.main {
+  .info {
+    .top {
+      text-align: right;
+      margin: 15px 0;
+    }
+  }
+}
+</style>

+ 110 - 8
src/views/vip/index.vue

@@ -1,32 +1,134 @@
 <template>
   <div id="index">
     <el-row>
-      <el-col :span="24">
-        <p>index</p>
+      <el-col :span="24" class="main">
+        <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
+        <el-col :span="24" class="container info">
+          <el-col :span="24" class="top">
+            <el-button type="primary" size="mini" @click="dialog = true">添加</el-button>
+          </el-col>
+          <el-col :span="24" class="list">
+            <data-table :fields="fields" :opera="opera" :data="list" :total="total" @edit="toEdit" @delete="toDelete" @query="search"></data-table>
+          </el-col>
+        </el-col>
       </el-col>
     </el-row>
+    <el-dialog :visible.sync="dialog" title="增加菜单" @close="toClose" :destroy-on-close="true" width="50%">
+      <data-form :data="form" :fields="formFields" :rules="rules" @save="turnSave"> </data-form>
+    </el-dialog>
   </div>
 </template>
 
 <script>
+import breadcrumb from '@c/common/breadcrumb.vue';
+import dataTable from '@/components/frame/filter-page-table.vue';
+import dataForm from '@/components/frame/form.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: role } = createNamespacedHelpers('role');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
   },
   name: 'index',
   props: {},
-  components: {},
+  components: {
+    breadcrumb,
+    dataTable,
+    dataForm,
+  },
   data: function() {
-    return {};
+    return {
+      opera: [
+        {
+          label: '修改',
+          icon: 'el-icon-edit',
+          method: 'edit',
+        },
+        {
+          label: '删除',
+          icon: 'el-icon-delete',
+          method: 'delete',
+        },
+      ],
+      fields: [
+        { label: '菜单名称', prop: 'role_name' },
+        { label: '路由', prop: 'url' },
+      ],
+      list: [],
+      total: 0,
+      // 增加菜单
+      dialog: false,
+      formFields: [
+        { label: '菜单名称', required: true, model: 'role_name' },
+        { label: '菜单地址', required: true, model: 'url' },
+      ],
+      form: {},
+      rules: {
+        role_name: [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
+        url: [{ required: true, message: '请输入菜单地址', trigger: 'blur' }],
+      },
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...role(['query', 'create', 'update', 'delete']),
+    // 查询列表
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data.reverse());
+        this.$set(this, `total`, res.total);
+      }
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$set(this, 'form', data);
+      this.dialog = true;
+    },
+    // 删除
+    async toDelete({ data }) {
+      const res = await this.delete(data.id);
+      if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) this.search();
+    },
+    // 增加菜单
+    // 保存
+    async turnSave({ data }) {
+      let res;
+      let msg;
+      data.type = 1;
+      if (data.id) {
+        res = await this.update(data);
+        msg = '修改成功';
+      } else {
+        res = await this.create(data);
+        msg = '创建成功';
+      }
+      if (this.$checkRes(res, msg, res.errmsg)) {
+        this.toClose();
+        this.search();
+      }
+    },
+    // 取消增加
+    toClose() {
+      this.form = {};
+      this.dialog = false;
+    },
   },
-  created() {},
-  methods: {},
   computed: {
     ...mapState(['user']),
   },
-  watch: {},
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.main {
+  .info {
+    .top {
+      text-align: right;
+      margin: 15px 0;
+    }
+  }
+}
+</style>