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

调整向导面板

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