Commit a4d5ae21 by cwq0219

修改

1 parent afb29b54
......@@ -6631,7 +6631,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
......@@ -6652,12 +6653,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -6672,17 +6675,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -6799,7 +6805,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
......@@ -6811,6 +6818,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -6825,6 +6833,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -6832,12 +6841,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
......@@ -6856,6 +6867,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -6936,7 +6948,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
......@@ -6948,6 +6961,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -7033,7 +7047,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
......@@ -7069,6 +7084,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......@@ -7088,6 +7104,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
......@@ -7131,12 +7148,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},
......@@ -12820,7 +12839,8 @@
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz",
"integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=",
"dev": true
"dev": true,
"optional": true
},
"rx-lite-aggregates": {
"version": "4.0.8",
......
......@@ -2,34 +2,24 @@
* @Author: limin
* @Date: 2019-08-26 18:02:41
* @Last Modified by: chenwq
* @Last Modified time: 2020-11-27 22:22:02
* @Last Modified time: 2021-01-02 11:28:55
*/
import axios from '@/plugin/axios'
import sign from './sign'
import RequestMethods from './request.methods'
import util from '@/libs/util.js'
import {
baseConfig
} from '@/main'
const request = (params = {}, method = RequestMethods.GET, noSignAttr = []) => {
// params.source = 'glsx'
params.appKey = window.location.href.includes('dj.glsx.com.cn') ? 'd7ffc3346fc9a45bccaaa35300d59022' : '48e5e13229b82c1b4e6e8c96151f0637'
params.timestamp = new Date().getTime()
params.v = '1.0.0'
params.format = 'json'
params.locale = 'zh_CN'
if (params.method !== 'dj.api.user.login') {
params.sessionId = util.cookies.get('token')
}
/**
* mock - url = params.method
* 调后端接口 - url = ''
*/
const url = params.method // ''
/**
* 调后端接口,请使用以下代码。
*/
const url = baseConfig.axios.baseURL + params.method
var reqData = (method === RequestMethods.POST) ? {
// baseURL: process.env.VUE_APP_API + '?method=' + params.method,
baseURL: process.env.VUE_APP_API,
baseURL: url,
data: sign(params, noSignAttr)
} : {
params: sign(params, noSignAttr)
......@@ -39,14 +29,5 @@ const request = (params = {}, method = RequestMethods.GET, noSignAttr = []) => {
method,
...reqData
})
/**
* mock,请使用以下代码。
*/
// return axios({
// url,
// method,
// params: sign(params, noSignAttr)
// })
}
export default request
......@@ -48,5 +48,5 @@ $prefix: d2;
padding: 4px 0 !important;
}
.el-table .cell {
padding: 0 0;
padding: 5px 5px;
}
\ No newline at end of file
......@@ -37,6 +37,10 @@ export default {
type: Object,
default: null
},
showBtnName: {
type: Array,
default: []
},
data: Object
},
functional: true, // 开启函数化组件
......@@ -49,8 +53,17 @@ export default {
* data 点击按钮时 需要得到的参数 比如 table 中的 当前行数据 row
* mapping 非必填 但: 当列表中的操作选项 根据 某个字段 变化的话 必填 且 必须 注明 field: 字段名
* label 当传入label 字段时 标识明确指定渲染该label 的按钮
* size 按钮样式,默认mini
* showBtnName 按需显示按钮
*/
const { category, data, mapping, label } = ctx.props
const {
category,
data,
mapping,
label,
size,
showBtnName
} = ctx.props
let curBtns = []
/**
* 判断一个按钮(btn)是否存在与当前行(data) 的映射关系(mapping)中
......@@ -81,11 +94,13 @@ export default {
* 循环最终显示的按钮列表
* 并渲染到页面
*/
curBtns.forEach(btn =>
curBtns = showBtnName.length ? curBtns.filter(item => showBtnName.includes(item.label)) : curBtns
curBtns.forEach(btn => {
__aBtns.push(h('el-button', {
props: {
type: btn.type || (btn.category === 'Button' ? '' : 'text'),
icon: btn.icon ? `el-icon-${btn.icon}` : ''
icon: btn.icon ? `el-icon-${btn.icon}` : '',
size: size
},
style: {
color: btn.color
......@@ -93,7 +108,8 @@ export default {
on: {
click: (e) => btn.handle && _this[btn.handle](data, e)
}
}, [btn.label])))
return h('div', {}, [...__aBtns, ctx.children])
}, [btn.ruleObj ? btn.ruleObj.rule[data[btn.ruleObj.attr]] : btn.label]))
})
return h('span', {}, [...__aBtns, ctx.children])
}
}
......@@ -26,7 +26,7 @@
width="60px"
label="序号"
type='index'
:index="index=>index+(pagination.currentPage - 1) * pagination.pageSize + 1"
:index="index=>index+(page.currentPage - 1) * page.pageSize + 1"
></el-table-column>
<el-table-column
v-for="(item, index) in tableParams.tableColumns"
......@@ -120,7 +120,6 @@ export default {
// 排序
sortColum: '',
sort: '',
pagination: {},
// 多选数组
mutiSelectArr: {}
}
......@@ -262,28 +261,11 @@ export default {
params.sort = this.sort === 'descending' ? 1 : 0
}
this.getListApi(params).then(res => {
this.pagination = {
currentPage: res.pageNum,
pageSize: res.pageSize
}
// this.tableParams.needUnique && (res[this.tableParams.listName].forEach((item) => {
// item[this.tableParams.mutiSelectUniqueKey]
// }))
this.data = res[this.tableParams.listName]
if (this.tableParams.needUnique) {
let temp = 1
this.data.forEach((item) => {
item[this.tableParams.mutiSelectUniqueKey] = temp
temp = temp + 1
if (item.hasOwnProperty('upgradeGoodsList')) {
item.upgradeGoodsList.forEach(subItem => {
subItem[this.tableParams.mutiSelectUniqueKey] = temp
temp = temp + 1
})
}
})
}
this.total = res.total
this.total = res.pagination.totalCount
this.loading = false
}).catch(() => {
this.loading = false
......
import store from '@/store'
import axios from 'axios'
// import axios from 'axios'
import {
Message
} from 'element-ui'
import util from '@/libs/util'
import router from '@/router'
// import router from '@/router'
// import {
// LogExternals
// } from '@/common/constants'
......@@ -58,21 +58,6 @@ service.interceptors.request.use(
config => {
return new Promise(async resolve => {
await store.commit('d2admin/loading/set', true)
// const uuid = util.cookies.get('uuid')
// 如果请求链接不在排除列表 (排除列表: 登录 基础数据) 并且cookie 过期(判断是否长时间未操作)
// if (!LogExternals.some(u => u === url || (params && u === params.method)) && !uuid) {
// await store.dispatch('d2admin/account/logout')
// router.replace('/login')
// }
// if (uuid) { // 判断 cookie 是否存在 存在则更新时间 避免登出时 记录空值
// const inExpiresMinutes = new Date(new Date().getTime() + expiresMinute * 60 * 1000)
// util.cookies.set('uuid', uuid, {
// expires: inExpiresMinutes
// })
// }
// config.url = baseConfig.axios.baseURL + config.url
config.url = baseConfig.axios.baseURL
// config.timeout = baseConfig.axios.timeout
resolve(config)
})
},
......@@ -92,13 +77,6 @@ service.interceptors.response.use(
const ruleResult = baseConfig.axios.result
// 这个状态码是和后端约定的
// 有 code 代表这是一个后端接口 可以进行进一步的判断
var goBackArr = ['20', '21']
if (goBackArr.includes(dataAxios[ruleResult.code_key])) {
// await store.dispatch('d2admin/account/logout')
util.cookies.remove('token')
router.replace('/login')
return
}
switch (+dataAxios[ruleResult.code_key]) {
case ruleResult.code_success_value:
// [ 示例 ] code === 0 代表没有错误
......
......@@ -60,167 +60,71 @@ export const sys = [
* 所有需动态过滤的资源点
*/
export const resources = {
// '102': {
// path: '/bb',
// icon: 'document',
// name: '表格组件',
// meta: {
// title: '表格组件',
// authId: '102',
// parentId: '0'
// }
// },
// '10201': {
// path: '/table1',
// icon: 'document-copy',
// name: 'fimsTable1',
// meta: {
// title: '默认使用',
// authId: '10201',
// parentId: '102',
// cache: true
// },
// component: _import('table1'),
// auth: [{
// authId: '1020101',
// parentId: '10201',
// label: '编辑',
// handle: 'handleEdit'
// }, {
// authId: '1020102',
// parentId: '10201',
// label: '删除',
// color: '#FF0000',
// handle: 'handleDelete'
// }, {
// authId: '1020103',
// parentId: '10201',
// label: '添加',
// category: 'Button',
// type: 'button',
// handle: 'handleEdit',
// icon: 'plus'
// }, {
// authId: '1020104',
// parentId: '10201',
// label: '批量操作',
// category: 'Button',
// type: 'button',
// handle: 'handleOperate'
// }]
// },
// '10202': {
// path: '/table2',
// icon: 'finished',
// name: 'fimsTable2',
// meta: {
// title: '外部数据传入',
// authId: '10202',
// parentId: '102',
// cache: true
// },
// component: _import('table2')
// },
// '107': {
// path: '/users',
// icon: 'user',
// name: '帐号管理',
// meta: {
// title: '用户管理',
// authId: '107',
// parentId: '0'
// }
// },
// '10701': {
// path: '/user',
// name: 'FimsUsers',
// icon: 'user-solid',
// meta: {
// title: '用户管理',
// authId: '10701',
// parentId: '107',
// cache: true
// },
// auth: [{ // 列表操作
// authId: '1070101',
// parentId: '10701',
// label: '审核',
// handle: 'handleVerify'
// }, { //
// authId: '1070102',
// parentId: '10701',
// label: '重置密码',
// handle: 'handleOperation'
// }, { //
// authId: '1070103',
// parentId: '10701',
// label: '编辑',
// handle: 'handleEdit'
// }, { //
// authId: '1070104',
// parentId: '10701',
// label: '延期',
// handle: 'handleOperation'
// }, { //
// authId: '1070105',
// parentId: '10701',
// label: '禁用',
// color: '#FF0000',
// handle: 'handleOperation'
// }, { //
// authId: '1070106',
// parentId: '10701',
// label: '激活',
// handle: 'handleOperation'
// }, { // 列表操作
// authId: '1070107',
// parentId: '10701',
// label: '创建用户',
// category: 'action',
// type: 'button',
// handle: 'handleRegister',
// icon: 'plus'
// }],
// component: _import('userManage/user')
// },
// '10702': {
// path: '/role',
// name: 'FimsRoles',
// icon: 'open',
// meta: {
// title: '权限管理',
// authId: '10702',
// parentId: '107'
// },
// auth: [{
// authId: '1070201',
// parentId: '10702',
// label: '创建角色',
// category: 'action',
// handle: 'handleEdit',
// type: 'button',
// icon: 'plus'
// }, {
// authId: '1070202',
// parentId: '10702',
// label: '权限编辑',
// handle: 'handleEdit',
// type: 'text'
// }],
// component: _import('userManage/role')
// },
// '10703': {
// path: '/loginLogs',
// name: 'FimsLoginLogs',
// icon: 'tickets',
// meta: {
// title: '登录日志',
// authId: '10703',
// parentId: '107',
// cache: true
// },
// component: _import('userManage/loginLogs')
// }
'102': {
path: '/bb',
icon: 'document',
name: '表格组件',
meta: {
title: '表格组件',
authId: '102',
parentId: '0'
}
},
'10201': {
path: '/table1',
icon: 'document-copy',
name: 'fimsTable1',
meta: {
title: '默认使用',
authId: '10201',
parentId: '102',
cache: true
},
component: _import('table1'),
auth: [{
authId: '1020101',
parentId: '10201',
label: '编辑',
handle: 'handleEdit'
}, {
authId: '1020102',
parentId: '10201',
label: '审核',
color: '#FF0000',
handle: 'handleDelete',
ruleObj: {
attr: 'status',
rule: { 1: '待审核', 2: '退回', 3: '' }
}
}, {
authId: '1020103',
parentId: '10201',
label: '添加',
category: 'Button',
type: 'button',
handle: 'handleEdit',
icon: 'plus'
}, {
authId: '1020104',
parentId: '10201',
label: '批量操作',
category: 'Button',
type: 'button',
handle: 'handleOperate'
}]
},
'10202': {
path: '/table2',
icon: 'finished',
name: 'fimsTable2',
meta: {
title: '外部数据传入',
authId: '10202',
parentId: '102',
cache: true
},
component: _import('table2')
}
}
/**
......
<!-- 首页 -->
<template>
<d2-container class="indexPage">
adsfasdfasdf
<div class="echarts">
<el-row>
<el-col :span="24">
......@@ -62,9 +61,9 @@ export default {
},
mounted() {
// this.$echarts = echarts
// this.totalECharts = this.$echarts.init(document.getElementById('totalEcharts'))
// this.getPie()
this.$echarts = echarts
this.totalECharts = this.$echarts.init(document.getElementById('totalEcharts'))
this.getPie()
},
methods: {
......
......@@ -50,7 +50,7 @@
slot="userName"
slot-scope="scope"
@click="handleClick(scope.scope.userName)"
></el-button>
>{{scope.scope.userName}}</el-button>
<auth-button
slot="auth-button"
slot-scope="scope"
......@@ -102,8 +102,8 @@ export default {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'orderList',
tag: Object.freeze({
type: ['', '', 'info', 'danger', 'warning', 'success'],
label: ['', '状态一', '状态二', '状态三', '状态四', '状态五']
type: ['', '', 'danger', 'success'],
label: ['', '待审核', '审核不通过', '审核通过']
}),
otherTag: Object.freeze({
type: ['', '', 'info', 'danger', 'warning', 'success'],
......
<!-- 登陆日志 -->
<template>
<d2-container class="loginLogs">
<el-form
:inline="true"
:model="searchForm"
label-width="85px"
slot="header"
>
<el-form-item label="用户">
<el-input v-model="searchForm.userName" placeholder="请输入用户名/姓名/联系电话" clearable></el-input>
</el-form-item>
<el-form-item label="登录方式">
<el-select v-model="searchForm.loginType" placeholder="请选择" clearable filterable>
<el-option label="PC" value="1"></el-option>
<el-option label="小程序" value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="登录时间">
<el-date-picker
v-model="loginTime"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" :id="tableParams.btnId">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="登录日志列表"></d2-table-header>
<d2-table
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
></d2-table>
</d2-container>
</template>
<script>
import { getLoginlogs } from '@api/sys.account'
import util from '@/libs/util'
export default {
name: 'FimsLoginLogs',
data() {
return {
getListApi: getLoginlogs,
loginTime: '',
searchForm: {
startTime: '',
endTime: '',
userName: '',
loginType: ''
},
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'loges',
tableColumns: [{
label: '登录时间',
prop: 'loginTime',
width: '200px'
}, {
label: '登录用户',
prop: 'loginName'
}, {
label: '姓名',
prop: 'userName'
}, {
label: '联系电话',
prop: 'mobile',
width: '180px'
}, {
label: '登录方式',
prop: 'loginTypeValue'
}, {
label: '登录设备',
prop: 'deviceCode',
width: '300px'
}]
}
}
},
watch: {
'loginTime'(value) {
Object.assign(this.searchForm, util.formatTime(this.loginTime))
}
},
mounted() {},
methods: {}
}
</script>
<style scoped>
</style>
<template>
<el-dialog
:title="title"
:before-close="handleClose"
:visible.sync="dialogVisible"
width="720px"
custom-class="edit-role-dialog"
:close-on-click-modal="false"
v-if="dialogVisible"
>
<el-form
ref="roleForm"
:model="roleForm"
label-width="120px"
class="edit-dialog-form"
:rules="rules"
>
<el-form-item label="角色名:" prop="roleName">
<el-input v-model="roleForm.roleName" requred maxlength="10" :show-word-limit="true" clearable placeholder="请输入角色名" :disabled="!!roleForm.roleId"></el-input>
</el-form-item>
<el-form-item label="描述:">
<el-input
type="textarea"
:rows="2"
placeholder="角色描述"
clearable
maxlength="50"
:show-word-limit="true"
v-model="roleForm.description">
</el-input>
</el-form-item>
</el-form>
<el-divider content-position="left">权限设置</el-divider>
<RoleTree :resources="resources" :authIds="authIds" ref="roleTree" :close="dialogVisible"></RoleTree>
<div slot="footer">
<el-button @click="submit" type="primary" :loading="$store.state.d2admin.loading.value" class="button-submit">保存</el-button>
<el-button @click="handleClose" type="plain" class="button-submit">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { RoleReg, RoleModify } from '@/api/sys.account'
import notice from '@/common/notice'
import RoleTree from './roleTree'
import { localRoutes } from '@/router/routes'
import util from '@/libs/util.js'
export default {
name: 'editDialog',
props: {
isVisible: {
type: Boolean,
default: false
},
editData: {
type: Object,
default: null
}
},
components: {
RoleTree
},
watch: {
editData: {
handler: function(value) {
this.title = value && value.roleId ? '编辑角色' : '创建角色'
Object.assign(this.roleForm, value)
this.authIds = this.roleForm.authes || []
delete this.roleForm.authes
},
immediate: true
}
},
computed: {
dialogVisible() {
if (!this.isVisible) {
util.resetForm.call(this, 'roleForm')
}
return this.isVisible
},
resources() {
const clone = util.deepClone(Object.values(localRoutes))
const { menus } = util.permision.packMenusBtns(clone)
const all = util.permision.flatten(clone)
menus.find(o => o.authId === '101').disabled = true
return { menus, all }
}
},
data() {
return {
authIds: [],
title: '',
roleForm: {
roleName: '',
description: ''
},
rules: Object.freeze({
roleName: [
{ required: true, message: '角色名不能为空', trigger: ['blur'] }
]
})
}
},
methods: {
handleClose(done) {
this.emitClose(false)
},
emitClose(reload) {
this.$event.$emit('e-role-dialog-close', reload)
reload && this.$refs.roleForm.resetFields()
},
submit() {
this.$refs.roleForm.validate(vaild => {
if (vaild) {
const authIds = this.$refs.roleTree.getCheckedNodes()
var __p = { ...this.roleForm, authIds }
const fMethod = __p.roleId ? RoleModify : RoleReg
fMethod(__p).then(res => {
const { operateStatus } = res
if (operateStatus) {
notice.okTips(`${this.title}成功!`)
this.emitClose(true)
} else {
notice.errorTips(`${this.title}失败!`)
}
})
}
})
}
},
mounted() {
}
}
</script>
<style lang="scss">
.edit-role-dialog {
.el-divider--horizontal{
margin: 30px 0px 20px;
}
.role-tree{
height: 443px;overflow-y: auto;
}
}
</style>
<!-- 权限管理 -->
<template>
<d2-container class="role">
<d2-table-header title="角色列表"><auth-button category="action" label="创建角色"></auth-button></d2-table-header>
<d2-table
ref="roleTable"
:tableParams="tableParams"
:pagination="pagination"
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
<edit-dialog
:isVisible="editVisible"
:editData="editData"
></edit-dialog>
</d2-container>
</template>
<script>
import { RoleList, RoleDetail } from '@/api/sys.account'
// import notice from '@/common/notice'
import { mapActions } from 'vuex'
import { BaseData } from '@/common/constants'
export default {
name: 'FimsRoles',
components: {
'EditDialog': () => import('./editDialog')
},
data() {
return {
getListApi: RoleList,
// 新增/编辑弹窗
editVisible: false,
// 表格
pagination: false,
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'roles',
tableOption: true,
tableColumns: Object.freeze([
{
label: '角色名称',
prop: 'roleName'
},
{
label: '描述',
prop: 'description'
},
{
label: '创建时间',
prop: 'createTime'
}
])
}
}
},
mounted() {
// this.fetchData()
this.$event.$on('e-role-dialog-close', async isReload => {
if (isReload) {
const { roles } = await RoleList()
this.set({ name: BaseData.ROLE.KEY, value: roles })
this.$refs.roleTable.refreshTable()
}
this.editVisible = false
})
},
methods: {
...mapActions('d2admin/base', ['set']),
async handleEdit(row) {
// this.editData = row && await RoleDetail({ roleId: row.roleId })
this.editData = row && Object.assign(row, await RoleDetail({ roleId: row.roleId }))
this.editVisible = true
}
}
}
</script>
<style scoped>
</style>
<template>
<div class="role-tree">
<el-tree
:data="resources.menus"
show-checkbox
ref="tree"
node-key="authId"
:default-expand-all="true"
:check-strictly="true"
@check-change="treeCheckChange"
:expand-on-click-node="true"
>
<span class="role-tree-node" slot-scope="{ node, data }">
<p v-text="node.label"></p>
<div class="role-tree-auth">
<template v-if="data.auth">
<el-checkbox-group size="mini" v-model="checked">
<el-checkbox
v-for="(btn,index) in data.auth"
:key="index"
:label="btn.authId"
@change="(sta)=>btnChange(node,btn,sta)"
><p v-text="btn.label"></p>
</el-checkbox>
</el-checkbox-group>
</template>
</div>
</span>
</el-tree>
</div>
</template>
<script>
export default {
data() {
return { checked: [] }
},
props: {
resources: {
type: Object,
default: null
},
authIds: [],
close: Boolean
},
watch: {
close(value) {
// !value && this.reset();
},
authIds: {
handler(value) {
if (!value) return
const chk = []
const treeChk = ['101']
this.$nextTick(() => {
value.forEach(v => {
v.authId += ''
const node = this.find(v.authId)
if (!node) return true
const check = node.hasOwnProperty('label') ? chk : treeChk
check.push(v.authId)
})
this.$refs.tree.setCheckedKeys(treeChk)
this.checked = chk
})
},
immediate: true
}
},
methods: {
treeCheckChange(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)
// !checked && (this.checked = this.checked.filter(obj=>this.resources.all.find( res => res.authId === obj).parentId!==node.authId))
// this.setCheckedNodes()
},
btnChange(node, data, sta) {
const 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()
},
getCheckedNodes() {
const { getCheckedKeys, getHalfCheckedKeys } = this.$refs.tree
let checkedIds = [
...getCheckedKeys(),
...getHalfCheckedKeys(),
...this.checked
]
checkedIds = checkedIds.map(node => {
const { authId, parentId } = this.resources.all.find(
res => res.authId === node
)
return { authId, parentId }
})
return checkedIds
// this.$emit('update:authIds', checkedIds)
},
reset() {
this.checked = []
this.$refs.tree.setCheckedKeys([])
// this.$emit('update:authIds', [])
},
find(authId) {
return this.resources.all.find(res => res.authId === authId)
}
}
}
</script>
<style lang="scss">
.role-tree {
padding-left: 30px;
.role-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding: 8px;
}
.el-tree-node__content {
height: 34px;
.el-checkbox {
margin-right: 5px;
.el-checkbox__label {
padding: 0;
}
}
}
&-auth {
word-break: break-all;
word-wrap: break-word;
white-space: normal;
position: absolute;
left: 200px;
padding: 5px 0;
}
}
</style>
<template>
<el-dialog
:title="title"
:visible.sync="dialogVisible"
:before-close="handleClose"
width="720px"
custom-class="reg-dialog-admin"
:close-on-click-modal="false"
v-if="dialogVisible"
:append-to-body="true"
:lock-scroll="false"
>
<el-form
ref="regForm"
:model="regForm"
label-width="120px"
class="reg-dialog-form"
:rules="rules"
>
<el-form-item label="用户名:" prop="loginName">
<el-input
v-model="regForm.loginName"
:disabled="!!regForm.userId"
requred
maxlength="10"
placeholder="请输入用户名"
clearable
:show-word-limit="true"
></el-input>
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="姓名:" prop="userName">
<el-input
v-model="regForm.userName"
placeholder="请输入姓名"
maxlength="8"
:show-word-limit="true"
clearable
></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="角色:" prop="roleId">
<el-select v-model="regForm.roleId" 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-col>
</el-row>
</el-form>
<div slot="footer">
<el-button @click="submit" type="primary" :loading="$store.state.d2admin.loading.value" class="button-submit">提交</el-button>
<el-button @click="handleClose" type="plain" class="button-submit">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import notice from '@/common/notice'
import util from '@/libs/util'
export default {
name: 'DialogReg',
props: {
isVisible: {
type: Boolean,
default: false
},
editData: {
type: Object,
default: null
},
verify: {
type: Function,
default: null
}
},
watch: {
editData: {
handler: function(value) {
if (!value || !value.data) return
const { data } = value
const { title, submit } = data
this.title = title
this.submitFunction = submit
delete value.data
Object.assign(this.regForm, value)
},
immediate: true
}
},
computed: {
dialogVisible() {
if (!this.isVisible) {
util.resetForm.call(this, 'regForm')
}
return this.isVisible
}
},
data() {
return {
regForm: {
loginName: '',
userName: '',
roleId: ''
},
title: '',
submitFunction: null,
rules: Object.freeze({
loginName: [
{ required: true, message: '用户名不能为空', trigger: ['blur'] }
],
userName: [
{ required: true, message: '姓名不能为空', trigger: ['blur'] }
],
roleId: [{ required: true, message: '角色不能为空', trigger: ['blur'] }]
})
}
},
methods: {
handleClose(done) {
this.$event.$emit('e-reg-dialog-close', false)
},
// 提交注册或审核数据
submit() {
this.$refs.regForm.validate(vaild => {
if (vaild) {
var __p = this.regForm
this.submitFunction(__p).then(res => {
const { operateStatus } = res
if (operateStatus) {
notice.okTips(`${this.title}成功!`)
this.$refs.regForm.resetFields()
this.$event.$emit('e-reg-dialog-close', true)
} else {
notice.errorTips(`${this.title}失败!`)
}
})
}
})
}
},
mounted() {
}
}
</script>
<!-- 用户管理 -->
<template>
<d2-container class="user">
<el-form :inline="true" :model="searchForm" label-width="85px" slot="header">
<el-form-item label="用户:">
<el-input v-model="searchForm.userName" placeholder="请输入用户名/姓名/联系电话" clearable></el-input>
</el-form-item>
<!-- <el-form-item label="角色:">
<el-select v-model="searchForm.roleId" clearable placeholder="请选择">
<el-option
v-for="(role,index) in baseData.roles"
:label="role.roleName"
:value="role.roleId"
:key="index"
></el-option>
</el-select>
</el-form-item> -->
<el-form-item label="注册时间:">
<el-date-picker
v-model="searchTimes"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" :id="tableParams.btnId">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="用户列表"><auth-button category="action" label="创建用户"></auth-button></d2-table-header>
<d2-table
ref="userTable"
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
:mapping="mapping"
></auth-button>
</d2-table>
<dialog-reg :isVisible="registerDialogVisible" :editData="editData" :key="key"/>
</d2-container>
</template>
<script>
import {
UserList,
PassWordReset,
AccountModify,
AccountIncrease,
AccountForbidden,
AccountValidate,
AccountActived,
Reg
} from '@/api/sys.account'
import notice from '@/common/notice'
import { mapActions } from 'vuex'
import util from '@/libs/util'
export default {
name: 'FimsUsers',
components: {
DialogReg: () => import('./dialogReg')
},
data() {
return {
getListApi: UserList,
key: new Date(),
mapping: Object.freeze({
field: 'status',
'1': ['重置密码', '编辑', '延期', '禁用'],
'2': ['重置密码', '编辑', '激活'],
'3': ['重置密码', '编辑', '激活'],
'4': ['审核']
}),
apiMapping: Object.freeze({
'重置密码': PassWordReset,
'延期': AccountIncrease,
'禁用': AccountForbidden,
'激活': AccountActived
}),
// 新增/编辑弹窗
registerDialogVisible: false,
editData: {},
// 搜索
searchForm: {
userName: '',
status: '',
stationCode: '',
postCode: '',
startTime: '',
endTime: ''
},
searchTimes: [],
// 表格
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'userList',
tag: Object.freeze({
type: ['', 'success', 'info', 'danger', 'warning'],
label: ['未知', '正常', '已过期', '禁用', '待审核']
}),
tableOption: true,
tableColumns: [{
label: '用户名',
prop: 'loginName',
width: '200'
}, {
label: '角色',
prop: 'roleName',
width: '140'
}, {
label: '注册时间',
prop: 'registerTime',
minWidth: '200'
}, {
label: '有效期',
prop: 'validTime',
minWidth: '200'
}, {
label: '状态',
prop: 'status',
width: '120',
tagLabel: true
}, {
label: '姓名',
prop: 'userName',
width: '120'
}]
}
/* -----------------------基础数据---------------------- */
// baseData: {
// // 所属站点
// stations: [],
// // 职务
// posts: [],
// // 角色
// roles: []
// }
}
},
watch: {
'searchTimes'(value) {
Object.assign(this.searchForm, util.formatTime(this.searchTimes))
}
// '$store.state.d2admin.base.role'(value) {
// this.baseData.roles = value
// this.key = new Date()
// }
},
mounted() {
// this.fetchData()
this.$event.$on('e-reg-dialog-close', isReload => {
isReload && this.$refs.userTable.refreshTable()
this.registerDialogVisible = false
})
},
methods: {
...mapActions('d2admin/base', ['load']),
// 加载业务所需所有数据
// fetchData() {
// this.loadBaseData()
// },
// async loadBaseData() {
// const { role, station, post } = await this.load()
// this.baseData.posts = post
// this.baseData.stations = station
// this.baseData.roles = role.roles
// Object.freeze(this.baseData)
// },
/* 接口请求-start */
filterTag(value, row) {
return row.status === value
},
handleRegister() {
const row = {
data: {
title: '用户创建',
submit: Reg
}
}
this.openDialog(row)
},
handleEdit(row) {
row = util.deepClone(row)
row.data = {
title: '用户编辑',
submit: AccountModify
}
this.openDialog(row)
},
openDialog(row) {
this.registerDialogVisible = true
this.editData = row
},
handleVerify(row) {
row = util.deepClone(row)
row.data = {
title: '用户审核',
submit: AccountValidate
}
this.openDialog(row)
},
// ------------
// 列表各种操作
async handleOperation(row, e) {
const _actionText = e.target.innerText
const res = await this.apiMapping[_actionText]({ userId: row.userId })
const { operateStatus } = res
if (operateStatus) {
notice.okTips(`${_actionText}成功!`)
this.$refs.userTable.refreshTable()
} else {
notice.errorTips(`${_actionText}失败!`)
}
}
}
}
</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!