Quellcode durchsuchen

Merge branch 'master' of http://git.cc-lotus.info/financial_platform/admin-cms

wuhongyuq vor 5 Jahren
Ursprung
Commit
14b32e82af

+ 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>

+ 0 - 4
src/layout/otheruser/otheruserForm.vue

@@ -9,9 +9,6 @@
           <el-form-item label="手机号" prop="phone">
             <el-input v-model="ruleForm.phone" placeholder="请输入手机号"></el-input>
           </el-form-item>
-          <el-form-item label="注册密码" prop="passwd">
-            <el-input v-model="ruleForm.passwd" placeholder="请输入注册密码" show-password></el-input>
-          </el-form-item>
           <el-form-item label="用户类型" prop="type">
             <el-select v-model="ruleForm.type" placeholder="请选择用户类型">
               <el-option label="金控集团后台管理员" value="0"></el-option>
@@ -39,7 +36,6 @@ export default {
   data: () => ({
     rules: {
       phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
-      passwd: [{ required: true, message: '请输入注册密码', trigger: 'blur' }],
       type: [{ required: true, message: '请选择用户类型', trigger: 'change' }],
     },
   }),

+ 32 - 2
src/layout/otheruser/otheruserList.vue

@@ -13,11 +13,24 @@
           </el-table-column>
           <el-table-column fixed="right" label="操作" align="center">
             <template slot-scope="scope">
+              <el-tooltip class="item" effect="dark" content="密码重置" placement="bottom">
+                <el-button @click="clickRest(scope.row.id)" type="text"><i class="el-icon-refresh"></i></el-button>
+              </el-tooltip>
               <el-button @click="$router.push({ path: '/otheruser/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-row class="page">
+          <el-pagination
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+            :current-page="currentPage"
+            layout="total, prev, pager, next, jumper"
+            :total="total"
+          >
+          </el-pagination>
+        </el-row>
       </el-col>
     </el-row>
   </div>
@@ -28,17 +41,34 @@ export default {
   name: 'otheruserList',
   props: {
     debtTable: null,
+    total: null,
   },
   components: {},
-  data: () => ({}),
+  data: () => ({
+    currentPage: 1,
+  }),
   created() {},
   computed: {},
   methods: {
     deleteRow(id) {
       this.$emit('deleteRow', id);
     },
+    clickRest(id) {
+      this.$emit('clickRest', id);
+    },
+    handleSizeChange(val) {
+      console.log(`每页 ${val} 条`);
+    },
+    handleCurrentChange(val) {
+      console.log(`当前页: ${val}`);
+    },
   },
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.page {
+  text-align: center;
+  padding: 15px 0;
+}
+</style>

+ 2 - 4
src/plugins/check-res.js

@@ -22,16 +22,14 @@ const Plugin = {
           return _okText();
         }
         if (_okText) {
-          // Message.success(_okText);
-          Notify({ type: 'success', message: _okText });
+          Message.success(_okText);
         }
         return true;
       }
       if (_.isFunction(_errText)) {
         return _errText();
       }
-      // Message.error(_errText || errmsg);
-      Notify({ type: 'danger', message: _okText });
+      Message.error(_errText || errmsg);
       // Message({ message: _errText || errmsg, duration: 60000 });
       return false;
     };

+ 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>

+ 20 - 13
src/views/otheruser/detail.vue

@@ -35,7 +35,9 @@ export default {
   data: () => ({
     display: 'none',
     topTitle: '用户信息管理',
-    ruleForm: {},
+    ruleForm: {
+      passwd: '123456',
+    },
   }),
   created() {
     this.searchInfo();
@@ -54,23 +56,28 @@ export default {
       }
     },
     // 提交
-    async submitForm(form) {
-      let data = form;
+    async submitForm({ data }) {
       let res;
       if (this.id) {
-        res = await this.updates(data);
-        this.$message({
-          message: '信息修改成功',
-          type: 'success',
-        });
+        res = await this.update(data);
+        if (res.errcode === 0) {
+          this.$message({
+            message: '信息修改成功',
+            type: 'success',
+          });
+        }
       } else {
         res = await this.create(data);
-        this.$message({
-          message: '信息添加成功',
-          type: 'success',
-        });
+        if (res.errcode === 0) {
+          this.$message({
+            message: '信息创建成功',
+            type: 'success',
+          });
+        }
       }
-      if (this.$checkRes(res)) this.$router.push({ path: '/otheruser/index' });
+      if (this.$checkRes(res)) this.resetForm();
+
+      console.log(res.data);
     },
     // 取消
     resetForm() {

+ 19 - 1
src/views/otheruser/index.vue

@@ -8,7 +8,7 @@
         <searchInfo></searchInfo>
       </el-col>
       <el-col :span="24" class="main">
-        <otheruserList :debtTable="debtTable" @deleteRow="deleteRow"></otheruserList>
+        <otheruserList :debtTable="debtTable" :total="total" @deleteRow="deleteRow" @clickRest="clickRest"></otheruserList>
       </el-col>
     </el-col>
   </div>
@@ -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: {},
@@ -32,6 +33,7 @@ export default {
     topTitle: '其他用户',
     display: 'block',
     debtTable: [],
+    total: '',
   }),
   created() {
     this.searchInfo();
@@ -39,9 +41,13 @@ export default {
   computed: {},
   methods: {
     ...otheruser(['query', 'delete']),
+    ...character({ userquery: 'query' }),
+
+    ...otheruser(['query', 'delete', 'update']),
     async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.query({ skip, limit, ...info });
       this.$set(this, `debtTable`, res.data);
+      this.$set(this, `total`, res.total);
     },
     // 添加
     clickBtn() {
@@ -53,6 +59,18 @@ export default {
       this.$checkRes(res, '删除成功', '删除失败');
       this.searchInfo();
     },
+    async clickRest(id) {
+      let data = {};
+      data.id = id;
+      data.passwd = '123456';
+      const res = await this.update(data);
+      if (res.errcode === 0) {
+        this.$message({
+          message: '密码重置成功',
+          type: 'success',
+        });
+      }
+    },
   },
 };
 </script>