Commit 96a286c1 by cwq0219

合并

2 parents 0fa854df 1ccf618b
......@@ -7,7 +7,7 @@ VUE_APP_TITLE=tFIMS
VUE_APP_API=http://192.168.3.171:7300/mock/5d638b3b6fbe9a0ac59d872e/tFIMS
# 仓库地址
VUE_APP_REPO=https://github.com/d2-projects/d2-admin-start-kit
VUE_APP_REPO=
# 国际化配置
VUE_APP_I18N_LOCALE=zh-chs
......
......@@ -8,19 +8,19 @@
<title><%= VUE_APP_TITLE %></title>
<style>
html, body, #app { height: 100%; margin: 0px; padding: 0px; width: 100%; }
.d2-home { background-color: #303133; height: 100%; display: flex; flex-direction: column; }
.d2-home { background-color:#000; height: 100%; display: flex; flex-direction: column; }
.d2-home__main { user-select: none; width: 100%; flex-grow: 1; display: flex; justify-content: center; align-items: center; flex-direction: column; }
.d2-home__footer { width: 100%; flex-grow: 0; text-align: center; padding: 1em 0; }
.d2-home__footer > a { font-size: 12px; color: #ABABAB; text-decoration: none; }
.d2-home__footer > a { font-size: 12px; color: #fff; text-decoration: none; }
.d2-home__loading { height: 32px; width: 32px; margin-bottom: 20px; }
.d2-home__title { color: #FFF; font-size: 14px; margin-bottom: 10px; }
.d2-home__sub-title { color: #ABABAB; font-size: 12px; }
.d2-home__title { color: #FFF; font-size: 20px; margin-bottom: 10px; }
.d2-home__sub-title { color: #fff; font-size: 14px; }
</style>
<script>
<!-- <script>
var _hmt = _hmt || [];
var hmid = "1dfa88d0c8571eef2d383070cb3e5ca1";
(function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?" + hmid; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s);})();
</script>
</script> -->
</head>
<body>
<noscript>
......
......@@ -14,4 +14,4 @@ function reportApi (data) {
export {
getListApi,
reportApi
}
\ No newline at end of file
}
......@@ -31,5 +31,5 @@ export {
methods,
// addApi,
editApi,
removeApi
}
\ No newline at end of file
removeApi
}
......@@ -7,4 +7,4 @@ const userMethods = {
export {
userMethods
}
\ No newline at end of file
}
......@@ -3,12 +3,13 @@
:size="size"
:type="type"
:loading="loading"
v-roles="['3']"
v-if="isInRole"
@click="handleClick"
>{{label}}</el-button>
</template>
<script>
import {mapGetters} from 'vuex'
export default {
name: 'AuthButton',
props: {
......@@ -32,16 +33,23 @@ export default {
type: Boolean,
default: false
},
perms: {
id: {
type: String,
default: null
}
},
computed: {
...mapGetters('d2admin/auth', ['curBtns'])
},
data () {
return {}
return {
isInRole:false
}
},
beforeCreate () {
this.$vrm.setRoles(['1', '2', '3'])
created () {
// this.$vrm.setRoles(this.btnIdAll)
const {action,operation} = this.curBtns
this.isInRole = [...action,...operation].find(obj=>obj.id===this.id||obj.label===this.label)
},
methods: {
handleClick: function () {
......
......@@ -27,11 +27,11 @@
<!-- 顶栏右侧 -->
<div class="d2-header-right" flex-box="0">
<!-- 如果你只想在开发环境显示这个按钮请添加 v-if="$env === 'development'" -->
<!-- <d2-header-search @click="handleSearchClick" v-if="$env === 'development'"/> -->
<!-- <d2-header-log v-if="$env === 'development'"/> -->
<d2-header-size/>
<d2-header-search @click="handleSearchClick"/>
<d2-header-log />
<!-- <d2-header-size /> -->
<d2-header-fullscreen/>
<!-- <d2-header-locales v-if="$env === 'development'"/> -->
<d2-header-locales />
<d2-header-theme/>
<d2-header-color/>
<d2-header-user/>
......
......@@ -76,42 +76,34 @@ util.deepFind = function (menus, id) {
return null
}
util.packRoutes = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aRouteInPermision = []
idsInPermision.forEach(obj => {
__aRouteInPermision.push(resources[obj.id])
})
return __aRouteInPermision
}
util.packAsideMenus = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aMenusInPermision = []
let __aSub = []
idsInPermision.forEach(obj => {
const { icon, path, meta } = resources[obj.id]
const { title, id, pid } = meta
if (obj.pid === '0') {
__aMenusInPermision.push({ title, icon, path, id, pid })
} else {
__aSub.push({ title, icon, path, id, pid })
}
})
let __parent = null
__aSub.forEach(obj => {
__parent = __aMenusInPermision.find(menu => menu.id === obj.pid)
if (__parent.children) {
__parent.children.push(obj)
} else {
__parent.children = [obj]
}
})
return __aMenusInPermision
/**
* 16进制颜色值 转换为 rgb
* @param {*} sColor 16进制颜色值
* @param {*} alpha 透明度
*/
util.colorToRgb = (sColor, alpha) => {
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
sColor = sColor.toLowerCase()
if (sColor && reg.test(sColor)) {
if (sColor.length === 4) {
var sColorNew = '#'
for (var i = 1; i < 4; i += 1) {
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1))
}
sColor = sColorNew
}
// 处理六位的颜色值
var sColorChange = []
for (let i = 1; i < 7; i += 2) {
sColorChange.push(parseInt('0x' + sColor.slice(i, i + 2)))
}
if (alpha || alpha === 0 || alpha === '0') {
return `rgba(${sColorChange.join(',')} ,${alpha})`
}
return `rgb(${sColorChange.join(',')})`
} else {
return sColor
}
}
export default util
......@@ -2,35 +2,65 @@
* @Author: limin
* @Date: 2019-08-27 19:16:26
* @Last Modified by: limin
* @Last Modified time: 2019-08-28 12:15:51
* @Last Modified time: 2019-08-28 23:05:36
*/
const permision = {
}
permision.packRoutes = function (resources, idsInPermision) {
const permision = {}
/**
* 打包如有与按钮
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packRoutesBtns = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aRouteInPermision = []
let __aRouteInPermision = [],
__oBtnInPermision = {},
// __aBtnIdAll=[],
__objResource = null
idsInPermision.forEach(obj => {
__aRouteInPermision.push(resources[obj.id])
__objResource = resources[obj.id]
if(__objResource){//直接能取到的为路由 (也可以在routes 中定标识变量)
__aRouteInPermision.push(resources[obj.id])//push 进 路由数组
}else{ //如果取不到 判断是否有父节点 并且父节点是否有auth属性 有 则视为按钮 (同样可以定义标识变量)
__objResource = resources[obj.pid]
if(__objResource && __objResource.auth && !__oBtnInPermision[obj.pid]){
__oBtnInPermision[obj.pid]=__objResource.auth
// __aBtnIdAll = __aBtnIdAll.concat([...__objResource.auth.action.map(o=>o.id),...__objResource.auth.operation.map(o=>o.id)])
}
}
})
return __aRouteInPermision
return {'route':__aRouteInPermision,'btn':__oBtnInPermision}
}
/**
* 打包菜单
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packAsideMenus = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aMenusInPermision = []
let __aSub = []
/**
* 第一次循环 分出一级菜单与所有子菜单
*/
idsInPermision.forEach(obj => {
const __oMenu = permision.format2Menu(resources[obj.id])
if (obj.pid === '0') {
if(!__oMenu){ //不存在 可能是 按钮 直接继续循环
return true
}
if (obj.pid === '0') {//取出1级菜单
__aMenusInPermision.push(__oMenu)
} else {
} else {//取出子菜单
__aSub.push(__oMenu)
}
})
/**
* 第二次循环所有子菜单 ,然后挂载到对应的一级菜单
*/
let __parent = null
__aSub.forEach(obj => {
__parent = __aMenusInPermision.find(menu => menu.id === obj.pid)
......@@ -47,6 +77,7 @@ permision.packAsideMenus = function (resources, idsInPermision) {
* 格式化菜单 封装成系统所需格式
*/
permision.format2Menu = function (oMenu) {
if(!oMenu) return null
const { icon, path, meta } = oMenu
const { title, id, pid } = meta
return { title, icon, path, id, pid }
......
......@@ -71,7 +71,8 @@ router.afterEach(to => {
store.dispatch('d2admin/page/open', to)
// 更改标题
util.title(to.meta.title)
// store.dispatch('d2admin/auth/set', to.meta.title)
// 保存当前页面meta信息
store.dispatch('d2admin/auth/setCurrentPageMeta', to.meta)
})
export default router
......@@ -28,6 +28,32 @@ export const home = {
},
component: _import('systemMonitor')
}
export const sys =[
// 系统 前端日志
{
path: 'log',
name: 'log',
meta: {
title: '前端日志',
auth: true
},
component: _import('system/log')
},
// 刷新页面 必须保留
{
path: 'refresh',
name: 'refresh',
hidden: true,
component: _import('system/function/refresh')
},
// 页面重定向 必须保留
{
path: 'redirect/:route*',
name: 'redirect',
hidden: true,
component: _import('system/function/redirect')
}
]
/**
* 所有需动态过滤的资源点
......@@ -67,11 +93,13 @@ export const resources = {
component: _import('demo/page2'),
auth: {
'operation': [{ // 列表操作
id: '1020101',
name: '查看'
id: '1020201',
pid:'10202',
label: '查看'
}, { //
id: '1020102',
name: '编辑'
id: '1020202',
pid:'10202',
label: '编辑'
}],
'action': [] // 按钮操作
}
......@@ -85,6 +113,18 @@ export const resources = {
id: '10203',
pid: '102'
},
auth: {
'operation': [{ // 列表操作
id: '1020301',
pid:'10203',
label: '查看'
}, { //
id: '1020302',
pid:'10203',
label: '编辑'
}],
'action': [] // 按钮操作
},
component: _import('demo/page3')
},
// '102': {
......@@ -110,7 +150,7 @@ export const resources = {
pid: '0'
},
component: _import('subSysManagement')
},
},
'104': {
path: 'trafficManagement',
icon: 'folder-o',
......@@ -122,7 +162,7 @@ export const resources = {
pid: '0'
},
component: _import('trafficManagement')
},
},
'105': {
path: 'bb',
icon: 'folder-o',
......@@ -132,8 +172,8 @@ export const resources = {
title: '单据管理',
id: '105',
pid: '0'
},
},
}
},
'10501': {
path: '/cc',
icon: 'folder-o',
......@@ -145,7 +185,7 @@ export const resources = {
pid: '105'
},
component: _import('trafficManagement')
},
},
'10502': {
path: '/dd',
icon: 'folder-o',
......@@ -157,9 +197,9 @@ export const resources = {
pid: '105'
},
component: _import('trafficManagement')
},
},
'107': {
path: 'page',
path: 'user',
icon: 'folder-o',
name: '用户管理',
meta: {
......@@ -202,6 +242,18 @@ export const resources = {
},
component: _import('userManage/loginLogs')
},
'108': {
path: 'page',
icon: 'folder-o',
name: '上报日志',
meta: {
auth: true,
title: '上报日志',
id: '108',
pid: '0'
},
component: _import('reportingLogs')
}
}
/**
......
......@@ -2,15 +2,18 @@
* @Author: limin
* @Date: 2019-08-27 17:25:12
* @Last Modified by: limin
* @Last Modified time: 2019-08-28 14:25:41
* @Last Modified time: 2019-08-29 00:53:59
*/
import util from '@/libs/util.js'
import router from '@/router'
import { resources as sources, home, frameInRoutes, errorPage } from '@/router/routes'
import { resources as sources, home, frameInRoutes,sys } from '@/router/routes'
export default {
namespaced: true,
state: {
source: ''
source:null,
meta:{},
btns:{},
btnIdAll:[]
},
getters: {
/**
......@@ -19,6 +22,34 @@ export default {
*/
source (state, dispatch) {
return state.source
},
/**
* @description 返回当前页面meta
* @param {Object} state state
*/
meta (state, dispatch) {
return state.meta
},
/**
* @description 当前角色拥有的所有按钮
* @param {Object} state state
*/
btns (state, dispatch) {
return state.btns
},
/**
* 返回当前页面的btn
* @param {*} state
*/
curBtns(state){
return state.btns[state.meta.id]
},
/**
* 返回当前页面的btn
* @param {*} state
*/
btnIdAll(state){
return state.btnIdAll
}
},
actions: {
......@@ -50,6 +81,17 @@ export default {
})
},
/**
* @description 保存当前角色权限资源
* @param {obj} source 需要保存的权限资源
*/
setCurrentPageMeta ({ state, commit, dispatch }, meta) {
return new Promise(async resolve => {
state.meta = meta
// end
resolve()
})
},
/**
* @description 从持久化数据加载资源数据
* @param {Object} context
*/
......@@ -61,13 +103,6 @@ export default {
path: 'source',
user: true
}, { root: true })
// console.log(document.querySelector('html').getAttribute('login')==='1');
// if( document.querySelector('html').getAttribute('login')==='1'){
// await dispatch('init')
// router.replace(router.currentRoute.path || '/')
// }
// 用户登录后从持久化数据加载一系列的设置
// await dispatch('d2admin/account/load', { root: true })
}
// end
resolve(state.source)
......@@ -79,33 +114,26 @@ export default {
*/
init ({ state, commit, dispatch }) {
return new Promise(async resolve => {
// 获取权限资源点
const __source = await dispatch('load')
// 过滤资源点 并动态添加到路由
const __aRoutesInPermisions = util.permision.packRoutes(sources, __source)
frameInRoutes[0].children = [home, ...__aRoutesInPermisions]
router.addRoutes(frameInRoutes)
// router.addRoutes(errorPage)
await commit('d2admin/page/init', frameInRoutes, { root: true })
// 过滤左侧菜单栏
const __aMenusInPermisions = util.permision.packAsideMenus(sources, __source)
const __oHome = util.permision.format2Menu(home)
await commit('d2admin/menu/asideSet', [__oHome, ...__aMenusInPermisions], { root: true })
// DB -> store 加载用户名
// await dispatch('d2admin/user/load', null, { root: true })
// // DB -> store 加载主题
// await dispatch('d2admin/theme/load', null, { root: true })
// // DB -> store 加载页面过渡效果设置
// await dispatch('d2admin/transition/load', null, { root: true })
// // DB -> store 持久化数据加载上次退出时的多页列表
// await dispatch('d2admin/page/openedLoad', null, { root: true })
// // DB -> store 持久化数据加载侧边栏折叠状态
// await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// // DB -> store 持久化数据加载全局尺寸
// await dispatch('d2admin/size/load', null, { root: true })
// 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true })
try {
// 获取权限资源点
const __source = await dispatch('load')
// 过滤资源点 并动态添加到路由
const { route,btn } = util.permision.packRoutesBtns(sources, __source)
frameInRoutes[0].children = [home, ...route,...sys]
router.addRoutes(frameInRoutes)
state.btns = btn
await commit('d2admin/page/init', frameInRoutes, { root: true })
const __aMenus = [util.permision.format2Menu(home), ...util.permision.packAsideMenus(sources, __source)]
// 过滤左侧菜单栏
await commit('d2admin/menu/asideSet', __aMenus, { root: true })
// 初始化页面搜索
await commit('d2admin/search/init', __aMenus, { root: true })
} catch (error) {
if (error.message === '参数错误' && !await dispatch('load')) {
router.replace('/login')
return false
}
}
// end
resolve(state.source)
})
......
......@@ -7,6 +7,15 @@ export default {
// 颜色
value: process.env.VUE_APP_ELEMENT_COLOR
},
getters: {
/**
* @description 返回当前颜色值
* @param {Object} state state
*/
color (state, dispatch) {
return state.value
}
},
actions: {
/**
* @description 设置颜色
......
import { get } from 'lodash'
import router from '@/router'
import setting from '@/setting.js'
// import setting from '@/setting.js'
import home from '@/router/routes'
// 判定是否需要缓存
const isKeepAlive = data => get(data, 'meta.cache', false)
......@@ -11,7 +12,7 @@ export default {
// 可以在多页 tab 模式下显示的页面
pool: [],
// 当前显示的多页面列表
opened: setting.page.opened,
opened: [home],
// 已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
openedLoaded: false,
// 当前页面
......@@ -45,7 +46,7 @@ export default {
const value = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'page.opened',
defaultValue: setting.page.opened,
defaultValue: [home],
user: true
}, { root: true })
// 在处理函数中进行数据优化 过滤掉现在已经失效的页签或者已经改变了信息的页签
......
......@@ -40,33 +40,26 @@
label="操作"
>
<template slot-scope="scope">
<el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
<el-button type="text" size="small">编辑</el-button>
<auth-button label="测试" @e-auth-click="test(scope.row)"/>
<auth-button label="测试11" @e-auth-click="test(scope.row)"/>
<auth-button label="查看" @e-auth-click="handleClick(scope.row)"/>
<auth-button label="编辑" @e-auth-click="handleClick(scope.row)"/>
<auth-button label="看不见我" @e-auth-click="handleClick(scope.row)"/>
</template>
</el-table-column>
</el-table>
</d2-container>
</template>
<script>
export default {
methods: {
handleClick (row) {
console.log(row)
},
test (row) {
console.log(row)
alert(JSON.stringify(row))
}
},
components: {
},
mounted () {
this.$event.$on('e-auth-click', function () {
alert(1)
})
},
data () {
return {
......
import Bg from './src/main'
/* istanbul ignore next */
// Bg.install = function(Vue) {
// Vue.component(Bg.name, Bg)
// }
export default Bg
import axios from '@/plugin/axios'
// 默认配置
const defaults = {
format: 'js',
idx: 0,
n: 1,
token: 'wqdjkwl1e21FQlk1j2',
wallpaper_path: ''
}
/**
* 返回数组
*/
export const getBingImages = options => {
// const xhr = new XMLHttpRequest()
// const data = null
return new Promise((resolve, reject) => {
let config = null
if (typeof options === 'undefined') {
config = defaults
} else {
config = {}
Object.assign(config, defaults, options)
}
axios({ url: config.wallpaper_path }).then(res => {
// request({ url: 'http://localhost:3000/api/wallpaper' }).then(res => {
// console.log(JSON.parse(res.data).base64)
// if (res.status === 'success') {
resolve(res)
// } else {
// reject('ERROR.')
// }
})
})
}
<template>
<div :style="oBgStyle" :class="withAnimation?'img imgA':'img'"></div>
</template>
<script>
import { getBingImages } from './get_bing_image.js'
export default {
name: 'Bg',
props: {
opacity: [String],
refresh: Boolean,
withAnimation: Boolean
},
data() {
return {
oBgStyle: {
backgroundImage: '',
opacity: this.opacity || '.1'
}
}
},
beforeMount() {
// const oBg = this.$get_session('oBg')
// if (oBg && !this.refresh) {
// this.oBgStyle.backgroundImage = oBg.bgi
// this.$emit('update:oBg', oBg)
// return
// }
getBingImages({ 'wallpaper_path': 'http://oss-config.test.glsx.com.cn:7060/api/wallpaper' }).then(data => {
const { path, copyright, copyrightlink } = data
this.oBgStyle.backgroundImage = `url(${path})`
const oBg = { bgi: this.oBgStyle.backgroundImage, copyright, copyrightlink }
// this.$set_session('oBg', JSON.stringify(oBg))
this.$emit('update:oBg', oBg)
}).catch(err=>{
console.log(err);
})
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@keyframes img-action {
from{
transform: scale(1.1)
}
to{
transform: scale(1)
}
}
.img {
width: 100%;
height: 100%;
position: absolute;
}
.imgA {
animation: img-action 18s
}
</style>
<template>
<div class="page-login">
<!-- <bg opacity="1" :oBg.sync="bing" :refresh="true" :withAnimation="true"></bg> -->
<div class="page-login--layer page-login--layer-area">
<ul class="circles">
<li v-for="n in 10" :key="n"></li>
......@@ -81,7 +82,7 @@
</div>
</div>
<div class="page-login--content-footer">
<p class="page-login--content-footer-locales">
<!-- <p class="page-login--content-footer-locales">
<a
v-for="language in $languages"
:key="language.value"
......@@ -89,7 +90,7 @@
@click="$i18n.locale = language.value">
{{ language.label }}
</a>
</p>
</!-->
<p class="page-login--content-footer-copyright">
Copyright
<d2-icon name="copyright"/>
......@@ -98,11 +99,11 @@
@FairyEver
</a>
</p>
<p class="page-login--content-footer-options">
<!-- <p class="page-login--content-footer-options">
<a href="#">帮助</a>
<a href="#">隐私</a>
<a href="#">条款</a>
</p>
</p> -->
</div>
</div>
</div>
......@@ -126,8 +127,15 @@
import dayjs from 'dayjs'
import { mapActions } from 'vuex'
export default {
components: {
'Bg': () => import('./Bg')
},
data () {
return {
bing: {
copyright: '',
copyrightlink: ''
},
timeInterval: null,
time: dayjs().format('HH:mm:ss'),
// 快速选择用户
......
......@@ -17,7 +17,7 @@
prop="trafficCode">
<el-input
:disabled="disabled"
v-model="editForm.trafficCode"
v-model="editForm.trafficCode"
placeholder="请输入车辆编号"
></el-input>
</el-form-item>
......@@ -79,8 +79,8 @@ export default {
},
watch: {
isVisible(val) {
this.disabled = this.editForm.trafficCode ? true : false
isVisible (val) {
this.disabled = !!this.editForm.trafficCode
this.editForm.openType = this.editForm.trafficCode ? this.editForm.openType : '1'
this.$refs.editRuleForm.resetFields()
}
......
......@@ -141,7 +141,7 @@ export default {
label: '接口开放',
prop: 'openType',
formatter: (cellValue) => {
if(cellValue.openType) {
if (cellValue.openType) {
return {
1: '是',
2: '否'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!