提交 046ef750 编写于 作者: Mosher's avatar Mosher

update:更新

上级 80d2f5d1
......@@ -975,7 +975,7 @@ ${gridColumn.getName()}
dataInfo = ' ... ' + (this.$t('app.gridpage.totle') as string) + _datas.length + (this.$t('app.gridpage.records') as string) + (this.$t('app.gridpage.data') as string);
}
const removeData = () => {
const removeData = async () => {
let keys: any[] = [];
_datas.forEach((data: any) => {
keys.push(data.srfkey);
......@@ -983,48 +983,55 @@ ${gridColumn.getName()}
let _removeAction = keys.length > 1 ? 'removeBatch' : this.removeAction ;
let _keys = keys.length > 1 ? keys : keys[0] ;
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 }),Object.assign({ ${ctrl.getPSAppDataEntity().codeName?lower_case}: _keys },{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.gridpage.delDataFail') as string)+',' + response.info });
try {
if (!(await this.handleCtrlEvents('onbeforeremove', { data: _keys }))) {
return;
}
const response: any = await this.service.delete(_removeAction, Object.assign(context,{ ${ctrl.getPSAppDataEntity().codeName?lower_case}: _keys }),Object.assign({ ${ctrl.getPSAppDataEntity().codeName?lower_case}: _keys },{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.gridpage.delSuccess') 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);
this.gridItemsModel.splice(index,1);
return true;
}
});
this.$Notice.error({ title: '', desc: (this.$t('app.gridpage.delDataFail') as string)+',' + response.info });
return;
}
if (!(await this.handleCtrlEvents('onremovesuccess', { data: response.data }))) {
return;
}
this.$Notice.success({ title: '', desc: (this.$t('app.gridpage.delSuccess') 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);
this.gridItemsModel.splice(index,1);
return true;
}
});
this.totalrow -= _datas.length;
this.$emit('remove', null);
this.selections = [];
resolve(response);
}).catch((response: any) => {
if (response && response.status != 200) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data && response.data.message ? response.data.message : "" });
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.totalrow -= _datas.length;
this.$emit('remove', null);
this.selections = [];
return response;
} catch (response: any) {
if (!(await this.handleCtrlEvents('onremoveerror', { data: response ? response.data : [] }))) {
return;
}
if (response && response.status != 200) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data && response.data.message ? response.data.message : "" });
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 response;
}
}
dataInfo = dataInfo.replace(/[null]/g, '').replace(/[undefined]/g, '');
this.$Modal.confirm({
title: (this.$t('app.commonWords.warning') as string),
content: (this.$t('app.gridpage.confirmDel') as string)+' ' + dataInfo + ','+(this.$t('app.gridpage.notRecoverable') as string),
content: (this.$t('app.gridpage.confirmDel') as string) + ' ' + dataInfo + ','+(this.$t('app.gridpage.notRecoverable') as string),
onOk: () => {
removeData();
},
......@@ -2234,20 +2241,25 @@ ${gridColumn.getName()}
public async save(args: any[], params?: any, $event?: any, xData?: any){
let _this = this;
// 拷贝模式
if(_this.viewparams && _this.viewparams.copymode && Object.is(_this.viewparams.copymode,'true') && _this.items && _this.items.length >0){
if (
_this.viewparams &&
_this.viewparams.copymode &&
Object.is(_this.viewparams.copymode,'true') &&
_this.items &&
_this.items.length >0) {
for (const item of _this.items) {
item.rowDataState = 'create';
}
}
if(_this.items && _this.items.length >0){
if (_this.items && _this.items.length > 0) {
for (const item of _this.items) {
if(Object.is(item.rowDataState, 'update')){
if (Object.is(item.rowDataState, 'update')) {
_this.updateDefault(item);
}
}
}
if (!await this.validateAll()) {
if(this.errorMessages && this.errorMessages.length > 0) {
if (this.errorMessages && this.errorMessages.length > 0) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: this.errorMessages[0] });
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.rulesException') as string) });
......@@ -2257,27 +2269,30 @@ ${gridColumn.getName()}
let successItems:any = [];
let errorItems:any = [];
let errorMessage:any = [];
if (!(await this.handleCtrlEvents('onbeforesave', { data: _this.items })));
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){
if (Object.is(item.rowDataState, 'create')) {
if (!this.createAction) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}'+(this.$t('app.gridpage.notConfig.createAction') as string) });
}else{
Object.assign(item,{viewparams:this.viewparams});
let response = await this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
} else {
Object.assign(item, { viewparams: this.viewparams });
const tempContext = Util.deepCopy(this.context);
let response = await this.service.add(this.createAction, tempContext, item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
}else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){
}else if (Object.is(item.rowDataState, 'update')){
if (!this.updateAction) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}'+(this.$t('app.gridpage.notConfig.updateAction') as string) });
}else{
Object.assign(item,{viewparams:this.viewparams});
} else {
Object.assign(item, { viewparams: this.viewparams });
const tempContext = Util.deepCopy(this.context);
<#if de??>
if(item.${appde.getCodeName()?lower_case}){
Object.assign(this.context,{${appde.getCodeName()?lower_case}:item.${appde.getCodeName()?lower_case}});
Object.assign(tempContext, { ${appde.getCodeName()?lower_case}: item.${appde.getCodeName()?lower_case} });
}
</#if>
let response = await this.service.update(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
let response = await this.service.update(this.updateAction, tempContext, item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
}
......@@ -2289,8 +2304,14 @@ ${gridColumn.getName()}
this.$emit('save', successItems);
this.refresh([]);
if(errorItems.length === 0 && successItems.length > 0){
if (!(await this.handleCtrlEvents('onsavesuccess', { data: successItems }))) {
return;
}
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) => {
if(errorMessage[index] && errorMessage[index].data) {
if(Object.is(errorMessage[index].data.errorKey, 'DupCheck')) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册