guhongwei 4 anni fa
parent
commit
eabeb2fedd

+ 14 - 35
src/components/common/Sidebar.vue

@@ -40,6 +40,7 @@
 <script>
 import _ from 'lodash';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: menu } = createNamespacedHelpers('menu');
 import bus from '../common/bus';
 export default {
   data() {
@@ -68,46 +69,24 @@ export default {
     });
   },
   methods: {
+    ...menu(['query']),
     // 分配用户彩带权限
-    getMenu() {
+    async getMenu() {
       // 客户信息
       let user = this.user;
       // 复制列表
       let list = _.cloneDeep(this.items);
-      let data = [
-        {
-          icon: 'el-icon-s-home',
-          index: 'menu',
-          title: '菜单管理',
-        },
-        {
-          icon: 'el-icon-s-home',
-          index: 'gly',
-          title: '管理员管理',
-        },
-        {
-          icon: 'el-icon-s-home',
-          index: 'jg',
-          title: '机构管理员',
-        },
-        {
-          icon: 'el-icon-s-home',
-          index: 'yw',
-          title: '业务管理员',
-        },
-        {
-          icon: 'el-icon-s-home',
-          index: 'qx',
-          title: '权限管理',
-        },
-        {
-          icon: 'el-icon-s-home',
-          index: 'user',
-          title: '用户管理',
-        },
-      ];
-      list.push(...data);
-      this.$set(this, `items`, _.uniqBy(list, 'index'));
+      if (user.role == '0') {
+        let res = await this.query();
+        if (this.$checkRes(res)) {
+          list.push(...res.data);
+          this.$set(this, `items`, _.uniqBy(list, 'index'));
+        }
+      } else {
+        let data = user.menus;
+        list.push(...data);
+        this.$set(this, `items`, _.uniqBy(list, 'index'));
+      }
     },
   },
   watch: {

+ 0 - 1
src/main.js

@@ -37,7 +37,6 @@ router.beforeEach((to, from, next) => {
     next('/login');
   } else {
     let user = jwt.decode(token);
-    console.log(user);
     store.commit('setUser', user, { root: true });
     next();
   }

+ 2 - 2
src/store/index.js

@@ -3,7 +3,7 @@ import Vuex from 'vuex';
 import * as ustate from './user/state';
 import * as umutations from './user/mutations';
 import adminLogin from './adminLogin';
-import place from '@common/src/store/place';
+import menu from '@common/src/store/menu';
 
 Vue.use(Vuex);
 
@@ -13,6 +13,6 @@ export default new Vuex.Store({
   actions: {},
   modules: {
     adminLogin,
-    place,
+    menu,
   },
 });

+ 73 - 2
src/views/gly/index.vue

@@ -6,17 +6,39 @@
           <el-button type="primary" size="mini" @click="add">添加</el-button>
         </el-col>
         <el-col :span="24" class="list">
-          <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @delete="toDelete"></data-table>
+          <data-table
+            :fields="fields"
+            :opera="opera"
+            :data="list"
+            :total="total"
+            @query="search"
+            @menuBtn="menuBtn"
+            @edit="toEdit"
+            @delete="toDelete"
+          ></data-table>
         </el-col>
       </el-col>
     </el-row>
+    <el-dialog title="权限信息管理" width="40%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
+      <data-form :data="form" :fields="formfields" :rules="rules" @save="toSave">
+        <template #custom="{item,form}">
+          <template v-if="item.model == 'menus'">
+            <el-checkbox-group v-model="form.menus">
+              <el-checkbox v-for="(i, index) in menuList" :key="index" :label="i.id">{{ i.title }}</el-checkbox>
+            </el-checkbox-group>
+          </template>
+        </template>
+      </data-form>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import dataTable from '@common/src/components/frame/filter-page-table.vue';
+import dataForm from '@common/src/components/frame/form.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
+const { mapActions: mapMenu } = createNamespacedHelpers('menu');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -25,10 +47,15 @@ export default {
   props: {},
   components: {
     dataTable,
+    dataForm,
   },
   data: function() {
     return {
       opera: [
+        {
+          label: '分配权限',
+          method: 'menuBtn',
+        },
         {
           label: '编辑',
           method: 'edit',
@@ -46,13 +73,28 @@ export default {
       ],
       list: [],
       total: 0,
+      // 分配权限
+      dialog: false,
+      formfields: [
+        { label: '用户名', model: 'name' },
+        { label: '机构名称', model: 'deptname' },
+        { label: '权限', model: 'menus', custom: true },
+      ],
+      form: {
+        menus: [],
+      },
+      rules: {},
+      // 菜单列表
+      menuList: [],
     };
   },
   async created() {
+    await this.searchOther();
     await this.search();
   },
   methods: {
-    ...adminLogin(['query', 'delete']),
+    ...adminLogin(['query', 'update', 'delete']),
+    ...mapMenu({ menuQuery: 'query' }),
     // 查询列表
     async search({ skip = 0, limit = 10, ...info } = {}) {
       let res = await this.query({ skip, limit, role: '1', ...info });
@@ -80,6 +122,35 @@ export default {
     add() {
       this.$router.push({ path: '/gly/detail' });
     },
+    // 分配菜单
+    menuBtn({ data }) {
+      this.$set(this, 'form', { ...data, menus: data.menus.map(i => i.id) });
+      this.dialog = true;
+    },
+    // 提交分配
+    async toSave({ data }) {
+      let res = await this.update(data);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '分配权限成功',
+          type: 'success',
+        });
+        this.handleClose();
+      }
+    },
+    // 取消添加
+    handleClose() {
+      this.form = { menus: [] };
+      this.dialog = false;
+      this.search();
+    },
+    // 查询其他信息
+    async searchOther() {
+      let res = await this.menuQuery();
+      if (this.$checkRes(res)) {
+        this.$set(this, `menuList`, res.data);
+      }
+    },
   },
   computed: {
     ...mapState(['user']),

+ 73 - 3
src/views/jg/index.vue

@@ -6,18 +6,39 @@
           <el-button type="primary" size="mini" @click="add">添加</el-button>
         </el-col>
         <el-col :span="24" class="list">
-          <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @delete="toDelete"></data-table>
+          <data-table
+            :fields="fields"
+            :opera="opera"
+            :data="list"
+            :total="total"
+            @query="search"
+            @menuBtn="menuBtn"
+            @edit="toEdit"
+            @delete="toDelete"
+          ></data-table>
         </el-col>
       </el-col>
     </el-row>
+    <el-dialog title="权限信息管理" width="40%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
+      <data-form :data="form" :fields="formfields" :rules="rules" @save="toSave">
+        <template #custom="{item,form}">
+          <template v-if="item.model == 'menus'">
+            <el-checkbox-group v-model="form.menus">
+              <el-checkbox v-for="(i, index) in menuList" :key="index" :label="i.id">{{ i.title }}</el-checkbox>
+            </el-checkbox-group>
+          </template>
+        </template>
+      </data-form>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import dataTable from '@common/src/components/frame/filter-page-table.vue';
+import dataForm from '@common/src/components/frame/form.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
-
+const { mapActions: mapMenu } = createNamespacedHelpers('menu');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -26,10 +47,15 @@ export default {
   props: {},
   components: {
     dataTable,
+    dataForm,
   },
   data: function() {
     return {
       opera: [
+        {
+          label: '分配权限',
+          method: 'menuBtn',
+        },
         {
           label: '编辑',
           method: 'edit',
@@ -47,13 +73,27 @@ export default {
       ],
       list: [],
       total: 0,
+      // 分配权限
+      dialog: false,
+      formfields: [
+        { label: '用户名', model: 'name' },
+        { label: '机构名称', model: 'deptname' },
+        { label: '权限', model: 'menus', custom: true },
+      ],
+      form: {
+        menus: [],
+      },
+      rules: {},
+      // 菜单列表
+      menuList: [],
     };
   },
   async created() {
     await this.search();
   },
   methods: {
-    ...adminLogin(['query', 'delete']),
+    ...adminLogin(['query', 'fetch', 'update', 'delete']),
+    ...mapMenu({ menuQuery: 'query' }),
     // 查询列表
     async search({ skip = 0, limit = 10, ...info } = {}) {
       if (this.user.role == '1' || this.user.role == '2') info.pid = this.user.id;
@@ -82,6 +122,36 @@ export default {
     add() {
       this.$router.push({ path: '/jg/detail' });
     },
+    // 分配菜单
+    menuBtn({ data }) {
+      this.searchOther(data.pid);
+      this.$set(this, 'form', { ...data, menus: data.menus.map(i => i.id) });
+      this.dialog = true;
+    },
+    // 查询该管理下得菜单
+    async searchOther(id) {
+      let res = await this.fetch(id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `menuList`, res.data.menus);
+      }
+    },
+    // 提交分配
+    async toSave({ data }) {
+      let res = await this.update(data);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '分配权限成功',
+          type: 'success',
+        });
+        this.handleClose();
+      }
+    },
+    // 取消添加
+    handleClose() {
+      this.form = { menus: [] };
+      this.dialog = false;
+      this.search();
+    },
   },
   computed: {
     ...mapState(['user']),

+ 39 - 8
src/views/menu/index.vue

@@ -20,7 +20,6 @@
         </template>
         <template #options="{item}">
           <template v-if="item.model === 'icon'">
-            <!-- <el-option v-for="(i, index) in iconList" :key="index" :label="i.name" :value="i.iconIndex"></el-option> -->
             <el-option v-for="(i, index) in iconList" :key="index" :label="i.name" :value="i.iconkey">
               <span style="float: left">{{ i.name }}</span>
               <span style="float: right; color: #8492a6; font-size: 13px"><i :class="i.iconkey"></i></span>
@@ -37,6 +36,7 @@ import dataTable from '@common/src/components/frame/filter-page-table.vue';
 import dataForm from '@common/src/components/frame/form.vue';
 import { iconmenu } from '@common/src/util/iconmenu';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: menu } = createNamespacedHelpers('menu');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -78,21 +78,52 @@ export default {
     await this.search();
   },
   methods: {
+    ...menu(['query', 'fetch', 'create', 'update', 'delete']),
     // 查询列表
-    search({ skip = 0, limit = 10, ...info } = {}) {
-      console.log('列表');
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     // 提交
-    toSave({ data }) {
-      console.log(data);
+    async toSave({ data }) {
+      if (data.id) {
+        let res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '信息修改成功',
+            type: 'success',
+          });
+          this.handleClose();
+        }
+      } else {
+        let res = await this.create(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '信息创建成功',
+            type: 'success',
+          });
+          this.handleClose();
+        }
+      }
     },
     // 修改
     toEdit({ data }) {
-      console.log('修改');
+      this.$set(this, `form`, data);
+      this.dialog = true;
     },
     // 删除
-    toDelete({ data }) {
-      console.log('删除');
+    async toDelete({ data }) {
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '信息修改成功',
+          type: 'success',
+        });
+        this.search();
+      }
     },
     // 取消添加
     handleClose() {

+ 45 - 37
src/views/qx/index.vue

@@ -7,12 +7,10 @@
     </el-row>
     <el-dialog title="菜单信息管理" width="40%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
       <data-form :data="form" :fields="formfields" :rules="rules" @save="toSave">
-        <template #custom="{item}">
-          <template v-if="item.model == 'menus'">
-            <el-checkbox-group v-model="menus">
-              <el-checkbox v-for="(i, index) in menuList" :key="index" :label="i">{{ i.title }}</el-checkbox>
-            </el-checkbox-group>
-          </template>
+        <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.title }}</el-checkbox>
+          </el-checkbox-group>
         </template>
       </data-form>
     </el-dialog>
@@ -24,6 +22,8 @@ import dataTable from '@common/src/components/frame/filter-page-table.vue';
 import dataForm from '@common/src/components/frame/form.vue';
 import { iconmenu } from '@common/src/util/iconmenu';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
+const { mapActions: menu } = createNamespacedHelpers('menu');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -43,12 +43,24 @@ export default {
         },
       ],
       fields: [
+        { label: '机构代码或邀请码', prop: 'code' },
         { label: '用户名', prop: 'name' },
+        { label: '联系电话', prop: 'phone' },
         { label: '机构名称', prop: 'deptname' },
       ],
       list: [
         {
-          name: '年',
+          name: 'sadas',
+          menus: [
+            {
+              id: '1',
+              title: '菜单一',
+            },
+            {
+              id: '2',
+              title: '菜单二',
+            },
+          ],
         },
       ],
       total: 0,
@@ -59,60 +71,49 @@ export default {
         { label: '机构名称', model: 'deptname' },
         { label: '权限', model: 'menus', custom: true },
       ],
-      form: {},
+      form: {
+        menus: [],
+      },
       rules: {},
       // 菜单列表
       menuList: [
         {
-          icon: 'el-icon-s-home',
-          index: 'menu',
-          title: '菜单管理',
+          id: '1',
+          title: '菜单一',
         },
         {
-          icon: 'el-icon-s-home',
-          index: 'gly',
-          title: '管理员管理',
+          id: '2',
+          title: '菜单二',
         },
         {
-          icon: 'el-icon-s-home',
-          index: 'jg',
-          title: '机构管理员',
-        },
-        {
-          icon: 'el-icon-s-home',
-          index: 'yw',
-          title: '业务管理员',
-        },
-        {
-          icon: 'el-icon-s-home',
-          index: 'qx',
-          title: '权限管理',
-        },
-        {
-          icon: 'el-icon-s-home',
-          index: 'user',
-          title: '用户管理',
+          id: '3',
+          title: '菜单三',
         },
       ],
-      menus: [],
     };
   },
   async created() {
+    await this.searchOther();
     await this.search();
   },
   methods: {
+    ...adminLogin(['query']),
+    ...menu({ menuQuery: 'query' }),
     // 查询列表
-    search({ skip = 0, limit = 10, ...info } = {}) {
-      console.log('列表');
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let 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.dialog = true;
-      console.log('分配权限');
+      this.$set(this, 'form', { ...data, menus: data.menus.map(i => i.id) });
     },
     // 提交分配
     toSave({ data }) {
-      data.menus = this.menus;
       console.log(data);
     },
     // 取消添加
@@ -121,6 +122,13 @@ export default {
       this.dialog = false;
       this.search();
     },
+    // 查询其他信息
+    async searchOther() {
+      let res = await this.menuQuery();
+      if (this.$checkRes(res)) {
+        // this.$set(this, `menuList`, res.data);
+      }
+    },
   },
   computed: {
     ...mapState(['user']),

+ 73 - 2
src/views/yw/index.vue

@@ -6,17 +6,39 @@
           <el-button type="primary" size="mini" @click="add">添加</el-button>
         </el-col>
         <el-col :span="24" class="list">
-          <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @delete="toDelete"></data-table>
+          <data-table
+            :fields="fields"
+            :opera="opera"
+            :data="list"
+            :total="total"
+            @query="search"
+            @menuBtn="menuBtn"
+            @edit="toEdit"
+            @delete="toDelete"
+          ></data-table>
         </el-col>
       </el-col>
     </el-row>
+    <el-dialog title="权限信息管理" width="40%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
+      <data-form :data="form" :fields="formfields" :rules="rules" @save="toSave">
+        <template #custom="{item,form}">
+          <template v-if="item.model == 'menus'">
+            <el-checkbox-group v-model="form.menus">
+              <el-checkbox v-for="(i, index) in menuList" :key="index" :label="i.id">{{ i.title }}</el-checkbox>
+            </el-checkbox-group>
+          </template>
+        </template>
+      </data-form>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import dataTable from '@common/src/components/frame/filter-page-table.vue';
+import dataForm from '@common/src/components/frame/form.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
+const { mapActions: mapMenu } = createNamespacedHelpers('menu');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -25,10 +47,15 @@ export default {
   props: {},
   components: {
     dataTable,
+    dataForm,
   },
   data: function() {
     return {
       opera: [
+        {
+          label: '分配权限',
+          method: 'menuBtn',
+        },
         {
           label: '编辑',
           method: 'edit',
@@ -46,13 +73,27 @@ export default {
       ],
       list: [],
       total: 0,
+      // 分配权限
+      dialog: false,
+      formfields: [
+        { label: '用户名', model: 'name' },
+        { label: '机构名称', model: 'deptname' },
+        { label: '权限', model: 'menus', custom: true },
+      ],
+      form: {
+        menus: [],
+      },
+      rules: {},
+      // 菜单列表
+      menuList: [],
     };
   },
   async created() {
     await this.search();
   },
   methods: {
-    ...adminLogin(['query', 'delete']),
+    ...adminLogin(['query', 'fetch', 'update', 'delete']),
+    ...mapMenu({ menuQuery: 'query' }),
     // 查询列表
     async search({ skip = 0, limit = 10, ...info } = {}) {
       if (this.user.role == '1' || this.user.role == '2') info.pid = this.user.id;
@@ -81,6 +122,36 @@ export default {
     add() {
       this.$router.push({ path: '/yw/detail' });
     },
+    // 分配菜单
+    menuBtn({ data }) {
+      this.searchOther(data.pid);
+      this.$set(this, 'form', { ...data, menus: data.menus.map(i => i.id) });
+      this.dialog = true;
+    },
+    // 查询该管理下得菜单
+    async searchOther(id) {
+      let res = await this.fetch(id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `menuList`, res.data.menus);
+      }
+    },
+    // 提交分配
+    async toSave({ data }) {
+      let res = await this.update(data);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '分配权限成功',
+          type: 'success',
+        });
+        this.handleClose();
+      }
+    },
+    // 取消添加
+    handleClose() {
+      this.form = { menus: [] };
+      this.dialog = false;
+      this.search();
+    },
   },
   computed: {
     ...mapState(['user']),