提交 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,42 +959,46 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -935,42 +959,46 @@ 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;
if (!response || response.status !== 200) { }
this.$Notice.error({ title: '', desc: (this.$t('app.commonWords.delDataFail') as string) + ',' + response.info }); 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 (!(await this.handleCtrlEvents('onremoveerror', { data: _keys }))) {
return; return;
} else {
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.deleteSuccess') as string) });
} }
//删除items中已删除的项 this.$Notice.error({ title: '', desc: (this.$t('app.commonWords.delDataFail') as string) + ',' + response.info });
_datas.forEach((data: any) => { return;
this.items.some((item:any,index:number)=>{ }
if(Object.is(item.srfkey,data.srfkey)){ if (!(await this.handleCtrlEvents('onremovesuccess', { data: response.data }))) {
this.items.splice(index,1); return;
<#if ctrl.isEnableGroup?? && ctrl.isEnableGroup()> }
this.group(); this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.deleteSuccess') as string) });
</#if> //删除items中已删除的项
return true; _datas.forEach((data: any) => {
} this.items.some((item:any,index:number)=>{
}); if(Object.is(item.srfkey,data.srfkey)){
this.items.splice(index,1);
<#if ctrl.isEnableGroup?? && ctrl.isEnableGroup()>
this.group();
</#if>
return true;
}
}); });
this.$emit('remove', null);
this.selections = [];
resolve(response);
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
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) });
reject(response);
return;
}
reject(response);
}); });
}); this.$emit('remove', null);
this.selections = [];
return response;
} catch (response: any) {
if (response && response.status === 401) {
return;
}
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 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,12 +1061,18 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -1030,12 +1061,18 @@ 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 {
errorItems.forEach((item:any,index:number)=>{ if (!(await this.handleCtrlEvents('onsaveerror', { data: errorItems }))) {
this.$Notice.error({ title: (this.$t('app.commonWords.saveFailed') as string), desc: item.majorentityname + (this.$t('app.commonWords.saveFailed') as string) + '!' }); return;
console.error(errorMessage[index]); }
}); 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) + '!' });
console.error(errorMessage[index]);
});
} }
return successItems; return successItems;
} }
...@@ -1083,13 +1120,18 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -1083,13 +1120,18 @@ import CodeListService from "@/codelist/codelist-service";
* *
*/ */
public selectchange() { public selectchange() {
this.selections = []; this.handleCtrlEvents('onselectionchange').then((res: boolean) => {
this.items.map((item: any) => { if (!res) {
if (item.isselected) { return;
this.selections.push(item);
} }
}); this.selections = [];
this.$emit('selectionchange', this.selections); this.items.map((item: any) => {
if (item.isselected) {
this.selections.push(item);
}
});
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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册