reloaded 5 år sedan
förälder
incheckning
daf52e56f8

+ 55 - 0
src/layout/character/characterForm.vue

@@ -0,0 +1,55 @@
+<template>
+  <div id="characterForm">
+    <el-row>
+      <el-col :span="24" class="form">
+        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
+          <el-form-item label="角色名称" prop="name">
+            <el-input v-model="ruleForm.name" placeholder="请输入角色名称"></el-input>
+          </el-form-item>
+          <el-form-item label="用户权限" prop="roles">
+            <el-checkbox-group v-model="ruleForm.roles">
+              <el-checkbox label="复选框 A" v-for="(item, index) in meunroles" :key="index">{{ item.name }}</el-checkbox>
+            </el-checkbox-group>
+          </el-form-item>
+          <el-form-item>
+            <el-button size="small" @click="resetForm('ruleForm')">取消</el-button>
+            <el-button type="primary" size="small" @click="submitForm('ruleForm')">提交</el-button>
+          </el-form-item>
+        </el-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'characterForm',
+  props: {
+    ruleForm: null,
+    meunroles: null,
+  },
+  components: {},
+  data: () => ({
+    rules: {
+      name: [{ required: true, message: '请输入角色名称', trigger: 'blur' }],
+      roles: [{ required: true, message: '请选择用户权限', trigger: 'change' }],
+    },
+  }),
+  created() {},
+  computed: {},
+  methods: {
+    submitForm() {
+      this.$emit('submitForm', { data: this.ruleForm });
+    },
+    resetForm() {
+      this.$emit('resetForm');
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.form {
+  padding: 0 200px 0 0;
+}
+</style>

+ 38 - 0
src/layout/character/characterList.vue

@@ -0,0 +1,38 @@
+<template>
+  <div id="characterList">
+    <el-row>
+      <el-col :span="24">
+        <el-table ref="debtTable" :data="debtTable" style="width: 100%" border>
+          <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
+          <el-table-column property="name" label="角色名称" align="center"> </el-table-column>
+          <el-table-column fixed="right" label="操作" align="center">
+            <template slot-scope="scope">
+              <el-button @click="$router.push({ path: '/chatacter/detail', query: { id: scope.row.id } })" type="text"><i class="el-icon-edit"></i></el-button>
+              <el-button @click.prevent="deleteRow(scope.row.id)" type="text"><i class="el-icon-delete"></i></el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'characterList',
+  props: {
+    debtTable: null,
+  },
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {
+    deleteRow(id) {
+      this.$emit('deleteRow', id);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 1 - 0
src/layout/layout-part/menus.vue

@@ -35,6 +35,7 @@
       </el-submenu>
       <el-menu-item index="/companyup/index"> <i class="el-icon-s-grid"></i>企业信息管理</el-menu-item>
       <el-menu-item index="/companyidentify/index"> <i class="el-icon-s-grid"></i>企业认证管理</el-menu-item>
+      <el-menu-item index="/character/index"> <i class="el-icon-s-grid"></i>角色管理</el-menu-item>
     </el-menu>
   </div>
 </template>

+ 10 - 0
src/router/index.js

@@ -63,6 +63,16 @@ const routes = [
     path: '/companyidentify/detail',
     component: () => import('../views/companyidentify/detail.vue'),
   },
+  // 角色管理-列表
+  {
+    path: '/character/index',
+    component: () => import('../views/character/index.vue'),
+  },
+  // 角色管理-详情
+  {
+    path: '/character/detail',
+    component: () => import('../views/character/detail.vue'),
+  },
 ];
 
 const router = new VueRouter({

+ 38 - 0
src/store/character.js

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

+ 4 - 0
src/store/index.js

@@ -5,6 +5,8 @@ import companyup from './companyup';
 import companyidentify from './companyidentify';
 import companyuser from './companyuser';
 import institution from './institution';
+import character from './character';
+import menurole from './menurole';
 
 Vue.use(Vuex);
 
@@ -15,6 +17,8 @@ export default new Vuex.Store({
     companyidentify,
     companyuser,
     institution,
+    character,
+    menurole,
   },
   state: {},
   mutations: {},

+ 38 - 0
src/store/menurole.js

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

+ 118 - 0
src/views/character/detail.vue

@@ -0,0 +1,118 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="debt">
+        <el-col :span="24" class="top">
+          <topInfo :topTitle="topTitle" :display="display"></topInfo>
+        </el-col>
+        <el-col :span="24" class="main">
+          <el-col :span="24" class="back">
+            <detailTop @goBack="goBack"></detailTop>
+          </el-col>
+          <el-col :span="24" class="info">
+            <characterForm :ruleForm="ruleForm" :meunroles="meunroles" @submitForm="submitForm" @resetForm="resetForm"></characterForm>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/common/topInfo.vue';
+import detailTop from '@/layout/common/detailTop.vue';
+import characterForm from '@/layout/character/characterForm.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: character } = createNamespacedHelpers('character');
+const { mapActions: menurole } = createNamespacedHelpers('menurole');
+export default {
+  name: 'detail',
+  props: {},
+  components: {
+    topInfo, //头部导航
+    detailTop, //头部返回
+    characterForm, //添加其他用户
+  },
+  data: () => ({
+    display: 'none',
+    topTitle: '用户信息管理',
+    ruleForm: {
+      passwd: '123456',
+    },
+    meunroles: [],
+  }),
+  created() {
+    this.searchInfo();
+    this.searchRole();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  methods: {
+    ...character(['query', 'fetch', 'update', 'create']),
+    ...menurole({ rolequery: 'query' }),
+    async searchInfo() {
+      if (this.id) {
+        const res = await this.fetch(this.id);
+        this.$set(this, `ruleForm`, res.data);
+      }
+    },
+    async searchRole() {
+      const res = await this.rolequery();
+      this.$set(this, `meunroles`, res.data);
+      console.log(res.data);
+    },
+    // 提交
+    async submitForm({ data }) {
+      let res;
+      if (this.id) {
+        res = await this.update(data);
+        if (res.errcode === 0) {
+          this.$message({
+            message: '信息修改成功',
+            type: 'success',
+          });
+        }
+      } else {
+        res = await this.create(data);
+        if (res.errcode === 0) {
+          this.$message({
+            message: '信息创建成功',
+            type: 'success',
+          });
+        }
+      }
+      if (this.$checkRes(res)) this.resetForm();
+
+      console.log(res.data);
+    },
+    // 取消
+    resetForm() {
+      this.$router.push({ path: '/character/index' });
+    },
+    // 返回
+    goBack() {
+      this.$router.go(-1);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.debt {
+  padding: 20px;
+}
+.top {
+  border-bottom: 1px solid #ccc;
+}
+.main {
+  border-radius: 10px;
+  margin: 20px 0 0 0;
+  box-shadow: 0 0 3px #666;
+}
+.main .back {
+  padding: 10px 0 10px 15px;
+}
+</style>

+ 68 - 0
src/views/character/index.vue

@@ -0,0 +1,68 @@
+<template>
+  <div id="index">
+    <el-col :span="24" class="debt">
+      <el-col :span="24" class="top">
+        <topInfo :topTitle="topTitle" :display="display" @clickBtn="clickBtn"></topInfo>
+      </el-col>
+      <el-col :span="24" class="search">
+        <searchInfo></searchInfo>
+      </el-col>
+      <el-col :span="24" class="main">
+        <characterList :debtTable="debtTable" @deleteRow="deleteRow"></characterList>
+      </el-col>
+    </el-col>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/common/topInfo.vue';
+import searchInfo from '@/layout/common/searchInfo.vue';
+import characterList from '@/layout/character/characterList.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: character } = createNamespacedHelpers('character');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    topInfo, //头部导航
+    searchInfo, //搜素
+    characterList, //角色列表
+  },
+  data: () => ({
+    topTitle: '角色管理',
+    display: 'block',
+    debtTable: [],
+  }),
+  created() {
+    this.searchInfo();
+  },
+  computed: {},
+  methods: {
+    ...character(['query', 'delete']),
+
+    async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      this.$set(this, `debtTable`, res.data);
+    },
+    // 添加
+    clickBtn() {
+      this.$router.push({ path: '/character/detail' });
+    },
+    // 删除
+    async deleteRow(id) {
+      const res = await this.delete(id);
+      this.$checkRes(res, '删除成功', '删除失败');
+      this.searchInfo();
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.debt {
+  padding: 20px;
+}
+.top {
+  border-bottom: 1px solid #ccc;
+}
+</style>

+ 3 - 0
src/views/otheruser/index.vue

@@ -20,6 +20,7 @@ import searchInfo from '@/layout/common/searchInfo.vue';
 import otheruserList from '@/layout/otheruser/otheruserList.vue';
 import { createNamespacedHelpers, mapGetters } from 'vuex';
 const { mapActions: otheruser } = createNamespacedHelpers('otheruser');
+const { mapActions: character } = createNamespacedHelpers('character');
 export default {
   name: 'index',
   props: {},
@@ -39,6 +40,8 @@ export default {
   computed: {},
   methods: {
     ...otheruser(['query', 'delete']),
+    ...character({ userquery: 'query' }),
+
     async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.query({ skip, limit, ...info });
       this.$set(this, `debtTable`, res.data);