Commit c5a1be12 by zhouzy

合并

2 parents a28b86dc 8c51978b
No preview for this file type
No preview for this file type
......@@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>icon.ico">
<link rel="icon" href="<%= BASE_URL %>icon.png">
<!-- 使用CDN的CSS文件 -->
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.css) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
......
No preview for this file type
......@@ -31,6 +31,15 @@ export function deviceList(data) {
return request(data)
}
// 设备管理-导入
export function deviceImport(data) {
return axios({
url: baseConfig.axios.baseURL + 'devicemgr/importDeviceList',
method: 'post',
data: data
})
}
// 获取客户名称下拉列表
export function userDropList(data) {
data.method = 'usermgr/getDropDownOptions'
......

7.43 KB | W: | H:

7.16 KB | W: | H:

src/assets/all.png
src/assets/all.png
src/assets/all.png
src/assets/all.png
  • 2-up
  • Swipe
  • Onion skin

1.62 KB | W: | H:

2.07 KB | W: | H:

src/assets/icon-only.png
src/assets/icon-only.png
src/assets/icon-only.png
src/assets/icon-only.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -120,7 +120,7 @@ export function export_table_to_excel(id) {
function formatJson(jsonData) {
console.log(jsonData)
}
export function export_json_to_excel(th, jsonData, defaultTitle) {
export function exportJsonToExcel(th, jsonData, defaultTitle) {
/* original data */
......
......@@ -2,111 +2,14 @@
* @Author: limin
* @Date: 2019-09-01 19:06:01
* @Last Modified by: chenwq
* @Last Modified time: 2020-11-19 11:14:42
* @Last Modified time: 2021-01-04 11:51:32
*/
// import { LOGIN_URL, REG_URL, ROLE_LIST_URL } from '@/api/sys.account'
// import { BASE_DATA_URL } from '@/api/sys.base'
export const TYPE_NAME = 'confType'
/**
* 后台提供一个接 通过类型获取对应数据
* 此处定义类型
*/
// export const ConfigType = {
// STATION: 'STATION_TYPE',
// POST: 'POST_TYPE',
// SUBSYS: 'SUBSYSTEM_TYPE'
// }
/**
* 前端基础数据管理对应的接口名称的key
*/
export const BaseData = {
channelType: 'channelType',
productType: 'productType'
}
/**
* 注册类型
*/
export const RegistType = {
BY_SELF: '1', // 自注册
BY_ADMIN: '2' // 管理员创建
}
/**
* 前端免登录验证接口名
*/
// export const LogExternals = [
// 'fims.user.login', // 登录
// 'fims.user.register', // 注册
// 'fims.configuration.from.conftype', // 基础数据
// 'fims.role.list' // 角色列表
// ]
/**
* 登录来源
*/
// export const LOGIN_TYPE = 1 // 1pc,2小程序
/**
* 超级管理员类型
*/
export const SUPPER_ADMIN = 1 //
/**
* 职务置灰选项
*/
// export const POST_DISABLED = ['2001', '2002', '2003'] // 总经理 仓库 部门经理
// 商户类型 - 除广汇外
export const userType = {
1: '员工',
2: '门店',
3: '市代',
4: '省代',
5: '工厂'
}
// 商户类型 - 广汇
export const ghUserType = {
1: '员工',
2: '门店',
3: '片区',
4: '大区',
5: '总部',
6: '供应商'
}
// 品牌商
export const brandMerchantList = [{
confId: '1',
confValue: '3M/福膜'
}, {
confId: '2',
confValue: '强生/福膜'
}, {
confId: '3',
confValue: '强生/斯帝飞'
}, {
confId: '4',
confValue: '3M/斯帝飞'
}, {
confId: '5',
confValue: '3M/今蓝'
}, {
confId: '6',
confValue: '量子/今蓝'
}, {
confId: '7',
confValue: '强生'
}, {
confId: '8',
confValue: '今蓝'
}, {
confId: '9',
confValue: '琥珀'
}, {
confId: '10',
confValue: '嘀嘀虎'
}]
// 新值,旧值,整数部分位数,小数部分位数,最小值,最大值,规则
export function limitPrice(newValue, oldValue, intergerDigit, pointDigit, minValue, maxValue, regRule) {
var reg = {
......@@ -133,3 +36,14 @@ export function limitPrice(newValue, oldValue, intergerDigit, pointDigit, minVal
return newValue ? oldValue : ''
}
}
/**
* 时间控件-限制月份
*/
export const rangePickerOptions = {
disabledDate(date) {
if (date > new Date()) {
return true
}
return false
}
}
......@@ -3,21 +3,21 @@ import Vue from 'vue'
export default new Vue({
methods: {
warningTips(message) {
this.$notify({
this.$message({
type: 'warning',
title: message
message: message
})
},
okTips(message) {
this.$notify({
this.$message({
type: 'success',
title: message || '操作成功'
message: message || '操作成功'
})
},
errorTips(message) {
this.$notify({
this.$message({
type: 'error',
title: message || '操作失败'
message: message || '操作失败'
})
}
}
......
......@@ -69,36 +69,46 @@ export const resources = {
parentId: '0',
cache: true
},
auth: [
{
authId: '10201',
parentId: '102',
label: '重置密码',
handle: 'handleResetPassword',
ruleObj: {
attr: 'status',
rule: { 0: '重置密码', 1: '重置密码', 2: '' }
auth: [{
authId: '10201',
parentId: '102',
label: '重置密码',
handle: 'handleResetPassword',
ruleObj: {
attr: 'status',
rule: {
0: '重置密码',
1: '重置密码',
2: ''
}
}, {
authId: '10202',
parentId: '102',
label: '启用',
handle: 'handleUpOrDown',
ruleObj: {
attr: 'status',
rule: { 0: '启用', 1: '停用', 2: '' }
}
}, {
authId: '10202',
parentId: '102',
label: '启用',
handle: 'handleUpOrDown',
ruleObj: {
attr: 'status',
rule: {
0: '启用',
1: '停用',
2: ''
}
}, {
authId: '10203',
parentId: '102',
label: '审核通过',
handle: 'handleExamine',
ruleObj: {
attr: 'status',
rule: { 0: '', 1: '', 2: '审核通过' }
}
}, {
authId: '10203',
parentId: '102',
label: '审核通过',
handle: 'handleExamine',
ruleObj: {
attr: 'status',
rule: {
0: '',
1: '',
2: '审核通过'
}
}
],
}],
component: _import('customer/customer')
},
'103': {
......@@ -111,100 +121,107 @@ export const resources = {
parentId: '0',
cache: true
},
component: _import('device/device')
},
'104': {
path: '/user',
icon: 'user-solid',
name: 'user',
meta: {
title: '用户管理',
authId: '104',
parentId: '0',
cache: true
},
component: _import('user/user')
},
'105': {
path: '/apiManage',
icon: 's-order',
name: 'apiManage',
meta: {
title: 'API管理',
authId: '105',
parentId: '0',
cache: true
}
},
'10501': {
path: '/apiList',
icon: 'document-copy',
name: 'apiList',
meta: {
title: 'API列表',
authId: '10501',
parentId: '105',
cache: true
},
auth: [{
authId: '1050101',
parentId: '10501',
label: '启用',
handle: 'handleUpOrDown',
ruleObj: {
attr: 'status',
rule: { 0: '启用', 1: '停用' }
}
}
],
component: _import('apiManage/apiList')
},
'10502': {
path: '/apiRecord',
icon: 'document-copy',
name: 'apiRecord',
meta: {
title: 'API调用记录',
authId: '10502',
parentId: '105',
cache: true
},
component: _import('apiManage/apiRecord')
},
'106': {
path: '/appMarket',
icon: 'document-copy',
name: 'appMarket',
meta: {
title: 'APP营销管理',
authId: '106',
parentId: '0',
cache: true
},
auth: [{
authId: '10601',
parentId: '106',
label: '新增',
authId: '10301',
parentId: '103',
label: '导入',
category: 'Button',
type: 'primary',
handle: 'handleAdd'
}, {
authId: '10602',
parentId: '106',
label: '编辑',
handle: 'handleEdit'
}, {
authId: '10603',
parentId: '106',
label: '下架',
handle: 'handleUpOrDown',
ruleObj: {
attr: 'status',
rule: { 0: '上架', 1: '下架' }
}
handle: 'handleImport'
}],
component: _import('appMarket/appMarket')
component: _import('device/device')
}
// '104': {
// path: '/user',
// icon: 'user-solid',
// name: 'user',
// meta: {
// title: '用户管理',
// authId: '104',
// parentId: '0',
// cache: true
// },
// component: _import('user/user')
// },
// '105': {
// path: '/apiManage',
// icon: 's-order',
// name: 'apiManage',
// meta: {
// title: 'API管理',
// authId: '105',
// parentId: '0',
// cache: true
// }
// },
// '10501': {
// path: '/apiList',
// icon: 'document-copy',
// name: 'apiList',
// meta: {
// title: 'API列表',
// authId: '10501',
// parentId: '105',
// cache: true
// },
// auth: [{
// authId: '1050101',
// parentId: '10501',
// label: '启用',
// handle: 'handleUpOrDown',
// ruleObj: {
// attr: 'status',
// rule: { 0: '启用', 1: '停用' }
// }
// }
// ],
// component: _import('apiManage/apiList')
// },
// '10502': {
// path: '/apiRecord',
// icon: 'document-copy',
// name: 'apiRecord',
// meta: {
// title: 'API调用记录',
// authId: '10502',
// parentId: '105',
// cache: true
// },
// component: _import('apiManage/apiRecord')
// }
// '106': {
// path: '/appMarket',
// icon: 'document-copy',
// name: 'appMarket',
// meta: {
// title: 'APP营销管理',
// authId: '106',
// parentId: '0',
// cache: true
// },
// auth: [{
// authId: '10601',
// parentId: '106',
// label: '新增',
// category: 'Button',
// type: 'primary',
// handle: 'handleAdd'
// }, {
// authId: '10602',
// parentId: '106',
// label: '编辑',
// handle: 'handleEdit'
// }, {
// authId: '10603',
// parentId: '106',
// label: '下架',
// handle: 'handleUpOrDown',
// ruleObj: {
// attr: 'status',
// rule: { 0: '上架', 1: '下架' }
// }
// }],
// component: _import('appMarket/appMarket')
// }
}
/**
......
......@@ -2,7 +2,7 @@
* @Author: limin
* @Date: 2019-09-01 17:56:57
* @Last Modified by: chenwq
* @Last Modified time: 2020-12-17 15:30:09
* @Last Modified time: 2021-01-04 10:33:34
*/
// import { FetchRoleList } from '@/api/sys.base'
......@@ -119,7 +119,6 @@ export default {
*/
getFromAjax({ state, dispatch, commit }, name) {
return new Promise(async resolve => {
// const value = await map[name]({ [TYPE_NAME]: Object.values(BaseData).find(data => data.KEY === name).TYPE })
resolve()
})
},
......
<!-- 设备管理 -->
<template>
<d2-container>
<d2-container class="device-list">
<el-form
slot="header"
inline="true"
......@@ -38,15 +38,16 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item label="激活时间:">
<el-form-item label="导入时间:">
<el-date-picker
v-model="activateTime"
v-model="createTime"
:size="$store.state.d2admin.size.value"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:clearable="false"
:picker-options="rangePickerOptions"
>
</el-date-picker>
</el-form-item>
......@@ -63,25 +64,94 @@
>重置</el-button>
</el-form-item>
</el-form>
<d2-table-header title="设备列表">
<auth-button category="Button"></auth-button>
</d2-table-header>
<d2-table
:beforeSearchFn="beforeSearchFn"
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
></d2-table>
<d2-dialog
:title="'导入'"
:isVisible="fileVisible"
@closeDialog="handleImport"
@confirmDialog="handleConfirmImport"
>
<slot>
<el-form
:model="fileForm"
ref="fileRuleForm"
:rules="fileRules"
label-width="120px"
>
<el-form-item
label="导入文件:"
prop="fileName"
>
<el-col :span="16">
<el-input
readonly
v-model="fileForm.fileName"
></el-input>
</el-col>
<el-col
:span="4"
class="m-l-md"
>
<el-button class="import-btn">导入文件
<input
type="file"
id="fileUpload"
class="import-input"
@change="importFile($event)"
/>
</el-button>
</el-col>
<el-col :span="24">
<a
href="设备导入模板.xls"
download="设备导入模板.xls"
class="import-template"
><i class="el-icon-link"></i>模版下载</a>
</el-col>
</el-form-item>
<el-form-item v-show="showNum">
<span>导入成功{{importNum.succNum}}条,导入失败{{importNum.failNum}}条</span>
</el-form-item>
</el-form>
</slot>
</d2-dialog>
</d2-container>
</template>
<script>
import { deviceList, userDeviceDropList, userDropList } from '@api/api'
import { deviceList, userDeviceDropList, userDropList, deviceImport } from '@api/api'
import { rangePickerOptions } from '@/common/constants'
import { exportJsonToExcel } from '@/common/Export2Excel.js'
export default {
name: 'device',
data() {
return {
rangePickerOptions: rangePickerOptions,
fileVisible: false,
fileForm: {
sellerUserId: ''
},
total: 0,
showNum: false,
importNum: {
succNum: 0,
failNum: 0
},
fileRules: {
fileName: [{ required: true, message: '请上传文件', trigger: 'change' }]
},
searchForm: {
customerName: ''
},
activateTime: [],
createTime: [],
getListApi: deviceList,
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
......@@ -92,25 +162,18 @@ export default {
}, {
label: '类型',
prop: 'deviceType',
width: '90px',
formatter: (cellValue) => {
return cellValue.deviceType
}
}, {
label: '客户',
prop: 'customerName',
width: '180px'
prop: 'customerName'
}, {
label: '激活时间',
prop: 'activatTime'
}, {
label: '状态',
prop: 'status',
width: '80px',
label: '导入时间',
prop: 'createTime',
formatter: (cellValue) => {
return {
0: '异常',
1: '正常'
}[cellValue.status]
return cellValue.createTime.split(' ')[0]
}
}]
},
......@@ -136,15 +199,85 @@ export default {
methods: {
beforeSearchFn() {
return new Promise(resolve => {
if (this.activateTime && this.activateTime.length) {
this.searchForm.activatStartTime = new Date(this.activateTime[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
this.searchForm.activatEndTime = new Date(this.activateTime[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
if (this.createTime && this.createTime.length) {
this.searchForm.createStartTime = new Date(this.createTime[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
this.searchForm.createEndTime = new Date(this.createTime[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
resolve()
})
},
importReset() {
this.showNum = false
this.importNum = {
succNum: 0,
failNum: 0
}
},
handleImport() {
this.fileForm = {
fileName: ''
}
this.importReset()
this.$refs.fileRuleForm && this.$refs.fileRuleForm.resetFields()
this.fileVisible = !this.fileVisible
},
// 上传文件
importFile(e) {
this.importReset()
this.o = new FormData()
this.o.append('file', e.target.files[0])
this.fileForm.fileName = e.target.files[0].name
document.getElementById('fileUpload').value = ''
},
handleConfirmImport() {
this.$refs.fileRuleForm.validate(valid => {
if (valid) {
deviceImport(this.o).then(res => {
// console.log(res)
this.fileForm.fileName = ''
document.getElementById('fileUpload').value = ''
var data = res.data.data
if (res.data.code === 500) {
this.notice.errorTips(res.data.message)
return true
}
if (data.errorCount) {
this.notice.errorTips()
this.showNum = true
this.importNum = {
succNum: data.successCount,
failNum: data.errorCount
}
this.exoprtErrorFile(data.errorMessage.map(item => {
return { errorTxt: item }
}))
} else if (typeof data.errorMessage !== 'string') {
this.notice.okTips()
this.showNum = true
this.importNum = {
succNum: data.successCount,
failNum: data.errorCount
}
} else {
this.notice.errorTips(data.errorMessage)
}
})
}
})
},
exoprtErrorFile(list) {
const tHeader = ['错误信息']
const fieldVal = ['errorTxt']
require.ensure([], () => {
const data = this.formatJson(fieldVal, list)
exportJsonToExcel(tHeader, data, '设备导入失败列表')
})
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]))
},
handleRest() {
this.activateTime = []
this.createTime = []
this.searchForm = {
customerName: ''
}
......@@ -159,5 +292,24 @@ export default {
}
</script>
<style scoped>
<style>
.device-list .import-btn {
position: relative;
}
.device-list .import-input {
opacity: 0;
position: absolute;
right: 0;
top: 0;
width: 98px;
height: 36px;
cursor: pointer;
font-size: 0;
}
.device-list .import-template {
/* position: absolute;
height: 20px;
top: 36px;
left: 0; */
}
</style>

110 KB | W: | H:

221 KB | W: | H:

src/views/system/login/image/bg.png
src/views/system/login/image/bg.png
src/views/system/login/image/bg.png
src/views/system/login/image/bg.png
  • 2-up
  • Swipe
  • Onion skin

1.88 KB | W: | H:

1.98 KB | W: | H:

src/views/system/login/image/bz.png
src/views/system/login/image/bz.png
src/views/system/login/image/bz.png
src/views/system/login/image/bz.png
  • 2-up
  • Swipe
  • Onion skin

23.4 KB | W: | H:

22.2 KB | W: | H:

src/views/system/login/image/title.png
src/views/system/login/image/title.png
src/views/system/login/image/title.png
src/views/system/login/image/title.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -141,9 +141,9 @@ export default {
}
},
created() {
this.systemName = this.baseConfig.sysName || '系统'
this.systemSubName = this.baseConfig.subName || '说明'
this.hasReg = this.baseConfig.hasReg || false
this.systemName = this.baseConfig.sysName
this.systemSubName = this.baseConfig.subName
this.hasReg = !!this.baseConfig.hasReg
},
mounted() {
this.timeInterval = setInterval(() => this.refreshTime(), 1000)
......
<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>
......@@ -27,11 +27,11 @@ const cdn = {
`${CDN_DOMAIN}/nprogress/0.2.0/nprogress.min.js`,
`${CDN_DOMAIN}/echarts/4.3.0-rc.1/echarts.min.js`,
`${CDN_DOMAIN}/lodash.js/4.17.15/lodash.min.js`,
`${CDN_DOMAIN}/qs/6.8.0/qs.min.js`,
`${CDN_DOMAIN}/qs/6.8.0/qs.min.js`
// `${CDN_DOMAIN}/core-js/2.6.9/core.min.js`,
// `${CDN_DOMAIN}/vue-i18n/8.14.0/vue-i18n.esm.js`,
// `${CDN_DOMAIN}/UAParser.js/0.7.20/ua-parser.min.js`,
'https://unpkg.com/better-scroll@1.15.2/dist/bscroll.min.js'
// 'https://unpkg.com/better-scroll@1.15.2/dist/bscroll.min.js'
]
}
module.exports = {
......@@ -61,7 +61,7 @@ module.exports = {
'lodash': '_',
// 'vue-i18n':'vue-i18n',
// 'ua-parser-js': 'UAParser',
'better-scroll': 'BScroll',
// 'better-scroll': 'BScroll',
'qs': 'Qs'
// 'core-js': 'core-js'
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!