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

update:更新

上级 9319a667
......@@ -55,7 +55,7 @@
viewparams,
actionData.event ? actionData.event : {},
this,
this.viewCtx && this.viewCtx.view ? this.viewCtx.view : {},
this,
context.srfparentdename ? context.srfparentdename : ''
);
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
*/
@Prop() public viewparams!: any;
/**
* 视图操作参数(父级)
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
@Prop() public pViewCtx!: any;
/**
* 视图操作参数
*
* @type {*}
* @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 @@
:viewState="viewState"
:viewparams="viewparams"
:context="context"
:viewCtx="viewCtx"
:pViewCtx="viewCtx"
<#if content??>
${content}<#t>
</#if>
......
......@@ -806,7 +806,7 @@ import CodeListService from "@/codelist/codelist-service";
* @param {boolean} [isReset=false] 是否重置items
* @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){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}' + (this.$t('app.list.notConfig.fetchAction') as string) });
return;
......@@ -828,14 +828,25 @@ import CodeListService from "@/codelist/codelist-service";
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) => {
if (!(await this.handleCtrlEvents('onbeforeload', { data: arg }))) {
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 (!(await this.handleCtrlEvents('onloaderror', { 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;
}
// 加载成功
if (!(await this.handleCtrlEvents('onloadsuccess', { data: response.data }))) {
return;
}
const data: any = response.data;
if(!this.isAddBehind){
this.items = [];
......@@ -873,6 +884,19 @@ import CodeListService from "@/codelist/codelist-service";
<#if ctrl.isEnableGroup?? && ctrl.isEnableGroup()>
this.group();
</#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) => {
if (response && response.status === 401) {
return;
......@@ -935,42 +959,46 @@ import CodeListService from "@/codelist/codelist-service";
});
let _removeAction = keys.length > 1 ? 'removeBatch' : this.removeAction ;
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);
return new Promise((resolve: any, reject: any) => {
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '', desc: (this.$t('app.commonWords.delDataFail') as string) + ',' + response.info });
try {
if (!(await this.handleCtrlEvents('onbeforeremove', { data: _keys }))) {
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 (!(await this.handleCtrlEvents('onremoveerror', { data: _keys }))) {
return;
} else {
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.deleteSuccess') as string) });
}
//删除items中已删除的项
_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.$Notice.error({ title: '', desc: (this.$t('app.commonWords.delDataFail') as string) + ',' + response.info });
return;
}
if (!(await this.handleCtrlEvents('onremovesuccess', { data: response.data }))) {
return;
}
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.deleteSuccess') as string) });
//删除items中已删除的项
_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, '');
......@@ -998,6 +1026,9 @@ import CodeListService from "@/codelist/codelist-service";
let successItems:any = [];
let errorItems:any = [];
let errorMessage:any = [];
if (!(await this.handleCtrlEvents('onbeforesave', { data: _this.items }))) {
return;
}
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
......@@ -1030,12 +1061,18 @@ import CodeListService from "@/codelist/codelist-service";
this.$emit('save', successItems);
this.refresh();
if(errorItems.length === 0){
if (!(await this.handleCtrlEvents('onsavesuccess', { data: successItems }))) {
return;
}
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.saveSuccess') as string) });
}else{
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]);
});
} else {
if (!(await this.handleCtrlEvents('onsaveerror', { data: errorItems }))) {
return;
}
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;
}
......@@ -1083,13 +1120,18 @@ import CodeListService from "@/codelist/codelist-service";
*
*/
public selectchange() {
this.selections = [];
this.items.map((item: any) => {
if (item.isselected) {
this.selections.push(item);
this.handleCtrlEvents('onselectionchange').then((res: boolean) => {
if (!res) {
return;
}
});
this.$emit('selectionchange', this.selections);
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()}
);
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;
}
if (response.data && response.data.message) {
......@@ -910,7 +910,7 @@ ${gridColumn.getName()}
return response;
} 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;
}
if (response && response.status === 401) {
......
......@@ -5,6 +5,10 @@
*/
public ${item.name}(params: any = {}, tag?: any, $event?: any) {
const { data, context, viewparams, xData, event } = params;
// 合并当前激活部件
if (xData) {
Object.assign(this.viewCtx, { ctrl: xData, xData });
}
<#if item.getPSAppDEUILogic?? && item.getPSAppDEUILogic()?? && item.getPSAppDEUILogic().getPSAppDataEntity()??>
window.uiServiceRegister.getService('${item.getPSAppDEUILogic().getPSAppDataEntity().codeName?lower_case}').then((uiService: any) => {
if (uiService) {
......@@ -17,7 +21,10 @@
xData,
this,
context && context.srfparentdename ? context.srfparentdename : ''
);
).then(() => {
delete this.viewCtx['ctrl'];
delete this.viewCtx['xData'];
});
}
});
</#if>
......
......@@ -380,7 +380,7 @@
*/
initViewCtx() {
Object.assign(this.viewCtx, {
app: this.$router,
app: this.$root,
view: this,
viewGlobal: {},
viewNavData: {},
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册