提交 1fccccc7 编写于 作者: Mosher's avatar Mosher

update:更新

上级 80447c57
<#macro initControlEvents ctrl view> <#macro initControlEvents ctrl view>
<#if ctrl.getPSControlLogics?? && ctrl.getPSControlLogics()??>
<#list ctrl.getPSControlLogics() as logic>
<#if logic.getLogicType() != 'APPVIEWLOGIC' && logic.getLogicType() != 'APPVIEWENGINE' && logic.getTriggerType() == 'CTRLEVENT'>
<#assign hasCtrlLogic = true />
</#if>
</#list>
</#if>
<#if hasCtrlLogic??>
/** /**
* 处理部件事件 * 处理部件事件
* *
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public async handleCtrlEvents(eventName: string, args: any = {}): Promise<boolean> { public async handleCtrlEvents(eventName: string, args: any = {}): Promise<boolean> {
const data = args && args.data ? args.data : this.getData() || {}; const actionData = {
const event = args && args.event ? args.event : {}; data: this.getData() || {},
context: Util.deepCopy(this.context),
viewparams: Util.deepCopy(this.viewparams)
}
let result: boolean = true; let result: boolean = true;
<#if ctrl.getPSControlLogics?? && ctrl.getPSControlLogics()??>
<#list ctrl.getPSControlLogics() as logic> <#list ctrl.getPSControlLogics() as logic>
<#if logic.getLogicType() != 'APPVIEWLOGIC' && logic.getLogicType() != 'APPVIEWENGINE' && logic.getTriggerType() == 'CTRLEVENT'> <#if logic.getLogicType() != 'APPVIEWLOGIC' && logic.getLogicType() != 'APPVIEWENGINE' && logic.getTriggerType() == 'CTRLEVENT'>
if ('${logic.getEventNames()?lower_case}'.indexOf(eventName) !== -1) { if ('${logic.getEventNames()?lower_case}'.indexOf(eventName) !== -1) {
result = await this.execute_${logic.name}_ctrl_logic(data, event) && result; result = await this.execute_${logic.name}_ctrl_logic(actionData) && result;
} }
</#if> </#if>
</#list> </#list>
</#if>
if (!result) { if (!result) {
return false; return false;
} }
...@@ -30,6 +27,7 @@ ...@@ -30,6 +27,7 @@
return true; return true;
} }
<#if ctrl.getPSControlLogics?? && ctrl.getPSControlLogics()??>
<#list ctrl.getPSControlLogics() as logic> <#list ctrl.getPSControlLogics() as logic>
<#if logic.getLogicType() != 'APPVIEWLOGIC' && logic.getLogicType() != 'APPVIEWENGINE' && logic.getTriggerType() == 'CTRLEVENT'> <#if logic.getLogicType() != 'APPVIEWLOGIC' && logic.getLogicType() != 'APPVIEWENGINE' && logic.getTriggerType() == 'CTRLEVENT'>
/** /**
...@@ -40,21 +38,22 @@ ...@@ -40,21 +38,22 @@
* @param {*} event 源事件对象 * @param {*} event 源事件对象
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public async execute_${logic.name}_ctrl_logic(data: any[], event?: any): Promise<boolean> { public async execute_${logic.name}_ctrl_logic(actionData: any): Promise<boolean> {
<#if logic.getLogicType() == 'DEUILOGIC'> <#if logic.getLogicType() == 'DEUILOGIC'>
<#if logic.getPSAppDEUILogic?? && logic.getPSAppDEUILogic()??> <#if logic.getPSAppDEUILogic?? && logic.getPSAppDEUILogic()??>
try { try {
const uiService = await window.uiServiceRegister.getService('${logic.getPSAppDEUILogic().getPSAppDataEntity().getCodeName()?lower_case}'); const uiService = await window.uiServiceRegister.getService('${logic.getPSAppDEUILogic().getPSAppDataEntity().getCodeName()?lower_case}');
if (uiService) { if (uiService) {
const { data, context, viewparams } = actionData;
const result = await uiService.executeUILogic( const result = await uiService.executeUILogic(
'${logic.getPSAppDEUILogic().codeName}', '${logic.getPSAppDEUILogic().codeName}',
data, data,
Util.deepCopy(this.context), context,
Util.deepCopy(this.viewparams), viewparams,
event, actionData.event ? actionData.event : {},
this, this,
this.viewCtx && this.viewCtx.view ? this.viewCtx.view : {}, this.viewCtx && this.viewCtx.view ? this.viewCtx.view : {},
this.context.srfparentdename ? this.context.srfparentdename : '' context.srfparentdename ? context.srfparentdename : ''
); );
if (result && result.hasOwnProperty('srfret') && (result.srfret === 'false' || result.srfret === false)) { if (result && result.hasOwnProperty('srfret') && (result.srfret === 'false' || result.srfret === false)) {
return false; return false;
......
...@@ -796,42 +796,65 @@ ${gridColumn.getName()} ...@@ -796,42 +796,65 @@ ${gridColumn.getName()}
* @param {*} [arg={}] * @param {*} [arg={}]
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public load(opt: any = {}, pageReset: boolean = false): void { public async load(opt: any = {}, pageReset: boolean = false): Promise<any> {
if(!this.fetchAction){ if (!this.fetchAction) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}'+(this.$t('app.gridpage.notConfig.fetchAction') as string) }); this.$Notice.error({
title: this.$t("app.commonWords.wrong") as string,
desc: "${view.getName()}" + (this.$t("app.gridpage.notConfig.fetchAction") as string),
});
return; return;
} }
if(pageReset){ if (pageReset) {
this.curPage = 1; this.curPage = 1;
} }
const arg: any = {...opt}; const arg: any = { ...opt };
const page: any = {}; const page: any = {};
if (this.isEnablePagingBar) { if (this.isEnablePagingBar) {
Object.assign(page, { page: this.curPage-1, size: this.limit }); Object.assign(page, { page: this.curPage - 1, size: this.limit });
} }
// 设置排序 // 设置排序
if (!this.isNoSort && !Object.is(this.minorSortDir, '') && !Object.is(this.minorSortPSDEF, '')) { if (!this.isNoSort && !Object.is(this.minorSortDir, "") && !Object.is(this.minorSortPSDEF, "")) {
const sort: string = this.minorSortPSDEF+","+this.minorSortDir; const sort: string = this.minorSortPSDEF + "," + this.minorSortDir;
Object.assign(page, { sort: sort }); Object.assign(page, { sort: sort });
} }
//清空selections // 清空selections
if(this.selections && this.selections.length > 0) { if (this.selections && this.selections.length > 0) {
this.selections = []; this.selections = [];
this.$emit('selectionchange', this.selections); this.$emit("selectionchange", this.selections);
} }
Object.assign(arg, page); Object.assign(arg, page);
const parentdata: any = {}; const parentdata: any = {};
this.$emit('beforeload', parentdata); this.$emit("beforeload", parentdata);
Object.assign(arg, parentdata); Object.assign(arg, parentdata);
let tempViewParams:any = parentdata.viewparams?parentdata.viewparams:{}; let tempViewParams: any = parentdata.viewparams ? parentdata.viewparams : {};
Object.assign(tempViewParams,JSON.parse(JSON.stringify(this.viewparams))); Object.assign(tempViewParams, Util.deepCopy(this.viewparams));
Object.assign(arg,{viewparams:tempViewParams}); Object.assign(arg, { viewparams: tempViewParams });
const post: Promise<any> = this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator); const tempContext = Util.deepCopy(this.context);
post.then((response: any) => { if (!(await this.handleCtrlEvents('onbeforeload', { context: tempContext, viewparams: arg }))) {
return;
}
try {
const response = await this.service.search(
this.fetchAction,
tempContext,
arg,
this.showBusyIndicator
);
if (!response.status || response.status !== 200) { if (!response.status || response.status !== 200) {
// 加载失败
if (!(await this.handleCtrlEvents('onloaderror', { data: response.data ? response.data : [], context: tempContext, viewparams: arg }))) {
return;
}
if (response.data && response.data.message) { if (response.data && response.data.message) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message }); this.$Notice.error({
title: this.$t("app.commonWords.wrong") as string,
desc: response.data.message,
});
} }
return response;
}
// 加载成功
if (!(await this.handleCtrlEvents('onloadsuccess', { data: response.data, context: tempContext, viewparams: arg }))) {
return; return;
} }
const data: any = response.data; const data: any = response.data;
...@@ -840,36 +863,38 @@ ${gridColumn.getName()} ...@@ -840,36 +863,38 @@ ${gridColumn.getName()}
// 清空selections,gridItemsModel // 清空selections,gridItemsModel
// this.selections = []; // this.selections = [];
this.gridItemsModel = []; this.gridItemsModel = [];
this.items.forEach(()=>{this.gridItemsModel.push(this.getGridRowModel())}); this.items.forEach(() => {
this.items.forEach((item:any)=>{ this.gridItemsModel.push(this.getGridRowModel());
Object.assign(item,this.getActionState(item));
}); });
this.$emit('load', this.items); this.items.forEach((item: any) => {
Object.assign(item, this.getActionState(item));
});
this.$emit("load", this.items);
// 设置默认选中 // 设置默认选中
let _this = this; let _this = this;
setTimeout(() => { setTimeout(() => {
//在导航视图中,如已有选中数据,则右侧展开已选中数据的视图,如无选中数据则默认选中第一条 //在导航视图中,如已有选中数据,则右侧展开已选中数据的视图,如无选中数据则默认选中第一条
if(_this.isSelectFirstDefault){ if (_this.isSelectFirstDefault) {
if(_this.selections && _this.selections.length > 0){ if (_this.selections && _this.selections.length > 0) {
_this.selections.forEach((select: any)=>{ _this.selections.forEach((select: any) => {
const index = _this.items.findIndex((item:any) => Object.is(item.srfkey,select.srfkey)); const index = _this.items.findIndex((item: any) => Object.is(item.srfkey, select.srfkey));
if(index != -1){ if (index != -1) {
_this.rowClick(_this.items[index]); _this.rowClick(_this.items[index]);
} }
}) });
}else{ } else {
_this.rowClick(this.items[0]); _this.rowClick(this.items[0]);
} }
} }
if(_this.selectedData){ if (_this.selectedData) {
const refs: any = _this.$refs; const refs: any = _this.$refs;
if (refs.multipleTable) { if (refs.multipleTable) {
refs.multipleTable.clearSelection(); refs.multipleTable.clearSelection();
JSON.parse(_this.selectedData).forEach((selection:any)=>{ JSON.parse(_this.selectedData).forEach((selection: any) => {
let selectedItem = _this.items.find((item:any)=>{ let selectedItem = _this.items.find((item: any) => {
return Object.is(item.srfkey, selection.srfkey); return Object.is(item.srfkey, selection.srfkey);
}); });
if(selectedItem){ if (selectedItem) {
_this.rowClick(selectedItem); _this.rowClick(selectedItem);
} }
}); });
...@@ -882,12 +907,21 @@ ${gridColumn.getName()} ...@@ -882,12 +907,21 @@ ${gridColumn.getName()}
<#if ctrl.isEnableGroup()> <#if ctrl.isEnableGroup()>
this.group(); this.group();
</#if> </#if>
}).catch((response: any) => { return response;
if (response && response.status === 401) { } catch (response: any) {
// 加载失败
if (!(await this.handleCtrlEvents('onloaderror', { data: response.data, context: tempContext, viewparams: tempViewParams }))) {
return; return;
} }
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data && response.data.message ? response.data.message : "" }); if (response && response.status === 401) {
return response;
}
this.$Notice.error({
title: this.$t("app.commonWords.wrong") as string,
desc: response.data && response.data.message ? response.data.message : "",
}); });
return response;
}
} }
/** /**
...@@ -898,8 +932,11 @@ ${gridColumn.getName()} ...@@ -898,8 +932,11 @@ ${gridColumn.getName()}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public async remove(datas: any[]): Promise<any> { public async remove(datas: any[]): Promise<any> {
if(!this.removeAction){ if (!this.removeAction) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}'+(this.$t('app.gridpage.notConfig.removeAction') as string) }); this.$Notice.error({
title: (this.$t('app.commonWords.wrong') as string),
desc: '${view.getName()}' + (this.$t('app.gridpage.notConfig.removeAction') as string)
});
return; return;
} }
let _datas:any[] = []; let _datas:any[] = [];
...@@ -912,7 +949,7 @@ ${gridColumn.getName()} ...@@ -912,7 +949,7 @@ ${gridColumn.getName()}
return true; return true;
} }
}); });
}else{ } else {
_datas.push(datas[index]); _datas.push(datas[index]);
} }
}); });
...@@ -1689,6 +1726,11 @@ ${gridColumn.getName()} ...@@ -1689,6 +1726,11 @@ ${gridColumn.getName()}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public select(selection: any, row: any): void { public select(selection: any, row: any): void {
// 选中事件
this.handleCtrlEvents('onselectionchange', [row]).then((result: boolean) => {
if (!result) {
return;
}
if(this.groupAppField) { if(this.groupAppField) {
let isContain:boolean = selection.some((item:any) =>{ let isContain:boolean = selection.some((item:any) =>{
return item == row; return item == row;
...@@ -1720,6 +1762,7 @@ ${gridColumn.getName()} ...@@ -1720,6 +1762,7 @@ ${gridColumn.getName()}
this.selections = [...JSON.parse(JSON.stringify(selection))]; this.selections = [...JSON.parse(JSON.stringify(selection))];
} }
this.$emit('selectionchange', this.selections); this.$emit('selectionchange', this.selections);
});
} }
/** /**
...@@ -2313,19 +2356,34 @@ ${gridColumn.getName()} ...@@ -2313,19 +2356,34 @@ ${gridColumn.getName()}
* @returns {void} * @returns {void}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public newRow(args: any[], params?: any, $event?: any, xData?: any): void { public async newRow(args: any[], params?: any, $event?: any, xData?: any): Promise<any> {
if(!this.loaddraftAction){ if(!this.loaddraftAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}'+(this.$t('app.gridpage.notConfig.loaddraftAction') as string) }); this.$Notice.error({
title: (this.$t('app.commonWords.wrong') as string),
desc: '${view.getName()}' + (this.$t('app.gridpage.notConfig.loaddraftAction') as string)
});
return; return;
} }
let _this = this; let _this = this;
Object.assign(args[0],{viewparams:this.viewparams}); Object.assign(args[0], { viewparams: Util.deepCopy(this.viewparams) });
let post: Promise<any> = this.service.loadDraft(this.loaddraftAction, JSON.parse(JSON.stringify(this.context)), args[0], this.showBusyIndicator); try {
post.then((response: any) => { // 加载草稿之前
if (!(await this.handleCtrlEvents('onbeforeloaddraft', { data: args[0] }))) {
return;
}
const response = await this.service.loadDraft(this.loaddraftAction, Util.deepCopy(this.context), args[0], this.showBusyIndicator);
if (!response.status || response.status !== 200) { if (!response.status || response.status !== 200) {
// 加载草稿失败
if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response.data ? response.data : {} }))) {
return;
}
if (response.data && response.data.message) { if (response.data && response.data.message) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message }); this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
} }
return response;
}
// 加载草稿成功
if (!(await this.handleCtrlEvents('onloaddraftsuccess', { data: response.data }))) {
return; return;
} }
const data = response.data; const data = response.data;
...@@ -2333,15 +2391,20 @@ ${gridColumn.getName()} ...@@ -2333,15 +2391,20 @@ ${gridColumn.getName()}
data.rowDataState = "create"; data.rowDataState = "create";
this.items.splice(0,0,data); this.items.splice(0,0,data);
_this.gridItemsModel.push(_this.getGridRowModel()); _this.gridItemsModel.push(_this.getGridRowModel());
}).catch((response: any) => { return response;
if (response && response.status === 401) { } catch(response: any) {
// 加载草稿失败
if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response.data ? response.data : {} }))) {
return; return;
} }
if (response && response.status === 401) {
return response;
}
if (!response || !response.status || !response.data) { if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) }); this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return; return;
} }
}); }
} }
/** /**
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<#list logicNode.getPSDEUILogicLinks() as link> <#list logicNode.getPSDEUILogicLinks() as link>
<#if link.getDstPSDEUILogicNode?? && link.getDstPSDEUILogicNode()??> <#if link.getDstPSDEUILogicNode?? && link.getDstPSDEUILogicNode()??>
<#if link.getPSDEUILogicLinkGroupCond?? && link.getPSDEUILogicLinkGroupCond()??> <#if link.getPSDEUILogicLinkGroupCond?? && link.getPSDEUILogicLinkGroupCond()??>
if(<@getCond link.getPSDEUILogicLinkGroupCond() />) { if (<@getCond link.getPSDEUILogicLinkGroupCond() />) {
await this.execute_${link.getDstPSDEUILogicNode().codeName?lower_case}_node(actionContext); await this.execute_${link.getDstPSDEUILogicNode().codeName?lower_case}_node(actionContext);
} }
<#else> <#else>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册