Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
22
议题
22
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7
提交
3ae8a5b3
提交
3ae8a5b3
编写于
11月 10, 2022
作者:
Mosher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update:更新表单事件
上级
2daa1904
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
152 行增加
和
100 行删除
+152
-100
CONTROL-BASE.vue.ftl
@CONTROL/表单/CONTROL-BASE.vue.ftl
+152
-100
未找到文件。
@CONTROL/表单/CONTROL-BASE.vue.ftl
浏览文件 @
3ae8a5b3
...
...
@@ -1164,33 +1164,45 @@ import { Environment } from '@/environments/environment';
* @param {*} [opt={}]
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public
load(opt: any = {}): void
{
public
async load(opt: any = {}): Promise<any>
{
if(!this.loadAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}' + (this.$t('app.formpage.notconfig.loadaction') as string) });
return;
}
const arg: any = { ...opt };
let viewparamResult:any = Object.assign(arg,this.viewparams);
const get: Promise<any> = this.service.get(this.loadAction,JSON.parse(JSON.stringify(this.context)),{viewparams:viewparamResult}, this.showBusyIndicator);
get.then((response: any) => {
let viewparamResult:any = Object.assign(arg, this.viewparams);
const tempContext = Util.deepCopy(this.context);
if (!(await this.handleCtrlEvents('onbeforeload', { context: tempContext, viewparams: viewparamResult, data: arg }))) {
return;
}
const get: Promise<any> = this.service.get(this.loadAction, tempContext,{ viewparams: viewparamResult }, this.showBusyIndicator);
try {
if (response && response.status === 200) {
if (!(await this.handleCtrlEvents('onloadsuccess', { data: response.data }))) {
return;
}
const data = response.data;
this.onFormLoad(data,'load');
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
} else {
if (!(await this.handleCtrlEvents('onloaderror', { data: response.data }))) {
return;
}
}
}).catch((response: any) => {
if (response && response.status && response.data
) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return response;
} catch (response: any
) {
if (!(await this.handleCtrlEvents('onloaderror', { context: tempContext, viewparams: viewparamResult, data: response && response.data ? response.data : arg }))) {
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)
});
if (
response && response.status &&
response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc:
response.data.message
});
return;
}
});
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
}
}
/**
...
...
@@ -1199,22 +1211,30 @@ import { Environment } from '@/environments/environment';
* @param {*} [opt={}]
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public
loadDraft(opt: any = {}): void
{
if
(!this.loaddraftAction)
{
public
async loadDraft(opt: any = {}): Promise<any>
{
if
(!this.loaddraftAction)
{
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}' + (this.$t('app.formpage.notconfig.loaddraftaction') as string) });
return;
}
const arg: any = { ...opt } ;
let viewparamResult:any = Object.assign(arg,this.viewparams);
let post: Promise<any> = this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)),{viewparams:viewparamResult}, this.showBusyIndicator);
post.then((response: any) => {
let viewparamResult:any = Object.assign(arg, this.viewparams);
try {
if (!(await this.handleCtrlEvents('onbeforeloaddraft', { data: arg }))) {
return;
}
const response: any = this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)),{viewparams:viewparamResult}, this.showBusyIndicator);
if (!response.status || response.status !== 200) {
if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response.data ? response.data : arg }))) {
return;
}
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
if (!(await this.handleCtrlEvents('onloaddraftsuccess', { data: response.data }))) {
return;
}
const data = response.data;
this.resetDraftFormStates();
this.onFormLoad(data,'loadDraft');
...
...
@@ -1240,16 +1260,17 @@ import { Environment } from '@/environments/environment';
});
}
});
}).catch((response: any) => {
if (response && response.status && response.data
) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return response;
} catch (response: any
) {
if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response.data ? response.data : arg }))) {
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;
if (
response && response.status &&
response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc:
response.data.message
});
return
response
;
}
});
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
}
}
/**
...
...
@@ -1344,7 +1365,7 @@ import { Environment } from '@/environments/environment';
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public
async
save(opt: any = {}, showResultInfo?: boolean, ifStateNext: boolean = true): Promise<any> {
public save(opt: any = {}, showResultInfo?: boolean, ifStateNext: boolean = true): Promise<any> {
return new Promise((resolve: any, reject: any) => {
showResultInfo = showResultInfo === undefined ? true : false;
if (!this.formValidateStatus()) {
...
...
@@ -1388,71 +1409,89 @@ import { Environment } from '@/environments/environment';
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}' + (this.$t('app.formpage.notconfig.actionname') as string) });
return;
}
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = Object.is(data.srfuf, '1')?this.service.update(action, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator):this.service.add(action,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
Object.assign(arg, { viewparams: this.viewparams });
this.handleCtrlEvents('onbeforesave', { data: arg }).then((beforeSaveResult: boolean) => {
if (!beforeSaveResult) {
return;
}
this.viewparams.copymode = false;
const data = response.data;
this.onFormLoad(data,'save');
this.$emit('save', data);
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
<#if ctrl.getFormFuncMode()?lower_case != 'wizardform'>
if (showResultInfo) {
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + ' '+ (this.$t('app.formpage.savesuccess') as string) });
}
</#if>
resolve(response);
}).catch((response: any) => {
if (response && response.status && response.data) {
if (response.data.errorKey) {
if(Object.is(response.data.errorKey, "versionCheck")) {
this.$Modal.confirm({
title: (this.$t('app.formpage.saveerror') as string),
content: (this.$t('app.formpage.savecontent') as string),
onOk: () => {
this.refresh([]);
},
onCancel: () => { }
});
} else if(Object.is(response.data.errorKey, 'DupCheck')) {
let errorProp: string = response.data.message.match(/\[[a-zA-Z]*\]/)[0];
let name: string = this.service.getNameByProp(errorProp.substr(1, errorProp.length-2));
if(name) {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: this.detailsModel[name].caption + " : " + arg[name] + (this.$t('app.commonWords.isExist') as string) + '!',
});
const post: Promise<any> = Object.is(data.srfuf, '1') ? this.service.update(action, JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator):this.service.add(action,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
this.handleCtrlEvents('onsaverror', { data: response && response.data ? response.data : arg }).then((saveErrorResult: boolean) => {
// 保存失败处理
})
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
this.handleCtrlEvents('onsavesuccess', { data: response.data }).then((saveSuccessResult: boolean) => {
if (!saveSuccessResult) {
return;
}
this.viewparams.copymode = false;
const data = response.data;
this.onFormLoad(data,'save');
this.$emit('save', data);
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
<#if ctrl.getFormFuncMode()?lower_case != 'wizardform'>
if (showResultInfo) {
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + ' '+ (this.$t('app.formpage.savesuccess') as string) });
}
</#if>
resolve(response);
})
}).catch((response: any) => {
this.handleCtrlEvents('onsaveerror', { data: response && response.data ? response.data : {} }).then((saveErrorResult: boolean) => {
if (!saveErrorResult) {
return;
}
if (response && response.status && response.data) {
if (response.data.errorKey) {
if(Object.is(response.data.errorKey, "versionCheck")) {
this.$Modal.confirm({
title: (this.$t('app.formpage.saveerror') as string),
content: (this.$t('app.formpage.savecontent') as string),
onOk: () => {
this.refresh([]);
},
onCancel: () => { }
});
} else if(Object.is(response.data.errorKey, 'DupCheck')) {
let errorProp: string = response.data.message.match(/\[[a-zA-Z]*\]/)[0];
let name: string = this.service.getNameByProp(errorProp.substr(1, errorProp.length-2));
if(name) {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: this.detailsModel[name].caption + " : " + arg[name] + (this.$t('app.commonWords.isExist') as string) + '!',
});
} else {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: response.data.message,
})
}
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
} else {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: response.data.message,
})
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
}
return;
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
} else {
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: (this.$t('app.commonWords.sysException') as string) });
reject(response);
}
reject(response);
}
return;
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
}
reject(response);
});
})
});
})
})
}
...
...
@@ -1471,24 +1510,37 @@ import { Environment } from '@/environments/environment';
}
const arg: any = opt[0];
const _this: any = this;
Object.assign(arg,{viewparams:this.viewparams});
this.service.delete(_this.removeAction, JSON.parse(JSON.stringify(this.context)),arg, showResultInfo).then((response: any) => {
if (response) {
const data = response.data;
this.$emit('remove',data);
this.formState.next({ type: 'remove', data: data });
this.data.ismodify = false;
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + ' ' + (this.$t('app.formpage.deletesuccess') as string) });
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
resolve(response);
Object.assign(arg, { viewparams: this.viewparams });
this.handleCtrlEvents('onbeforeremove', { data: arg }).then((beforeRemoveResult: boolean) => {
if (!beforeRemoveResult) {
return;
}
}).catch((error: any) => {
const { data: _data } = error;
this.$Notice.error({ title: _data.title, desc: _data.message });
reject(error);
});
this.service.delete(_this.removeAction, JSON.parse(JSON.stringify(this.context)), arg, showResultInfo).then((response: any) => {
if (response && response.status === 200) {
this.handleCtrlEvents('onremovesuccess', { data: response.data }).then((removeSuccessResult: boolean) => {
const data = response.data;
this.$emit('remove',data);
this.formState.next({ type: 'remove', data: data });
this.data.ismodify = false;
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + ' ' + (this.$t('app.formpage.deletesuccess') as string) });
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
resolve(response);
})
} else {
this.handleCtrlEvents('onremoveerror', { data: response && response.data ? response.data : arg });
}
}).catch((error: any) => {
this.handleCtrlEvents('onremoveerror', { data: error && error.data ? error.data : arg }).then((removeErrorResult) => {
if (!removeErrorResult) {
const { data: _data } = error;
this.$Notice.error({ title: _data.title, desc: _data.message });
reject(error);
}
})
});
})
});
}
<#if ctrl.getControlType() == 'FORM'>
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录