提交 48df5d5c 编写于 作者: zcdtk's avatar zcdtk

视图参数处理工具化

上级 bda575c3
...@@ -141,8 +141,8 @@ export default class ${srfclassname('${view.name}')}Base extends Vue { ...@@ -141,8 +141,8 @@ export default class ${srfclassname('${view.name}')}Base extends Vue {
@Watch('_context') @Watch('_context')
on_context(newVal: string, oldVal: string) { on_context(newVal: string, oldVal: string) {
const _this: any = this; const _this: any = this;
this.parseViewParam();
if (!Object.is(newVal, oldVal) && _this.engine) { if (!Object.is(newVal, oldVal) && _this.engine) {
_this.parseViewParam();
_this.engine.load(); _this.engine.load();
} }
<#if _context_block??>${_context_block}</#if> <#if _context_block??>${_context_block}</#if>
...@@ -158,12 +158,7 @@ export default class ${srfclassname('${view.name}')}Base extends Vue { ...@@ -158,12 +158,7 @@ export default class ${srfclassname('${view.name}')}Base extends Vue {
*/ */
@Watch('_viewparams') @Watch('_viewparams')
on_viewparams(newVal: string, oldVal: string) { on_viewparams(newVal: string, oldVal: string) {
if (!Object.is(newVal, oldVal)) { this.parseViewParam();
if (!this.viewDefaultUsage && this._viewparams && !Object.is(this._viewparams, '')) {
Object.assign(this.viewparams, JSON.parse(this._viewparams));
return;
}
}
} }
/** /**
...@@ -213,34 +208,9 @@ ${P.getCtrlCode(ctrl, 'CONTROL.vue').code} ...@@ -213,34 +208,9 @@ ${P.getCtrlCode(ctrl, 'CONTROL.vue').code}
* @memberof ${srfclassname('${view.name}')}Base * @memberof ${srfclassname('${view.name}')}Base
*/ */
protected parseViewParam(): void { protected parseViewParam(): void {
if (!this.viewDefaultUsage && this._context && !Object.is(this._context, '')) { const { context, viewparams } = this.$viewTool.parseViewData(this, ${view.isPSDEView()?c});
Object.assign(this.context, JSON.parse(this._context)); this.context = { ...this.context, ...context };
<#if self_viewparam??> this.viewparams = { ...this.viewparams, ...viewparams }
${self_viewparam}
</#if>
return;
}
// 参数异常
if (!this.viewDefaultUsage) {
return;
}
const path = (this.$route.matched[this.$route.matched.length - 1]).path;
const keys: Array<any> = [];
const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
const matchArray = curReg.exec(this.$route.path);
let tempValue: Object = {};
keys.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item.name, {
enumerable: true,
value: matchArray[index + 1]
});
});
this.$viewTool.formatRouteParams(tempValue, this.$route, this.context, this.viewparams);
<#if view.isPSDEView()>
//初始化视图唯一标识
Object.assign(this.context, { srfsessionid: this.$util.createUUID() });
</#if>
} }
<#-- 移动端参数:BEGIN --> <#-- 移动端参数:BEGIN -->
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册