Commit 153d1dc5 by liimin

实现用户列表操作

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