Commit 153d1dc5 by liimin

实现用户列表操作

1 parent df62a8bf
......@@ -5,22 +5,22 @@
</template>
<script>
import util from "@/libs/util";
import util from '@/libs/util'
export default {
name: "app",
name: 'app',
watch: {
"$i18n.locale": "i18nHandle"
'$i18n.locale': 'i18nHandle'
},
created() {
this.i18nHandle(this.$i18n.locale);
created () {
this.i18nHandle(this.$i18n.locale)
},
methods: {
i18nHandle(val, oldVal) {
util.cookies.set("lang", val);
document.querySelector("html").setAttribute("lang", val);
i18nHandle (val, oldVal) {
util.cookies.set('lang', val)
document.querySelector('html').setAttribute('lang', val)
}
}
};
}
</script>
<style lang="scss">
......
......@@ -39,7 +39,6 @@ export function UserList (data = {}) {
return request(data, RequestMethods.GET)
}
/**
* 重置密码
* @param {*} data 参数
......@@ -85,8 +84,6 @@ export function AccountValidate (data = {}) {
return request(data, RequestMethods.GET)
}
/**
* 获取角色权限资源列表
* @param {*} data 参数
......@@ -114,7 +111,6 @@ export function RoleModify (data = {}) {
return request(data, RequestMethods.GET)
}
/**
* 权限列表
* @param {*} data 参数
......
......@@ -22,4 +22,7 @@
}
.el-color-picker__trigger{
border-color:rgba(255,255,255,.1)
}
.el-table{
margin:4px 0 !important;
}
\ No newline at end of file
/*
* @Author: limin
* @Date: 2019-09-01 19:06:01
* @Author: limin
* @Date: 2019-09-01 19:06:01
* @Last Modified by: limin
* @Last Modified time: 2019-09-04 15:04:57
*/
/**
* 前端基础数据管理对应的接口名称的key
*/
export const TYPE_NAME='confType'
export const TYPE_NAME = 'confType'
/**
* 后台提供一个接 通过类型获取对应数据
* 此处定义类型
*/
export const ConfigType ={
STATION: 'STATION_TYPE',
POST:'POST_TYPE',
SUBSYS:'SUBSYSTEM_TYPE'
export const ConfigType = {
STATION: 'STATION_TYPE',
POST: 'POST_TYPE',
SUBSYS: 'SUBSYSTEM_TYPE'
}
export const BaseData = {
ROLE: {KEY:'role',TYPE:''},
// COMPANY: 'company',
// DEPART: 'depart',
STATION: {KEY:'station',TYPE:ConfigType.STATION},
POST:{KEY:'post',TYPE:ConfigType.POST},
SUBSYS:{KEY:'subsys',TYPE:ConfigType.SUBSYS}
ROLE: { KEY: 'role', TYPE: '' },
// COMPANY: 'company',
// DEPART: 'depart',
STATION: { KEY: 'station', TYPE: ConfigType.STATION },
POST: { KEY: 'post', TYPE: ConfigType.POST },
SUBSYS: { KEY: 'subsys', TYPE: ConfigType.SUBSYS }
}
/**
* 注册类型
*/
export const RegistType = {
BY_SELF:'1', //自注册
BY_ADMIN:'2' //管理员创建
BY_SELF: '1', // 自注册
BY_ADMIN: '2' // 管理员创建
}
......@@ -13,7 +13,7 @@ export default {
// type: String,
// default: 'text'
// },
category:{
category: {
type: String,
default: 'operation'
},
......@@ -37,60 +37,60 @@ export default {
type: Object,
default: null
},
data: Object,
data: Object
},
functional: true , // 开启函数化组件
functional: true, // 开启函数化组件
render: (h, ctx) => {
const _this = ctx.parent //获取 vue this 实例
const _this = ctx.parent // 获取 vue this 实例
// console.log(ctx);
/**
* 获取传入参数
* category 非必填 button 类别 暂时两种 1 表格操作:operation ,2 Button 按钮: action 默认 operation ----- route 中不标明 视为默认值 operation
* 获取传入参数
* category 非必填 button 类别 暂时两种 1 表格操作:operation ,2 Button 按钮: action 默认 operation ----- route 中不标明 视为默认值 operation
* data 点击按钮时 需要得到的参数 比如 table 中的 当前行数据 row
* mapping 非必填 但: 当列表中的操作选项 根据 某个字段 变化的话 必填 且 必须 注明 field: 字段名
* label 当传入label 字段时 标识明确指定渲染该label 的按钮
* label 当传入label 字段时 标识明确指定渲染该label 的按钮
*/
const { category , data , mapping, label } = ctx.props
const { category, data, mapping, label } = ctx.props
let curBtns = []
/**
* 判断一个按钮(btn)是否存在与当前行(data) 的映射关系(mapping)中
* @param {*} btn
* @param {*} btn
*/
const filter = btn => mapping ? mapping[data[mapping['field']]].includes(btn.label):true
const filter = btn => mapping ? mapping[data[mapping['field']]].includes(btn.label) : true
const $store = _this.$store.getters['d2admin/auth/curBtns']
if(!$store) return h('div')
if(label){ //指定label
const __item = $store.find(btn => (btn.label === label) && filter(btn))
if (!$store) return h('div')
if (label) { // 指定label
const __item = $store.find(btn => (btn.label === label) && filter(btn))
__item && curBtns.push(__item)
}else {
} else {
/**
* 拿到当前模块(页面) 所拥有按钮列表 过滤type属性 与 映射关系 返回需要显示的按钮列表
*/
curBtns = $store.filter(btn => {
if(category === 'operation'){
curBtns = $store.filter(btn => {
if (category === 'operation') {
return (btn.category === 'operation' || !btn.category) && filter(btn)
}
return (btn.category === category) && filter(btn)
})
}
if(curBtns.length===0) return h('div')
if (curBtns.length === 0) return h('div')
const __aBtns = []
/**
* 循环最终显示的按钮列表
* 循环最终显示的按钮列表
* 并渲染到页面
*/
curBtns.forEach(btn =>
__aBtns.push(h('el-button', {
props: {
type:btn.type||'text',
type: btn.type || 'text'
},
style:{
color:btn.color
style: {
color: btn.color
},
on: {
click: ()=>btn.handle && _this[btn.handle](data)
click: (e) => btn.handle && _this[btn.handle](data, e)
}
}, [btn.label])))
return h('div', {}, [...__aBtns,ctx.children])
return h('div', {}, [...__aBtns, ctx.children])
}
}
\ No newline at end of file
}
......@@ -99,7 +99,7 @@ export default {
type: 'warning'
}).then(async () => {
await this.$store.commit('d2admin/gray/set', false)
localStorage.clear();
localStorage.clear()
window.location.reload()
})
.catch(() => {
......
......@@ -106,15 +106,19 @@ util.colorToRgb = (sColor, alpha) => {
}
}
util.resetForm = function(formName){
/**
* 重置form
* 用法: util.resetForm.call(this,'formName')
*/
util.resetForm = function (formName) {
this.$nextTick(() => {
for (var key in this[formName]) {
if (this.regForm.hasOwnProperty(key)) {
this[formName][key] = "";
if (this[formName].hasOwnProperty(key)) {
this[formName][key] = ''
}
}
this.$refs[formName] && this.$refs[formName].resetFields();
});
};
this.$refs[formName] && this.$refs[formName].resetFields()
})
}
export default util
......@@ -93,7 +93,7 @@ permision.packMenusBtns = function (resources) {
}
let __aParent = []
let __aSub = []
let __aAll =[]
let __aAll = []
/**
* 第一次循环 分出一级菜单与所有子菜单
*/
......@@ -105,8 +105,8 @@ permision.packMenusBtns = function (resources) {
if (__oMenu.parentId === '0') { // 取出1级菜单
__aParent.push(__oMenu)
__aAll.push(__oMenu)
if (__oMenu.auth){
__aAll = [...__aAll,...__oMenu.auth]
if (__oMenu.auth) {
__aAll = [...__aAll, ...__oMenu.auth]
}
} else { // 取出子菜单
__aSub.push(__oMenu)
......@@ -118,9 +118,9 @@ permision.packMenusBtns = function (resources) {
let __parent = null
__aSub.forEach(obj => {
__aAll.push(obj)
if (obj.auth){
__aAll = [...__aAll,...obj.auth]
}
if (obj.auth) {
__aAll = [...__aAll, ...obj.auth]
}
__parent = __aParent.find(menu => menu.authId === obj.parentId)
if (__parent.children) {
__parent.children.push(obj)
......@@ -128,7 +128,7 @@ permision.packMenusBtns = function (resources) {
__parent.children = [obj]
}
})
return {menus:__aParent,all:__aAll}
return { menus: __aParent, all: __aAll }
}
/**
......@@ -136,14 +136,14 @@ permision.packMenusBtns = function (resources) {
*/
permision.format2Menu = function (oMenu) {
if (!oMenu) return null
const {icon, path, meta} = oMenu
const {title, authId, parentId} = meta
const { icon, path, meta } = oMenu
const { title, authId, parentId } = meta
return {
title,
icon,
path,
authId,
parentId}
parentId }
}
/**
......@@ -151,14 +151,14 @@ permision.format2Menu = function (oMenu) {
*/
permision.format2ResourceMenu = function (oMenu) {
if (!oMenu) return null
const {icon, meta, auth} = oMenu
const {title, authId, parentId} = meta
const { icon, meta, auth } = oMenu
const { title, authId, parentId } = meta
return {
label:title,
label: title,
icon,
authId,
parentId,
auth}
auth }
}
export default permision
......@@ -7,7 +7,7 @@ import 'flex.css'
import '@/components'
// svg 图标
import '@/assets/svg-icons'
//指令
// 指令
import '@/directives'
// 功能插件
......@@ -31,7 +31,7 @@ export default {
// 事件传递
Vue.prototype.$event = new Vue()
// Element
Vue.use(ElementUI,{ size: 'medium', zIndex: 3000 })
Vue.use(ElementUI, { size: 'medium', zIndex: 3000 })
// 插件
Vue.use(pluginError)
Vue.use(pluginLog)
......
......@@ -31,11 +31,11 @@ export const home = {
auth: [{
authId: '10101',
parentId: '101',
label: '导出',
type: 'button',
category:'Button',
handle: 'exportFile'
}]
label: '导出',
type: 'button',
category: 'Button',
handle: 'exportFile'
}]
}
export const sys = [
// 系统 前端日志
......@@ -68,71 +68,6 @@ export const sys = [
* 所有需动态过滤的资源点
*/
export const resources = {
// '102': {
// path: '/page',
// icon: 'folder-o',
// name: '页面',
// meta: {
// auth: true,
// title: '页面',
// authId: '102',
// parentId: '0',
// cache: true
// }
// },
// '10201': {
// path: '/page1',
// name: 'page1',
// meta: {
// auth: true,
// title: '页面 1',
// authId: '10201',
// parentId: '102',
// cache: true
// },
// component: _import('demo/page1')
// },
// '10202': {
// path: '/page2',
// name: 'page2',
// meta: {
// auth: true,
// title: '页面 2',
// authId: '10202',
// parentId: '102',
// cache: true
// },
// component: _import('demo/page2'),
// auth: [{ // 列表操作
// authId: '1020201',
// parentId: '10202',
// label: '查看'
// }, { //
// authId: '1020202',
// parentId: '10202',
// label: '编辑'
// }],
// },
// '10203': {
// path: '/page3',
// name: '页面 3',
// meta: {
// auth: true,
// title: '页面 3',
// authId: '10203',
// parentId: '102'
// },
// auth: [{ // 列表操作
// authId: '1020301',
// parentId: '10203',
// label: '查看'
// }, { //
// authId: '1020302',
// parentId: '10203',
// label: '编辑'
// }],
// component: _import('demo/page3')
// },
'102': {
path: '/trafficManagement',
icon: 'train',
......@@ -147,21 +82,21 @@ export const resources = {
auth: [{
authId: '10201',
parentId: '102',
label: '编辑',
handle: 'handleEdit'
}, {
authId: '10202',
parentId: '102',
label: '删除',
handle: 'handleDelete'
}, {
authId: '10203',
parentId: '102',
label: '添加车辆',
category: 'Button',
type: 'button',
handle: 'handleEdit'
}]
label: '编辑',
handle: 'handleEdit'
}, {
authId: '10202',
parentId: '102',
label: '删除',
handle: 'handleDelete'
}, {
authId: '10203',
parentId: '102',
label: '添加车辆',
category: 'Button',
type: 'button',
handle: 'handleEdit'
}]
},
'103': {
path: '/subSysManagement',
......@@ -177,21 +112,21 @@ export const resources = {
auth: [{
authId: '10301',
parentId: '103',
label: '编辑',
handle: 'handleEdit'
}, {
authId: '10302',
parentId: '103',
label: '删除',
handle: 'handleDelete'
}, {
authId: '10303',
parentId: '103',
label: '添加子系统',
category: 'Button',
type: 'button',
handle: 'handleEdit'
}]
label: '编辑',
handle: 'handleEdit'
}, {
authId: '10302',
parentId: '103',
label: '删除',
handle: 'handleDelete'
}, {
authId: '10303',
parentId: '103',
label: '添加子系统',
category: 'Button',
type: 'button',
handle: 'handleEdit'
}]
},
'104': {
path: '/deviceManagement',
......@@ -207,27 +142,27 @@ export const resources = {
auth: [{
authId: '10401',
parentId: '104',
label: '编辑',
handle: 'handleEdit'
}, {
authId: '10402',
parentId: '104',
label: '删除',
handle: 'handleDelete'
}, {
authId: '10403',
parentId: '104',
label: '导出',
type:'button',
category:'Button',
handle: 'exportFile'
}, {
authId: '10404',
parentId: '104',
label: '导入',
type:'button',
category:'Button'
}]
label: '编辑',
handle: 'handleEdit'
}, {
authId: '10402',
parentId: '104',
label: '删除',
handle: 'handleDelete'
}, {
authId: '10403',
parentId: '104',
label: '导出',
type: 'button',
category: 'Button',
handle: 'exportFile'
}, {
authId: '10404',
parentId: '104',
label: '导入',
type: 'button',
category: 'Button'
}]
},
'105': {
path: 'materialList',
......@@ -240,7 +175,7 @@ export const resources = {
authId: '105',
parentId: '0'
},
component: _import('materialList'),
component: _import('materialList')
},
'106': {
path: '/bb',
......@@ -267,21 +202,21 @@ export const resources = {
auth: [{
authId: '1060101',
parentId: '10601',
label: '查看详情',
handle: 'handleDetail'
}, {
authId: '1060102',
parentId: '10601',
label: '删除',
handle: 'handleDelete'
}, {
authId: '1060103',
parentId: '10601',
label: '订单下载',
category: 'Button',
type: 'button',
handle: 'exportFile'
}]
label: '查看详情',
handle: 'handleDetail'
}, {
authId: '1060102',
parentId: '10601',
label: '删除',
handle: 'handleDelete'
}, {
authId: '1060103',
parentId: '10601',
label: '订单下载',
category: 'Button',
type: 'button',
handle: 'exportFile'
}]
},
'10602': {
path: '/maintainManagement',
......@@ -297,16 +232,16 @@ export const resources = {
auth: [{
authId: '1060201',
parentId: '10602',
label: '删除',
handle: 'handleDelete'
}, {
authId: '1060202',
parentId: '10602',
label: '导出订单',
category: 'Button',
type: 'button',
handle: 'exportOrder'
}]
label: '删除',
handle: 'handleDelete'
}, {
authId: '1060202',
parentId: '10602',
label: '导出订单',
category: 'Button',
type: 'button',
handle: 'exportOrder'
}]
},
'107': {
path: '/users',
......@@ -333,36 +268,40 @@ export const resources = {
authId: '1070101',
parentId: '10701',
label: '审核',
handle:'handleEdit'
handle: 'handleOperation'
}, { //
authId: '1070102',
parentId: '10701',
label: '重置密码'
label: '重置密码',
handle: 'handleOperation'
}, { //
authId: '1070103',
parentId: '10701',
label: '编辑',
handle:'handleEdit'
handle: 'handleEdit'
}, { //
authId: '1070104',
parentId: '10701',
label: '延期'
label: '延期',
handle: 'handleOperation'
}, { //
authId: '1070105',
parentId: '10701',
label: '禁用',
color:'#FF0000'
color: '#FF0000',
handle: 'handleOperation'
}, { //
authId: '1070106',
parentId: '10701',
label: '激活'
label: '激活',
handle: 'handleOperation'
}, { // 列表操作
authId: '1070107',
parentId: '10701',
label: '创建用户',
category:'action',
type:'button',
handle:'handleRegister'
category: 'action',
type: 'button',
handle: 'handleRegister'
}],
component: _import('userManage/user')
},
......@@ -376,18 +315,18 @@ export const resources = {
authId: '10702',
parentId: '107'
},
auth:[{
authId:'1070201',
parentId:'10702',
label:'创建角色',
handle: "handleEdit",
type:'button'
},{
authId:'1070202',
parentId:'10702',
label:'权限编辑',
handle: "handleEdit",
type:'text'
auth: [{
authId: '1070201',
parentId: '10702',
label: '创建角色',
handle: 'handleEdit',
type: 'button'
}, {
authId: '1070202',
parentId: '10702',
label: '权限编辑',
handle: 'handleEdit',
type: 'text'
}],
component: _import('userManage/role')
},
......@@ -448,4 +387,4 @@ export default [
// dashboard,
...frameOut,
errorPage
]
\ No newline at end of file
]
......@@ -118,7 +118,7 @@ export default {
// 获取权限资源点
const __source = await dispatch('load')
// 过滤资源点 并动态添加到路由
const { route, btn } = util.permision.packRoutesBtns({...sources,[home.meta.authId]:home}, __source)
const { route, btn } = util.permision.packRoutesBtns({ ...sources, [home.meta.authId]: home }, __source)
frameInRoutes[0].children = [home, ...route, ...sys]
router.addRoutes(frameInRoutes)
state.btns = btn
......
......@@ -5,8 +5,8 @@
* @Last Modified time: 2019-09-04 14:06:32
*/
import { FetchRoleList, CompanyList, DepartList, StationList,PostList , BaseDataApi } from '@/api/sys.base'
import { BaseData,TYPE_NAME,ConfigType } from '@/common/constants'
import { FetchRoleList, CompanyList, DepartList, StationList, PostList, BaseDataApi } from '@/api/sys.base'
import { BaseData, TYPE_NAME, ConfigType } from '@/common/constants'
const map = {
[BaseData.ROLE.KEY]: FetchRoleList,
// [BaseData.COMPANY]: CompanyList,
......@@ -22,16 +22,16 @@ export default {
role: [],
// 站点
station: [],
//职务
post:[],
//子系统
subsys:[]
// 职务
post: [],
// 子系统
subsys: []
},
actions: {
/**
* 初始化获取 基础数据 并 前端持久化
* 每次登录会强制 初始化
* @param {*} param0
* @param {*} param0
*/
init ({ state, dispatch, commit }) {
return new Promise(async resolve => {
......@@ -39,17 +39,17 @@ export default {
FetchRoleList(),
// CompanyList(),
// DepartList(),
BaseDataApi({[TYPE_NAME]:ConfigType.STATION}),
BaseDataApi({[TYPE_NAME]:ConfigType.POST}),
BaseDataApi({[TYPE_NAME]:ConfigType.SUBSYS})
BaseDataApi({ [TYPE_NAME]: ConfigType.STATION }),
BaseDataApi({ [TYPE_NAME]: ConfigType.POST }),
BaseDataApi({ [TYPE_NAME]: ConfigType.SUBSYS })
]).then( async ([role,station, post,subsys] = res) => {
]).then(async ([role, station, post, subsys] = res) => {
state.role = role
state.station = station
state.subsys = subsys
state.post = post
await dispatch('save2db', {path: `base`,value: {role, station,post,subsys}})
resolve({role, station,post,subsys})
await dispatch('save2db', { path: `base`, value: { role, station, post, subsys } })
resolve({ role, station, post, subsys })
})
})
},
......@@ -62,11 +62,11 @@ export default {
*/
get ({ state, dispatch }, name) {
return new Promise(async resolve => {
let __data = state[name]
let __data = state[name]
if (!__data.length) {
__data = await dispatch('getFromdb', `base.${name}`) || await dispatch('getFromAjax', name)
state[name] = __data
await dispatch('save2db', {path: `base.${name}`,value: __data})
await dispatch('save2db', { path: `base.${name}`, value: __data })
}
resolve(__data)
})
......@@ -75,20 +75,20 @@ export default {
* 获取所有基础数据
* 获取步骤:
* 内存 -> 前端持久化数据库 -> 后台接口
* @param {*} param0
* @param {*} param0
*/
load ({ state,dispatch }) {
load ({ state, dispatch }) {
return new Promise(async resolve => {
if (state.role.length === 0) {
state = await dispatch('getFromdb','base') || await dispatch('init')
state = await dispatch('getFromdb', 'base') || await dispatch('init')
}
const {role, station,post,subsys} = state
resolve({role, station,post,subsys})
const { role, station, post, subsys } = state
resolve({ role, station, post, subsys })
})
},
/**
* 内部方法 从前端持久化数据库 获取指定数据
* @param {*} param0
* @param {*} param0
* @param {*} path 数据 路径
*/
getFromdb ({ dispatch }, path) {
......@@ -104,10 +104,10 @@ export default {
/**
* 内部方法 前端持久化 一个 数据
* @param {*} param0
* @param {*} param0
* @param {*} param1 value 需要持久化的数据 path 需要持久化的数据路径
*/
save2db ({ dispatch }, {value,path}) {
save2db ({ dispatch }, { value, path }) {
return new Promise(async resolve => {
await dispatch('d2admin/db/set', {
dbName: 'database',
......@@ -120,12 +120,12 @@ export default {
},
/**
* 从后端获取一个数据
* @param {*} param0
* @param {*} param0
* @param {*} name @/common/constants/BaseData 中的常量
*/
getFromAjax ({ state, dispatch, commit }, name) {
return new Promise(async resolve => {
const value = await map[name]({[TYPE_NAME]:BaseData.find(data=>data.KEY===name).TYPE})
const value = await map[name]({ [TYPE_NAME]: BaseData.find(data => data.KEY === name).TYPE })
resolve(value)
})
}
......
......@@ -29,7 +29,7 @@
<el-col :span="12">物料列表</el-col>
<el-col :span="12" style="text-align: right; position: relative;">
<auth-button
category="Button"
category="Button"
>
<input
type="file"
......@@ -228,7 +228,7 @@ export default {
notice.errorTips()
})
},
exportFile () {
const params = this.getParams()
exportApi(params).then(res => {
......
......@@ -28,7 +28,7 @@ export default {
type: Boolean,
default: false
},
title: ''
// title:
},
mounted () {},
......
......@@ -78,7 +78,7 @@
import { Reg } from '@/api/sys.account'
import { mapActions } from 'vuex'
import notice from '@/common/notice'
import {RegistType} from '@/common/constants';
import { RegistType } from '@/common/constants'
export default {
name: 'DialogReg',
props: {
......@@ -96,7 +96,7 @@ export default {
return {
company: [],
regForm: {
createType:RegistType.BY_SELF,// 1 自注册 2 管理员创建
createType: RegistType.BY_SELF, // 1 自注册 2 管理员创建
loginName: '',
password: '',
confirm: '',
......@@ -208,7 +208,7 @@ export default {
},
// 加载业务所需所有数据
async fetchData () {
const { role, company, depart, station,post } = await this.load()
const { role, company, depart, station, post } = await this.load()
this.baseData.posts = post
this.baseData.stations = station
this.baseData.departs = depart
......
......@@ -114,7 +114,7 @@
import { getListApi, reportApi, exportApi } from '@api/systemMonitor'
import notice from '@/common/notice'
require('echarts/lib/chart/pie')
require("echarts/lib/component/tooltip");
require('echarts/lib/component/tooltip')
let echarts = require('echarts/lib/echarts')
......
<template>
<el-dialog
center
title="添加角色"
:visible.sync="dialogVisible"
:title="roleForm.roleId?'编辑角色':'创建角色'"
:before-close="handleClose"
:visible.sync="dialogVisible"
width="720px"
custom-class="edit-dialog"
v-if="dialogVisible"
>
<el-form
ref="editForm"
:model="editForm"
ref="roleForm"
:model="roleForm"
label-width="120px"
class="edit-dialog-form"
:rules="rules"
>
<el-form-item label="角色名:" prop="roleName">
<el-input v-model="editForm.roleName" requred maxlength="10" placeholder="请输入角色名"></el-input>
<el-input v-model="roleForm.roleName" requred maxlength="10" placeholder="请输入角色名"></el-input>
</el-form-item>
<el-form-item label="描述:">
<el-input
type="textarea"
:rows="2"
placeholder="角色描述"
v-model="editForm.description">
v-model="roleForm.description">
</el-input>
</el-form-item>
</el-form>
<span>权限设置</span>
<RoleTree :resources="resources" :checkedNodes.sync="checkedNodes" :defaultCheck="checked" :close="dialogVisible"></RoleTree>
<RoleTree :resources="resources" :checkedNodes.sync="checkedNodes" :defaultCheck="defaultCheck" :close="dialogVisible"></RoleTree>
<div slot="footer">
<el-button @click="submit" type="primary" class="button-submit">保存</el-button>
<el-button @click="handleClose" type="plain" class="button-submit">取消</el-button>
......@@ -38,7 +38,7 @@
import { Reg } from '@/api/sys.account'
import { mapActions } from 'vuex'
import notice from '@/common/notice'
import RoleTree from "./roleTree"
import RoleTree from './roleTree'
import { resources as sources, home } from '@/router/routes'
import util from '@/libs/util.js'
export default {
......@@ -48,30 +48,39 @@ export default {
type: Boolean,
default: false
},
datas: {
editData: {
type: Object,
default: {},
default: {}
}
},
components:{
components: {
RoleTree
},
watch: {
editData: {
handler: function (value) {
Object.assign(this.roleForm, value)
this.defaultCheck = this.roleForm.roles
},
immediate: true
}
},
computed: {
dialogVisible () {
if (!this.isVisible) {
util.resetForm.call(this, 'roleForm')
}
return this.isVisible
},
resources() {
return util.permision.packMenusBtns(util.deepClone(Object.values({...sources,[home.meta.id]:home})))
},
checked() {
return this.datas.roles
resources () {
return util.permision.packMenusBtns(util.deepClone(Object.values({ ...sources, [home.meta.id]: home })))
}
},
data () {
return {
key:new Date(),
checkedNodes:[],
editForm: {
defaultCheck: '',
checkedNodes: [],
roleForm: {
roleName: '',
description: ''
},
......@@ -84,7 +93,6 @@ export default {
},
methods: {
handleClose (done) {
this.$refs.editForm.resetFields();
this.$event.$emit('e-reg-dialog', false)
},
// 提交注册数据
......@@ -100,12 +108,12 @@ export default {
// })
// }
// })
},
}
},
mounted () {
this.$event.$on('e-role-data',(data)=>{
console.log(2);
this.$event.$emit('e-default-role-check',data.roles)
this.$event.$on('e-role-data', (data) => {
console.log(2)
this.$event.$emit('e-default-role-check', data.roles)
})
// this.checkedNodes = this.data.roles
// console.log(this.checkedNodes);
......
......@@ -27,99 +27,101 @@
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:current-page="page.pageCount"
:page-sizes="[10,20,30,40]"
:page-size="pageSize"
:total="total"
:page-size="page.pageSize"
:total="page.total"
layout="sizes,total,->,prev,pager,next,jumper"
></el-pagination>
<edit-dialog
:isVisible="editVisible"
:datas="editData"
:editData="editData"
></edit-dialog>
</d2-container>
</template>
<script>
import { RoleList } from "@/api/sys.account";
import notice from "@/common/notice";
import { RoleList } from '@/api/sys.account'
import notice from '@/common/notice'
import util from '@/libs/util'
export default {
name: "FimsRoles",
name: 'FimsRoles',
components: {
'EditDialog':() => import('./editDialog')
'EditDialog': () => import('./editDialog')
},
data() {
data () {
return {
// 新增/编辑弹窗
editVisible: false,
editData:{
roles:[],
editData: {
roles: []
},
// 表格
tableLoading: false,
tableData: [],
tableColumns:Object.freeze([
tableColumns: Object.freeze([
{
label: "角色名称",
prop: "roleName"
label: '角色名称',
prop: 'roleName'
},
{
label: "描述",
prop: "description"
label: '描述',
prop: 'description'
},
{
label: "创建时间",
prop: "createTime"
label: '创建时间',
prop: 'createTime'
}
]),
page: {
// 页码
pageCount: 1,
pageSize: 10
pageCount: 1, // 每页条数
pageSize: 10, // 页码
total: 100
}
};
}
},
mounted() {
this.fetchData();
mounted () {
this.fetchData()
this.$event.$on('e-reg-dialog', res => this.editVisible = res)
},
methods: {
fetchData() {
this.loadRoleList();
fetchData () {
this.loadRoleList()
},
loadRoleList() {
this.tableLoading = true;
loadRoleList () {
this.tableLoading = true
RoleList()
.then(res => {
this.tableData = res;
// Object.freeze(this.tableData)
this.tableLoading = false;
this.tableData = res
// Object.freeze(this.tableData)
this.tableLoading = false
})
.catch(err => {
notice.errorTips(err);
this.tableLoading = false;
});
notice.errorTips(err)
this.tableLoading = false
})
},
// 页码
handleSizeChange(value) {
this.page.pageSize = value;
handleSizeChange (value) {
this.page.pageSize = value
// 调接口
this.loadRoleList();
this.loadRoleList()
},
handleCurrentChange(value) {
this.page.pageCount = value;
handleCurrentChange (value) {
this.page.pageCount = value
// 调接口
this.loadRoleList();
this.loadRoleList()
},
handleEdit(row = {}) {
row.roles = [{authId:'101',parentId:'0'},{authId:'10601',parentId:'106'},{authId:'1060101',parentId:'10601'}]
this.editVisible = true;
this.editData = row
handleEdit (row = {}) {
row.roles = [{ authId: '101', parentId: '0' }, { authId: '10601', parentId: '106' }, { authId: '1060101', parentId: '10601' }]
this.editVisible = true
this.editData = util.deepClone(row)
}
}
};
}
</script>
<style scoped>
</style>
......@@ -5,7 +5,7 @@
show-checkbox
ref="tree"
node-key="authId"
default-expand-all
:default-expand-all="false"
@check-change="checkChange"
:expand-on-click-node="false"
>
......@@ -28,10 +28,10 @@
</div>
</template>
<script>
import util from "@/libs/util.js";
import util from '@/libs/util.js'
export default {
data() {
return { checked: [] };
data () {
return { checked: [] }
},
props: {
resources: {
......@@ -41,70 +41,73 @@ export default {
defaultCheck: [],
close: false
},
mounted() {
mounted () {
// this.$event.$on("e-default-role-check", roles => {
// console.log(3);
// });
},
watch: {
close(value) {
close (value) {
// !value && this.reset();
},
defaultCheck: {
handler(value) {
let chk = [],
treeChk = [];
handler (value) {
let chk = []
let treeChk = []
value.forEach(v => {
if (v.parentId.length >= 5) {
// TODO 不科学
chk.push(v.authId);
chk.push(v.authId)
} else {
treeChk.push(v.authId);
treeChk.push(v.authId)
}
});
setTimeout(() => {
this.$refs.tree.setCheckedKeys(treeChk);
this.checked = chk;
}, 0);
})
this.$nextTick(() => {
this.$refs.tree.setCheckedKeys(treeChk)
this.checked = chk
})
},
immediate: true
}
},
methods: {
checkChange(node, checked, childChecked) {
checkChange (node, checked, childChecked) {
// if(node.parentId ==='0') return
// this.checked=checked?[...this.resources.all.filter(res=> res.parentId === node.authId),...this.checked]:this.checked.filter(obj=>obj.parentId!==node.authId)
this.setCheckedNodes();
this.setCheckedNodes()
},
change(node, data, sta) {
change (node, data, sta) {
// let checked = sta //|| this.checked.some(child => child.parentId === node.key && child.authId !== data.authId);
// checked && this.$refs.tree.setChecked(node.key, checked, true);
this.setCheckedNodes();
this.setCheckedNodes()
},
setCheckedNodes() {
setCheckedNodes () {
const { getCheckedKeys, getHalfCheckedKeys } = this.$refs.tree
let checkedNodes = [
...this.$refs.tree.getCheckedKeys(),
...this.$refs.tree.getHalfCheckedKeys(),
...getCheckedKeys(),
...getHalfCheckedKeys(),
...this.checked
];
]
checkedNodes = checkedNodes.map(node => {
const { authId, parentId } = this.resources.all.find(res => res.authId === node);
return { authId, parentId };
});
this.$emit("update:checkedNodes", checkedNodes);
const { authId, parentId } = this.resources.all.find(
res => res.authId === node
)
return { authId, parentId }
})
this.$emit('update:checkedNodes', checkedNodes)
},
reset() {
this.checked = [];
this.$refs.tree.setCheckedKeys([]);
this.$emit("update:checkedNodes", []);
reset () {
this.checked = []
this.$refs.tree.setCheckedKeys([])
this.$emit('update:checkedNodes', [])
}
}
};
}
</script>
<style lang="scss">
.role-tree {
padding-left: 30px;
padding-left: 30px;
.role-tree-node {
flex: 1;
display: flex;
......@@ -117,8 +120,8 @@ export default {
height: 34px;
.el-checkbox {
margin-right: 5px;
.el-checkbox__label{
padding: 0;
.el-checkbox__label {
padding: 0;
}
}
}
......@@ -128,8 +131,8 @@ export default {
white-space: normal;
position: absolute;
left: 200px;
background-color: rgba(0,0,0,.05);
background-color: rgba(0, 0, 0, 0.05);
padding: 5px 0;
}
}
</style>
\ No newline at end of file
</style>
<template>
<el-dialog
center
title="用户注册"
:title="regForm.id?'编辑用户':'创建用户'"
:visible.sync="dialogVisible"
:before-close="handleClose"
width="720px"
custom-class="reg-dialog"
custom-class="reg-dialog-admin"
v-if="dialogVisible"
>
<el-form
......@@ -68,7 +67,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="所属站点:" prop="stationCode">
<el-select v-model="regForm.stationCode" placeholder="请选择" class="sigle-select">
<el-select v-model="regForm.stationCode" placeholder="请选择">
<el-option
:label="station.confValue"
:value="station.confCode"
......@@ -87,13 +86,13 @@
</el-dialog>
</template>
<script>
import { Reg } from "@/api/sys.account";
import { mapActions } from "vuex";
import notice from "@/common/notice";
import { RegistType } from "@/common/constants";
import util from "@/libs/util";
import { Reg } from '@/api/sys.account'
import { mapActions } from 'vuex'
import notice from '@/common/notice'
import { RegistType } from '@/common/constants'
import util from '@/libs/util'
export default {
name: "DialogReg",
name: 'DialogReg',
props: {
isVisible: {
type: Boolean,
......@@ -106,57 +105,58 @@ export default {
},
watch: {
editData: {
handler: function(value) {
Object.assign(this.regForm, value);
handler: function (value) {
Object.assign(this.regForm, value)
console.log(this.regForm)
},
immediate: true
}
},
computed: {
dialogVisible() {
dialogVisible () {
if (!this.isVisible) {
util.resetForm.call(this,'regForm')
util.resetForm.call(this, 'regForm')
}
return this.isVisible;
return this.isVisible
}
},
data() {
data () {
return {
regForm: {
createType: RegistType.BY_ADMIN, // 1 自注册 2 管理员创建
loginName: "",
userName: "",
mobile: "",
companyName: "",
departName: "",
postCode: "",
stationCode: "",
roleId: ""
loginName: '',
userName: '',
mobile: '',
companyName: '',
departName: '',
postCode: '',
stationCode: '',
roleId: ''
},
resetForm: {},
rules: Object.freeze({
loginName: [
{ required: true, message: "用户名不能为空", trigger: ["blur"] }
{ required: true, message: '用户名不能为空', trigger: ['blur'] }
],
userName: [
{ required: true, message: "姓名不能为空", trigger: ["blur"] }
{ required: true, message: '姓名不能为空', trigger: ['blur'] }
],
mobile: [
{ required: true, message: "联系方式不能为空", trigger: ["blur"] }
{ required: true, message: '联系方式不能为空', trigger: ['blur'] }
],
companyName: [
{ required: true, message: "所属公司不能为空", trigger: ["blur"] }
{ required: true, message: '所属公司不能为空', trigger: ['blur'] }
],
departName: [
{ required: true, message: "部门不能为空", trigger: ["blur"] }
{ required: true, message: '部门不能为空', trigger: ['blur'] }
],
postCode: [
{ required: true, message: "职务不能为空", trigger: ["blur"] }
{ required: true, message: '职务不能为空', trigger: ['blur'] }
],
stationCode: [
{ required: true, message: "所属站点不能为空", trigger: ["blur"] }
{ required: true, message: '所属站点不能为空', trigger: ['blur'] }
],
roleId: [{ required: true, message: "角色不能为空", trigger: ["blur"] }]
roleId: [{ required: true, message: '角色不能为空', trigger: ['blur'] }]
}),
/* -----------------------基础数据---------------------- */
baseData: {
......@@ -164,47 +164,46 @@ export default {
stations: [],
// 职务
posts: [],
//roles
// roles
roles: []
}
};
}
},
methods: {
...mapActions("d2admin/base", ["load"]),
handleClose(done) {
this.$event.$emit("e-reg-dialog", false);
...mapActions('d2admin/base', ['load']),
handleClose (done) {
this.$event.$emit('e-reg-dialog', false)
},
// 提交注册数据
submit() {
submit () {
this.$refs.regForm.validate(vaild => {
if (vaild) {
var __p = this.regForm;
var __p = this.regForm
Reg(__p).then(res => {
notice.okTips("注册信息已提交,请等待管理员审核");
this.$refs.regForm.resetFields();
this.$event.$emit("e-reg-dialog", false);
});
notice.okTips('创建成功')
this.$event.$emit('e-reg-dialog', false)
})
}
});
})
},
// 加载业务所需所有数据
async fetchData() {
const { role, station, post } = await this.load();
this.baseData.posts = post;
this.baseData.stations = station;
this.baseData.roles = role;
Object.freeze(this.baseData);
async fetchData () {
const { role, station, post } = await this.load()
this.baseData.posts = post
this.baseData.stations = station
this.baseData.roles = role
Object.freeze(this.baseData)
}
},
mounted() {
this.fetchData();
mounted () {
this.fetchData()
}
};
}
</script>
<style lang="scss">
$login-dialog-lable-width: 90px;
$login-dialog-font: 13px;
.reg-dialog {
.reg-dialog-admin{
.el-dialog__footer {
text-align: right;
.el-button {
......
......@@ -11,10 +11,11 @@
<el-form-item label="注册时间:">
<el-date-picker
v-model="searchForm.times"
type="datetimerange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
></el-date-picker>
</el-form-item>
<el-form-item label="角色:">
......@@ -94,97 +95,112 @@
:total="total"
layout="sizes,total,->,prev,pager,next,jumper"
></el-pagination>
<dialog-reg :isVisible="registerDialogVisible" :editData="editData"/>
<dialog-reg :isVisible="registerDialogVisible" :editData="editData" />
</d2-container>
</template>
<script>
import { UserList,PassWordReset,AccountModify,AccountIncrease,AccountForbidden,AccountValidate } from "@/api/sys.account";
import notice from "@/common/notice";
import { mapActions } from "vuex";
import util from "@/libs/util";
import {
UserList,
PassWordReset,
AccountModify,
AccountIncrease,
AccountForbidden,
AccountValidate
} from '@/api/sys.account'
import notice from '@/common/notice'
import { mapActions } from 'vuex'
import util from '@/libs/util'
export default {
name: "FimsUsers",
name: 'FimsUsers',
components: {
'DialogReg': () => import('./dialogReg')
DialogReg: () => import('./dialogReg')
},
data() {
data () {
return {
mapping:Object.freeze({
'field':'status',
'1':['重置密码','编辑','延期','禁用'],
'2':['重置密码','编辑','激活'],
'3':['重置密码','编辑','激活'],
'4':['审核']
}),
mapping: Object.freeze({
field: 'status',
'1': ['重置密码', '编辑', '延期', '禁用'],
'2': ['重置密码', '编辑', '激活'],
'3': ['重置密码', '编辑', '激活'],
'4': ['审核']
}),
apiMapping: Object.freeze({
'重置密码': PassWordReset,
'延期': AccountIncrease,
'禁用': AccountForbidden,
'审核': AccountValidate,
'编辑': AccountModify,
'激活': ''
}),
// 新增/编辑弹窗
registerDialogVisible: false,
editData: {},
// 搜索
searchForm: {
userName: "",
companyName: "",
times: "",
postCode: "",
status: "",
stationCode: "",
postCode: ""
userName: '',
companyName: '',
times: '',
postCode: '',
status: '',
stationCode: '',
postCode: ''
},
// 表格
tableLoading: false,
tableData: [],
tableColumns: [
{
label: "用户名",
prop: "loginName"
label: '用户名',
prop: 'loginName'
},
{
label: "角色",
prop: "roleName"
label: '角色',
prop: 'roleName'
},
{
label: "注册时间",
prop: "registerTime"
label: '注册时间',
prop: 'registerTime'
},
{
label: "有效期",
prop: "validTime"
label: '有效期',
prop: 'validTime'
},
{
label: "状态",
prop: "status",
label: '状态',
prop: 'status',
formatter: cellValue => {
return {
1: "正常",
2: "已过期",
3:'禁用',
4:'待审核'
}[cellValue.status];
1: '正常',
2: '已过期',
3: '禁用',
4: '待审核'
}[cellValue.status]
}
},
{
label: "姓名",
prop: "userName"
label: '姓名',
prop: 'userName'
},
{
label: "联系电话",
prop: "mobile"
label: '联系电话',
prop: 'mobile'
},
{
label: "所属公司",
prop: "companyName"
label: '所属公司',
prop: 'companyName'
},
{
label: "部门",
prop: "departName"
label: '部门',
prop: 'departName'
},
{
label: "职务",
prop: "postName"
label: '职务',
prop: 'postName'
},
{
label: "所属站点",
prop: "stationName"
label: '所属站点',
prop: 'stationName'
}
],
page: {
......@@ -198,76 +214,87 @@ export default {
stations: [],
// 职务
posts: [],
//角色
// 角色
roles: []
}
};
}
},
mounted() {
this.fetchData();
this.$event.$on('e-reg-dialog', res => this.registerDialogVisible = res)
mounted () {
this.fetchData()
this.$event.$on('e-reg-dialog', res => (this.registerDialogVisible = res))
},
methods: {
...mapActions("d2admin/base", ["load"]),
...mapActions('d2admin/base', ['load']),
// 加载业务所需所有数据
fetchData() {
this.loadBaseData(), this.loadUserList();
fetchData () {
this.loadBaseData(), this.loadUserList()
},
async loadBaseData() {
const { role, station, post } = await this.load();
this.baseData.posts = post;
this.baseData.stations = station;
this.baseData.roles = role;
Object.freeze(this.baseData);
async loadBaseData () {
const { role, station, post } = await this.load()
this.baseData.posts = post
this.baseData.stations = station
this.baseData.roles = role
Object.freeze(this.baseData)
},
/* 接口请求-start */
getParams() {
getParams () {
let startTime = ''
let endTime = ''
if (this.searchForm.times) {
[startTime, endTime] = this.searchForm.times
delete this.searchForm.times
}
return {
...this.page,
...this.searchForm
};
...this.searchForm,
startTime,
endTime
}
},
loadUserList() {
this.tableLoading = true;
const params = this.getParams();
loadUserList () {
this.tableLoading = true
const params = this.getParams()
UserList(params)
.then(res => {
this.tableData = res;
this.tableLoading = false;
this.tableData = res
this.tableLoading = false
})
.catch(err => {
notice.errorTips(err);
this.tableLoading = false;
});
notice.errorTips(err)
this.tableLoading = false
})
},
handleRegister(){
this.registerDialogVisible = true
handleRegister () {
this.registerDialogVisible = true
},
handleSearch () {
this.loadUserList()
},
// 页码
handleSizeChange(value) {
this.page.pageSize = value;
// 调接口
this.loadUserList();
handleSizeChange (value) {
this.page.pageSize = value
this.loadUserList()
},
handleCurrentChange(value) {
this.page.pageCount = value;
// 调接口
this.loadUserList();
handleCurrentChange (value) {
this.page.pageCount = value
this.loadUserList()
},
handleEdit(row){
this.registerDialogVisible = true
this.editData = util.deepClone(row)
handleEdit (row) {
this.registerDialogVisible = true
this.editData = util.deepClone(row)
},
// ------------
//重置密码
// ------------
// 列表各种操作
handleOperation (row, e) {
this.apiMapping[e.target.innerText]({ userId: row.userId })
}
}
};
}
</script>
<style scoped>
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!