Commit 060784a8 by liimin

权限完善

1 parent c2e97b11
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: limin * @Author: limin
* @Date: 2019-08-26 18:02:55 * @Date: 2019-08-26 18:02:55
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-09-01 17:18:41 * @Last Modified time: 2019-09-02 14:26:14
*/ */
import request from './request' import request from './request'
...@@ -27,3 +27,12 @@ export function Reg (data = {}) { ...@@ -27,3 +27,12 @@ export function Reg (data = {}) {
data.method = `${user_path}register` data.method = `${user_path}register`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
/**
* 获取用户列表
* @param {*} data 参数
*/
export function UserList (data = {}) {
data.method = `${user_path}search`
return request(data, RequestMethods.GET)
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: limin * @Author: limin
* @Date: 2019-08-26 18:02:55 * @Date: 2019-08-26 18:02:55
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-09-01 17:19:07 * @Last Modified time: 2019-09-02 10:49:21
*/ */
import request from './request' import request from './request'
...@@ -44,3 +44,12 @@ export function FetchRoleList (data = {}) { ...@@ -44,3 +44,12 @@ export function FetchRoleList (data = {}) {
data.method = `fims.role.list` data.method = `fims.role.list`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
/**
* 获取职务列表
* @param {*} data 参数
*/
export function PostList (data = {}) {
data.method = `${path}post`
return request(data, RequestMethods.GET)
}
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
.d2-layout-header-aside-content { .d2-layout-header-aside-content {
// [布局] 顶栏 // [布局] 顶栏
.d2-theme-header { .d2-theme-header {
transition: .1s ease;
// logo区域 // logo区域
.logo-group { .logo-group {
transition: width .3s; transition: width .3s;
...@@ -143,6 +144,7 @@ ...@@ -143,6 +144,7 @@
} }
} }
.el-menu-item { .el-menu-item {
transition: .1s ease;
@extend %header-menu-item; @extend %header-menu-item;
border-bottom: none; border-bottom: none;
} }
......
/* /*
* @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-01 19:06:01 * @Last Modified time: 2019-09-02 10:52:44
*/ */
export const BaseData = { export const BaseData = {
ROLE: 'role', ROLE: 'role',
COMPANY: 'company', COMPANY: 'company',
DEPART: 'depart', DEPART: 'depart',
STATION: 'station' STATION: 'station',
POST:'post'
} }
...@@ -48,8 +48,11 @@ export default { ...@@ -48,8 +48,11 @@ export default {
}, },
created () { created () {
// this.$vrm.setRoles(this.btnIdAll) // this.$vrm.setRoles(this.btnIdAll)
const { action, operation } = this.curBtns if(this.curBtns){
this.isInRole = [...action, ...operation].find(obj => obj.id === this.id || obj.label === this.label) // const { action, operation } = this.curBtns
// console.log(this.label);
this.isInRole = this.curBtns.find(obj => obj.id === this.id || obj.label === this.label)
}
}, },
methods: { methods: {
handleClick: function () { handleClick: function () {
......
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
data () { data () {
return { return {
options: [ options: [
{ label: '默认', value: 'default' }, { label: '大', value: 'default' },
{ label: '中', value: 'medium' }, { label: '中', value: 'medium' },
{ label: '小', value: 'small' }, { label: '小', value: 'small' },
{ label: '最小', value: 'mini' } { label: '最小', value: 'mini' }
......
...@@ -16,12 +16,9 @@ ...@@ -16,12 +16,9 @@
flex-box="0" flex-box="0"
flex> flex>
<div class="logo-group d2-theme-header-logo" :class="asideCollapse ? 'logo-only' : 'logo-all'" flex-box="0"> <div class="logo-group d2-theme-header-logo" :class="asideCollapse ? 'logo-only' : 'logo-all'" flex-box="0">
<img v-if="asideCollapse" :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/icon-only.png`"> <img v-if="asideCollapse" :src="`${$baseUrl}image/theme/logo/icon-only.png`">
<img v-else :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/all.png`"> <img v-else :src="`${$baseUrl}image/theme/logo/all.png`">
</div> </div>
<!-- <div class="toggle-aside-btn" @click="handleToggleAside" flex-box="0">
<d2-icon name="bars"/>
</div> -->
<hamburger :onClick="handleToggleAside" :isActive="asideCollapse" flex-box="0" class="toggle-aside-btn"></hamburger> <hamburger :onClick="handleToggleAside" :isActive="asideCollapse" flex-box="0" class="toggle-aside-btn"></hamburger>
<d2-menu-header flex-box="1"/> <d2-menu-header flex-box="1"/>
<!-- 顶栏右侧 --> <!-- 顶栏右侧 -->
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: limin * @Author: limin
* @Date: 2019-08-27 19:16:26 * @Date: 2019-08-27 19:16:26
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-08-28 23:05:36 * @Last Modified time: 2019-09-02 16:20:21
*/ */
const permision = {} const permision = {}
/** /**
...@@ -16,21 +16,30 @@ permision.packRoutesBtns = function (resources, idsInPermision) { ...@@ -16,21 +16,30 @@ permision.packRoutesBtns = function (resources, idsInPermision) {
} }
let __aRouteInPermision = [] let __aRouteInPermision = []
let __oBtnInPermision = {} let __oBtnInPermision = {}
// __aBtnIdAll=[],
let __objResource = null let __objResource = null
let __obj = null
idsInPermision.forEach(obj => { idsInPermision.forEach(obj => {
__objResource = resources[obj.id] __objResource = resources[obj.id]
if (__objResource) { // 直接能取到的为路由 (也可以在routes 中定标识变量) if (__objResource) { // 直接能取到的为路由 (也可以在routes 中定标识变量)
__aRouteInPermision.push(resources[obj.id])// push 进 路由数组 __aRouteInPermision.push(resources[obj.id]) // push 进 路由数组
} else { // 如果取不到 判断是否有父节点 并且父节点是否有auth属性 有 则视为按钮 (同样可以定义标识变量) } else { // 如果取不到 判断是否有父节点 并且父节点是否有auth属性 有 则视为按钮 (同样可以定义标识变量)
__objResource = resources[obj.pid] __objResource = resources[obj.pid]
if (__objResource && __objResource.auth && !__oBtnInPermision[obj.pid]) { if (__objResource && __objResource.auth) {
__oBtnInPermision[obj.pid] = __objResource.auth __obj =__objResource.auth.find(o => o.id === obj.id)
if (__oBtnInPermision[obj.pid] && __oBtnInPermision[obj.pid].length) {
__oBtnInPermision[obj.pid].push(__obj)
} else {
__oBtnInPermision[obj.pid] = [__obj]
}
// __oBtnInPermision[obj.pid] = __objResource.auth
// __aBtnIdAll = __aBtnIdAll.concat([...__objResource.auth.action.map(o=>o.id),...__objResource.auth.operation.map(o=>o.id)]) // __aBtnIdAll = __aBtnIdAll.concat([...__objResource.auth.action.map(o=>o.id),...__objResource.auth.operation.map(o=>o.id)])
} }
} }
}) })
return { 'route': __aRouteInPermision, 'btn': __oBtnInPermision } return {
'route': __aRouteInPermision,
'btn': __oBtnInPermision
}
} }
/** /**
...@@ -78,9 +87,23 @@ permision.packAsideMenus = function (resources, idsInPermision) { ...@@ -78,9 +87,23 @@ permision.packAsideMenus = function (resources, idsInPermision) {
*/ */
permision.format2Menu = function (oMenu) { permision.format2Menu = function (oMenu) {
if (!oMenu) return null if (!oMenu) return null
const { icon, path, meta } = oMenu const {
const { title, id, pid } = meta icon,
return { title, icon, path, id, pid } path,
meta
} = oMenu
const {
title,
id,
pid
} = meta
return {
title,
icon,
path,
id,
pid
}
} }
export default permision export default permision
\ No newline at end of file \ No newline at end of file
...@@ -8,11 +8,12 @@ const _import = require('@/libs/util.import.' + process.env.NODE_ENV) ...@@ -8,11 +8,12 @@ const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
*/ */
const frameIn = [{ const frameIn = [{
path: '/', path: '/',
redirect: { name: 'index' }, redirect: {
name: 'index'
},
component: layoutHeaderAside, component: layoutHeaderAside,
children: [] children: []
} }]
]
/** /**
* 首页 * 首页
*/ */
...@@ -94,18 +95,15 @@ export const resources = { ...@@ -94,18 +95,15 @@ export const resources = {
cache: true cache: true
}, },
component: _import('demo/page2'), component: _import('demo/page2'),
auth: { auth: [{ // 列表操作
'operation': [{ // 列表操作 id: '1020201',
id: '1020201', pid: '10202',
pid: '10202', label: '查看'
label: '查看' }, { //
}, { // id: '1020202',
id: '1020202', pid: '10202',
pid: '10202', label: '编辑'
label: '编辑' }],
}],
'action': [] // 按钮操作
}
}, },
'10203': { '10203': {
path: '/page3', path: '/page3',
...@@ -116,18 +114,15 @@ export const resources = { ...@@ -116,18 +114,15 @@ export const resources = {
id: '10203', id: '10203',
pid: '102' pid: '102'
}, },
auth: { auth: [{ // 列表操作
'operation': [{ // 列表操作 id: '1020301',
id: '1020301', pid: '10203',
pid: '10203', label: '查看'
label: '查看' }, { //
}, { // id: '1020302',
id: '1020302', pid: '10203',
pid: '10203', label: '编辑'
label: '编辑' }],
}],
'action': [] // 按钮操作
},
component: _import('demo/page3') component: _import('demo/page3')
}, },
// '102': { // '102': {
...@@ -202,7 +197,7 @@ export const resources = { ...@@ -202,7 +197,7 @@ export const resources = {
component: _import('maintainManagement') component: _import('maintainManagement')
}, },
'107': { '107': {
path: '/user', path: '/userManager',
icon: 'users', icon: 'users',
name: '用户管理', name: '用户管理',
meta: { meta: {
...@@ -213,7 +208,7 @@ export const resources = { ...@@ -213,7 +208,7 @@ export const resources = {
} }
}, },
'10701': { '10701': {
path: '/userManage', path: '/user',
name: '用户管理', name: '用户管理',
icon: 'user', icon: 'user',
meta: { meta: {
...@@ -222,7 +217,36 @@ export const resources = { ...@@ -222,7 +217,36 @@ export const resources = {
id: '10701', id: '10701',
pid: '107' pid: '107'
}, },
component: _import('userManage/loginLogs') auth: [{ // 列表操作
id: '1070101',
pid: '10701',
label: '审核'
}, { //
id: '1070102',
pid: '10701',
label: '重置密码'
}, { //
id: '1070103',
pid: '10701',
label: '编辑'
}, { //
id: '1070104',
pid: '10701',
label: '延期'
}, { //
id: '1070105',
pid: '10701',
label: '禁用'
}, { //
id: '1070106',
pid: '10701',
label: '激活'
}, { // 列表操作
id: '1070107',
pid: '10701',
label: '创建用户'
}],
component: _import('userManage/user')
}, },
'10702': { '10702': {
path: '/jurisdictionManage', path: '/jurisdictionManage',
...@@ -293,4 +317,4 @@ export default [ ...@@ -293,4 +317,4 @@ export default [
// dashboard, // dashboard,
...frameOut, ...frameOut,
errorPage errorPage
] ]
\ No newline at end of file \ No newline at end of file
...@@ -37,7 +37,7 @@ export default { ...@@ -37,7 +37,7 @@ export default {
name: user.name name: user.name
}, { root: true }) }, { root: true })
// 强制初始化基础数据 // 强制初始化基础数据
await dispatch('d2admin/base/init', null, { root: true }) dispatch('d2admin/base/init', null, { root: true })
// 用户登录后从持久化数据加载一系列的设置 // 用户登录后从持久化数据加载一系列的设置
await dispatch('load') await dispatch('load')
// 结束 // 结束
...@@ -84,13 +84,10 @@ export default { ...@@ -84,13 +84,10 @@ export default {
await dispatch('d2admin/page/openedLoad', null, { root: true }) await dispatch('d2admin/page/openedLoad', null, { root: true })
// DB -> store 持久化数据加载侧边栏折叠状态 // DB -> store 持久化数据加载侧边栏折叠状态
await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true }) await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// await dispatch('d2admin/size/set', 'medium', { root: true })
// DB -> store 持久化数据加载全局尺寸 // DB -> store 持久化数据加载全局尺寸
await dispatch('d2admin/size/load', null, { root: true }) await dispatch('d2admin/size/load', null, { root: true })
// DB - > 初始化 基础数据 // DB - > 初始化 基础数据
// await dispatch('d2admin/base/init', null, { root: true }) // await dispatch('d2admin/base/init', null, { root: true })
// // store 设置系统主色
// await dispatch('d2admin/color/set', process.env.VUE_APP_MAIN_COLOR)
// 后台接口 -> store // 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true }) // await dispatch('d2admin/auth/init', null, { root: true })
// end // end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: limin * @Author: limin
* @Date: 2019-08-27 17:25:12 * @Date: 2019-08-27 17:25:12
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-09-01 19:00:46 * @Last Modified time: 2019-09-02 16:30:11
*/ */
import util from '@/libs/util.js' import util from '@/libs/util.js'
import router from '@/router' import router from '@/router'
...@@ -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, __source) const { route, btn } = util.permision.packRoutesBtns({...sources,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
......
...@@ -2,16 +2,17 @@ ...@@ -2,16 +2,17 @@
* @Author: limin * @Author: limin
* @Date: 2019-09-01 17:56:57 * @Date: 2019-09-01 17:56:57
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-09-01 18:57:45 * @Last Modified time: 2019-09-02 11:20:15
*/ */
import { FetchRoleList, CompanyList, DepartList, StationList } from '@/api/sys.base' import { FetchRoleList, CompanyList, DepartList, StationList,PostList } from '@/api/sys.base'
import { BaseData } from '@/common/constants' import { BaseData } from '@/common/constants'
const map = { const map = {
[BaseData.ROLE]: FetchRoleList, [BaseData.ROLE]: FetchRoleList,
[BaseData.COMPANY]: CompanyList, [BaseData.COMPANY]: CompanyList,
[BaseData.DEPART]: DepartList, [BaseData.DEPART]: DepartList,
[BaseData.STATION]: StationList [BaseData.STATION]: StationList,
[BaseData.POST]: PostList
} }
export default { export default {
namespaced: true, namespaced: true,
...@@ -23,7 +24,9 @@ export default { ...@@ -23,7 +24,9 @@ export default {
// 部门 // 部门
depart: [], depart: [],
// 站点 // 站点
station: [] station: [],
//职务
post:[]
}, },
actions: { actions: {
/** /**
...@@ -37,14 +40,16 @@ export default { ...@@ -37,14 +40,16 @@ export default {
FetchRoleList(), FetchRoleList(),
CompanyList(), CompanyList(),
DepartList(), DepartList(),
StationList() StationList(),
]).then( async ([role, company, depart, station] = res) => { PostList()
]).then( async ([role, company, depart, station, post] = res) => {
state.role = role state.role = role
state.station = station state.station = station
state.depart = depart state.depart = depart
state.company = company state.company = company
await dispatch('save2db', {path: `base`,value: {role, company, depart, station}}) state.post = post
resolve({ role, company, depart, station }) await dispatch('save2db', {path: `base`,value: {role, company, depart, station,post}})
resolve({ role, company, depart, station,post })
}) })
}) })
}, },
...@@ -77,8 +82,8 @@ export default { ...@@ -77,8 +82,8 @@ export default {
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, company, depart, station} = state const {role, company, depart, station, post} = state
resolve({role, company, depart, station}) resolve({role, company, depart, station, post})
}) })
}, },
/** /**
......
import Vue from 'vue' import Vue from 'vue'
import router from '@/router' import router from '@/router'
const size = 'medium' // medium small mini
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
// 尺寸 // 尺寸
value: 'medium' // medium small mini value: ''// medium small mini
}, },
actions: { actions: {
/** /**
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
state.value = await dispatch('d2admin/db/get', { state.value = await dispatch('d2admin/db/get', {
dbName: 'sys', dbName: 'sys',
path: 'size.value', path: 'size.value',
defaultValue: 'default', defaultValue: size,
user: true user: true
}, { root: true }) }, { root: true })
// 应用 // 应用
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<el-table <el-table
:data="tableData" :data="tableData"
border border
size="small"
style="width: 100%"> style="width: 100%">
<el-table-column <el-table-column
fixed fixed
......
...@@ -62,9 +62,9 @@ ...@@ -62,9 +62,9 @@
<el-form-item label="职务:" prop="postCode"> <el-form-item label="职务:" prop="postCode">
<el-select v-model="regForm.postCode" placeholder="请选择"> <el-select v-model="regForm.postCode" placeholder="请选择">
<el-option <el-option
:label="role.roleName" :label="post.postName"
:value="role.roleId" :value="post.postCode"
v-for="(role,index) in baseData.roles" v-for="(post,index) in baseData.posts"
:key="index" :key="index"
></el-option> ></el-option>
</el-select> </el-select>
...@@ -191,8 +191,8 @@ export default { ...@@ -191,8 +191,8 @@ export default {
baseData: { baseData: {
// 所属站点 // 所属站点
stations: [], stations: [],
// 角色 // 职务
roles: [], posts: [],
// 部门 // 部门
departs: [], departs: [],
// 公司 // 公司
...@@ -220,8 +220,8 @@ export default { ...@@ -220,8 +220,8 @@ export default {
}, },
// 加载业务所需所有数据 // 加载业务所需所有数据
async fetchData () { async fetchData () {
const { role, company, depart, station } = await this.load() const { role, company, depart, station,post } = await this.load()
this.baseData.roles = role this.baseData.posts = post
this.baseData.stations = station this.baseData.stations = station
this.baseData.departs = depart this.baseData.departs = depart
this.baseData.companys = company this.baseData.companys = company
......
<!-- 车辆管理 -->
<template>
<d2-container class="user">
<el-form :inline="true" :model="searchForm" label-width="85px">
<el-form-item label="用户">
<el-input v-model="searchForm.name" placeholder="请输入用户名/姓名/联系电话" clearable></el-input>
</el-form-item>
<el-form-item label="所属公司:">
<el-select v-model="searchForm.companyCode" placeholder="请选择">
<el-option
:label="company.companyName"
:value="company.companyCode"
v-for="(company,index) in baseData.companys"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="注册时间">
<el-date-picker
v-model="searchForm.times"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item label="角色:">
<el-select v-model="searchForm.postCode" placeholder="请选择">
<el-option
:label="role.roleName"
:value="role.roleId"
v-for="(role,index) in baseData.roles"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable filterable>
<el-option label="在网" value="1"></el-option>
<el-option label="离网" value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="所属站点:">
<el-select v-model="searchForm.stationCode" placeholder="请选择" class="sigle-select">
<el-option
:label="station.stationName"
:value="station.stationCode"
v-for="(station,index) in baseData.stations"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="职务:">
<el-select v-model="searchForm.postCode" placeholder="请选择">
<el-option
:label="post.postName"
:value="post.postCode"
v-for="(post,index) in baseData.posts"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">查询</el-button>
</el-form-item>
</el-form>
<el-row style="height: 40px; line-height: 40px">
<el-col :span="12">用户列表</el-col>
<el-col :span="12" style="text-align: right">
<el-button @click="register()">创建用户</el-button>
</el-col>
</el-row>
<el-table :data="tableData" v-loading="tableLoading" border style="margin: 20px 0;">
<el-table-column align="center" width="60px" label="序号" type="index"></el-table-column>
<el-table-column
v-for="(item, index) in tableColumns"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
align="center"
>
<template slot-scope="scope">
<template v-if="item.formatter">{{item.formatter(scope.row)}}</template>
<template v-else>{{tableData[scope.$index][item.prop]}}</template>
</template>
</el-table-column>
<el-table-column align="center" label="操作">
<template slot-scope="scope">
<auth-button type="text" label="重置密码" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="审核" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="编辑" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="延期" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="禁用" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="激活" @click="handleEdit(scope.row, scope.$index)"></auth-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10,20,30,40]"
:page-size="pageSize"
:total="total"
layout="sizes,total,->,prev,pager,next,jumper"
></el-pagination>
<!-- <edit-dialog
:isVisible="editVisible"
:editForm="editForm"
@closeDialog="handleEditClose"
@confirmDialog="handleEditConfirm"
></edit-dialog>-->
</d2-container>
</template>
<script>
// import EditDialog from './editDialog'
import { UserList } from "@/api/sys.account";
import notice from "@/common/notice";
import { mapActions } from "vuex";
export default {
name: "FimsUserUsers",
components: {
// EditDialog
},
data() {
return {
// 新增/编辑弹窗
editVisible: false,
editForm: {
name: "",
stationCode: "",
stationName: "",
merchantName: "",
openType: ""
},
// 搜索
searchForm: {
name: "",
companyCode: "",
times: "",
postCode: "",
status: "",
stationCode: "",
postCode: ""
},
// 表格
tableLoading: false,
tableData: [],
tableColumns: [
{
label: "用户名",
prop: "loginName"
},
{
label: "角色",
prop: "roleName"
},
{
label: "注册时间",
prop: "registerTime"
},
{
label: "有效期",
prop: "validTime"
},
{
label: "状态",
prop: "status",
formatter: cellValue => {
return {
1: "正常",
2: "已过期",
3:'禁用'
}[cellValue.status];
}
},
{
label: "姓名",
prop: "userName"
},
{
label: "联系电话",
prop: "mobile"
},
{
label: "所属公司",
prop: "companyName"
},
{
label: "部门",
prop: "departName"
},
{
label: "职务",
prop: "postName"
},
{
label: "所属站点",
prop: "stationName"
}
],
page: {
// 页码
pageCount: 1,
pageSize: 10
},
/* -----------------------基础数据---------------------- */
baseData: {
// 所属站点
stations: [],
// 职务
posts: [],
// 部门
departs: [],
// 公司
companys: [],
//角色
roles: []
}
};
},
mounted() {
this.fetchData();
},
methods: {
...mapActions("d2admin/base", ["load"]),
// 加载业务所需所有数据
fetchData() {
this.loadBaseData(), this.loadUserList();
},
async loadBaseData() {
const { role, company, depart, station, post } = await this.load();
this.baseData.posts = post;
this.baseData.stations = station;
this.baseData.departs = depart;
this.baseData.companys = company;
this.baseData.roles = role;
Object.freeze(this.baseData);
},
/* 接口请求-start */
getParams() {
return {
...this.page,
...this.searchForm
};
},
loadUserList() {
this.tableLoading = true;
const params = this.getParams();
UserList(params)
.then(res => {
this.tableData = res;
this.tableLoading = false;
})
.catch(err => {
notice.errorTips(err);
this.tableLoading = false;
});
},
// 页码
handleSizeChange(value) {
this.page.pageSize = value;
// 调接口
this.loadUserList();
},
handleCurrentChange(value) {
this.page.pageCount = value;
// 调接口
this.loadUserList();
},
handleDelete(index, row) {
this.$confirm("确认删除?", "删除", {
comfirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
console.log(index);
console.log(row);
this.$message({
type: "success",
message: "删除成功"
});
})
.catch(err => {});
}
}
};
</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!