mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-01-02 19:15:26 +08:00
JeecgBoot 2.3 里程碑版本发布,支持微服务和单体自由切换、提供新行编辑表格JVXETable
This commit is contained in:
@ -174,7 +174,10 @@ function hasColoum(item,authList){
|
||||
|
||||
//权限无效时不做控制,有效时控制,只能控制 显示不显示
|
||||
//根据授权码前缀获取未授权的列信息
|
||||
function getNoAuthCols(pre){
|
||||
export function getNoAuthCols(pre){
|
||||
if(!pre || pre.length==0){
|
||||
return []
|
||||
}
|
||||
let permissionList = [];
|
||||
let allPermissionList = [];
|
||||
|
||||
|
||||
60
ant-design-vue-jeecg/src/utils/desform/DesformRouteUtils.js
Normal file
60
ant-design-vue-jeecg/src/utils/desform/DesformRouteUtils.js
Normal file
@ -0,0 +1,60 @@
|
||||
import router from '@/router'
|
||||
import { getAction } from '@api/manage'
|
||||
|
||||
/** 表单设计器路由类型 */
|
||||
export const DESFORM_ROUTE_TYPE = {
|
||||
/** 跳转到表单 */
|
||||
form: '1',
|
||||
/** 跳转到菜单 */
|
||||
menu: '2',
|
||||
/** 跳转到外部链接 */
|
||||
href: '3',
|
||||
}
|
||||
/** 表单设计器路由跳转带过来的ID名字 */
|
||||
export const DESFORM_ROUTE_DATA_ID = 'routeDataId'
|
||||
|
||||
/**
|
||||
* 获取当前路由或指定路由的 routeDataId
|
||||
*
|
||||
* @param $route 路由对象,默认为当前路由
|
||||
*/
|
||||
export function getDesformRouteDataId($route) {
|
||||
if (arguments.length === 0) {
|
||||
$route = router.currentRoute
|
||||
}
|
||||
if ($route) {
|
||||
return $route.query[DESFORM_ROUTE_DATA_ID]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据路由跳转带过来的ID来获取表单设计器的数据
|
||||
* @param param 表单设计器路由跳转带过来的ID(可以直接传id字符串,也可以传 this.$route,自动从$route里获取id,如果不传就获取当前路由的参数)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function getDesformDataByRouteDataId(param) {
|
||||
if (!param) {
|
||||
param = router.currentRoute
|
||||
}
|
||||
let id
|
||||
if (typeof param == 'string') {
|
||||
id = param
|
||||
} else if (typeof param.query === 'object') {
|
||||
id = getDesformRouteDataId(param)
|
||||
if (!id) {
|
||||
// 当前$route.query里没有带表单设计器路由ID,直接返回null
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
throw new Error('传递的参数不能识别,可以直接传id字符串,也可以传 this.$route,自动从$route里获取id,如果不传就获取当前路由的参数')
|
||||
}
|
||||
let url = `/desform/data/queryById?id=${id}`
|
||||
let { success, result, message } = await getAction(url)
|
||||
if (success) {
|
||||
result.desformDataJson = JSON.parse(result.desformDataJson)
|
||||
return result
|
||||
} else {
|
||||
throw new Error('表单设计器路由数据获取失败:' + message)
|
||||
}
|
||||
}
|
||||
185
ant-design-vue-jeecg/src/utils/desform/pcaaUtils.js
Normal file
185
ant-design-vue-jeecg/src/utils/desform/pcaaUtils.js
Normal file
@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 省市区联动组件通用工具类。
|
||||
* 列表翻译、组件反推、表单设计器组件反推等功能都可以用该工具类实现。
|
||||
*
|
||||
* 1. leafName字段的意义:
|
||||
* AntdvUI和ElementUI的叶级节点名字是不一样的,
|
||||
* AntdvUI的名字是 isLeaf,ElementUI是 leaf,
|
||||
* 默认是AntdvUI的名字,在表单设计器那边需要手动 setLeafName
|
||||
*/
|
||||
|
||||
import { pcaa } from 'area-data'
|
||||
|
||||
export { pcaa }
|
||||
|
||||
/** 根节点Code = 86 */
|
||||
export const ROOT_CODE = '86'
|
||||
|
||||
/** 叶级节点的名字 */
|
||||
let leafName = 'isLeaf'
|
||||
|
||||
/**
|
||||
* set leafName
|
||||
* @param $leafName
|
||||
*/
|
||||
export function setLeafName($leafName = 'isLeaf') {
|
||||
leafName = $leafName
|
||||
}
|
||||
|
||||
/**
|
||||
* 将地区数据转换成下拉框等组件可识别的Options数组
|
||||
* @param data 地区data
|
||||
* @param labelName label标签名字
|
||||
* @return
|
||||
*/
|
||||
export function transToOptions(data, labelName = 'label') {
|
||||
if (data) {
|
||||
return Object.keys(data).map(key => ({ value: key, [labelName]: data[key] }))
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子级Data对象
|
||||
*
|
||||
* @param code 父级地区Code
|
||||
*/
|
||||
export function getChildrenDataByCode(code) {
|
||||
return pcaa[code]
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子级Options对象
|
||||
*
|
||||
* @param code 父级地区Code
|
||||
* @return {Array} 返回的值一定是一个数组,如果数组length===0,则代表没有子级
|
||||
*/
|
||||
export function getChildrenOptionsByCode(code) {
|
||||
let options = []
|
||||
let data = getChildrenDataByCode(code)
|
||||
if (data) {
|
||||
for (let key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
options.push({ value: key, label: data[key], })
|
||||
}
|
||||
}
|
||||
return options
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取兄弟Data对象
|
||||
*
|
||||
* @param code 地区Code
|
||||
*/
|
||||
export function getSiblingsDataByCode(code) {
|
||||
if (typeof code === 'string' && code.length === 6) {
|
||||
// 父级节点Code
|
||||
let parentCode = `${code.substring(0, 4)}00`
|
||||
return getChildrenDataByCode(parentCode)
|
||||
} else {
|
||||
console.warn('[getSiblingsByCode]: code不合法')
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应的 Label
|
||||
*
|
||||
* @param code 地区Code
|
||||
*/
|
||||
export function getLabelByCode(code) {
|
||||
if (code) {
|
||||
// 获取当前code所有的兄弟节点
|
||||
let siblingsData = getSiblingsDataByCode(code)
|
||||
// 然后取出自己的值
|
||||
return siblingsData[code]
|
||||
} else {
|
||||
return code
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的 Label,包括自身和所有父级
|
||||
*
|
||||
* @param code 地区Code
|
||||
* @param joinText 合并文本
|
||||
*/
|
||||
export function getAllLabelByCode(code, joinText = ' / ') {
|
||||
if (code) {
|
||||
let { labels } = getAllParentByCode(code)
|
||||
return labels.join(joinText)
|
||||
} else {
|
||||
return code
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过子级 code 反推所有父级的 code
|
||||
*
|
||||
* @param code 子级地区Code
|
||||
* @returns {Object} options: 所有父级的选项;codes: 所有父级的code;labels: 所有父级的显示名
|
||||
*/
|
||||
export function getAllParentByCode(code) {
|
||||
code = (typeof code === 'string' ? code : '').trim()
|
||||
if (code.length === 0) {
|
||||
return { options: [], codes: [], labels: [] }
|
||||
}
|
||||
// 获取第一级数据
|
||||
let rootOptions = getChildrenOptionsByCode(ROOT_CODE)
|
||||
hasChildren(rootOptions)
|
||||
// 父级code数组,code长度
|
||||
let parentCodes = [code], length = code.length
|
||||
// 父级label数组
|
||||
let parentLabels = [getLabelByCode(code)]
|
||||
// 级别,位数,是否继续循环
|
||||
let level = 1, num = 2, flag = true
|
||||
|
||||
let options = rootOptions
|
||||
do {
|
||||
let endIndex = num * level++
|
||||
// 末尾补零个数
|
||||
let zeroPadding = [...new Array(length - endIndex)].map(i => '0').join('')
|
||||
// 裁剪并补零(获取上级的方式就是将当前code的后两位变成 00)
|
||||
let parentCode = code.substring(0, endIndex) + zeroPadding
|
||||
// 是否找到在选项中的位置
|
||||
let findIt = false
|
||||
for (let option of options) {
|
||||
if (option.value === parentCode) {
|
||||
if (option[leafName]) {
|
||||
flag = false
|
||||
} else {
|
||||
let children = getChildrenOptionsByCode(option.value)
|
||||
hasChildren(children)
|
||||
option.children = children
|
||||
options = children
|
||||
parentCodes.splice(parentCodes.length - 1, 0, option.value)
|
||||
parentLabels.splice(parentLabels.length - 1, 0, option.label)
|
||||
}
|
||||
findIt = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (findIt) {
|
||||
findIt = false
|
||||
} else {
|
||||
flag = false
|
||||
}
|
||||
} while (flag)
|
||||
return { options: rootOptions, codes: parentCodes, labels: parentLabels }
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断所有的项是否有子节点
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
export function hasChildren(options) {
|
||||
options.forEach(option => {
|
||||
option[leafName] = getChildrenOptionsByCode(option.value).length === 0
|
||||
})
|
||||
}
|
||||
@ -109,7 +109,21 @@ export function filterGlobalPermission(el, binding, vnode) {
|
||||
let permissions = [];
|
||||
for (let item of permissionList) {
|
||||
if(item.type != '2'){
|
||||
permissions.push(item.action);
|
||||
//update--begin--autor:wangshuai-----date:20200729------for:按钮权限,授权标识的提示信息是多个用逗号分隔逻辑处理 gitee#I1OUGU-------
|
||||
if(item.action){
|
||||
if(item.action.includes(",")){
|
||||
let split = item.action.split(",")
|
||||
for (let i = 0; i <split.length ; i++) {
|
||||
if(!split[i] ||split[i].length==0){
|
||||
continue;
|
||||
}
|
||||
permissions.push(split[i]);
|
||||
}
|
||||
}else{
|
||||
permissions.push(item.action);
|
||||
}
|
||||
}
|
||||
//update--end--autor:wangshuai-----date:20200729------for:按钮权限,授权标识的提示信息是多个用逗号分隔逻辑处理 gitee#I1OUGU------
|
||||
}
|
||||
}
|
||||
if (!permissions.includes(binding.value)) {
|
||||
|
||||
20
ant-design-vue-jeecg/src/utils/portal/constant.js
Normal file
20
ant-design-vue-jeecg/src/utils/portal/constant.js
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 功能模块
|
||||
* @type {{LEAVE_EARLY: {text: string, value: string}, LATE: {text: string, value: string}, ABSENT: {text: string, value: string}, NO_SIGN: {text: string, value: string}, NORMAL: {text: string, value: string}}}
|
||||
*/
|
||||
export const FunctionEnum = {
|
||||
EoaCmsBanner: { path: 'modules/eoa/cmsoa/modules/EoaCmsBanner', formData: 'carouselImg' },
|
||||
EoaCmsNewsInfo: { path: 'modules/eoa/cmsoa/modules/EoaCmsNewsInfo', formData: 'newsInfo' },
|
||||
EoaCmsRuleInfo: { path: 'modules/eoa/cmsoa/modules/EoaCmsRuleInfo', formData: 'ruleDownInfo' },
|
||||
EoaCmsSignNews: { path: 'modules/eoa/cmsoa/modules/EoaCmsSignNews', formData: 'signNews' },
|
||||
EoaCmsUserNotice: { path: 'modules/eoa/cmsoa/modules/EoaCmsUserNotice', formData: 'userNotice' },
|
||||
EoaCmsPlan: { path: 'modules/eoa/cmsoa/modules/EoaCmsPlan', formData: '' },
|
||||
EoaCmsLink: { path: 'modules/eoa/cmsoa/modules/EoaCmsLink', formData: '' },
|
||||
EoaCmsCommUse:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsCommUse', formData: '' },
|
||||
EoaCmsMyProcess:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsMyProcess', formData: '' },
|
||||
EoaCmsApplyProcess:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsApplyProcess', formData: '' },
|
||||
EoaCmsProcessNotice:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsProcessNotice', formData: '' },
|
||||
EoaCmsProcessChatData:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsProcessChatData', formData: '' },
|
||||
EoaCmsProcessTypeChat:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsProcessTypeChat', formData: '' },
|
||||
EoaCmsEmail:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsEmail', formData: '' },
|
||||
}
|
||||
@ -32,8 +32,9 @@ const err = (error) => {
|
||||
notification.error({ message: '系统提示', description: '拒绝访问',duration: 4})
|
||||
break
|
||||
case 500:
|
||||
let path = window.location.href
|
||||
//notification.error({ message: '系统提示', description:'Token失效,请重新登录!',duration: 4})
|
||||
if(token && data.message=="Token失效,请重新登录"){
|
||||
if(token && data.message.includes("Token失效") && path.indexOf('/user/login') < 0){
|
||||
// update-begin- --- author:scott ------ date:20190225 ---- for:Token失效采用弹框模式,不直接跳转----
|
||||
// store.dispatch('Logout').then(() => {
|
||||
// window.location.reload()
|
||||
@ -47,7 +48,6 @@ const err = (error) => {
|
||||
store.dispatch('Logout').then(() => {
|
||||
Vue.ls.remove(ACCESS_TOKEN)
|
||||
try {
|
||||
let path=that.$route.path;
|
||||
if(path.indexOf('/user/login')==-1){
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
@ -458,7 +458,7 @@ export function simpleDebounce(fn, delay = 100) {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
timer = setTimeout(() => {
|
||||
fn.apply(null, args)
|
||||
fn.apply(this, args)
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
@ -527,4 +527,14 @@ export function getVmParentByName(vm, name) {
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 使一个值永远不会为(null | undefined)
|
||||
*
|
||||
* @param value 要处理的值
|
||||
* @param def 默认值,如果value为(null | undefined)则返回的默认值,可不传,默认为''
|
||||
*/
|
||||
export function neverNull(value, def) {
|
||||
return value == null ? (neverNull(def, '')) : value
|
||||
}
|
||||
Reference in New Issue
Block a user