jeecg-boot 2.0 模块开发版本发布

This commit is contained in:
zhangdaihao
2019-05-19 18:54:09 +08:00
parent 64fb100ea2
commit 4858af9f33
770 changed files with 85014 additions and 19508 deletions

View File

@ -5,7 +5,9 @@ const FormTypes = {
checkbox: 'checkbox',
select: 'select',
date: 'date',
datetime: 'datetime'
datetime: 'datetime',
upload: 'upload',
slot: 'slot'
}
const VALIDATE_NO_PASSED = Symbol()
export { FormTypes, VALIDATE_NO_PASSED }

View File

@ -0,0 +1,112 @@
import { USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types"
export function disabledAuthFilter(code,formData) {
if(nodeDisabledAuth(code,formData)){
return true;
}else{
return globalDisabledAuth(code);
}
}
function nodeDisabledAuth(code,formData){
console.log("页面权限禁用--NODE--开始");
var permissionList = [];
try {
var obj = formData;
//console.log("页面权限禁用--NODE--开始",obj);
if (obj) {
let bpmList = obj.permissionList;
for (var bpm of bpmList) {
if(bpm.type == '2') {
permissionList.push(bpm);
}
}
}
} catch (e) {
//console.log("页面权限异常----", e);
}
if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {
return false;
}
let permissions = [];
for (var item of permissionList) {
if(item.type == '2') {
permissions.push(item.action);
}
}
//console.log("页面权限----"+code);
if (!permissions.includes(code)) {
return false;
}else{
for (var item2 of permissionList) {
if(code === item2.action){
console.log("页面权限禁用--NODE--生效");
return true;
}
}
}
return false;
}
function globalDisabledAuth(code){
console.log("页面禁用权限--Global--开始");
var permissionList = [];
var allPermissionList = [];
//let authList = Vue.ls.get(USER_AUTH);
let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");
for (var auth of authList) {
if(auth.type == '2') {
permissionList.push(auth);
}
}
//console.log("页面禁用权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));
let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]");
for (var gauth of allAuthList) {
if(gauth.type == '2') {
allPermissionList.push(gauth);
}
}
//设置全局配置是否有命中
var gFlag = false;//禁用命中
var invalidFlag = false;//无效命中
if(allPermissionList != null && allPermissionList != "" && allPermissionList != undefined && allPermissionList.length > 0){
for (var itemG of allPermissionList) {
if(code === itemG.action){
if(itemG.status == '0'){
invalidFlag = true;
break;
}else{
gFlag = true;
break;
}
}
}
}
if(invalidFlag){
return false;
}
if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {
return gFlag;
}
let permissions = [];
for (var item of permissionList) {
if(item.type == '2') {
permissions.push(item.action);
}
}
//console.log("页面禁用权限----"+code);
if (!permissions.includes(code)) {
return gFlag;
}else{
for (var item2 of permissionList) {
if(code === item2.action){
console.log("页面权限解除禁用--Global--生效");
gFlag = false;
}
}
return gFlag;
}
}

View File

@ -1,27 +1,116 @@
import { USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types"
const hasPermission = {
install (Vue, options) {
console.log(options);
Vue.directive('has', {
inserted: (el, binding, vnode)=>{
console.log("页面权限----",el);
let permissionList = vnode.context.$route.meta.permissionList;
if (permissionList === null || permissionList === "" || permissionList === undefined) {
el.parentNode.removeChild(el)
return
}
let permissions = [];
for (var item of permissionList) {
permissions.push(item.action);
}
//console.log("页面权限----"+permissions);
//console.log("页面权限----"+binding.value);
if (!permissions.includes(binding.value)) {
//if(el.parentNode)
el.parentNode.removeChild(el)
}
console.log("页面权限控制----");
//节点权限处理,如果命中则不进行全局权限处理
if(!filterNodePermission(el, binding, vnode)){
filterGlobalPermission(el, binding, vnode);
}
}
});
}
};
/**
* 全局权限控制
*/
export function filterNodePermission(el, binding, vnode) {
console.log("页面权限--NODE--");
var permissionList = [];
try {
var obj = vnode.context.$props.formData;
if (obj) {
let bpmList = obj.permissionList;
for (var bpm of bpmList) {
if(bpm.type != '2') {
permissionList.push(bpm);
}
}
}
} catch (e) {
//console.log("页面权限异常----", e);
}
if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {
//el.parentNode.removeChild(el)
return false;
}
let permissions = [];
for (var item of permissionList) {
if(item.type != '2') {
permissions.push(item.action);
}
}
//console.log("页面权限----"+permissions);
//console.log("页面权限----"+binding.value);
if (!permissions.includes(binding.value)) {
//el.parentNode.removeChild(el)
return false;
}else{
for (var item2 of permissionList) {
if(binding.value === item2.action){
return true;
}
}
}
return false;
}
/**
* 全局权限控制
*/
export function filterGlobalPermission(el, binding, vnode) {
console.log("页面权限--Global--");
var permissionList = [];
var allPermissionList = [];
//let authList = Vue.ls.get(USER_AUTH);
let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");
for (var auth of authList) {
if(auth.type != '2') {
permissionList.push(auth);
}
}
//console.log("页面权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));
let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]");
for (var gauth of allAuthList) {
if(gauth.type != '2') {
allPermissionList.push(gauth);
}
}
//设置全局配置是否有命中
var invalidFlag = false;//无效命中
if(allPermissionList != null && allPermissionList != "" && allPermissionList != undefined && allPermissionList.length > 0){
for (var itemG of allPermissionList) {
if(binding.value === itemG.action){
if(itemG.status == '0'){
invalidFlag = true;
break;
}
}
}
}
if(invalidFlag){
return;
}
if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {
el.parentNode.removeChild(el);
return;
}
let permissions = [];
for (var item of permissionList) {
if(item.type != '2'){
permissions.push(item.action);
}
}
if (!permissions.includes(binding.value)) {
el.parentNode.removeChild(el);
}
}
export default hasPermission;

View File

@ -136,8 +136,8 @@ function generateChildRouters (data) {
//--update-begin----author:scott---date:20190320------for:根据后台菜单配置判断是否路由菜单字段动态选择是否生成路由为了支持参数URL菜单------
//判断是否生成路由
if(item.route && item.route === '0'){
console.log(' 不生成路由 item.route '+item.route);
console.log(' 不生成路由 item.path '+item.path);
//console.log(' 不生成路由 item.route '+item.route);
//console.log(' 不生成路由 item.path '+item.path);
}else{
routers.push(menu);
}
@ -157,12 +157,30 @@ export function cloneObject(obj) {
/**
* 随机生成数字
* @param min 最小值
* @param max 最大值
*
* 示例:生成长度为 12 的随机数randomNumber(12)
* 示例:生成 3~23 之间的随机数randomNumber(3, 23)
*
* @param1 最小值 | 长度
* @param2 最大值
* @return int 生成后的数字
*/
export function randomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
export function randomNumber() {
// 生成 最小值 到 最大值 区间的随机数
const random = (min, max) => {
return Math.floor(Math.random() * (max - min + 1) + min)
}
if (arguments.length === 1) {
let [length] = arguments
// 生成指定长度的随机数字,首位一定不是 0
let nums = [...Array(length).keys()].map((i) => (i > 0 ? random(0, 9) : random(1, 9)))
return parseInt(nums.join(''))
} else if (arguments.length >= 2) {
let [min, max] = arguments
return random(min, max)
} else {
return Number.NaN
}
}
/**
@ -192,35 +210,12 @@ export function randomUUID() {
}
/**
* 【顶部导航栏模式】
* @date 2019-04-08
* 顶部导航栏滚动条位置滚动到选中的菜单处
* @param doc document 对象
* 下划线转驼峰
* @param string
* @returns {*}
*/
export function topNavScrollToSelectItem(doc) {
let scrollWidth = doc.getElementById('top-nav-scroll-width')
if (scrollWidth == null) return
let menu = scrollWidth.getElementsByClassName('ant-menu')[0]
if (menu) {
let menuItems = menu.getElementsByTagName('li')
for (let item of menuItems) {
let index1 = item.className.indexOf('ant-menu-item-selected') !== -1
let index2 = item.className.indexOf('ant-menu-submenu-selected') !== -1
if (index1 || index2) {
// scrollLeft = 选中项left - 选中项width - (第一个隐藏的div的宽度)
let scrollLeft = (item.offsetLeft - item.offsetWidth - (index1 ? 100 : 60))
let scrollView = doc.getElementById('top-nav-scroll-view')
// scrollTo() 方法存在兼容性问题
if (typeof scrollView.scrollTo === 'function') {
scrollView.scrollTo({
left: scrollLeft,
behavior: 'smooth'
})
} else {
scrollView.scrollLeft = scrollLeft
}
break
}
}
}
export function underLine2CamelCase(string){
return string.replace( /_([a-z])/g, function( all, letter ) {
return letter.toUpperCase();
});
}

View File

@ -0,0 +1,5 @@
import Bus from 'vue';
let install = function (Vue) {
Vue.prototype.$bus = new Bus()
}
export default { install };