【modify】使用ESLint格式化代码
This commit is contained in:
@@ -11,13 +11,13 @@ const FormTypes = {
|
||||
upload: 'upload',
|
||||
file: 'file',
|
||||
image: 'image',
|
||||
popup:'popup',
|
||||
list_multi:"list_multi",
|
||||
sel_search:"sel_search",
|
||||
sel_search_async:"sel_search_async",
|
||||
radio:'radio',
|
||||
checkbox_meta:"checkbox_meta",
|
||||
input_pop:'input_pop',
|
||||
popup: 'popup',
|
||||
list_multi: 'list_multi',
|
||||
sel_search: 'sel_search',
|
||||
sel_search_async: 'sel_search_async',
|
||||
radio: 'radio',
|
||||
checkbox_meta: 'checkbox_meta',
|
||||
input_pop: 'input_pop',
|
||||
sel_depart: 'sel_depart',
|
||||
sel_user: 'sel_user',
|
||||
slot: 'slot',
|
||||
@@ -32,10 +32,10 @@ export { FormTypes, VALIDATE_NO_PASSED }
|
||||
* 这个方法可以等待挂载完成之后再返回 $refs 的对象,避免报错
|
||||
* @author sunjianlei
|
||||
**/
|
||||
export function getRefPromise(vm, name) {
|
||||
export function getRefPromise (vm, name) {
|
||||
return new Promise((resolve) => {
|
||||
(function next() {
|
||||
let ref = vm.$refs[name]
|
||||
(function next () {
|
||||
const ref = vm.$refs[name]
|
||||
if (ref) {
|
||||
resolve(ref)
|
||||
} else {
|
||||
@@ -54,13 +54,12 @@ export function getRefPromise(vm, name) {
|
||||
* @returns {Promise<any>}
|
||||
* @author sunjianlei
|
||||
*/
|
||||
export function validateFormAndTables(form, cases) {
|
||||
|
||||
export function validateFormAndTables (form, cases) {
|
||||
if (!(form && typeof form.validateFields === 'function')) {
|
||||
throw `form 参数需要的是一个form对象,而传入的却是${typeof form}`
|
||||
}
|
||||
|
||||
let options = {}
|
||||
const options = {}
|
||||
return new Promise((resolve, reject) => {
|
||||
// 验证主表表单
|
||||
form.validateFields((err, values) => {
|
||||
@@ -76,7 +75,6 @@ export function validateFormAndTables(form, cases) {
|
||||
}).catch(error => {
|
||||
return Promise.reject(error)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,16 +84,15 @@ export function validateFormAndTables(form, cases) {
|
||||
* @returns {Promise<any>}
|
||||
* @author sunjianlei
|
||||
*/
|
||||
export function validateFormModelAndTables(form,values, cases) {
|
||||
|
||||
export function validateFormModelAndTables (form, values, cases) {
|
||||
if (!(form && typeof form.validate === 'function')) {
|
||||
throw `form 参数需要的是一个form对象,而传入的却是${typeof form}`
|
||||
}
|
||||
let options = {}
|
||||
const options = {}
|
||||
return new Promise((resolve, reject) => {
|
||||
// 验证主表表单
|
||||
form.validate((valid,obj) => {
|
||||
valid ?resolve(values):reject({ error: VALIDATE_NO_PASSED })
|
||||
form.validate((valid, obj) => {
|
||||
valid ? resolve(values) : reject({ error: VALIDATE_NO_PASSED })
|
||||
})
|
||||
}).then(values => {
|
||||
Object.assign(options, { formValue: values })
|
||||
@@ -107,7 +104,6 @@ export function validateFormModelAndTables(form,values, cases) {
|
||||
}).catch(error => {
|
||||
return Promise.reject(error)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,39 +112,41 @@ export function validateFormModelAndTables(form,values, cases) {
|
||||
* @param deleteTempId 是否删除临时ID,如果设为true,行编辑就不返回新增行的ID,ID需要后台生成
|
||||
* @author sunjianlei
|
||||
*/
|
||||
export function validateTables(cases, deleteTempId) {
|
||||
export function validateTables (cases, deleteTempId) {
|
||||
if (!(cases instanceof Array)) {
|
||||
throw `'validateTables'函数的'cases'参数需要的是一个数组,而传入的却是${typeof cases}`
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
let tables = []
|
||||
let index = 0;
|
||||
if(!cases || cases.length === 0){
|
||||
const tables = []
|
||||
let index = 0
|
||||
if (!cases || cases.length === 0) {
|
||||
resolve()
|
||||
}
|
||||
(function next() {
|
||||
let vm = cases[index]
|
||||
(function next () {
|
||||
const vm = cases[index]
|
||||
vm.getAll(true, deleteTempId).then(all => {
|
||||
tables[index] = all
|
||||
// 判断校验是否全部完成,完成返回成功,否则继续进行下一步校验
|
||||
if (++index === cases.length) {
|
||||
resolve(tables)
|
||||
} else (
|
||||
next()
|
||||
)
|
||||
} else {
|
||||
(
|
||||
next()
|
||||
)
|
||||
}
|
||||
}, error => {
|
||||
// 出现未验证通过的表单,不再进行下一步校验,直接返回失败并跳转到该表格
|
||||
if (error === VALIDATE_NO_PASSED) {
|
||||
// 尝试获取tabKey,如果在ATab组件内即可获取
|
||||
let paneKey;
|
||||
let tabPane = getVmParentByName(vm, 'ATabPane')
|
||||
let paneKey
|
||||
const tabPane = getVmParentByName(vm, 'ATabPane')
|
||||
if (tabPane) {
|
||||
paneKey = tabPane.$vnode.key
|
||||
}
|
||||
reject({error: VALIDATE_NO_PASSED, index, paneKey})
|
||||
reject({ error: VALIDATE_NO_PASSED, index, paneKey })
|
||||
}
|
||||
reject(error)
|
||||
})
|
||||
})()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import { getRefPromise } from '@/utils/JEditableTableUtil'
|
||||
/* 日历的视图类型 */
|
||||
const calendarViewType = {
|
||||
month: 'month', // 月视图
|
||||
basicWeek: 'basicWeek', // 基础周视图
|
||||
basicDay: 'basicDay',// 基础天视图
|
||||
basicWeek: 'basicWeek', // 基础周视图
|
||||
basicDay: 'basicDay', // 基础天视图
|
||||
agendaWeek: 'agendaWeek', // 议程周视图
|
||||
agendaDay: 'agendaDay', // 议程天视图
|
||||
agendaDay: 'agendaDay' // 议程天视图
|
||||
}
|
||||
|
||||
/* 定义默认视图 */
|
||||
@@ -36,7 +36,7 @@ const defaultSettings = {
|
||||
center: 'title',
|
||||
right: 'hide, custom, month,agendaWeek,agendaDay'
|
||||
},
|
||||
//点击今天日列表图
|
||||
// 点击今天日列表图
|
||||
eventLimitClick: 'day',
|
||||
// 隐藏超出的事件
|
||||
eventLimit: true,
|
||||
@@ -55,25 +55,25 @@ const defaultSettings = {
|
||||
// 周视图和日视同的左侧时间显示
|
||||
slotLabelFormat: 'HH:mm',
|
||||
// 设置第二天阈值
|
||||
nextDayThreshold: '00:00:00',
|
||||
nextDayThreshold: '00:00:00'
|
||||
}
|
||||
|
||||
/** 提供了一些增强方法 */
|
||||
const CalendarMixins = {
|
||||
data() {
|
||||
data () {
|
||||
return {
|
||||
calenderCurrentViewType: defaultView
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
getCalendarConfigEventHandler() {
|
||||
getCalendarConfigEventHandler () {
|
||||
return {
|
||||
// 处理 view changed 事件
|
||||
viewRender: (view, element) => {
|
||||
let { type } = view
|
||||
const { type } = view
|
||||
|
||||
let lastViewType = this.calenderCurrentViewType
|
||||
const lastViewType = this.calenderCurrentViewType
|
||||
this.calenderCurrentViewType = type
|
||||
|
||||
if (typeof this.handleViewRender === 'function') {
|
||||
@@ -83,25 +83,24 @@ const CalendarMixins = {
|
||||
if (lastViewType !== this.calenderCurrentViewType && typeof this.handleViewChanged === 'function') {
|
||||
this.handleViewChanged(type, view, element)
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** 获取 LunarFullCalendar 实例,ref = baseCalendar */
|
||||
getCalendar(fn) {
|
||||
getCalendar (fn) {
|
||||
return getRefPromise(this, 'baseCalendar').then(fn)
|
||||
},
|
||||
|
||||
calendarEmit(name, data) {
|
||||
calendarEmit (name, data) {
|
||||
this.getCalendar(ref => ref.$emit(name, data))
|
||||
},
|
||||
|
||||
/** 强制重新加载所有的事件(日程)*/
|
||||
calendarReloadEvents() {
|
||||
/** 强制重新加载所有的事件(日程) */
|
||||
calendarReloadEvents () {
|
||||
this.calendarEmit('reload-events')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { defaultSettings, calendarViewType, CalendarMixins }
|
||||
export { defaultSettings, calendarViewType, CalendarMixins }
|
||||
|
||||
+134
-144
@@ -1,121 +1,118 @@
|
||||
import { USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types"
|
||||
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);
|
||||
export function disabledAuthFilter (code, formData) {
|
||||
if (nodeDisabledAuth(code, formData)) {
|
||||
return true
|
||||
} else {
|
||||
return globalDisabledAuth(code)
|
||||
}
|
||||
}
|
||||
|
||||
function nodeDisabledAuth(code,formData){
|
||||
let permissionList = [];
|
||||
function nodeDisabledAuth (code, formData) {
|
||||
let permissionList = []
|
||||
try {
|
||||
if (formData) {
|
||||
let bpmList = formData.permissionList;
|
||||
permissionList = bpmList.filter(item=>item.type=='2')
|
||||
const bpmList = formData.permissionList
|
||||
permissionList = bpmList.filter(item => item.type == '2')
|
||||
// for (let bpm of bpmList) {
|
||||
// if(bpm.type == '2') {
|
||||
// permissionList.push(bpm);
|
||||
// }
|
||||
// }
|
||||
}else{
|
||||
return false;
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} catch (e) {
|
||||
//console.log("页面权限异常----", e);
|
||||
// console.log("页面权限异常----", e);
|
||||
}
|
||||
if (permissionList.length == 0) {
|
||||
return false;
|
||||
if (permissionList.length == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
console.log("流程节点页面权限禁用--NODE--开始");
|
||||
let permissions = [];
|
||||
for (let item of permissionList) {
|
||||
if(item.type == '2') {
|
||||
permissions.push(item.action);
|
||||
console.log('流程节点页面权限禁用--NODE--开始')
|
||||
const permissions = []
|
||||
for (const item of permissionList) {
|
||||
if (item.type == '2') {
|
||||
permissions.push(item.action)
|
||||
}
|
||||
}
|
||||
//console.log("页面权限----"+code);
|
||||
// console.log("页面权限----"+code);
|
||||
if (!permissions.includes(code)) {
|
||||
return false;
|
||||
}else{
|
||||
for (let item2 of permissionList) {
|
||||
if(code === item2.action){
|
||||
console.log("流程节点页面权限禁用--NODE--生效");
|
||||
return true;
|
||||
return false
|
||||
} else {
|
||||
for (const item2 of permissionList) {
|
||||
if (code === item2.action) {
|
||||
console.log('流程节点页面权限禁用--NODE--生效')
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
function globalDisabledAuth(code){
|
||||
function globalDisabledAuth (code) {
|
||||
const permissionList = []
|
||||
const allPermissionList = []
|
||||
|
||||
let permissionList = [];
|
||||
let allPermissionList = [];
|
||||
|
||||
//let authList = Vue.ls.get(USER_AUTH);
|
||||
let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");
|
||||
for (let auth of authList) {
|
||||
if(auth.type == '2') {
|
||||
permissionList.push(auth);
|
||||
// let authList = Vue.ls.get(USER_AUTH);
|
||||
const authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || '[]')
|
||||
for (const 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 (let gauth of allAuthList) {
|
||||
if(gauth.type == '2') {
|
||||
allPermissionList.push(gauth);
|
||||
// console.log("页面禁用权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));
|
||||
const allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || '[]')
|
||||
for (const gauth of allAuthList) {
|
||||
if (gauth.type == '2') {
|
||||
allPermissionList.push(gauth)
|
||||
}
|
||||
}
|
||||
//设置全局配置是否有命中
|
||||
let gFlag = false;//禁用命中
|
||||
let invalidFlag = false;//无效命中
|
||||
if(allPermissionList != null && allPermissionList != "" && allPermissionList != undefined && allPermissionList.length > 0){
|
||||
for (let itemG of allPermissionList) {
|
||||
if(code === itemG.action){
|
||||
if(itemG.status == '0'){
|
||||
invalidFlag = true;
|
||||
break;
|
||||
}else{
|
||||
gFlag = true;
|
||||
break;
|
||||
// 设置全局配置是否有命中
|
||||
let gFlag = false// 禁用命中
|
||||
let invalidFlag = false// 无效命中
|
||||
if (allPermissionList != null && allPermissionList != '' && allPermissionList != undefined && allPermissionList.length > 0) {
|
||||
for (const itemG of allPermissionList) {
|
||||
if (code === itemG.action) {
|
||||
if (itemG.status == '0') {
|
||||
invalidFlag = true
|
||||
break
|
||||
} else {
|
||||
gFlag = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(invalidFlag){
|
||||
return false;
|
||||
if (invalidFlag) {
|
||||
return false
|
||||
}
|
||||
if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {
|
||||
return gFlag;
|
||||
if (permissionList === null || permissionList === '' || permissionList === undefined || permissionList.length <= 0) {
|
||||
return gFlag
|
||||
}
|
||||
let permissions = [];
|
||||
for (let item of permissionList) {
|
||||
if(item.type == '2') {
|
||||
permissions.push(item.action);
|
||||
const permissions = []
|
||||
for (const item of permissionList) {
|
||||
if (item.type == '2') {
|
||||
permissions.push(item.action)
|
||||
}
|
||||
}
|
||||
//console.log("页面禁用权限----"+code);
|
||||
// console.log("页面禁用权限----"+code);
|
||||
if (!permissions.includes(code)) {
|
||||
return gFlag;
|
||||
}else{
|
||||
for (let item2 of permissionList) {
|
||||
if(code === item2.action){
|
||||
gFlag = false;
|
||||
return gFlag
|
||||
} else {
|
||||
for (const item2 of permissionList) {
|
||||
if (code === item2.action) {
|
||||
gFlag = false
|
||||
}
|
||||
}
|
||||
return gFlag;
|
||||
return gFlag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function colAuthFilter(columns,pre) {
|
||||
let authList = getNoAuthCols(pre);
|
||||
export function colAuthFilter (columns, pre) {
|
||||
const authList = getNoAuthCols(pre)
|
||||
const cols = columns.filter(item => {
|
||||
if (hasColoum(item,authList)) {
|
||||
if (hasColoum(item, authList)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -131,27 +128,27 @@ export function colAuthFilter(columns,pre) {
|
||||
* @param pre
|
||||
* @returns {*}
|
||||
*/
|
||||
export function colAuthFilterJEditableTable(columns,pre) {
|
||||
let authList = getAllShowAndDisabledAuthCols(pre);
|
||||
export function colAuthFilterJEditableTable (columns, pre) {
|
||||
const authList = getAllShowAndDisabledAuthCols(pre)
|
||||
const cols = columns.filter(item => {
|
||||
let oneAuth = authList.find(auth => {
|
||||
return auth.action === pre + item.key;
|
||||
});
|
||||
if(!oneAuth){
|
||||
return auth.action === pre + item.key
|
||||
})
|
||||
if (!oneAuth) {
|
||||
return true
|
||||
}
|
||||
|
||||
//代码严谨处理,防止一个授权标识,配置多次
|
||||
if(oneAuth instanceof Array){
|
||||
// 代码严谨处理,防止一个授权标识,配置多次
|
||||
if (oneAuth instanceof Array) {
|
||||
oneAuth = oneAuth[0]
|
||||
}
|
||||
|
||||
//禁用逻辑
|
||||
// 禁用逻辑
|
||||
if (oneAuth.type == '2' && !oneAuth.isAuth) {
|
||||
item["disabled"] = true
|
||||
item.disabled = true
|
||||
return true
|
||||
}
|
||||
//隐藏逻辑逻辑
|
||||
// 隐藏逻辑逻辑
|
||||
if (oneAuth.type == '1' && !oneAuth.isAuth) {
|
||||
return false
|
||||
}
|
||||
@@ -160,81 +157,78 @@ export function colAuthFilterJEditableTable(columns,pre) {
|
||||
return cols
|
||||
}
|
||||
|
||||
|
||||
function hasColoum(item,authList){
|
||||
function hasColoum (item, authList) {
|
||||
if (authList.includes(item.dataIndex)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
//权限无效时不做控制,有效时控制,只能控制 显示不显示
|
||||
//根据授权码前缀获取未授权的列信息
|
||||
export function getNoAuthCols(pre){
|
||||
if(!pre || pre.length==0){
|
||||
// 权限无效时不做控制,有效时控制,只能控制 显示不显示
|
||||
// 根据授权码前缀获取未授权的列信息
|
||||
export function getNoAuthCols (pre) {
|
||||
if (!pre || pre.length == 0) {
|
||||
return []
|
||||
}
|
||||
let permissionList = [];
|
||||
let allPermissionList = [];
|
||||
const permissionList = []
|
||||
const allPermissionList = []
|
||||
|
||||
//let authList = Vue.ls.get(USER_AUTH);
|
||||
let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");
|
||||
for (let auth of authList) {
|
||||
//显示策略,有效状态
|
||||
if(auth.type == '1'&&startWith(auth.action,pre)) {
|
||||
permissionList.push(substrPre(auth.action,pre));
|
||||
// let authList = Vue.ls.get(USER_AUTH);
|
||||
const authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || '[]')
|
||||
for (const auth of authList) {
|
||||
// 显示策略,有效状态
|
||||
if (auth.type == '1' && startWith(auth.action, pre)) {
|
||||
permissionList.push(substrPre(auth.action, pre))
|
||||
}
|
||||
}
|
||||
//console.log("页面禁用权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));
|
||||
let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]");
|
||||
for (let gauth of allAuthList) {
|
||||
//显示策略,有效状态
|
||||
if(gauth.type == '1'&&gauth.status == '1'&&startWith(gauth.action,pre)) {
|
||||
allPermissionList.push(substrPre(gauth.action,pre));
|
||||
// console.log("页面禁用权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));
|
||||
const allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || '[]')
|
||||
for (const gauth of allAuthList) {
|
||||
// 显示策略,有效状态
|
||||
if (gauth.type == '1' && gauth.status == '1' && startWith(gauth.action, pre)) {
|
||||
allPermissionList.push(substrPre(gauth.action, pre))
|
||||
}
|
||||
}
|
||||
const cols = allPermissionList.filter(item => {
|
||||
if (permissionList.includes(item)) {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
return true
|
||||
})
|
||||
return cols;
|
||||
return cols
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Online的行编辑按钮权限,添加至本地存储
|
||||
*/
|
||||
export function addOnlineBtAuth2Storage(pre, authList){
|
||||
let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]");
|
||||
let newAuthList = allAuthList.filter(item=>{
|
||||
if(!item.action){
|
||||
export function addOnlineBtAuth2Storage (pre, authList) {
|
||||
const allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || '[]')
|
||||
const newAuthList = allAuthList.filter(item => {
|
||||
if (!item.action) {
|
||||
return true
|
||||
}
|
||||
return item.action.indexOf(pre)<0
|
||||
return item.action.indexOf(pre) < 0
|
||||
})
|
||||
if(authList && authList.length>0){
|
||||
for(let item of authList){
|
||||
if (authList && authList.length > 0) {
|
||||
for (const item of authList) {
|
||||
newAuthList.push({
|
||||
action: pre+item,
|
||||
type:1,
|
||||
status:1
|
||||
action: pre + item,
|
||||
type: 1,
|
||||
status: 1
|
||||
})
|
||||
}
|
||||
let temp = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");
|
||||
let newArr = temp.filter(item=>{
|
||||
if(!item.action){
|
||||
const temp = JSON.parse(sessionStorage.getItem(USER_AUTH) || '[]')
|
||||
const newArr = temp.filter(item => {
|
||||
if (!item.action) {
|
||||
return true
|
||||
}
|
||||
return item.action.indexOf(pre)<0 || authList.indexOf(item.action.replace(pre, ''))<0
|
||||
return item.action.indexOf(pre) < 0 || authList.indexOf(item.action.replace(pre, '')) < 0
|
||||
})
|
||||
sessionStorage.setItem(USER_AUTH, JSON.stringify(newArr))
|
||||
}
|
||||
sessionStorage.setItem(SYS_BUTTON_AUTH, JSON.stringify(newAuthList))
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 额外增加方法【用于行编辑组件】
|
||||
* date: 2020-04-05
|
||||
@@ -242,32 +236,28 @@ export function addOnlineBtAuth2Storage(pre, authList){
|
||||
* @param pre
|
||||
* @returns {*[]}
|
||||
*/
|
||||
function getAllShowAndDisabledAuthCols(pre){
|
||||
//用户拥有的权限
|
||||
let userAuthList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");
|
||||
//全部权限配置
|
||||
let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]");
|
||||
function getAllShowAndDisabledAuthCols (pre) {
|
||||
// 用户拥有的权限
|
||||
const userAuthList = JSON.parse(sessionStorage.getItem(USER_AUTH) || '[]')
|
||||
// 全部权限配置
|
||||
const allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || '[]')
|
||||
|
||||
let newAllAuthList = allAuthList.map(function (item, index) {
|
||||
let hasAuthArray = userAuthList.filter(u => u.action===item.action );
|
||||
if (hasAuthArray && hasAuthArray.length>0) {
|
||||
item["isAuth"] = true
|
||||
const newAllAuthList = allAuthList.map(function (item, index) {
|
||||
const hasAuthArray = userAuthList.filter(u => u.action === item.action)
|
||||
if (hasAuthArray && hasAuthArray.length > 0) {
|
||||
item.isAuth = true
|
||||
}
|
||||
return item;
|
||||
return item
|
||||
})
|
||||
|
||||
return newAllAuthList;
|
||||
return newAllAuthList
|
||||
}
|
||||
|
||||
function startWith(str,pre) {
|
||||
if (pre == null || pre == "" || str==null|| str==""|| str.length == 0 || pre.length > str.length)
|
||||
return false;
|
||||
if (str.substr(0, pre.length) == pre)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
function startWith (str, pre) {
|
||||
if (pre == null || pre == '' || str == null || str == '' || str.length == 0 || pre.length > str.length) { return false }
|
||||
if (str.substr(0, pre.length) == pre) { return true } else { return false }
|
||||
}
|
||||
|
||||
function substrPre(str,pre) {
|
||||
return str.substr(pre.length);
|
||||
}
|
||||
function substrPre (str, pre) {
|
||||
return str.substr(pre.length)
|
||||
}
|
||||
|
||||
+33
-33
@@ -1,37 +1,37 @@
|
||||
const VueAxios = {
|
||||
vm: {},
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
install(Vue, router = {}, instance) {
|
||||
if (this.installed) {
|
||||
return;
|
||||
}
|
||||
this.installed = true;
|
||||
|
||||
if (!instance) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('You have to install axios');
|
||||
return;
|
||||
}
|
||||
|
||||
Vue.axios = instance;
|
||||
|
||||
Object.defineProperties(Vue.prototype, {
|
||||
axios: {
|
||||
get: function get() {
|
||||
return instance;
|
||||
}
|
||||
},
|
||||
$http: {
|
||||
get: function get() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
});
|
||||
vm: {},
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
install (Vue, router = {}, instance) {
|
||||
if (this.installed) {
|
||||
return
|
||||
}
|
||||
};
|
||||
this.installed = true
|
||||
|
||||
if (!instance) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('You have to install axios')
|
||||
return
|
||||
}
|
||||
|
||||
Vue.axios = instance
|
||||
|
||||
Object.defineProperties(Vue.prototype, {
|
||||
axios: {
|
||||
get: function get () {
|
||||
return instance
|
||||
}
|
||||
},
|
||||
$http: {
|
||||
get: function get () {
|
||||
return instance
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
VueAxios,
|
||||
// eslint-disable-next-line no-undef
|
||||
//instance as axios
|
||||
}
|
||||
VueAxios
|
||||
// eslint-disable-next-line no-undef
|
||||
// instance as axios
|
||||
}
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
//判断是否IE<11浏览器
|
||||
export function isIE() {
|
||||
// 判断是否IE<11浏览器
|
||||
export function isIE () {
|
||||
return navigator.userAgent.indexOf('compatible') > -1 && navigator.userAgent.indexOf('MSIE') > -1
|
||||
|
||||
}
|
||||
|
||||
export function isIE11() {
|
||||
export function isIE11 () {
|
||||
return navigator.userAgent.indexOf('Trident') > -1 && navigator.userAgent.indexOf('rv:11.0') > -1
|
||||
}
|
||||
|
||||
//判断是否IE的Edge浏览器
|
||||
export function isEdge() {
|
||||
// 判断是否IE的Edge浏览器
|
||||
export function isEdge () {
|
||||
return navigator.userAgent.indexOf('Edge') > -1 && !isIE()
|
||||
}
|
||||
|
||||
export function getIEVersion() {
|
||||
let userAgent = navigator.userAgent //取得浏览器的userAgent字符串
|
||||
let isIE = isIE()
|
||||
let isIE11 = isIE11()
|
||||
let isEdge = isEdge()
|
||||
export function getIEVersion () {
|
||||
const userAgent = navigator.userAgent // 取得浏览器的userAgent字符串
|
||||
const isIE = isIE()
|
||||
const isIE11 = isIE11()
|
||||
const isEdge = isEdge()
|
||||
|
||||
if (isIE) {
|
||||
let reIE = new RegExp('MSIE (\\d+\\.\\d+);')
|
||||
const reIE = new RegExp('MSIE (\\d+\\.\\d+);')
|
||||
reIE.test(userAgent)
|
||||
let fIEVersion = parseFloat(RegExp['$1'])
|
||||
const fIEVersion = parseFloat(RegExp.$1)
|
||||
if (fIEVersion === 7 || fIEVersion === 8 || fIEVersion === 9 || fIEVersion === 10) {
|
||||
return fIEVersion
|
||||
} else {
|
||||
return 6//IE版本<7
|
||||
return 6// IE版本<7
|
||||
}
|
||||
} else if (isEdge) {
|
||||
return 'edge'
|
||||
@@ -35,4 +34,4 @@ export function getIEVersion() {
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
import { getFileAccessHttpUrl } from '@/api/manage'
|
||||
const getFileName=(path)=>{
|
||||
if(path.lastIndexOf("\\")>=0){
|
||||
let reg=new RegExp("\\\\","g");
|
||||
path = path.replace(reg,"/");
|
||||
const getFileName = (path) => {
|
||||
if (path.lastIndexOf('\\') >= 0) {
|
||||
const reg = new RegExp('\\\\', 'g')
|
||||
path = path.replace(reg, '/')
|
||||
}
|
||||
return path.substring(path.lastIndexOf("/")+1);
|
||||
return path.substring(path.lastIndexOf('/') + 1)
|
||||
}
|
||||
|
||||
const uidGenerator=()=>{
|
||||
return '-'+parseInt(Math.random()*10000+1,10);
|
||||
const uidGenerator = () => {
|
||||
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
||||
}
|
||||
|
||||
const getFilePaths=(uploadFiles)=>{
|
||||
let arr = [];
|
||||
if(!uploadFiles){
|
||||
return ""
|
||||
const getFilePaths = (uploadFiles) => {
|
||||
const arr = []
|
||||
if (!uploadFiles) {
|
||||
return ''
|
||||
}
|
||||
for(let a=0;a<uploadFiles.length;a++){
|
||||
for (let a = 0; a < uploadFiles.length; a++) {
|
||||
arr.push(uploadFiles[a].response.message)
|
||||
}
|
||||
if(arr && arr.length>0){
|
||||
return arr.join(",")
|
||||
if (arr && arr.length > 0) {
|
||||
return arr.join(',')
|
||||
}
|
||||
return ""
|
||||
return ''
|
||||
}
|
||||
|
||||
const getUploadFileList=(paths)=>{
|
||||
if(!paths){
|
||||
return [];
|
||||
const getUploadFileList = (paths) => {
|
||||
if (!paths) {
|
||||
return []
|
||||
}
|
||||
let fileList = [];
|
||||
let arr = paths.split(",")
|
||||
for(let a=0;a<arr.length;a++){
|
||||
if(!arr[a]){
|
||||
const fileList = []
|
||||
const arr = paths.split(',')
|
||||
for (let a = 0; a < arr.length; a++) {
|
||||
if (!arr[a]) {
|
||||
continue
|
||||
}else{
|
||||
} else {
|
||||
fileList.push({
|
||||
uid:uidGenerator(),
|
||||
name:getFileName(arr[a]),
|
||||
uid: uidGenerator(),
|
||||
name: getFileName(arr[a]),
|
||||
status: 'done',
|
||||
url: getFileAccessHttpUrl(arr[a]),
|
||||
response:{
|
||||
status:"history",
|
||||
message:arr[a]
|
||||
response: {
|
||||
status: 'history',
|
||||
message: arr[a]
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return fileList;
|
||||
return fileList
|
||||
}
|
||||
export {getFilePaths,getUploadFileList}
|
||||
export { getFilePaths, getUploadFileList }
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
*/
|
||||
|
||||
/** 字段默认值官方示例:获取地址 */
|
||||
export function demoFieldDefVal_getAddress(arg) {
|
||||
export function demoFieldDefVal_getAddress (arg) {
|
||||
if (!arg) {
|
||||
arg = '朝阳区'
|
||||
}
|
||||
return `北京市 ${arg}`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ const enquireScreen = function (call) {
|
||||
enquireJs.register('screen and (max-width: 767.99px)', handler2)
|
||||
}
|
||||
|
||||
export default enquireScreen
|
||||
export default enquireScreen
|
||||
|
||||
@@ -4,7 +4,7 @@ import { axios } from '@/utils/request'
|
||||
* 获取RSA公钥
|
||||
* @returns {*}
|
||||
*/
|
||||
export function getRSAPublicKey() {
|
||||
export function getRSAPublicKey () {
|
||||
return axios({
|
||||
url: `/sys/getRSAPublicKey`,
|
||||
method: 'get',
|
||||
@@ -13,4 +13,4 @@ export function getRSAPublicKey() {
|
||||
'Content-Type': 'application/json;charset=UTF-8'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+1669
-1728
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
import md5 from 'md5'
|
||||
//签名密钥串(前后端要一致,正式发布请自行修改)
|
||||
const signatureSecret = "dd05f1c54d63749eda95f9fa6d49v442a";
|
||||
// 签名密钥串(前后端要一致,正式发布请自行修改)
|
||||
const signatureSecret = 'dd05f1c54d63749eda95f9fa6d49v442a'
|
||||
|
||||
export default class signMd5Utils {
|
||||
/**
|
||||
@@ -8,103 +8,102 @@ export default class signMd5Utils {
|
||||
* @param jsonObj 发送参数
|
||||
*/
|
||||
|
||||
static sortAsc(jsonObj) {
|
||||
let arr = new Array();
|
||||
let num = 0;
|
||||
for (let i in jsonObj) {
|
||||
arr[num] = i;
|
||||
num++;
|
||||
static sortAsc (jsonObj) {
|
||||
const arr = new Array()
|
||||
let num = 0
|
||||
for (const i in jsonObj) {
|
||||
arr[num] = i
|
||||
num++
|
||||
}
|
||||
let sortArr = arr.sort();
|
||||
let sortObj = {};
|
||||
for (let i in sortArr) {
|
||||
sortObj[sortArr[i]] = jsonObj[sortArr[i]];
|
||||
const sortArr = arr.sort()
|
||||
const sortObj = {}
|
||||
for (const i in sortArr) {
|
||||
sortObj[sortArr[i]] = jsonObj[sortArr[i]]
|
||||
}
|
||||
return sortObj;
|
||||
return sortObj
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param url 请求的url,应该包含请求参数(url的?后面的参数)
|
||||
* @param requestParams 请求参数(POST的JSON参数)
|
||||
* @returns {string} 获取签名
|
||||
*/
|
||||
static getSign(url, requestParams) {
|
||||
let urlParams = this.parseQueryString(url);
|
||||
let jsonObj = this.mergeObject(urlParams, requestParams);
|
||||
//console.log("sign jsonObj: ",jsonObj)
|
||||
let requestBody = this.sortAsc(jsonObj);
|
||||
console.log("sign requestBody: ",requestBody)
|
||||
return md5(JSON.stringify(requestBody) + signatureSecret).toUpperCase();
|
||||
static getSign (url, requestParams) {
|
||||
const urlParams = this.parseQueryString(url)
|
||||
const jsonObj = this.mergeObject(urlParams, requestParams)
|
||||
// console.log("sign jsonObj: ",jsonObj)
|
||||
const requestBody = this.sortAsc(jsonObj)
|
||||
console.log('sign requestBody: ', requestBody)
|
||||
return md5(JSON.stringify(requestBody) + signatureSecret).toUpperCase()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url 请求的url
|
||||
* @returns {{}} 将url中请求参数组装成json对象(url的?后面的参数)
|
||||
*/
|
||||
static parseQueryString(url) {
|
||||
let urlReg = /^[^\?]+\?([\w\W]+)$/,
|
||||
paramReg = /([^&=]+)=([\w\W]*?)(&|$|#)/g,
|
||||
urlArray = urlReg.exec(url),
|
||||
result = {};
|
||||
static parseQueryString (url) {
|
||||
const urlReg = /^[^\?]+\?([\w\W]+)$/
|
||||
const paramReg = /([^&=]+)=([\w\W]*?)(&|$|#)/g
|
||||
const urlArray = urlReg.exec(url)
|
||||
const result = {}
|
||||
|
||||
// 获取URL上最后带逗号的参数变量 sys/dict/getDictItems/sys_user,realname,username
|
||||
//【这边条件没有encode】带条件参数例子:/sys/dict/getDictItems/sys_user,realname,id,username!='admin'%20order%20by%20create_time
|
||||
let lastpathVariable = url.substring(url.lastIndexOf('/') + 1);
|
||||
if(lastpathVariable.includes(",")){
|
||||
if(lastpathVariable.includes("?")){
|
||||
lastpathVariable = lastpathVariable.substring(0, lastpathVariable.indexOf("?"));
|
||||
// 【这边条件没有encode】带条件参数例子:/sys/dict/getDictItems/sys_user,realname,id,username!='admin'%20order%20by%20create_time
|
||||
let lastpathVariable = url.substring(url.lastIndexOf('/') + 1)
|
||||
if (lastpathVariable.includes(',')) {
|
||||
if (lastpathVariable.includes('?')) {
|
||||
lastpathVariable = lastpathVariable.substring(0, lastpathVariable.indexOf('?'))
|
||||
}
|
||||
//解决Sign 签名校验失败 #2728
|
||||
result["x-path-variable"] = decodeURIComponent(lastpathVariable);
|
||||
// 解决Sign 签名校验失败 #2728
|
||||
result['x-path-variable'] = decodeURIComponent(lastpathVariable)
|
||||
}
|
||||
if (urlArray && urlArray[1]) {
|
||||
let paramString = urlArray[1], paramResult;
|
||||
const paramString = urlArray[1]; let paramResult
|
||||
while ((paramResult = paramReg.exec(paramString)) != null) {
|
||||
//数字值转为string类型,前后端加密规则保持一致
|
||||
if(this.myIsNaN(paramResult[2])){
|
||||
// 数字值转为string类型,前后端加密规则保持一致
|
||||
if (this.myIsNaN(paramResult[2])) {
|
||||
paramResult[2] = paramResult[2].toString()
|
||||
}
|
||||
result[paramResult[1]] = paramResult[2];
|
||||
result[paramResult[1]] = paramResult[2]
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {*} 将两个对象合并成一个
|
||||
*/
|
||||
static mergeObject(objectOne, objectTwo) {
|
||||
static mergeObject (objectOne, objectTwo) {
|
||||
if (objectTwo && Object.keys(objectTwo).length > 0) {
|
||||
for (let key in objectTwo) {
|
||||
for (const key in objectTwo) {
|
||||
if (objectTwo.hasOwnProperty(key) === true) {
|
||||
//数字值转为string类型,前后端加密规则保持一致
|
||||
if(this.myIsNaN(objectTwo[key])){
|
||||
// 数字值转为string类型,前后端加密规则保持一致
|
||||
if (this.myIsNaN(objectTwo[key])) {
|
||||
objectTwo[key] = objectTwo[key].toString()
|
||||
}
|
||||
objectOne[key] = objectTwo[key];
|
||||
objectOne[key] = objectTwo[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
return objectOne;
|
||||
return objectOne
|
||||
}
|
||||
|
||||
static urlEncode(param, key, encode) {
|
||||
if (param == null) return '';
|
||||
let paramStr = '';
|
||||
let t = typeof (param);
|
||||
static urlEncode (param, key, encode) {
|
||||
if (param == null) return ''
|
||||
let paramStr = ''
|
||||
const t = typeof (param)
|
||||
if (t == 'string' || t == 'number' || t == 'boolean') {
|
||||
paramStr += '&' + key + '=' + ((encode == null || encode) ? encodeURIComponent(param) : param);
|
||||
paramStr += '&' + key + '=' + ((encode == null || encode) ? encodeURIComponent(param) : param)
|
||||
} else {
|
||||
for (let i in param) {
|
||||
let k = key == null ? i : key + (param instanceof Array ? '[' + i + ']' : '.' + i);
|
||||
paramStr += this.urlEncode(param[i], k, encode);
|
||||
for (const i in param) {
|
||||
const k = key == null ? i : key + (param instanceof Array ? '[' + i + ']' : '.' + i)
|
||||
paramStr += this.urlEncode(param[i], k, encode)
|
||||
}
|
||||
}
|
||||
return paramStr;
|
||||
return paramStr
|
||||
};
|
||||
|
||||
static getDateTimeToString() {
|
||||
static getDateTimeToString () {
|
||||
const date_ = new Date()
|
||||
const year = date_.getFullYear()
|
||||
let month = date_.getMonth() + 1
|
||||
@@ -121,9 +120,9 @@ export default class signMd5Utils {
|
||||
if (msecs < 10) secs = '0' + msecs
|
||||
return year + '' + month + '' + day + '' + hours + '' + mins + '' + secs
|
||||
}
|
||||
// true:数值型的,false:非数值型
|
||||
static myIsNaN(value) {
|
||||
return typeof value === 'number' && !isNaN(value);
|
||||
}
|
||||
|
||||
}
|
||||
// true:数值型的,false:非数值型
|
||||
static myIsNaN (value) {
|
||||
return typeof value === 'number' && !isNaN(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import Vue from "vue";
|
||||
import * as dayjs from "dayjs";
|
||||
import Vue from 'vue'
|
||||
import * as dayjs from 'dayjs'
|
||||
|
||||
Vue.filter('NumberFormat', function (value) {
|
||||
if (!value) {
|
||||
return '0'
|
||||
}
|
||||
let intPartFormat = value.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') //将整数部分逢三一断
|
||||
const intPartFormat = value.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') // 将整数部分逢三一断
|
||||
return intPartFormat
|
||||
})
|
||||
|
||||
Vue.filter('dayjs', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
|
||||
Vue.filter('dayjs', function (dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
|
||||
return dayjs(dataStr).format(pattern)
|
||||
})
|
||||
|
||||
Vue.filter('moment', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
|
||||
Vue.filter('moment', function (dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
|
||||
return dayjs(dataStr).format(pattern)
|
||||
})
|
||||
|
||||
/** 字符串超长截取省略号显示 */
|
||||
Vue.filter('ellipsis', function (value, vlength = 25) {
|
||||
if(!value){
|
||||
return "";
|
||||
if (!value) {
|
||||
return ''
|
||||
}
|
||||
if (value.length > vlength) {
|
||||
return value.slice(0, vlength) + '...'
|
||||
}
|
||||
return value
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,131 +1,130 @@
|
||||
import { USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types"
|
||||
import { USER_AUTH, SYS_BUTTON_AUTH } from '@/store/mutation-types'
|
||||
|
||||
const hasPermission = {
|
||||
install (Vue, options) {
|
||||
Vue.directive('has', {
|
||||
inserted: (el, binding, vnode)=>{
|
||||
//console.time()
|
||||
//节点权限处理,如果命中则不进行全局权限处理
|
||||
if(!filterNodePermission(el, binding, vnode)){
|
||||
filterGlobalPermission(el, binding, vnode);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
install (Vue, options) {
|
||||
Vue.directive('has', {
|
||||
inserted: (el, binding, vnode) => {
|
||||
// console.time()
|
||||
// 节点权限处理,如果命中则不进行全局权限处理
|
||||
if (!filterNodePermission(el, binding, vnode)) {
|
||||
filterGlobalPermission(el, binding, vnode)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程节点权限控制
|
||||
*/
|
||||
export function filterNodePermission(el, binding, vnode) {
|
||||
let permissionList = [];
|
||||
export function filterNodePermission (el, binding, vnode) {
|
||||
const permissionList = []
|
||||
try {
|
||||
let obj = vnode.context.$props.formData;
|
||||
const obj = vnode.context.$props.formData
|
||||
if (obj) {
|
||||
let bpmList = obj.permissionList;
|
||||
for (let bpm of bpmList) {
|
||||
if(bpm.type != '2') {
|
||||
permissionList.push(bpm);
|
||||
const bpmList = obj.permissionList
|
||||
for (const bpm of bpmList) {
|
||||
if (bpm.type != '2') {
|
||||
permissionList.push(bpm)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} catch (e) {
|
||||
//console.log("页面权限异常----", e);
|
||||
// console.log("页面权限异常----", e);
|
||||
}
|
||||
if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {
|
||||
//el.parentNode.removeChild(el)
|
||||
return false;
|
||||
if (permissionList === null || permissionList === '' || permissionList === undefined || permissionList.length <= 0) {
|
||||
// el.parentNode.removeChild(el)
|
||||
return false
|
||||
}
|
||||
|
||||
console.log("流程节点页面权限--NODE--");
|
||||
let permissions = [];
|
||||
for (let item of permissionList) {
|
||||
if(item.type != '2') {
|
||||
permissions.push(item.action);
|
||||
console.log('流程节点页面权限--NODE--')
|
||||
const permissions = []
|
||||
for (const item of permissionList) {
|
||||
if (item.type != '2') {
|
||||
permissions.push(item.action)
|
||||
}
|
||||
}
|
||||
//console.log("页面权限----"+permissions);
|
||||
//console.log("页面权限----"+binding.value);
|
||||
// console.log("页面权限----"+permissions);
|
||||
// console.log("页面权限----"+binding.value);
|
||||
if (!permissions.includes(binding.value)) {
|
||||
//el.parentNode.removeChild(el)
|
||||
return false;
|
||||
}else{
|
||||
for (let item2 of permissionList) {
|
||||
if(binding.value === item2.action){
|
||||
return true;
|
||||
// el.parentNode.removeChild(el)
|
||||
return false
|
||||
} else {
|
||||
for (const item2 of permissionList) {
|
||||
if (binding.value === item2.action) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局权限控制
|
||||
*/
|
||||
export function filterGlobalPermission(el, binding, vnode) {
|
||||
export function filterGlobalPermission (el, binding, vnode) {
|
||||
const permissionList = []
|
||||
const allPermissionList = []
|
||||
|
||||
let permissionList = [];
|
||||
let allPermissionList = [];
|
||||
|
||||
//let authList = Vue.ls.get(USER_AUTH);
|
||||
let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");
|
||||
for (let auth of authList) {
|
||||
if(auth.type != '2') {
|
||||
permissionList.push(auth);
|
||||
// let authList = Vue.ls.get(USER_AUTH);
|
||||
const authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || '[]')
|
||||
for (const 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 (let gauth of allAuthList) {
|
||||
if(gauth.type != '2') {
|
||||
allPermissionList.push(gauth);
|
||||
// console.log("页面权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));
|
||||
const allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || '[]')
|
||||
for (const gauth of allAuthList) {
|
||||
if (gauth.type != '2') {
|
||||
allPermissionList.push(gauth)
|
||||
}
|
||||
}
|
||||
//设置全局配置是否有命中
|
||||
let invalidFlag = false;//无效命中
|
||||
if(allPermissionList != null && allPermissionList != "" && allPermissionList != undefined && allPermissionList.length > 0){
|
||||
for (let itemG of allPermissionList) {
|
||||
if(binding.value === itemG.action){
|
||||
if(itemG.status == '0'){
|
||||
invalidFlag = true;
|
||||
break;
|
||||
// 设置全局配置是否有命中
|
||||
let invalidFlag = false// 无效命中
|
||||
if (allPermissionList != null && allPermissionList != '' && allPermissionList != undefined && allPermissionList.length > 0) {
|
||||
for (const itemG of allPermissionList) {
|
||||
if (binding.value === itemG.action) {
|
||||
if (itemG.status == '0') {
|
||||
invalidFlag = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(invalidFlag){
|
||||
return;
|
||||
if (invalidFlag) {
|
||||
return
|
||||
}
|
||||
if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {
|
||||
el.parentNode.removeChild(el);
|
||||
return;
|
||||
if (permissionList === null || permissionList === '' || permissionList === undefined || permissionList.length <= 0) {
|
||||
el.parentNode.removeChild(el)
|
||||
return
|
||||
}
|
||||
let permissions = [];
|
||||
for (let item of permissionList) {
|
||||
//权限策略1显示2禁用
|
||||
if(item.type != '2'){
|
||||
//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]);
|
||||
const permissions = []
|
||||
for (const item of permissionList) {
|
||||
// 权限策略1显示2禁用
|
||||
if (item.type != '2') {
|
||||
// update--begin--autor:wangshuai-----date:20200729------for:按钮权限,授权标识的提示信息是多个用逗号分隔逻辑处理 gitee#I1OUGU-------
|
||||
if (item.action) {
|
||||
if (item.action.includes(',')) {
|
||||
const 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);
|
||||
} else {
|
||||
permissions.push(item.action)
|
||||
}
|
||||
}
|
||||
//update--end--autor:wangshuai-----date:20200729------for:按钮权限,授权标识的提示信息是多个用逗号分隔逻辑处理 gitee#I1OUGU------
|
||||
// update--end--autor:wangshuai-----date:20200729------for:按钮权限,授权标识的提示信息是多个用逗号分隔逻辑处理 gitee#I1OUGU------
|
||||
}
|
||||
}
|
||||
if (!permissions.includes(binding.value)) {
|
||||
el.parentNode.removeChild(el);
|
||||
el.parentNode.removeChild(el)
|
||||
}
|
||||
}
|
||||
|
||||
export default hasPermission;
|
||||
export default hasPermission
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// import Vue from 'vue'
|
||||
import { mapState } from "vuex";
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
// const mixinsComputed = Vue.config.optionMergeStrategies.computed
|
||||
// const mixinsMethods = Vue.config.optionMergeStrategies.methods
|
||||
@@ -11,7 +11,7 @@ const mixin = {
|
||||
navTheme: state => state.app.theme,
|
||||
primaryColor: state => state.app.color,
|
||||
colorWeak: state => state.app.weak,
|
||||
multipage: state => state.app.multipage,//多页签设置
|
||||
multipage: state => state.app.multipage, // 多页签设置
|
||||
fixedHeader: state => state.app.fixedHeader,
|
||||
fixSiderbar: state => state.app.fixSiderbar,
|
||||
contentWidth: state => state.app.contentWidth,
|
||||
@@ -24,7 +24,7 @@ const mixin = {
|
||||
const mixinDevice = {
|
||||
computed: {
|
||||
...mapState({
|
||||
device: state => state.app.device,
|
||||
device: state => state.app.device
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
@@ -37,4 +37,4 @@ const mixinDevice = {
|
||||
}
|
||||
}
|
||||
|
||||
export { mixin, mixinDevice }
|
||||
export { mixin, mixinDevice }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export function actionToObject(json) {
|
||||
export function actionToObject (json) {
|
||||
try {
|
||||
return JSON.parse(json)
|
||||
} catch (e) {
|
||||
console.log('err', e.message)
|
||||
}
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/**
|
||||
* 该文件截取自 "ant-design-vue/es/_util/props-util.js" 文件,并对其做出特殊修改
|
||||
*/
|
||||
function classNames() {
|
||||
let classes = []
|
||||
function classNames () {
|
||||
const classes = []
|
||||
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let arg = arguments[i]
|
||||
const arg = arguments[i]
|
||||
if (!arg) continue
|
||||
|
||||
let argType = typeof arg
|
||||
const argType = typeof arg
|
||||
|
||||
if (argType === 'string' || argType === 'number') {
|
||||
classes.push(arg)
|
||||
} else if (Array.isArray(arg) && arg.length) {
|
||||
let inner = classNames.apply(null, arg)
|
||||
const inner = classNames.apply(null, arg)
|
||||
if (inner) {
|
||||
classes.push(inner)
|
||||
}
|
||||
} else if (argType === 'object') {
|
||||
for (let key in arg) {
|
||||
for (const key in arg) {
|
||||
if (arg.hasOwnProperty(key) && arg[key]) {
|
||||
classes.push(key)
|
||||
}
|
||||
@@ -30,18 +30,17 @@ function classNames() {
|
||||
|
||||
const camelizeRE = /-(\w)/g
|
||||
|
||||
function camelize(str) {
|
||||
function camelize (str) {
|
||||
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''))
|
||||
}
|
||||
|
||||
|
||||
function objectCamelize(obj) {
|
||||
let res = {}
|
||||
function objectCamelize (obj) {
|
||||
const res = {}
|
||||
Object.keys(obj).forEach(k => (res[camelize(k)] = obj[k]))
|
||||
return res
|
||||
}
|
||||
|
||||
function parseStyleText(cssText = '', camel) {
|
||||
function parseStyleText (cssText = '', camel) {
|
||||
const res = {}
|
||||
const listDelimiter = /;(?![^(]*\))/g
|
||||
const propertyDelimiter = /:(.+)/
|
||||
@@ -57,7 +56,7 @@ function parseStyleText(cssText = '', camel) {
|
||||
return res
|
||||
}
|
||||
|
||||
export function getClass(ele) {
|
||||
export function getClass (ele) {
|
||||
let data = {}
|
||||
if (ele.data) {
|
||||
data = ele.data
|
||||
@@ -87,8 +86,7 @@ export function getClass(ele) {
|
||||
return cls
|
||||
}
|
||||
|
||||
export function getStyle(ele, camel) {
|
||||
|
||||
export function getStyle (ele, camel) {
|
||||
getClass(ele)
|
||||
|
||||
let data = {}
|
||||
@@ -112,4 +110,3 @@ export function getStyle(ele, camel) {
|
||||
}
|
||||
return { ...staticStyle, ...style }
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import axios from 'axios'
|
||||
import store from '@/store'
|
||||
import { VueAxios } from './axios'
|
||||
import router from '@/router/index'
|
||||
import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types"
|
||||
import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
|
||||
|
||||
/**
|
||||
* 【指定 axios的 baseURL】
|
||||
@@ -11,35 +11,35 @@ import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types"
|
||||
* 则映射后端域名,通过 vue.config.js
|
||||
* @type {*|string}
|
||||
*/
|
||||
let apiBaseUrl = window._CONFIG['domianURL'] || "/jero-boot";
|
||||
//console.log("apiBaseUrl= ",apiBaseUrl)
|
||||
const apiBaseUrl = window._CONFIG.domianURL || '/jero-boot'
|
||||
// console.log("apiBaseUrl= ",apiBaseUrl)
|
||||
// 创建 axios 实例
|
||||
const service = axios.create({
|
||||
//baseURL: '/jero-boot',
|
||||
// baseURL: '/jero-boot',
|
||||
baseURL: apiBaseUrl, // api base_url
|
||||
timeout: 10000 // 请求超时时间
|
||||
})
|
||||
|
||||
const err = (error) => {
|
||||
if (error.response) {
|
||||
let data = error.response.data
|
||||
const data = error.response.data
|
||||
const token = Vue.ls.get(ACCESS_TOKEN)
|
||||
console.log("------异常响应------",token)
|
||||
console.log("------异常响应------",error.response.status)
|
||||
console.log('------异常响应------', token)
|
||||
console.log('------异常响应------', error.response.status)
|
||||
switch (error.response.status) {
|
||||
case 403:
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '拒绝访问',duration: 4})
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '拒绝访问', duration: 4 })
|
||||
break
|
||||
case 500:
|
||||
console.log("------error.response------",error.response)
|
||||
console.log('------error.response------', error.response)
|
||||
// update-begin- --- author:liusq ------ date:20200910 ---- for:处理Blob情况----
|
||||
let type=error.response.request.responseType;
|
||||
if(type === 'blob'){
|
||||
blobToJson(data);
|
||||
break;
|
||||
const type = error.response.request.responseType
|
||||
if (type === 'blob') {
|
||||
blobToJson(data)
|
||||
break
|
||||
}
|
||||
// update-end- --- author:liusq ------ date:20200910 ---- for:处理Blob情况----
|
||||
if(token && data.includes("Token失效")){
|
||||
if (token && data.includes('Token失效')) {
|
||||
// update-begin- --- author:scott ------ date:20190225 ---- for:Token失效采用弹框模式,不直接跳转----
|
||||
if (/wxwork|dingtalk/i.test(navigator.userAgent)) {
|
||||
Vue.prototype.$Jmessage.loading('登录已过期,正在重新登陆', 0)
|
||||
@@ -58,13 +58,13 @@ const err = (error) => {
|
||||
}
|
||||
break
|
||||
case 404:
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description:'很抱歉,资源未找到!',duration: 4})
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '很抱歉,资源未找到!', duration: 4 })
|
||||
break
|
||||
case 504:
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时'})
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时' })
|
||||
break
|
||||
case 401:
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description:'未授权,请重新登录',duration: 4})
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '未授权,请重新登录', duration: 4 })
|
||||
if (token) {
|
||||
store.dispatch('Logout').then(() => {
|
||||
setTimeout(() => {
|
||||
@@ -83,19 +83,19 @@ const err = (error) => {
|
||||
}
|
||||
} else if (error.message) {
|
||||
if (error.message.includes('timeout')) {
|
||||
Vue.prototype.$Jnotification.error({message: '系统提示', description: '网络超时'})
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时' })
|
||||
} else {
|
||||
Vue.prototype.$Jnotification.error({message: '系统提示', description: error.message})
|
||||
Vue.prototype.$Jnotification.error({ message: '系统提示', description: error.message })
|
||||
}
|
||||
}
|
||||
return Promise.reject(error)
|
||||
};
|
||||
}
|
||||
|
||||
// request interceptor
|
||||
service.interceptors.request.use(config => {
|
||||
const token = Vue.ls.get(ACCESS_TOKEN)
|
||||
if (token) {
|
||||
config.headers[ 'X-Access-Token' ] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
|
||||
config.headers['X-Access-Token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
|
||||
}
|
||||
|
||||
// update-begin--author:sunjianlei---date:20200723---for 如果当前在low-app环境,并且携带了appId,就向Header里传递appId
|
||||
@@ -105,23 +105,23 @@ service.interceptors.request.use(config => {
|
||||
}
|
||||
// update-end--author:sunjianlei---date:20200723---for 如果当前在low-app环境,并且携带了appId,就向Header里传递appId
|
||||
|
||||
//update-begin-author:taoyan date:2020707 for:多租户
|
||||
// update-begin-author:taoyan date:2020707 for:多租户
|
||||
let tenantid = Vue.ls.get(TENANT_ID)
|
||||
if (!tenantid) {
|
||||
tenantid = 0;
|
||||
tenantid = 0
|
||||
}
|
||||
config.headers[ 'tenant-id' ] = tenantid
|
||||
//update-end-author:taoyan date:2020707 for:多租户
|
||||
if(config.method=='get'){
|
||||
if(config.url.indexOf("sys/dict/getDictItems")<0){
|
||||
config.headers['tenant-id'] = tenantid
|
||||
// update-end-author:taoyan date:2020707 for:多租户
|
||||
if (config.method == 'get') {
|
||||
if (config.url.indexOf('sys/dict/getDictItems') < 0) {
|
||||
config.params = {
|
||||
_t: Date.parse(new Date())/1000,
|
||||
_t: Date.parse(new Date()) / 1000,
|
||||
...config.params
|
||||
}
|
||||
}
|
||||
}
|
||||
return config
|
||||
},(error) => {
|
||||
}, (error) => {
|
||||
return Promise.reject(error)
|
||||
})
|
||||
|
||||
@@ -140,16 +140,16 @@ const installer = {
|
||||
* Blob解析
|
||||
* @param data
|
||||
*/
|
||||
function blobToJson(data) {
|
||||
let fileReader = new FileReader();
|
||||
let token = Vue.ls.get(ACCESS_TOKEN);
|
||||
fileReader.onload = function() {
|
||||
function blobToJson (data) {
|
||||
const fileReader = new FileReader()
|
||||
const token = Vue.ls.get(ACCESS_TOKEN)
|
||||
fileReader.onload = function () {
|
||||
try {
|
||||
let jsonData = JSON.parse(this.result); // 说明是普通对象数据,后台转换失败
|
||||
console.log("jsonData",jsonData)
|
||||
const jsonData = JSON.parse(this.result) // 说明是普通对象数据,后台转换失败
|
||||
console.log('jsonData', jsonData)
|
||||
if (jsonData.status === 500) {
|
||||
console.log("token----------》",token)
|
||||
if(token && jsonData.message.includes("Token失效")){
|
||||
console.log('token----------》', token)
|
||||
if (token && jsonData.message.includes('Token失效')) {
|
||||
Modal.error({
|
||||
title: '登录已过期',
|
||||
content: '很抱歉,登录已过期,请重新登录',
|
||||
@@ -166,13 +166,13 @@ function blobToJson(data) {
|
||||
}
|
||||
} catch (err) {
|
||||
// 解析成对象失败,说明是正常的文件流
|
||||
console.log("blob解析fileReader返回err",err)
|
||||
console.log('blob解析fileReader返回err', err)
|
||||
}
|
||||
};
|
||||
}
|
||||
fileReader.readAsText(data)
|
||||
}
|
||||
|
||||
export {
|
||||
installer as VueAxios,
|
||||
service as axios
|
||||
}
|
||||
}
|
||||
|
||||
+14
-17
@@ -1,5 +1,5 @@
|
||||
const validateMobile = (rule, value, callback) => {
|
||||
let reg = /^1(3|4|5|7|8)\d{9}$/
|
||||
const reg = /^1(3|4|5|7|8)\d{9}$/
|
||||
if (!reg.test(value)) {
|
||||
callback('请输入正确手机号')
|
||||
} else {
|
||||
@@ -7,8 +7,8 @@ const validateMobile = (rule, value, callback) => {
|
||||
}
|
||||
}
|
||||
const validateEn = (rule, value, callback) => {
|
||||
let reg = /^[_a-zA-Z0-9]+$/
|
||||
let reg2 = /^.{4,18}$/
|
||||
const reg = /^[_a-zA-Z0-9]+$/
|
||||
const reg2 = /^.{4,18}$/
|
||||
// 长度为6到18个字符
|
||||
if (value !== '' && !reg.test(value)) {
|
||||
callback('只允许字母、数字、下划线')
|
||||
@@ -66,30 +66,30 @@ export const rules = {
|
||||
// 255位以内的字符
|
||||
char0to255: /^.{0,255}$/,
|
||||
char0to255Msg: '请输入255位以内的字符',
|
||||
required: function(min, max) {
|
||||
let rule = [{ required: true, message: '', trigger: 'blur' }]
|
||||
required: function (min, max) {
|
||||
const rule = [{ required: true, message: '', trigger: 'blur' }]
|
||||
if (min) {
|
||||
let r = { min: min, message: '最小长度' + min + '位字符' }
|
||||
const r = { min: min, message: '最小长度' + min + '位字符' }
|
||||
rule.push(r)
|
||||
}
|
||||
if (max) {
|
||||
let m = { max: max, message: '最大长度' + max + '位字符' }
|
||||
const m = { max: max, message: '最大长度' + max + '位字符' }
|
||||
rule.push(m)
|
||||
}
|
||||
return rule
|
||||
},
|
||||
select: function() {
|
||||
let rule = [{ required: true, message: '', trigger: 'change' }]
|
||||
select: function () {
|
||||
const rule = [{ required: true, message: '', trigger: 'change' }]
|
||||
return rule
|
||||
},
|
||||
checked: function(min, max) {
|
||||
let rule = [{ required: true, type: 'array', message: '', trigger: 'change' }]
|
||||
checked: function (min, max) {
|
||||
const rule = [{ required: true, type: 'array', message: '', trigger: 'change' }]
|
||||
if (min) {
|
||||
let r = { type: 'array', min: min, message: '最少选择' + min + '项' }
|
||||
const r = { type: 'array', min: min, message: '最少选择' + min + '项' }
|
||||
rule.push(r)
|
||||
}
|
||||
if (max) {
|
||||
let m = { type: 'array', max: max, message: '最多选择' + max + '项' }
|
||||
const m = { type: 'array', max: max, message: '最多选择' + max + '项' }
|
||||
rule.push(m)
|
||||
}
|
||||
return rule
|
||||
@@ -98,13 +98,10 @@ export const rules = {
|
||||
/**
|
||||
* @description 排序值验证,排序值不可以大于255
|
||||
*/
|
||||
export const validateOrder = function(rule, value, callback) {
|
||||
export const validateOrder = function (rule, value, callback) {
|
||||
if (parseInt(value) > 255) {
|
||||
return callback(new Error('排序值不可以大于255'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,21 +7,21 @@
|
||||
*/
|
||||
export const setStore = (name, content, maxAge = null) => {
|
||||
if (!global.window || !name) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof content !== 'string') {
|
||||
content = JSON.stringify(content)
|
||||
}
|
||||
|
||||
let storage = global.window.localStorage
|
||||
const storage = global.window.localStorage
|
||||
|
||||
storage.setItem(name, content)
|
||||
if (maxAge && !isNaN(parseInt(maxAge))) {
|
||||
let timeout = parseInt(new Date().getTime() / 1000)
|
||||
const timeout = parseInt(new Date().getTime() / 1000)
|
||||
storage.setItem(`${name}_expire`, timeout + maxAge)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage
|
||||
@@ -31,16 +31,16 @@ export const setStore = (name, content, maxAge = null) => {
|
||||
*/
|
||||
export const getStore = name => {
|
||||
if (!global.window || !name) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
let content = window.localStorage.getItem(name)
|
||||
let _expire = window.localStorage.getItem(`${name}_expire`)
|
||||
const content = window.localStorage.getItem(name)
|
||||
const _expire = window.localStorage.getItem(`${name}_expire`)
|
||||
|
||||
if (_expire) {
|
||||
let now = parseInt(new Date().getTime() / 1000)
|
||||
const now = parseInt(new Date().getTime() / 1000)
|
||||
if (now > _expire) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export const getStore = name => {
|
||||
} catch (e) {
|
||||
return content
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear storage
|
||||
@@ -58,21 +58,20 @@ export const getStore = name => {
|
||||
*/
|
||||
export const clearStore = name => {
|
||||
if (!global.window || !name) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
window.localStorage.removeItem(name)
|
||||
window.localStorage.removeItem(`${name}_expire`)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all storage
|
||||
*/
|
||||
export const clearAll = () => {
|
||||
if (!global.window || !name) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
window.localStorage.clear()
|
||||
}
|
||||
|
||||
|
||||
+146
-149
@@ -4,23 +4,23 @@ import { isURL } from '@/utils/validate'
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
import onlineCommons from '@/components/onlineForm/onlineForm'
|
||||
//
|
||||
export function timeFix() {
|
||||
export function timeFix () {
|
||||
const time = new Date()
|
||||
const hour = time.getHours()
|
||||
return hour < 9 ? '早上好' : (hour <= 11 ? '上午好' : (hour <= 13 ? '中午好' : (hour < 20 ? '下午好' : '晚上好')))
|
||||
}
|
||||
|
||||
export function welcome() {
|
||||
export function welcome () {
|
||||
const arr = ['休息一会儿吧', '准备吃什么呢?', '要不要打一把 DOTA', '我猜你可能累了']
|
||||
let index = Math.floor((Math.random()*arr.length))
|
||||
const index = Math.floor((Math.random() * arr.length))
|
||||
return arr[index]
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发 window.resize
|
||||
*/
|
||||
export function triggerWindowResizeEvent() {
|
||||
let event = document.createEvent('HTMLEvents')
|
||||
export function triggerWindowResizeEvent () {
|
||||
const event = document.createEvent('HTMLEvents')
|
||||
event.initEvent('resize', true, true)
|
||||
event.eventType = 'message'
|
||||
window.dispatchEvent(event)
|
||||
@@ -31,18 +31,18 @@ export function triggerWindowResizeEvent() {
|
||||
* @param obj
|
||||
* @returns {*}
|
||||
*/
|
||||
export function filterObj(obj) {
|
||||
if (!(typeof obj == 'object')) {
|
||||
return;
|
||||
export function filterObj (obj) {
|
||||
if (!(typeof obj === 'object')) {
|
||||
return
|
||||
}
|
||||
|
||||
for ( let key in obj) {
|
||||
if (obj.hasOwnProperty(key)
|
||||
&& (obj[key] == null || obj[key] == undefined || obj[key] === '')) {
|
||||
delete obj[key];
|
||||
for (const key in obj) {
|
||||
if (obj.hasOwnProperty(key) &&
|
||||
(obj[key] == null || obj[key] == undefined || obj[key] === '')) {
|
||||
delete obj[key]
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,130 +51,130 @@ export function filterObj(obj) {
|
||||
* @param fmt
|
||||
* @returns {*}
|
||||
*/
|
||||
export function formatDate(value, fmt) {
|
||||
let regPos = /^\d+(\.\d+)?$/;
|
||||
if(regPos.test(value)){
|
||||
//如果是数字
|
||||
let getDate = new Date(value);
|
||||
let o = {
|
||||
export function formatDate (value, fmt) {
|
||||
const regPos = /^\d+(\.\d+)?$/
|
||||
if (regPos.test(value)) {
|
||||
// 如果是数字
|
||||
const getDate = new Date(value)
|
||||
const o = {
|
||||
'M+': getDate.getMonth() + 1,
|
||||
'd+': getDate.getDate(),
|
||||
'h+': getDate.getHours(),
|
||||
'm+': getDate.getMinutes(),
|
||||
's+': getDate.getSeconds(),
|
||||
'q+': Math.floor((getDate.getMonth() + 3) / 3),
|
||||
'S': getDate.getMilliseconds()
|
||||
};
|
||||
S: getDate.getMilliseconds()
|
||||
}
|
||||
if (/(y+)/.test(fmt)) {
|
||||
fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length))
|
||||
}
|
||||
for (let k in o) {
|
||||
for (const k in o) {
|
||||
if (new RegExp('(' + k + ')').test(fmt)) {
|
||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
|
||||
}
|
||||
}
|
||||
return fmt;
|
||||
}else{
|
||||
//TODO
|
||||
value = value.trim();
|
||||
return value.substr(0,fmt.length);
|
||||
return fmt
|
||||
} else {
|
||||
// TODO
|
||||
value = value.trim()
|
||||
return value.substr(0, fmt.length)
|
||||
}
|
||||
}
|
||||
|
||||
// 生成首页路由
|
||||
export function generateIndexRouter(data) {
|
||||
export function generateIndexRouter (data) {
|
||||
const redirectPath = findFirstRoute(data)
|
||||
let indexRouter = [{
|
||||
path: '/',
|
||||
name: 'dashboard',
|
||||
//component: () => import('@/components/layouts/BasicLayout'),
|
||||
component: resolve => require(['@/components/layouts/TabLayout'], resolve),
|
||||
meta: { title: '首页' },
|
||||
redirect: redirectPath,
|
||||
children: [
|
||||
...generateChildRouters(data)
|
||||
]
|
||||
},{
|
||||
"path": "*", "redirect": "/404", "hidden": true
|
||||
}]
|
||||
return indexRouter;
|
||||
const indexRouter = [{
|
||||
path: '/',
|
||||
name: 'dashboard',
|
||||
// component: () => import('@/components/layouts/BasicLayout'),
|
||||
component: resolve => require(['@/components/layouts/TabLayout'], resolve),
|
||||
meta: { title: '首页' },
|
||||
redirect: redirectPath,
|
||||
children: [
|
||||
...generateChildRouters(data)
|
||||
]
|
||||
}, {
|
||||
path: '*', redirect: '/404', hidden: true
|
||||
}]
|
||||
return indexRouter
|
||||
}
|
||||
|
||||
// 生成嵌套路由(子路由)
|
||||
|
||||
function generateChildRouters (data) {
|
||||
const routers = [];
|
||||
for (let item of data) {
|
||||
let component = "";
|
||||
if(item.component.indexOf("layouts")>=0){
|
||||
component = "components/"+item.component;
|
||||
}else{
|
||||
component = "views/"+item.component;
|
||||
function generateChildRouters (data) {
|
||||
const routers = []
|
||||
for (const item of data) {
|
||||
let component = ''
|
||||
if (item.component.indexOf('layouts') >= 0) {
|
||||
component = 'components/' + item.component
|
||||
} else {
|
||||
component = 'views/' + item.component
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
let URL = (item.meta.url|| '').replace(/{{([^}}]+)?}}/g, (s1, s2) => eval(s2)) // URL支持{{ window.xxx }}占位符变量
|
||||
if (isURL(URL) || (item.meta.url && item.meta.url.indexOf("{{") == 0)) {
|
||||
item.meta.url = URL;
|
||||
if (isURL(URL) || (item.meta.url && item.meta.url.indexOf('{{') == 0)) {
|
||||
item.meta.url = URL
|
||||
}
|
||||
|
||||
let componentPath
|
||||
if(item.component=="modules/online/cgform/OnlCgformHeadList"){
|
||||
if (item.component == 'modules/online/cgform/OnlCgformHeadList') {
|
||||
componentPath = onlineCommons.OnlCgformHeadList
|
||||
}else if(item.component=="modules/online/cgform/OnlCgformCopyList"){
|
||||
} else if (item.component == 'modules/online/cgform/OnlCgformCopyList') {
|
||||
componentPath = onlineCommons.OnlCgformCopyList
|
||||
}else if(item.component=="modules/online/cgform/auto/OnlCgformAutoList"){
|
||||
} else if (item.component == 'modules/online/cgform/auto/OnlCgformAutoList') {
|
||||
componentPath = onlineCommons.OnlCgformAutoList
|
||||
}else if(item.component=="modules/online/cgform/auto/OnlCgformTreeList"){
|
||||
} else if (item.component == 'modules/online/cgform/auto/OnlCgformTreeList') {
|
||||
componentPath = onlineCommons.OnlCgformTreeList
|
||||
}else if(item.component=="modules/online/cgform/auto/erp/OnlCgformErpList"){
|
||||
} else if (item.component == 'modules/online/cgform/auto/erp/OnlCgformErpList') {
|
||||
componentPath = onlineCommons.OnlCgformErpList
|
||||
}else if(item.component=="modules/online/cgform/auto/tab/OnlCgformTabList"){
|
||||
} else if (item.component == 'modules/online/cgform/auto/tab/OnlCgformTabList') {
|
||||
componentPath = onlineCommons.OnlCgformTabList
|
||||
}else if(item.component=="modules/online/cgform/auto/innerTable/OnlCgformInnerTableList"){
|
||||
} else if (item.component == 'modules/online/cgform/auto/innerTable/OnlCgformInnerTableList') {
|
||||
componentPath = onlineCommons.OnlCgformInnerTableList
|
||||
}else if(item.component=="modules/online/cgreport/OnlCgreportHeadList"){
|
||||
} else if (item.component == 'modules/online/cgreport/OnlCgreportHeadList') {
|
||||
componentPath = onlineCommons.OnlCgreportHeadList
|
||||
}else if(item.component=="modules/online/cgreport/auto/OnlCgreportAutoList"){
|
||||
} else if (item.component == 'modules/online/cgreport/auto/OnlCgreportAutoList') {
|
||||
componentPath = onlineCommons.OnlCgreportAutoList
|
||||
}else{
|
||||
componentPath = resolve => require(['@/' + component+'.vue'], resolve)
|
||||
} else {
|
||||
componentPath = resolve => require(['@/' + component + '.vue'], resolve)
|
||||
}
|
||||
|
||||
let menu = {
|
||||
const menu = {
|
||||
path: item.path,
|
||||
name: item.name,
|
||||
redirect:item.redirect,
|
||||
redirect: item.redirect,
|
||||
component: componentPath,
|
||||
//component: resolve => require(['@/' + component+'.vue'], resolve),
|
||||
hidden:item.hidden,
|
||||
// component: resolve => require(['@/' + component+'.vue'], resolve),
|
||||
hidden: item.hidden,
|
||||
meta: {
|
||||
title:item.meta.title ,
|
||||
title: item.meta.title,
|
||||
icon: item.meta.icon,
|
||||
url:item.meta.url ,
|
||||
permissionList:item.meta.permissionList,
|
||||
keepAlive:item.meta.keepAlive,
|
||||
/*update_begin author:wuxianquan date:20190908 for:赋值 */
|
||||
internalOrExternal:item.meta.internalOrExternal,
|
||||
/*update_end author:wuxianquan date:20190908 for:赋值 */
|
||||
componentName:item.meta.componentName
|
||||
url: item.meta.url,
|
||||
permissionList: item.meta.permissionList,
|
||||
keepAlive: item.meta.keepAlive,
|
||||
/* update_begin author:wuxianquan date:20190908 for:赋值 */
|
||||
internalOrExternal: item.meta.internalOrExternal,
|
||||
/* update_end author:wuxianquan date:20190908 for:赋值 */
|
||||
componentName: item.meta.componentName
|
||||
}
|
||||
}
|
||||
if(item.alwaysShow){
|
||||
menu.alwaysShow = true;
|
||||
menu.redirect = menu.path;
|
||||
if (item.alwaysShow) {
|
||||
menu.alwaysShow = true
|
||||
menu.redirect = menu.path
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
menu.children = [...generateChildRouters( item.children)];
|
||||
menu.children = [...generateChildRouters(item.children)]
|
||||
}
|
||||
//--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);
|
||||
}else{
|
||||
routers.push(menu);
|
||||
// --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);
|
||||
} else {
|
||||
routers.push(menu)
|
||||
}
|
||||
//--update-end----author:scott---date:20190320------for:根据后台菜单配置,判断是否路由菜单字段,动态选择是否生成路由(为了支持参数URL菜单)------
|
||||
// --update-end----author:scott---date:20190320------for:根据后台菜单配置,判断是否路由菜单字段,动态选择是否生成路由(为了支持参数URL菜单)------
|
||||
}
|
||||
return routers
|
||||
}
|
||||
@@ -184,7 +184,7 @@ function generateChildRouters (data) {
|
||||
* @param obj 被克隆的对象
|
||||
* @return 克隆后的对象
|
||||
*/
|
||||
export function cloneObject(obj) {
|
||||
export function cloneObject (obj) {
|
||||
return JSON.parse(JSON.stringify(obj))
|
||||
}
|
||||
|
||||
@@ -198,18 +198,18 @@ export function cloneObject(obj) {
|
||||
* @param2 最大值
|
||||
* @return int 生成后的数字
|
||||
*/
|
||||
export function randomNumber() {
|
||||
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)))
|
||||
const [length] = arguments
|
||||
// 生成指定长度的随机数字,首位一定不是 0
|
||||
const 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
|
||||
const [min, max] = arguments
|
||||
return random(min, max)
|
||||
} else {
|
||||
return Number.NaN
|
||||
@@ -222,12 +222,12 @@ export function randomNumber() {
|
||||
* @param chats 可选字符串区间(只会生成传入的字符串中的字符)
|
||||
* @return string 生成的字符串
|
||||
*/
|
||||
export function randomString(length, chats) {
|
||||
export function randomString (length, chats) {
|
||||
if (!length) length = 1
|
||||
if (!chats) chats = '0123456789qwertyuioplkjhgfdsazxcvbnm'
|
||||
let str = ''
|
||||
for (let i = 0; i < length; i++) {
|
||||
let num = randomNumber(0, chats.length - 1)
|
||||
const num = randomNumber(0, chats.length - 1)
|
||||
str += chats[num]
|
||||
}
|
||||
return str
|
||||
@@ -237,8 +237,8 @@ export function randomString(length, chats) {
|
||||
* 随机生成uuid
|
||||
* @return string 生成的uuid
|
||||
*/
|
||||
export function randomUUID() {
|
||||
let chats = '0123456789abcdef'
|
||||
export function randomUUID () {
|
||||
const chats = '0123456789abcdef'
|
||||
return randomString(32, chats)
|
||||
}
|
||||
|
||||
@@ -247,10 +247,10 @@ export function randomUUID() {
|
||||
* @param string
|
||||
* @returns {*}
|
||||
*/
|
||||
export function underLine2CamelCase(string){
|
||||
return string.replace( /_([a-z])/g, function( all, letter ) {
|
||||
return letter.toUpperCase();
|
||||
});
|
||||
export function underLine2CamelCase (string) {
|
||||
return string.replace(/_([a-z])/g, function (all, letter) {
|
||||
return letter.toUpperCase()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,11 +258,11 @@ export function underLine2CamelCase(string){
|
||||
* @param bpmStatus
|
||||
* @returns {*}
|
||||
*/
|
||||
export function showDealBtn(bpmStatus){
|
||||
if(bpmStatus!="1"&&bpmStatus!="3"&&bpmStatus!="4"){
|
||||
return true;
|
||||
export function showDealBtn (bpmStatus) {
|
||||
if (bpmStatus != '1' && bpmStatus != '3' && bpmStatus != '4') {
|
||||
return true
|
||||
}
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,13 +270,13 @@ export function showDealBtn(bpmStatus){
|
||||
* @param css 要增强的css
|
||||
* @param id style标签的id,可以用来清除旧样式
|
||||
*/
|
||||
export function cssExpand(css, id) {
|
||||
let style = document.createElement('style')
|
||||
style.type = "text/css"
|
||||
export function cssExpand (css, id) {
|
||||
const style = document.createElement('style')
|
||||
style.type = 'text/css'
|
||||
style.innerHTML = `@charset "UTF-8"; ${css}`
|
||||
// 清除旧样式
|
||||
if (id) {
|
||||
let $style = document.getElementById(id)
|
||||
const $style = document.getElementById(id)
|
||||
if ($style != null) $style.outerHTML = ''
|
||||
style.id = id
|
||||
}
|
||||
@@ -284,7 +284,6 @@ export function cssExpand(css, id) {
|
||||
document.head.appendChild(style)
|
||||
}
|
||||
|
||||
|
||||
/** 用于js增强事件,运行JS代码,可以传参 */
|
||||
// options 所需参数:
|
||||
// 参数名 类型 说明
|
||||
@@ -292,18 +291,17 @@ export function cssExpand(css, id) {
|
||||
// event Object event对象
|
||||
// jsCode String 待执行的js代码
|
||||
// errorMessage String 执行出错后的提示(控制台)
|
||||
export function jsExpand(options = {}) {
|
||||
|
||||
export function jsExpand (options = {}) {
|
||||
// 绑定到window上的keyName
|
||||
let windowKeyName = 'J_CLICK_EVENT_OPTIONS'
|
||||
if (typeof window[windowKeyName] != 'object') {
|
||||
const windowKeyName = 'J_CLICK_EVENT_OPTIONS'
|
||||
if (typeof window[windowKeyName] !== 'object') {
|
||||
window[windowKeyName] = {}
|
||||
}
|
||||
|
||||
// 随机生成JS增强的执行id,防止冲突
|
||||
let id = randomString(16, 'qwertyuioplkjhgfdsazxcvbnm'.toUpperCase())
|
||||
const id = randomString(16, 'qwertyuioplkjhgfdsazxcvbnm'.toUpperCase())
|
||||
// 封装按钮点击事件
|
||||
let code = `
|
||||
const code = `
|
||||
(function (o_${id}) {
|
||||
try {
|
||||
(function (globalEvent, vm) {
|
||||
@@ -322,13 +320,13 @@ export function jsExpand(options = {}) {
|
||||
vm: options.vm,
|
||||
event: options.event,
|
||||
// 当执行完成时,无论如何都会调用的回调事件
|
||||
done() {
|
||||
done () {
|
||||
// 执行完后删除新增的 script 标签不会撤销执行结果(已产生的结果不会被撤销)
|
||||
script.outerHTML = ''
|
||||
delete window[windowKeyName]['EVENT_' + id]
|
||||
},
|
||||
// 当js运行出错的时候调用的事件
|
||||
error(e) {
|
||||
error (e) {
|
||||
console.group(`${options.errorMessage || '用户自定义JS增强代码运行出错'}(${new Date()})`)
|
||||
console.error(e)
|
||||
console.groupEnd()
|
||||
@@ -339,7 +337,6 @@ export function jsExpand(options = {}) {
|
||||
document.body.appendChild(script)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重复值验证工具方法
|
||||
*
|
||||
@@ -352,11 +349,11 @@ export function jsExpand(options = {}) {
|
||||
* @param dataId 数据ID,可空
|
||||
* @param callback
|
||||
*/
|
||||
export function validateDuplicateValue(tableName, fieldName, fieldVal, dataId, callback) {
|
||||
export function validateDuplicateValue (tableName, fieldName, fieldVal, dataId, callback) {
|
||||
if (fieldVal) {
|
||||
let params = { tableName, fieldName, fieldVal, dataId }
|
||||
const params = { tableName, fieldName, fieldVal, dataId }
|
||||
api.duplicateCheck(params).then(res => {
|
||||
res['success'] ? callback() : callback(res['message'])
|
||||
res.success ? callback() : callback(res.message)
|
||||
}).catch(err => {
|
||||
callback(err.message || err)
|
||||
})
|
||||
@@ -375,11 +372,11 @@ export function validateDuplicateValue(tableName, fieldName, fieldVal, dataId, c
|
||||
* @param value 被验证的值
|
||||
* @param callback
|
||||
*/
|
||||
export function validateCheckRule(ruleCode, value, callback) {
|
||||
export function validateCheckRule (ruleCode, value, callback) {
|
||||
if (ruleCode && value) {
|
||||
value = encodeURIComponent(value)
|
||||
api.checkRuleByCode({ ruleCode, value }).then(res => {
|
||||
res['success'] ? callback() : callback(res['message'])
|
||||
res.success ? callback() : callback(res.message)
|
||||
}).catch(err => {
|
||||
callback(err.message || err)
|
||||
})
|
||||
@@ -395,8 +392,8 @@ export function validateCheckRule(ruleCode, value, callback) {
|
||||
* @param key 可空,如果比较的是对象,可能存在地址不一样但值实际上是一样的情况,可以传此字段判断对象中唯一的字段,例如 id。不传则直接比较实际值
|
||||
* @returns {boolean} 成功 push 返回 true,不处理返回 false
|
||||
*/
|
||||
export function pushIfNotExist(array, value, key) {
|
||||
for (let item of array) {
|
||||
export function pushIfNotExist (array, value, key) {
|
||||
for (const item of array) {
|
||||
if (key && (item[key] === value[key])) {
|
||||
return false
|
||||
} else if (item === value) {
|
||||
@@ -425,7 +422,7 @@ export const failedSymbol = Symbol()
|
||||
* @param promise 可传Promise对象或返回Promise对象的方法
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export function alwaysResolve(promise) {
|
||||
export function alwaysResolve (promise) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let p = promise
|
||||
if (typeof promise === 'function') {
|
||||
@@ -454,10 +451,10 @@ export function alwaysResolve(promise) {
|
||||
* @param delay 防抖的毫秒数
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function simpleDebounce(fn, delay = 100) {
|
||||
export function simpleDebounce (fn, delay = 100) {
|
||||
let timer = null
|
||||
return function () {
|
||||
let args = arguments
|
||||
const args = arguments
|
||||
if (timer) {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
@@ -474,8 +471,8 @@ export function simpleDebounce(fn, delay = 100) {
|
||||
* @param replacer 替换后的内容
|
||||
* @returns {String} 替换后的字符串
|
||||
*/
|
||||
export function replaceAll(text, checker, replacer) {
|
||||
let lastText = text
|
||||
export function replaceAll (text, checker, replacer) {
|
||||
const lastText = text
|
||||
text = text.replace(checker, replacer)
|
||||
if (lastText !== text) {
|
||||
return replaceAll(text, checker, replacer)
|
||||
@@ -487,9 +484,9 @@ export function replaceAll(text, checker, replacer) {
|
||||
* 获取事件冒泡路径,兼容 IE11,Edge,Chrome,Firefox,Safari
|
||||
* 目前使用的地方:JEditableTable Span模式
|
||||
*/
|
||||
export function getEventPath(event) {
|
||||
let target = event.target
|
||||
let path = (event.composedPath && event.composedPath()) || event.path
|
||||
export function getEventPath (event) {
|
||||
const target = event.target
|
||||
const path = (event.composedPath && event.composedPath()) || event.path
|
||||
|
||||
if (path != null) {
|
||||
return (path.indexOf(window) < 0) ? path.concat(window) : path
|
||||
@@ -499,7 +496,7 @@ export function getEventPath(event) {
|
||||
return [window]
|
||||
}
|
||||
|
||||
let getParents = (node, memo) => {
|
||||
const getParents = (node, memo) => {
|
||||
memo = memo || []
|
||||
const parentNode = node.parentNode
|
||||
|
||||
@@ -518,13 +515,13 @@ export function getEventPath(event) {
|
||||
* @param name
|
||||
* @returns {Vue | null|null|Vue}
|
||||
*/
|
||||
export function getVmParentByName(vm, name) {
|
||||
let parent = vm.$parent
|
||||
export function getVmParentByName (vm, name) {
|
||||
const parent = vm.$parent
|
||||
if (parent && parent.$options) {
|
||||
if (parent.$options.name === name) {
|
||||
return parent
|
||||
} else {
|
||||
let res = getVmParentByName(parent, name)
|
||||
const res = getVmParentByName(parent, name)
|
||||
if (res) {
|
||||
return res
|
||||
}
|
||||
@@ -539,7 +536,7 @@ export function getVmParentByName(vm, name) {
|
||||
* @param value 要处理的值
|
||||
* @param def 默认值,如果value为(null | undefined)则返回的默认值,可不传,默认为''
|
||||
*/
|
||||
export function neverNull(value, def) {
|
||||
export function neverNull (value, def) {
|
||||
return value == null ? (neverNull(def, '')) : value
|
||||
}
|
||||
|
||||
@@ -550,19 +547,19 @@ export function neverNull(value, def) {
|
||||
* @param value 属性值
|
||||
* @returns {string}
|
||||
*/
|
||||
export function removeArrayElement(array, prod, value) {
|
||||
export function removeArrayElement (array, prod, value) {
|
||||
let index = -1
|
||||
for(let i = 0;i<array.length;i++){
|
||||
if(array[i][prod] == value){
|
||||
index = i;
|
||||
break;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i][prod] == value) {
|
||||
index = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if(index>=0){
|
||||
array.splice(index, 1);
|
||||
if (index >= 0) {
|
||||
array.splice(index, 1)
|
||||
}
|
||||
}
|
||||
export function findFirstRoute(data){
|
||||
export function findFirstRoute (data) {
|
||||
if (data[0]) {
|
||||
if (data[0] && data[0].children && data[0].children.length > 0) {
|
||||
return findFirstRoute(data[0].children)
|
||||
@@ -575,7 +572,7 @@ export function findFirstRoute(data){
|
||||
}
|
||||
|
||||
/** 判断是否是OAuth2APP环境 */
|
||||
export function isOAuth2AppEnv() {
|
||||
export function isOAuth2AppEnv () {
|
||||
return /wxwork|dingtalk/i.test(navigator.userAgent)
|
||||
}
|
||||
|
||||
@@ -586,7 +583,7 @@ export function isOAuth2AppEnv() {
|
||||
* @param open 是否自动打开
|
||||
* @returns {*}
|
||||
*/
|
||||
export function getReportPrintUrl(url, id, open) {
|
||||
export function getReportPrintUrl (url, id, open) {
|
||||
// URL支持{{ window.xxx }}占位符变量
|
||||
url = url.replace(/{{([^}]+)?}}/g, (s1, s2) => eval(s2))
|
||||
if (url.includes('?')) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Bus from 'vue';
|
||||
let install = function (Vue) {
|
||||
import Bus from 'vue'
|
||||
const install = function (Vue) {
|
||||
Vue.prototype.$bus = new Bus()
|
||||
}
|
||||
export default { install };
|
||||
export default { install }
|
||||
|
||||
Reference in New Issue
Block a user