提交 c6531eaf 编写于 作者: sq3536's avatar sq3536

reset

上级 898e4350
/**
* 获取部门成员
*
* @param state
*/
export const getDepartmentPersonnel = (state: any) => () => {
return state.departmentPersonnel;
}
/**
* 获取代码表对象
*
* @param state
*/
export const getCodeList = (state: any) => (srfkey: string) => {
return state.codelists.find((_codelist: any) => Object.is(_codelist.srfkey, srfkey));
}
/**
* 获取代码表
*
* @param state
*/
export const getCodeListItems = (state: any) => (srfkey: string) => {
let items: any[] = [];
const codelist = state.codelists.find((_codelist: any) => Object.is(_codelist.srfkey, srfkey));
if (!codelist) {
console.log(`----${srfkey}----代码表不存在`);
} else {
items = [...codelist.items];
}
return items;
}
/**
* 获取本地应用数据
*
* @param state
*/
export const getLocalData = (state: any) => () => {
return state.localdata;
}
/**
* 获取应用数据
*
* @param state
*/
export const getAppData = (state: any) => () => {
let result:any = JSON.parse(JSON.stringify(state.appdata));
if(state.localdata && Object.keys(state.localdata).length >0){
let copyContext:any = result.context?result.context:{};
Object.assign(copyContext,state.localdata);
result.context = copyContext;
}
return result;
}
/**
* 获取导航标签页面
*
* @param state
*/
export const getPage = (state: any) => (arg: any) => {
let page: any = null;
if (isNaN(arg)) {
const index = state.pageTagList.findIndex((page: any) => Object.is(page.fullPath, arg));
if (index >= 0) {
page = state.pageTagList[index];
}
} else {
page = state.pageTagList[arg];
}
return page;
}
/**
* 获取 z-index
*
* @param state
*/
export const getZIndex = (state: any) => () => {
return state.zIndex;
}
/**
* 获取视图split
*
* @param state
*/
export const getViewSplit = (state: any) => (viewUID: string) => {
return state.viewSplit[viewUID];
}
/**
* 获取单位数据
*
* @param state
*/
export const getOrgData = (state: any) => (srfkey: string) => {
let orgData = state.orgDataMap[srfkey];
return orgData;
}
/**
* 获取部门数据
*
* @param state
*/
export const getDepData = (state: any) => (srfkey: string) => {
let depData = state.depDataMap[srfkey];
return depData;
}
\ No newline at end of file
import { Environment } from '@/environments/environment';
/**
* 添加部门成员
*
* @param state
* @param codelists
*/
export const addDepartmentPersonnel = (state: any, departmentPersonnel: Array<any>) => {
state.departmentPersonnel = [];
state.departmentPersonnel = [...departmentPersonnel];
}
/**
* 添加代码表
*
* @param state
* @param codelists
*/
export const addCodeLists = (state: any, codelists: any) => {
state.codelists = [];
state.codelists = [...codelists];
}
/**
* 添加本地应用数据
*
* @param state
* @param localdata
*/
export const addLocalData = (state: any, localdata: any = {}) => {
Object.assign(state.localdata, localdata);
localStorage.setItem('localdata',JSON.stringify(state.localdata));
}
/**
* 添加应用数据
*
* @param state
* @param localdata
*/
export const addAppData = (state: any, appdata: string) => {
state.appdata = appdata;
}
/**
* 修改应用数据
*
* @param state
* @param localdata
*/
export const updateAppData = (state: any, appdata: string) => {
state.appdata = appdata;
}
/**
* 更新代码表值
*
* @param state
* @param param1
*/
export const updateCodeList = (state: any, { srfkey, items }: { srfkey: string, items: any[] }) => {
const index = state.codelists.findIndex((_codelist: any) => Object.is(_codelist.srfkey, srfkey));
if (index === -1) {
console.log(`${srfkey} ---- 代码表不存在`);
return;
}
state.codelists[index].items = [...items];
}
/**
* 修改主题
*
* @param state
* @param val
*/
export const setCurrentSelectTheme = (state: any, val: any) => {
state.selectTheme = val;
}
/**
* 修改字体
*
* @param state
* @param val
*/
export const setCurrentSelectFont = (state: any, val: any) => {
state.selectFont = val;
}
/**
* 重置分页导航数据
*
* @param state
*/
export const resetRootStateData = (state: any) => {
state.pageTagList = [];
state.pageMetas = [];
state.historyPathList = [];
}
/**
* 添加导航页面
*
* @param state
* @param arg
*/
export const addPage = (state: any, arg: any) => {
if (!arg) {
return;
}
// 视图类型为REDIRECTVIEW和NOTAB的视图不添加缓存
if(Object.is(arg.meta.viewType, 'REDIRECTVIEW') || Object.is(arg.meta.viewType, 'NOTAB')){
return;
}else if (Object.is(arg.meta.viewType, 'APPINDEX')) {
window.sessionStorage.setItem(Environment.AppName, arg.fullPath);
} else {
const page: any = {};
const pageMeta: any = {};
Object.assign(page, arg);
Object.assign(pageMeta, page.meta, { info: null });
const index = state.pageTagList.findIndex((tag: any) => Object.is(tag.fullPath, page.fullPath));
if (index < 0) {
state.pageTagList.push(page);
state.pageMetas.push(pageMeta);
} else {
const index2 = state.historyPathList.indexOf(page.fullPath);
if (index2 >= 0) {
state.historyPathList.splice(index2, 1);
}
}
state.historyPathList.push(page.fullPath);
}
}
/**
* 删除导航页面
*
* @param state
* @param arg
*/
export const deletePage = (state: any, arg: any) => {
let delPage: any = null;
if (isNaN(arg)) {
const index = state.pageTagList.findIndex((page: any) => Object.is(page.fullPath, arg));
if (index >= 0) {
delPage = state.pageTagList[index];
state.pageTagList.splice(index, 1);
state.pageMetas.splice(index, 1);
}
} else {
delPage = state.pageTagList[arg];
state.pageTagList.splice(arg, 1);
state.pageMetas.splice(arg, 1);
}
const index = state.historyPathList.findIndex((path: any) => Object.is(path, delPage.fullPath));
if (index >= 0) {
state.historyPathList.splice(index, 1);
}
}
/**
* 设置导航页面
*
* @param state
* @param arg
*/
export const setCurPage = (state: any, arg: any) => {
let page: any = null;
if (isNaN(arg)) {
const index = state.pageTagList.findIndex((page: any) => Object.is(page.fullPath, arg));
if (index >= 0) {
page = state.pageTagList[index];
}
} else {
page = state.pageTagList[arg];
}
if (page) {
const index = state.historyPathList.findIndex((path: any) => Object.is(path, page.fullPath));
if (index >= 0) {
state.historyPathList.splice(index, 1);
state.historyPathList.push(page.fullPath);
}
}
}
/**
* 设置导航页面标题
*
* @param state
* @param param1
*/
export const setCurPageCaption = (state: any, { route, caption, info }: { route: any, caption: string | null, info: string | null }) => {
if (route) {
const index = state.pageTagList.findIndex((page: any) => Object.is(page.fullPath, route.fullPath));
if (index >= 0) {
state.pageMetas[index].caption = caption;
state.pageMetas[index].info = info;
}
}
}
/**
* 添加当前视图视图标识
*
* @param state
* @param param1
*/
export const addCurPageViewtag = (state: any, { fullPath, viewtag }: { fullPath: string, viewtag: string }) => {
const index = state.pageTagList.findIndex((page: any) => Object.is(page.fullPath, fullPath));
if (index >= 0) {
state.pageTagList[index].viewtag = viewtag;
}
}
/**
* 删除所有导航页面
*
* @param state
*/
export const removeAllPage = (state: any) => {
if (state.pageTagList.length > 0) {
state.pageMetas = [];
state.pageTagList = [];
state.historyPathList = [];
}
}
/**
* 删除其他导航页面
*
* @param state
*/
export const removeOtherPage = (state: any) => {
if (state.historyPathList.length > 0) {
const curPath = state.historyPathList[state.historyPathList.length - 1];
const index = state.pageTagList.findIndex((page: any) => Object.is(page.fullPath, curPath));
if (index >= 0) {
const page = state.pageTagList[index];
const meta: any = {};
Object.assign(meta, page.meta);
state.pageTagList = [];
state.pageMetas = [];
state.historyPathList = [];
state.historyPathList.push(page.fullPath);
state.pageTagList.push(page);
state.pageMetas.push(meta);
}
}
}
/**
* 更新 z-index
*
* @param state
* @param zIndex
*/
export const updateZIndex = (state: any, zIndex: number) => {
state.zIndex = zIndex;
}
/**
* 设置视图split
*
* @param state
* @param {viewSplit: number, viewUID: string}
*/
export const setViewSplit = (state: any, args: {viewSplit: number,viewUID:string}) => {
state.viewSplit[args.viewUID] = args.viewSplit;
}
/**
* 添加单位数据
*
* @param state
* @param args
*/
export const addOrgData = (state: any, args: {srfkey: string,orgData: any}) => {
if(args && args.srfkey && args.orgData){
state.orgDataMap[args.srfkey] = JSON.parse(JSON.stringify(args.orgData));
}
}
/**
* 添加部门数据
*
* @param state
* @param args
*/
export const addDepData = (state: any, args: {srfkey: string,depData: any}) => {
if(args && args.srfkey && args.depData){
state.depDataMap[args.srfkey] = JSON.parse(JSON.stringify(args.depData));
}
}
\ No newline at end of file
import { Http } from '../http/http';
/**
* AuthGuard net 对象
* 调用 getInstance() 获取实例
*
* @class Http
*/
export class AuthGuard {
/**
* 获取 Auth 单例对象
*
* @static
* @returns {Auth}
* @memberof Auth
*/
public static getInstance(): AuthGuard {
if (!AuthGuard.auth) {
AuthGuard.auth = new AuthGuard();
}
return this.auth;
}
/**
* 单例变量声明
*
* @private
* @static
* @type {AuthGuard}
* @memberof AuthGuard
*/
private static auth: AuthGuard;
/**
* Creates an instance of AuthGuard.
* 私有构造,拒绝通过 new 创建对象
*
* @memberof AuthGuard
*/
private constructor() { }
/**
* post请求
*
* @param {string} url url 请求路径
* @param {*} [params={}] 请求参数
* @returns {Promise<any>} 请求相响应对象
* @memberof AuthGuard
*/
public authGuard(url: string, params: any = {}, router: any): Promise<boolean> {
return new Promise((resolve: any, reject: any) => {
const get: Promise<any> = Http.getInstance().get(url);
get.then((response: any) => {
if (response && response.status === 200) {
let { data }: { data: any } = response;
if (data) {
// token认证把用户信息放入应用级数据
if(localStorage.getItem('user')){
let user:any = JSON.parse(localStorage.getItem('user') as string);
let localAppData:any = {};
if(user.sessionParams){
localAppData = {context:user.sessionParams};
Object.assign(localAppData,data);
}
data = JSON.parse(JSON.stringify(localAppData));
}
if(localStorage.getItem('localdata')){
router.app.$store.commit('addLocalData', JSON.parse(localStorage.getItem('localdata') as string));
}
router.app.$store.commit('addAppData', data);
// 提交统一资源数据
router.app.$store.dispatch('authresource/commitAuthData', data);
}
}
resolve(true);
}).catch((error: any) => {
resolve(true);
console.error("获取应用数据出现异常");
});
});
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册