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

update:更新

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