提交 0e7d444c 编写于 作者: zcdtk's avatar zcdtk

工具文件多余方法异常

上级 3cc1d4b3
......@@ -81,107 +81,6 @@ export class ViewTool {
return viewdata;
}
/**
* 处理路由路径
*
* @param {Route} route 路由
* @param {*} [viewParam={}]
* @param {any[]} deResParameters 关系实体参数对象
* @param {any[]} parameters 当前应用视图参数对象
* @param {any[]} args 多项数据
* @param {*} data 行为参数
* @returns {string}
* @memberof ViewTool
*/
public buildUpRoutePath(route: Route, viewParam: any = {}, deResParameters: any[], parameters: any[], args: any[], data: any, isDefaultPage?: boolean): string {
const indexRoutePath = this.getIndexRoutePath(route, isDefaultPage);
const deResRoutePath = this.getDeResRoutePath(viewParam, deResParameters, args);
const deRoutePath = this.getActiveRoutePath(parameters, args, data);
return `${indexRoutePath}${deResRoutePath}${deRoutePath}`;
}
/**
* 获取首页根路由路径
*
* @private
* @param {Route} route
* @param {boolean} [isDefaultPage]
* @returns {string}
* @memberof ViewTool
*/
private getIndexRoutePath(route: Route, isDefaultPage?: boolean): string {
const { parameters: _parameters }: { parameters: any[] } = route.meta;
let { pathName: _pathName, parameterName: _parameterName }: { pathName: string, parameterName: string } = _parameters[0];
const param = route.params[_parameterName];
if (!isDefaultPage) {
_pathName = 'viewshell';
}
if (param && !Object.is(param, '')) {
return `/${_pathName}/${param}`;
}
return `/${_pathName}/null`;
}
/**
* 获取关系实体路径
*
* @private
* @param {*} [viewParam={}] 视图参数
* @param {any[]} deResParameters 关系实体参数对象
* @param {any[]} args 多项数据
* @returns {string}
* @memberof ViewTool
*/
private getDeResRoutePath(viewParam: any = {}, deResParameters: any[], args: any[]): string {
let routePath: string = '';
let [arg] = args;
arg = arg ? arg : {};
deResParameters.forEach(({ pathName, parameterName }: { pathName: string, parameterName: string }) => {
let value: any = null;
if (viewParam[parameterName] && !Object.is(viewParam[parameterName], '') && !Object.is(viewParam[parameterName], 'null')) {
value = viewParam[parameterName];
} else if (arg[parameterName] && !Object.is(arg[parameterName], '') && !Object.is(arg[parameterName], 'null')) {
value = arg[parameterName];
}
routePath = `${routePath}/${pathName}/${value}`;
});
return routePath;
}
/**
* 当前激活路由路径
*
* @private
* @param {any[]} parameters 当前应用视图参数对象
* @param {any[]} args 多项数据
* @param {*} data 行为参数
* @returns {string}
* @memberof ViewTool
*/
private getActiveRoutePath(parameters: any[], args: any[], data: any): string {
let routePath: string = '';
// 不存在应用实体
if (parameters.length === 1) {
const [{ pathName, parameterName }] = parameters;
routePath = `/${pathName}`;
if (Object.keys(data).length > 0) {
routePath = `${routePath}/${qs.stringify(data, { delimiter: ';' })}`;
}
} else if (parameters.length === 2) {
let [arg] = args;
arg = arg ? arg : {};
const [{ pathName: _pathName, parameterName: _parameterName }, { pathName: _pathName2, parameterName: _parameterName2 }] = parameters;
const _value: any = arg[_parameterName] && !Object.is(arg[_parameterName], '') ?
arg[_parameterName] : null;
routePath = `/${_pathName}/${_value}/${_pathName2}`;
if (Object.keys(data).length > 0) {
routePath = `${routePath}/${qs.stringify(data, { delimiter: ';' })}`;
}
}
return routePath;
}
/**
* 格式化路由参数
*
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册