提交 4a8a8a83 编写于 作者: Mosher's avatar Mosher

update:更新

上级 9319a667
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
viewparams, viewparams,
actionData.event ? actionData.event : {}, actionData.event ? actionData.event : {},
this, this,
this.viewCtx && this.viewCtx.view ? this.viewCtx.view : {}, this,
context.srfparentdename ? 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)) {
......
...@@ -77,13 +77,32 @@ export default class ${srfclassname('${ctrl.codeName}')}Base extends Vue impleme ...@@ -77,13 +77,32 @@ export default class ${srfclassname('${ctrl.codeName}')}Base extends Vue impleme
*/ */
@Prop() public viewparams!: any; @Prop() public viewparams!: any;
/**
* 视图操作参数(父级)
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
@Prop() public pViewCtx!: any;
/** /**
* 视图操作参数 * 视图操作参数
* *
* @type {*} * @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
@Prop() public viewCtx!: any; public viewCtx: any = {};
/**
* 监听视图操作参数变化
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
@Watch('pViewCtx', { immediate: true, deep: true })
public onViewCtxChange(newVal: any, oldVal: any) {
Object.assign(this.viewCtx, newVal, { xData: this, ctrl: this });
}
/** /**
* 视图状态事件 * 视图状态事件
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
:viewState="viewState" :viewState="viewState"
:viewparams="viewparams" :viewparams="viewparams"
:context="context" :context="context"
:viewCtx="viewCtx" :pViewCtx="viewCtx"
<#if content??> <#if content??>
${content}<#t> ${content}<#t>
</#if> </#if>
......
...@@ -806,7 +806,7 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -806,7 +806,7 @@ import CodeListService from "@/codelist/codelist-service";
* @param {boolean} [isReset=false] 是否重置items * @param {boolean} [isReset=false] 是否重置items
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public load(opt: any = {}, isReset: boolean = false): void { public async load(opt: any = {}, isReset: 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.list.notConfig.fetchAction') as string) }); this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}' + (this.$t('app.list.notConfig.fetchAction') as string) });
return; return;
...@@ -828,14 +828,25 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -828,14 +828,25 @@ import CodeListService from "@/codelist/codelist-service";
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,JSON.parse(JSON.stringify(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); if (!(await this.handleCtrlEvents('onbeforeload', { data: arg }))) {
post.then((response: any) => { return;
}
try {
const response = await this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
if (!response || response.status !== 200) { if (!response || response.status !== 200) {
// 加载失败
if (!(await this.handleCtrlEvents('onloaderror', { 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; return;
} }
// 加载成功
if (!(await this.handleCtrlEvents('onloadsuccess', { data: response.data }))) {
return;
}
const data: any = response.data; const data: any = response.data;
if(!this.isAddBehind){ if(!this.isAddBehind){
this.items = []; this.items = [];
...@@ -873,6 +884,19 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -873,6 +884,19 @@ import CodeListService from "@/codelist/codelist-service";
<#if ctrl.isEnableGroup?? && ctrl.isEnableGroup()> <#if ctrl.isEnableGroup?? && ctrl.isEnableGroup()>
this.group(); this.group();
</#if> </#if>
} catch (response: any) {
// 加载失败
if (!(await this.handleCtrlEvents('onloaderror', { data: response && response.data ? response.data : [] }))) {
return;
}
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data && response.data.message ? response.data.message : "" });
}
const post: Promise<any> =
post.then((response: any) => {
}, (response: any) => { }, (response: any) => {
if (response && response.status === 401) { if (response && response.status === 401) {
return; return;
...@@ -935,15 +959,22 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -935,15 +959,22 @@ import CodeListService from "@/codelist/codelist-service";
}); });
let _removeAction = keys.length > 1 ? 'removeBatch' : this.removeAction ; let _removeAction = keys.length > 1 ? 'removeBatch' : this.removeAction ;
const context:any = JSON.parse(JSON.stringify(this.context)); const context:any = JSON.parse(JSON.stringify(this.context));
const post: Promise<any> = this.service.delete(_removeAction,Object.assign(context,{ ${ctrl.getPSAppDataEntity().codeName?lower_case}: keys.join(';') }),Object.assign({ ${ctrl.getPSAppDataEntity().codeName?lower_case}: keys.join(';') },{viewparams:this.viewparams}), this.showBusyIndicator); try {
return new Promise((resolve: any, reject: any) => { if (!(await this.handleCtrlEvents('onbeforeremove', { data: _keys }))) {
post.then((response: any) => { return;
}
const response: any = this.service.delete(_removeAction,Object.assign(context,{ ${ctrl.getPSAppDataEntity().codeName?lower_case}: keys.join(';') }),Object.assign({ ${ctrl.getPSAppDataEntity().codeName?lower_case}: keys.join(';') },{viewparams:this.viewparams}), this.showBusyIndicator);
if (!response || response.status !== 200) { if (!response || response.status !== 200) {
if (!(await this.handleCtrlEvents('onremoveerror', { data: _keys }))) {
return;
}
this.$Notice.error({ title: '', desc: (this.$t('app.commonWords.delDataFail') as string) + ',' + response.info }); this.$Notice.error({ title: '', desc: (this.$t('app.commonWords.delDataFail') as string) + ',' + response.info });
return; return;
} else {
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.deleteSuccess') as string) });
} }
if (!(await this.handleCtrlEvents('onremovesuccess', { data: response.data }))) {
return;
}
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.deleteSuccess') as string) });
//删除items中已删除的项 //删除items中已删除的项
_datas.forEach((data: any) => { _datas.forEach((data: any) => {
this.items.some((item:any,index:number)=>{ this.items.some((item:any,index:number)=>{
...@@ -958,19 +989,16 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -958,19 +989,16 @@ import CodeListService from "@/codelist/codelist-service";
}); });
this.$emit('remove', null); this.$emit('remove', null);
this.selections = []; this.selections = [];
resolve(response); return response;
}).catch((response: any) => { } catch (response: any) {
if (response && response.status === 401) { if (response && response.status === 401) {
return; return;
} }
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) });
reject(response);
return;
} }
reject(response); return response;
}); }
});
} }
dataInfo = dataInfo.replace(/[null]/g, '').replace(/[undefined]/g, '').replace(/[ ]/g, ''); dataInfo = dataInfo.replace(/[null]/g, '').replace(/[undefined]/g, '').replace(/[ ]/g, '');
...@@ -998,6 +1026,9 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -998,6 +1026,9 @@ import CodeListService from "@/codelist/codelist-service";
let successItems:any = []; let successItems:any = [];
let errorItems:any = []; let errorItems:any = [];
let errorMessage:any = []; let errorMessage:any = [];
if (!(await this.handleCtrlEvents('onbeforesave', { data: _this.items }))) {
return;
}
for (const item of _this.items) { for (const item of _this.items) {
try { try {
if(Object.is(item.rowDataState, 'create')){ if(Object.is(item.rowDataState, 'create')){
...@@ -1030,8 +1061,14 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -1030,8 +1061,14 @@ import CodeListService from "@/codelist/codelist-service";
this.$emit('save', successItems); this.$emit('save', successItems);
this.refresh(); this.refresh();
if(errorItems.length === 0){ if(errorItems.length === 0){
if (!(await this.handleCtrlEvents('onsavesuccess', { data: successItems }))) {
return;
}
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.saveSuccess') as string) }); this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.saveSuccess') as string) });
}else{ } else {
if (!(await this.handleCtrlEvents('onsaveerror', { data: errorItems }))) {
return;
}
errorItems.forEach((item:any,index:number)=>{ errorItems.forEach((item:any,index:number)=>{
this.$Notice.error({ title: (this.$t('app.commonWords.saveFailed') as string), desc: item.majorentityname + (this.$t('app.commonWords.saveFailed') as string) + '!' }); this.$Notice.error({ title: (this.$t('app.commonWords.saveFailed') as string), desc: item.majorentityname + (this.$t('app.commonWords.saveFailed') as string) + '!' });
console.error(errorMessage[index]); console.error(errorMessage[index]);
...@@ -1083,6 +1120,10 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -1083,6 +1120,10 @@ import CodeListService from "@/codelist/codelist-service";
* *
*/ */
public selectchange() { public selectchange() {
this.handleCtrlEvents('onselectionchange').then((res: boolean) => {
if (!res) {
return;
}
this.selections = []; this.selections = [];
this.items.map((item: any) => { this.items.map((item: any) => {
if (item.isselected) { if (item.isselected) {
...@@ -1090,6 +1131,7 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -1090,6 +1131,7 @@ import CodeListService from "@/codelist/codelist-service";
} }
}); });
this.$emit('selectionchange', this.selections); this.$emit('selectionchange', this.selections);
})
} }
/** /**
......
...@@ -842,7 +842,7 @@ ${gridColumn.getName()} ...@@ -842,7 +842,7 @@ ${gridColumn.getName()}
); );
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 }))) { if (!(await this.handleCtrlEvents('onloaderror', { data: response.data ? response.data : [] }))) {
return; return;
} }
if (response.data && response.data.message) { if (response.data && response.data.message) {
...@@ -910,7 +910,7 @@ ${gridColumn.getName()} ...@@ -910,7 +910,7 @@ ${gridColumn.getName()}
return response; return response;
} catch (response: any) { } catch (response: any) {
// 加载失败 // 加载失败
if (!(await this.handleCtrlEvents('onloaderror', { data: response.data, context: tempContext, viewparams: tempViewParams }))) { if (!(await this.handleCtrlEvents('onloaderror', { data: response && response.data ? response.data : [] }))) {
return; return;
} }
if (response && response.status === 401) { if (response && response.status === 401) {
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
*/ */
public ${item.name}(params: any = {}, tag?: any, $event?: any) { public ${item.name}(params: any = {}, tag?: any, $event?: any) {
const { data, context, viewparams, xData, event } = params; const { data, context, viewparams, xData, event } = params;
// 合并当前激活部件
if (xData) {
Object.assign(this.viewCtx, { ctrl: xData, xData });
}
<#if item.getPSAppDEUILogic?? && item.getPSAppDEUILogic()?? && item.getPSAppDEUILogic().getPSAppDataEntity()??> <#if item.getPSAppDEUILogic?? && item.getPSAppDEUILogic()?? && item.getPSAppDEUILogic().getPSAppDataEntity()??>
window.uiServiceRegister.getService('${item.getPSAppDEUILogic().getPSAppDataEntity().codeName?lower_case}').then((uiService: any) => { window.uiServiceRegister.getService('${item.getPSAppDEUILogic().getPSAppDataEntity().codeName?lower_case}').then((uiService: any) => {
if (uiService) { if (uiService) {
...@@ -17,7 +21,10 @@ ...@@ -17,7 +21,10 @@
xData, xData,
this, this,
context && context.srfparentdename ? context.srfparentdename : '' context && context.srfparentdename ? context.srfparentdename : ''
); ).then(() => {
delete this.viewCtx['ctrl'];
delete this.viewCtx['xData'];
});
} }
}); });
</#if> </#if>
......
...@@ -380,7 +380,7 @@ ...@@ -380,7 +380,7 @@
*/ */
initViewCtx() { initViewCtx() {
Object.assign(this.viewCtx, { Object.assign(this.viewCtx, {
app: this.$router, app: this.$root,
view: this, view: this,
viewGlobal: {}, viewGlobal: {},
viewNavData: {}, viewNavData: {},
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册