提交 f8be8578 编写于 作者: tony001's avatar tony001

调整向导面板

上级 9fca5187
......@@ -78,6 +78,14 @@ ${ctrl.render.code}
*/
public stateField: string = '${ctrl.getStatePSAppDEField().getCodeName()?lower_case}';
/**
* 步骤标识集合
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public stepTags: any = {};
/**
* 获取多项数据
*
......@@ -167,7 +175,7 @@ ${ctrl.render.code}
*/
public created(): void {
this.regFormActions();
if(this.activeForm) {
if(this.activeForm && !this.stateField) {
this.historyForms.push(this.activeForm);
}
if (this.viewState) {
......@@ -203,7 +211,7 @@ ${ctrl.render.code}
public regFormActions() {
<#if ctrl.getPSDEWizard()?? && ctrl.getPSDEWizard().getPSDEWizardForms()??>
<#list ctrl.getPSDEWizard().getPSDEWizardForms() as form>
this.regFormAction('${ctrl.name}_form_${form.getFormTag()}',<#if form.getPrevPSDEAction?? && form.getPrevPSDEAction()??>${form.getPrevPSDEAction()}</#if>[<#if form.getStepActions()??><#list form.getStepActions() as action><#if action_index gt 0>,</#if>'${action}'</#list></#if>]);
this.regFormAction('${ctrl.name}_form_${form.getFormTag()}',{<#if form.getLoadPSDEAction?? && form.getLoadPSDEAction()??>loadAction:"${form.getLoadPSDEAction().getCodeName()}",</#if><#if form.getGoBackPSDEAction?? && form.getGoBackPSDEAction()??>preAction:'${form.getGoBackPSDEAction().getCodeName()}',</#if><#if form.getSavePSDEAction?? && form.getSavePSDEAction()??>saveAction:'${form.getSavePSDEAction().getCodeName()}',</#if><#if form.getStepActions()??>actions:[<#list form.getStepActions() as action><#if action_index gt 0>,</#if>'${action}'</#list>]</#if>});
</#list>
</#if>
}
......@@ -213,8 +221,9 @@ ${ctrl.render.code}
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public regFormAction(name: string, actions: Array<string>) {
this.stepActions[name] = actions;
public regFormAction(name: string, actionParams: any,stepTag:any) {
this.stepActions[name] = actionParams;
this.stepTags[name] = stepTag;
this.wizardForms.push(name);
}
......@@ -235,7 +244,7 @@ ${ctrl.render.code}
if(response.data.${ctrl.getPSAppDataEntity().getCodeName()?lower_case}){
Object.assign(this.context,{${ctrl.getPSAppDataEntity().getCodeName()?lower_case}:response.data.${ctrl.getPSAppDataEntity().getCodeName()?lower_case}})
}
this.formLoad();
this.formLoad(this.formParam);
}
}).catch((response: any) => {
if (response && response.status === 401) {
......@@ -251,9 +260,28 @@ ${ctrl.render.code}
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public formLoad() {
public formLoad(data:any) {
if(this.stateField) this.computedActiveForm(data);
if(this.activeForm) {
this.wizardState.next({ tag: this.activeForm, action: 'load', data: this.formParam });
this.wizardState.next({ tag: this.activeForm, action:'panelaction',data: {action:this.stepActions[this.activeForm].loadAction,emitAction:'load',data:this.formParam} });
}
}
/**
* 根据状态获取当前激活表单
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public computedActiveForm(data:any){
if(data && data[this.stateField]){
if(Object.keys(this.stepTags).length >0){
Object.keys(this.stepTags).forEach((name:string) =>{
if(this.stepTags[name] === data[this.stateField]){
this.activeForm = name;
return;
}
})
}
}
}
......@@ -308,13 +336,24 @@ ${ctrl.render.code}
Object.assign(this.formParam, args);
if(Object.is(this.curState, 'NEXT')) {
this.historyForms.push(name);
if (this.getNextForm()) {
this.activeForm = this.getNextForm();
setTimeout(() => {
this.formLoad();
}, 1);
} else {
this.doFinish();
if(!this.stateField){
if (this.getNextForm()) {
this.activeForm = this.getNextForm();
setTimeout(() => {
this.formLoad(this.formParam);
}, 1);
} else {
this.doFinish();
}
}else{
this.computedActiveForm(args);
if(this.activeForm && Object.is(this.activeForm,this.wizardForms[this.wizardForms.length - 1]) ){
this.doFinish();
}else{
setTimeout(() => {
this.formLoad(this.formParam);
}, 1);
}
}
}else if(Object.is(this.curState, 'FINISH')) {
this.doFinish();
......@@ -343,14 +382,28 @@ ${ctrl.render.code}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public onClickPrev() {
const length = this.historyForms.length;
if(length > 1) {
this.curState = 'PREV';
this.activeForm = this.historyForms[length - 1];
setTimeout(() => {
this.formLoad();
}, 1);
this.historyForms.splice(length - 1, 1);
if(!this.stateField){
const length = this.historyForms.length;
if(length > 1) {
this.curState = 'PREV';
this.activeForm = this.historyForms[length - 1];
setTimeout(() => {
this.formLoad(this.formParam);
}, 1);
this.historyForms.splice(length - 1, 1);
}
}else{
if(this.activeForm) {
if(this.$refs && this.$refs[this.activeForm]){
let form: any = this.$refs[this.activeForm];
if(form.formValidateStatus()) {
this.curState = 'PREV';
this.wizardState.next({ tag: this.activeForm, action:'panelaction',data: {action:this.stepActions[this.activeForm].preAction,emitAction:'save',data:this.formParam} });
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.rulesException') as string) });
}
}
}
}
}
......@@ -365,7 +418,7 @@ ${ctrl.render.code}
let form: any = this.$refs[this.activeForm];
if(form.formValidateStatus()) {
this.curState = 'NEXT';
this.wizardState.next({ tag: this.activeForm, action: 'save', data: this.formParam });
this.wizardState.next({ tag: this.activeForm, action:'panelaction',data: {action:this.stepActions[this.activeForm].saveAction,emitAction:'save',data:this.formParam} });
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.rulesException') as string) });
}
......@@ -384,7 +437,7 @@ ${ctrl.render.code}
let form: any = this.$refs[this.activeForm];
if(form.formValidateStatus()) {
this.curState = 'FINISH';
this.wizardState.next({ tag: this.activeForm, action: 'save', data: this.formParam });
this.wizardState.next({ tag: this.activeForm, action:'panelaction',data: {action:this.stepActions[this.activeForm].saveAction,emitAction:'save',data:this.formParam} });
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.rulesException') as string) });
}
......@@ -399,7 +452,7 @@ ${ctrl.render.code}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public isDisabled(type: string) {
const actions: Array<string> = this.stepActions[this.activeForm]
const actions: Array<string> = this.stepActions[this.activeForm].actions;
if(actions && actions.indexOf(type) < 0) {
return true;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册