Commit c0df00d2 by 姜雷

添加系统管理

parent fba33186
......@@ -3,7 +3,6 @@ import { Message, MessageBox } from 'element-ui';
import store from '../store';
import config from '../config/index';
import { errorHandle } from './validate';
import md5 from 'blueimp-md5';
// 创建axios实例
const service = axios.create({
......
import fetch from '@/api/fetch';
export const fetchUserList = entity =>
fetch({
url: '/admin/admin4Page',
method: 'post',
data: entity,
});
import fetch from '@/api/fetch';
// 获取系统用户列表
export const fetchList = entity =>
fetch({
url: '/admin/admin4Page',
method: 'post',
data: entity,
});
// 重置密码
export const resetPwd = entity =>
fetch({
url: '/admin/admin4ResetPwd',
method: 'post',
data: { ...entity, type: 1 },
});
// 账号冻结解冻
export const toggleUserFreezeState = entity =>
fetch({
url: '/admin/admin4ResetPwd',
method: 'post',
data: { ...entity, type: 2 },
});
// 系统用户新增
export const addAccount = entity =>
fetch({
url: '/admin/admin4Add',
method: 'post',
data: entity,
});
// 系统用户修改
export const updateAccount = entity =>
fetch({
url: '/admin/admin4Update',
method: 'post',
data: entity,
});
......@@ -16,6 +16,7 @@ export const logout = () =>
// 修改密码
export const changePwd = entity =>
fetch({
url: '/admin/admin4ResetPwd',
method: 'post',
data: entity,
});
......@@ -4,6 +4,17 @@ export const PAGE_TITLE = '管理系统';
export const RYM_GZKEY = 'dc2017';
export const IMG_URL = 'http://qiniu.dcrym.com/';
export const CONSTANTS = constants;
export const accountStatusOptions = [
{
label: '正常',
value: 0,
},
{
label: '冻结',
value: 1,
},
];
export default {
...constants,
accountStatusOptions,
};
......@@ -86,7 +86,7 @@ export default {
checkPwdForm() {
this.$refs.pwdForm.validate(valid => {
if (valid) {
this.updatePassword(this.pwd)
this.updatePassword({ ...this.pwd, type: 3 })
.then(() => {
this.$message.success('修改密码成功!');
......
<template>
<div>publicCar</div>
</template>
<template>
<div>repair</div>
</template>
export const GET_USER_LIST = 'GET_USER_LIST';
import store from '@/store/index';
import user from './user';
export default {
install() {
if (!store.state.management) {
store.registerModule(['management'], {
namespaced: true,
});
}
store.registerModule(['management', 'user'], user);
},
uninstall() {
store.unregisterModule(['management', 'user']);
},
};
import pagination from '../../../store/modules/pagination';
import { fetchUserList } from '@/api/management/user';
import { GET_USER_LIST } from './mutation-types';
const state = {
list: [],
};
const getters = {
userList: state => state.list,
};
const actions = {
fetchUserList({ dispatch, state, commit }, entity) {
return fetchUserList({
...state.pagination,
...entity,
}).then(res => {
const { list, ...pagination } = res.data;
dispatch('updatePagination', pagination);
commit(GET_USER_LIST, list);
});
},
};
const mutations = {
[GET_USER_LIST](state, list) {
state.list = list;
},
};
export default {
namespaced: true,
modules: {
pagination,
},
state,
getters,
actions,
mutations,
};
<template>
<div class="account-manage main-wrap">
<el-form class="search-bar">
<div class="grid-content">
<el-input v-model.trim="filters.name" placeholder="请输入姓名" clearable></el-input>
</div>
<div class="grid-content">
<el-input v-model.trim="filters.department" placeholder="请输入科室" clearable></el-input>
</div>
<div class="grid-content">
<el-select v-model="filters.isFrozen" filterable clearable placeholder="账号状态">
<el-option v-for="item in accountStatusOptions" :key="item.id" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
<el-button type="primary" icon="el-icon-search" @click="searchUser">搜索</el-button>
<el-button v-if="$route.meta.buts.a1" class="margin-css" type="primary" icon="el-icon-upload" @click="addAction">新增</el-button>
</el-form>
<div class="tabel-wrap">
<el-table border v-loading="loading" :data="userList" style="width: 100%">
<el-table-column type="index" label="序号" width="50">
</el-table-column>
<el-table-column prop="name" label="姓名" min-width="120">
</el-table-column>
<el-table-column prop="department" label="部门科室" min-width="120">
</el-table-column>
<el-table-column prop="trueName" label="职务" min-width="120">
</el-table-column>
<el-table-column prop="trueName" label="职称" min-width="120">
</el-table-column>
<el-table-column prop="trueName" label="性别" min-width="120">
</el-table-column>
<el-table-column prop="trueName" label="出生年月" min-width="120">
</el-table-column>
<el-table-column prop="trueName" label="手机号" min-width="120">
</el-table-column>
<el-table-column fixed="right" label="操作" min-width="80" align="center">
<template slot-scope="scope">
<el-dropdown trigger="click">
<el-button type="primary" size="mini">
<i class="el-icon-setting"></i>
</el-button>
<el-dropdown-menu class="AccountIndex" slot="dropdown">
<el-dropdown-item>
<el-button type="primary" size="mini" class="operationBtnWidth" @click="editUser(scope)">修改</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button type="danger" size="mini" class="operationBtnWidth" @click="freezeUser(scope)">账户冻结</el-button>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-pagination layout="prev, pager, next" :current-page="pagination.pageNum" :page-size="pagination.pageSize" :total="pagination.total" @current-change="changePage">
</el-pagination>
</div>
<!-- 新增/编辑账号 -->
<drag-dialog :title="editType ? '编辑账号' : '新增账号'" :visible.sync="dialogEditVisible" :before-close="resetEditDialog">
<el-form :disabled="loading">
<el-form-item label="运营商" label-width="200px">
<el-select v-model="selected.operatorId" @change="changeOperator" filterable clearable placeholder="请选择运营商">
<el-option v-for="item in operatorList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="校区" label-width="200px">
<el-select v-model="selected.campusId" @change="changeCampus" filterable clearable placeholder="请选择校区">
<el-option v-for="item in operatorAllCampusList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-form>
<p class="psText">注:登陆运维端口帐号为系统自动生成4位随机数字帐号,初始密码与账号相同</p>
<div slot="footer" class="dialog-footer">
<el-button @click="resetEditDialog">取 消</el-button>
<el-button type="primary" @click="updateEditLocation">确 定</el-button>
</div>
</drag-dialog>
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex';
import store from './store.js';
export default {
beforeRouteEnter(to, from, next) {
store.install();
next();
},
data() {
return {
filters: {
name: '',
department: '',
isFrozen: '',
},
editType: 0,
dialogEditVisible: false,
accountStatusOptions: [
{
label: '解冻',
value: 0,
},
{
label: '冻结',
value: 1,
},
],
selected: {},
};
},
computed: {
...mapGetters('management/user', ['userList', 'pagination']),
...mapGetters(['loading']),
},
methods: {
initfilters() {
this.filters = {
name: '',
department: '',
isFrozen: '',
};
},
searchUser() {},
changePage(index) {
const filters = this.getFilters();
this.fetchAccountList({
...filters,
pageNum: index,
});
},
showEditDialog(type, data) {
this.editType = type;
if (type) {
this.selected = {
id: data.row.id,
campusId: data.row.campusId,
campusName: data.row.campusName,
operatorId: data.row.operatorId,
operatorName: data.row.operatorName,
};
} else {
this.selected = this.initSelected();
}
this.dialogEditVisible = true;
},
},
};
</script>
import pagination from '../../../store/modules/pagination';
import { fetchList } from '@/api/system/account';
import { GET_ACCOUNT_LIST } from './mutation-types';
const state = {
list: [],
};
const getters = {
accountList: state => state.list,
};
const actions = {
fetchList({ dispatch, state, commit }, entity) {
return fetchList({
...state.pagination,
...entity,
}).then(res => {
const { list, ...pagination } = res.data;
dispatch('updatePagination', pagination);
commit(GET_ACCOUNT_LIST, list);
});
},
};
const mutations = {
[GET_ACCOUNT_LIST](state, list) {
state.list = list;
},
};
export default {
namespaced: true,
modules: {
pagination,
},
state,
getters,
actions,
mutations,
};
<template>
<div>account</div>
<div class="system-account main-wrap">
<el-form class="search-bar">
<div class="grid-content">
<el-input v-model.trim="filters.name" placeholder="请输入姓名" clearable></el-input>
</div>
<div class="grid-content">
<el-input v-model.trim="filters.department" placeholder="请输入科室" clearable></el-input>
</div>
<div class="grid-content">
<el-select v-model="filters.isFrozen" filterable clearable placeholder="账号状态">
<el-option v-for="item in accountStatusOptions" :key="item.id" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
<el-button type="primary" icon="el-icon-search" @click="searchList">搜索</el-button>
<el-button class="margin-css" type="primary" icon="el-icon-upload" @click="showEditDialog(0)">新增</el-button>
</el-form>
<div class="tabel-wrap">
<el-table border v-loading="loading" :data="list" style="width: 100%">
<el-table-column type="index" label="序号" width="50">
</el-table-column>
<el-table-column prop="name" label="姓名" min-width="120">
</el-table-column>
<el-table-column prop="department" label="部门科室" min-width="120">
</el-table-column>
<el-table-column prop="cellphone" label="手机号" min-width="120">
</el-table-column>
<el-table-column prop="sex" :formatter="getSexValue" label="性别" min-width="120">
</el-table-column>
<el-table-column prop="account" label="登陆账号" min-width="120">
</el-table-column>
<el-table-column prop="isFrozen" :formatter="getStatusValue" label="状态" min-width="120">
</el-table-column>
<el-table-column fixed="right" label="操作" min-width="80" align="center">
<template slot-scope="scope">
<el-dropdown trigger="click">
<el-button type="primary" size="mini">
<i class="el-icon-setting"></i>
</el-button>
<el-dropdown-menu class="AccountIndex" slot="dropdown">
<el-dropdown-item>
<el-button type="primary" size="mini" class="operationBtnWidth" @click="showEditDialog(1, scope)">修改</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button type="primary" size="mini" class="operationBtnWidth" @click="showUserAuth(scope)">授权</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button type="primary" size="mini" class="operationBtnWidth" @click="showResetUserPwd(scope)">重置密码</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button type="primary" size="mini" class="operationBtnWidth" @click="freezeUser(scope)">{{scope.row.isFrozen?'账户解冻':'账户冻结'}}</el-button>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-pagination layout="prev, pager, next" :current-page="pagination.pageNum" :page-size="pagination.pageSize" :total="pagination.total" @current-change="changePage">
</el-pagination>
</div>
<drag-dialog class="rateDialog" :title="editType?'修改':'新增'" :visible.sync="dialogEditVisible" :before-close="resetEditDialog">
<el-form :disabled="loading">
<el-form-item label="姓名" label-width="200px">
<el-input v-model.trim="selected.name" placeholder="请输入姓名" :maxlength="20" clearable></el-input>
</el-form-item>
<el-form-item label="部门科室" label-width="200px">
<el-input v-model.trim="selected.department" placeholder="请输入姓名" :maxlength="20" clearable></el-input>
</el-form-item>
<el-form-item label="登陆账号" label-width="200px">
<span v-if="editType">{{selected.account}}</span>
<el-input v-else v-model.trim="selected.account" placeholder="请输入姓名" :maxlength="20" clearable></el-input>
</el-form-item>
<el-form-item label="手机号" label-width="200px">
<el-input v-model.trim="selected.cellphone" placeholder="请输入姓名" :maxlength="11" clearable></el-input>
</el-form-item>
<el-form-item label="性别" label-width="200px">
<el-radio v-model="selected.sex" :label="1"></el-radio>
<el-radio v-model="selected.sex" :label="2"></el-radio>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="resetEditDialog">取 消</el-button>
<el-button type="primary" @click="updateAccount">确 定</el-button>
</div>
</drag-dialog>
</div>
</template>
<script>
import listMixin from '../../../mixin/listPage.js';
import { accountStatusOptions } from '@/config';
import { mapGetters, mapActions } from 'vuex';
import store from './store.js';
import {
resetPwd,
toggleUserFreezeState,
addAccount,
updateAccount,
} from '@/api/system/account';
export default {
beforeRouteEnter(to, from, next) {
store.install();
next();
},
mixins: [listMixin],
data() {
return {
filters: {
name: '',
department: '',
isFrozen: '',
},
accountStatusOptions: accountStatusOptions,
};
},
computed: {
...mapGetters('system/account', {
list: 'accountList',
pagination: 'pagination',
}),
},
methods: {
...mapActions('system/account', { fetchList: 'fetchList' }),
initSelected() {
this.selected = {
name: '',
account: '',
department: '',
cellphone: '',
sex: '',
};
},
getSexValue(c, r, val) {
return val == 1 ? '男' : '女';
},
getStatusValue(c, r, val) {
let item = this.accountStatusOptions.find(item => item.value == val);
return item ? item.label : val;
},
showEditDialog(type, data) {
this.editType = type;
if (type) {
this.selected = {
id: data.row.id,
name: data.row.name,
account: data.row.account,
department: data.row.department,
cellphone: data.row.cellphone,
sex: data.row.sex,
};
} else {
this.initSelected();
}
this.dialogEditVisible = true;
},
showResetUserPwd(data) {
this.$confirm(`是否要重置密码?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
const entity = {
id: data.row.id,
};
resetPwd(entity)
.then(res => {
this.fetchList();
this.$message.success('密码已重置为123456!');
})
.catch(err => {
this.$message.error('重置密码失败!');
});
})
.catch(action => {
console.log(action);
});
},
freezeUser(data) {
this.$confirm(
`确认要${data.row.isFrozen ? '解冻' : '冻结'} ${data.row.name} 用户吗?`,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
const entity = {
id: data.row.id,
isFrozen: data.row.isFrozen ? 0 : 1,
};
toggleUserFreezeState(entity)
.then(res => {
this.fetchList();
this.$message.success(res.msg);
})
.catch(err => {
this.$message.error('冻结/解冻失败!');
});
})
.catch(action => {
console.log(action);
});
},
validateSelect() {
if (!this.selected.name) {
this.$message.error('请输入姓名!');
return;
}
if (!this.selected.baseUseType) {
this.$message.error('请选择初始使用方法!');
return;
}
return true;
},
updateAccount() {
if (!this.validateSelect()) {
return;
}
const entity = {};
if (this.editType) {
addAccount(entity)
.then(() => {})
.catch(err => {});
} else {
updateAccount(entity)
.then(() => {})
.catch(err => {});
}
},
},
};
</script>
export const GET_ACCOUNT_LIST = 'GET_ACCOUNT_LIST';
import store from '@/store/index';
import account from './account';
export default {
install() {
if (store.state.system && store.state.system.account) return;
store.registerModule(['system'], {
namespaced: true,
});
store.registerModule(['system', 'account'], account);
},
uninstall() {
store.unregisterModule(['system', 'account']);
},
};
import { mapGetters } from 'vuex';
export default {
data() {
return {
filters: {},
selected: {},
selectedList: [],
editType: 0,
dialogEditVisible: false,
};
},
computed: {
...mapGetters(['loading']),
},
created() {
this.fetchList({
pageNum: 1,
});
},
methods: {
fetchList() {},
searchList() {
this.changePage(1);
},
getFilters() {
let filters = this.$getFilters(this.filters);
return filters;
},
changePage(index) {
const filters = this.getFilters();
this.fetchList({
...filters,
pageNum: index,
});
},
handleSelectionChange(val) {
this.selectedList = val;
},
resetEditDialog(done) {
this.selected = {};
done && typeof done == 'function'
? done()
: (this.dialogEditVisible = false);
},
},
};
......@@ -5,6 +5,8 @@ import Login from '@/containers/login/index';
import errorPage404 from '@/containers/errorPage/404';
import errorPage401 from '@/containers/errorPage/401';
import systemRoute from './system';
import baseRoute from './baseData';
import managementRoute from './management';
const _import = require('./_import_' + process.env.NODE_ENV);
......@@ -36,6 +38,8 @@ export const asyncRouterMap = [
component: Layout,
meta: { icon: 'example' },
},
...managementRoute,
...baseRoute,
...systemRoute,
{ path: '*', redirect: '/404', hidden: true },
];
......
const _import = require('./_import_' + process.env.NODE_ENV);
const managementRoutes = [
{
id: 4,
component: _import('management/user/user'),
},
{
id: 5,
component: _import('management/repair/repair'),
},
{
id: 6,
component: _import('management/publicCar/publicCar'),
},
];
export default managementRoutes;
......@@ -24,13 +24,12 @@ const actions = {
return new Promise((resolve, reject) => {
login(entity)
.then(response => {
const { admin, menu } = response.data;
const { admin, menu, token } = response.data;
console.log(admin, menu);
// setToken(token);
setToken('token');
// commit(SET_TOKEN, token);
commit(SET_TOKEN, 'token');
if (token) {
setToken(token);
commit(SET_TOKEN, token);
}
commit(UPDATE_USERINFO, admin);
dispatch('initRoute', menu).then(() => {
resolve();
......@@ -60,9 +59,10 @@ const actions = {
},
// 修改密码
updatePassword({ state }, { oldPwd, newPwd }) {
updatePassword({ state }, { type, oldPwd, newPwd }) {
return changePwd({
id: state.id,
type,
oldPwd,
newPwd,
});
......
import { asyncRouterMap, constantRouterMap } from '@/router/index';
import { INIT_ROUTERS, SET_ROUTERS, ROUTERS_DONE } from './mutation-types';
import cloneDeep from 'lodash/cloneDeep';
let initRouter = cloneDeep(constantRouterMap);
const filterAsyncRouter = () => {};
const state = {
isRouteDone: false, // 是否生成了动态路由
routers: initRouter,
routers: constantRouterMap,
addRouters: [],
};
......@@ -22,41 +19,43 @@ const actions = {
initRoute({ commit }, menus) {
return new Promise(resolve => {
let authList = [];
menus.map(item => {
const mainMenu = {
...asyncRouterMap[0],
};
if (mainMenu) {
const { children, ...routeMenu } = mainMenu;
let subMenuList = [];
if (item.childList && item.childList.length) {
item.childList.map(subItem => {
const subMenu = asyncRouterMap.find(
menu => menu.id === subItem.id
);
if (subMenu) {
subMenuList.push({
...subMenu,
path: subItem.menuUrl,
name: subItem.id,
meta: {
...subMenu.meta,
title: subItem.menuName,
buts: { ...subItem.buts },
},
});
}
menus &&
menus.length &&
menus.map(item => {
const mainMenu = {
...asyncRouterMap[0],
};
if (mainMenu) {
const { children, ...routeMenu } = mainMenu;
let subMenuList = [];
if (item.childList && item.childList.length) {
item.childList.map(subItem => {
const subMenu = asyncRouterMap.find(
menu => menu.id === subItem.id
);
if (subMenu) {
subMenuList.push({
...subMenu,
path: subItem.menuUrl,
name: subItem.id,
meta: {
...subMenu.meta,
title: subItem.menuName,
buts: { ...subItem.buts },
},
});
}
});
}
authList.push({
...routeMenu,
path: item.menuUrl,
name: item.menuName,
meta: { ...routeMenu.meta, title: item.menuName },
children: subMenuList,
});
}
authList.push({
...routeMenu,
path: item.menuUrl,
name: item.menuName,
meta: { ...routeMenu.meta, title: item.menuName },
children: subMenuList,
});
}
});
});
console.log(authList);
authList.push(asyncRouterMap[asyncRouterMap.length - 1]); // 添加404页面
commit(SET_ROUTERS, authList);
......@@ -69,7 +68,7 @@ const actions = {
commit(ROUTERS_DONE);
resolve();
} else {
dispatch('Login')
dispatch('Login', {})
.then(() => {
commit(ROUTERS_DONE);
resolve();
......@@ -85,7 +84,7 @@ const actions = {
const mutations = {
[SET_ROUTERS](state, routers) {
state.addRouters = routers;
state.routers = initRouter.concat(routers);
state.routers = constantRouterMap.concat(routers);
},
[ROUTERS_DONE](state) {
state.isRouteDone = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment