提交 ae5b0ddb 编写于 作者: tony001's avatar tony001

适配表格数据对象方式新建、更新默认值

上级 8b046a7f
...@@ -2163,9 +2163,9 @@ import { Environment } from '@/environments/environment'; ...@@ -2163,9 +2163,9 @@ import { Environment } from '@/environments/environment';
*/ */
public createDefault(row: any){ public createDefault(row: any){
<#list ctrl.getPSDEGridEditItems() as editItem><#t> <#list ctrl.getPSDEGridEditItems() as editItem><#t>
<#if editItem.getCreateDV?? && editItem.getCreateDV()??><#t> <#if editItem.getCreateDV?? && editItem.getCreateDV()?? && editItem.getCreateDV() !=""><#t>
<#if !(editItem.getCreateDV() == '') || editItem.getCreateDVT() == 'CURTIME'><#t>
if (row.hasOwnProperty('${editItem.getCodeName()?lower_case}')) { if (row.hasOwnProperty('${editItem.getCodeName()?lower_case}')) {
<#if !(editItem.getCreateDV() == '')><#t>
<#-- 网页请求 --> <#-- 网页请求 -->
<#if editItem.getCreateDVT() == 'CONTEXT'> <#if editItem.getCreateDVT() == 'CONTEXT'>
row['${editItem.getCodeName()?lower_case}'] = this.viewparams['${editItem.getCreateDV()}']; row['${editItem.getCodeName()?lower_case}'] = this.viewparams['${editItem.getCreateDV()}'];
...@@ -2184,13 +2184,16 @@ import { Environment } from '@/environments/environment'; ...@@ -2184,13 +2184,16 @@ import { Environment } from '@/environments/environment';
<#-- 当前时间 --> <#-- 当前时间 -->
<#elseif editItem.getCreateDVT() == 'CURTIME'> <#elseif editItem.getCreateDVT() == 'CURTIME'>
row['${editItem.getCodeName()?lower_case}'] = this.$util.dateFormat(new Date()); row['${editItem.getCodeName()?lower_case}'] = this.$util.dateFormat(new Date());
<#else> <#-- 数据对象属性 -->
<#elseif editItem.getCreateDVT() == 'PARAM'>
row['${editItem.getCodeName()?lower_case}'] = this.computeDefaultValueWithParam("CREATE","${editItem.getCreateDV()}");
</#if>
<#else>
<#-- 默认值 --> <#-- 默认值 -->
<#assign datatype=srfjavatype(editItem.getPSAppDEField().getStdDataType())> <#assign datatype=srfjavatype(editItem.getPSAppDEField().getStdDataType())>
row['${editItem.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${editItem.getCreateDV()}<#else>'${editItem.getCreateDV()}'</#if>; row['${editItem.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${editItem.getCreateDV()}<#else>'${editItem.getCreateDV()}'</#if>;
</#if>
}
</#if> </#if>
}
</#if> </#if>
</#list> </#list>
} }
...@@ -2202,9 +2205,9 @@ import { Environment } from '@/environments/environment'; ...@@ -2202,9 +2205,9 @@ import { Environment } from '@/environments/environment';
*/ */
public updateDefault(row: any){ public updateDefault(row: any){
<#list ctrl.getPSDEGridEditItems() as editItem><#t> <#list ctrl.getPSDEGridEditItems() as editItem><#t>
<#if editItem.getUpdateDV?? && editItem.getUpdateDV()??><#t> <#if editItem.getUpdateDV?? && editItem.getUpdateDV()?? && editItem.getUpdateDV() !=""><#t>
<#if !(editItem.getUpdateDV() == '') || editItem.getUpdateDVT() == 'CURTIME'><#t>
if (row.hasOwnProperty('${editItem.getCodeName()?lower_case}') && !row.${editItem.getCodeName()?lower_case} && !row.hasUpdated) { if (row.hasOwnProperty('${editItem.getCodeName()?lower_case}') && !row.${editItem.getCodeName()?lower_case} && !row.hasUpdated) {
<#if !(editItem.getUpdateDV() == '')><#t>
<#-- 网页请求 --> <#-- 网页请求 -->
<#if editItem.getUpdateDVT() == 'CONTEXT'> <#if editItem.getUpdateDVT() == 'CONTEXT'>
row['${editItem.getCodeName()?lower_case}'] = this.viewparams['${editItem.getUpdateDV()}']; row['${editItem.getCodeName()?lower_case}'] = this.viewparams['${editItem.getUpdateDV()}'];
...@@ -2223,17 +2226,39 @@ import { Environment } from '@/environments/environment'; ...@@ -2223,17 +2226,39 @@ import { Environment } from '@/environments/environment';
<#-- 当前时间 --> <#-- 当前时间 -->
<#elseif editItem.getUpdateDVT() == 'CURTIME'> <#elseif editItem.getUpdateDVT() == 'CURTIME'>
row['${editItem.getCodeName()?lower_case}'] = this.$util.dateFormat(new Date()); row['${editItem.getCodeName()?lower_case}'] = this.$util.dateFormat(new Date());
<#else> <#-- 数据对象属性 -->
<#-- 默认值 --> <#elseif editItem.getUpdateDVT() == 'PARAM'>
row['${editItem.getCodeName()?lower_case}'] = this.computeDefaultValueWithParam("UPDATE","${editItem.getUpdateDV()}");
</#if>
<#else>
<#-- 默认值 -->
<#assign datatype=srfjavatype(editItem.getPSAppDEField().getStdDataType())> <#assign datatype=srfjavatype(editItem.getPSAppDEField().getStdDataType())>
row['${editItem.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${editItem.getUpdateDV()}<#else>'${editItem.getUpdateDV()}'</#if>; row['${editItem.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${editItem.getUpdateDV()}<#else>'${editItem.getUpdateDV()}'</#if>;
</#if>
}
</#if> </#if>
}
</#if> </#if>
</#list> </#list>
} }
/**
* 计算数据对象类型的默认值
* @param {string} action 行为
* @param {string} param 参数
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public computeDefaultValueWithParam(action:string,param:string){
if(Object.is(action,"UPDATE")){
const nativeData:any = this.service.getCopynativeData();
if(nativeData && (nativeData instanceof Array) && nativeData.length >0){
}else{
return null;
}
}else{
return this.service.getRemoteCopyData().test?this.service.getRemoteCopyData().test:null;
}
}
/** /**
* 校验属性值规则 * 校验属性值规则
* *
......
...@@ -24,7 +24,15 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi ...@@ -24,7 +24,15 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi
* @type {*} * @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Service * @memberof ${srfclassname('${ctrl.codeName}')}Service
*/ */
public copynativeData:any; private copynativeData:any;
/**
* 远端数据
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
private remoteCopyData:any = {};
<#list ctrl.getPSDEGridEditItems() as deItem> <#list ctrl.getPSDEGridEditItems() as deItem>
<#if deItem.getPSEditor()?? && deItem.getPSEditor().getPSAppDataEntity?? && deItem.getPSEditor().getPSAppDataEntity()??> <#if deItem.getPSEditor()?? && deItem.getPSEditor().getPSAppDataEntity?? && deItem.getPSEditor().getPSAppDataEntity()??>
...@@ -259,7 +267,7 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi ...@@ -259,7 +267,7 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi
result =_appEntityService.FetchDefault(Context,Data, isloading); result =_appEntityService.FetchDefault(Context,Data, isloading);
} }
result.then((response) => { result.then((response) => {
this.copynativeData = Util.deepCopy(response.data); this.setCopynativeData(response.data);
this.handleResponse(action, response); this.handleResponse(action, response);
resolve(response); resolve(response);
}).catch(response => { }).catch(response => {
...@@ -343,6 +351,7 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi ...@@ -343,6 +351,7 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi
response.data.${appde.getKeyPSAppDEField().getCodeName()?lower_case} = Util.createUUID(); response.data.${appde.getKeyPSAppDEField().getCodeName()?lower_case} = Util.createUUID();
</#if> </#if>
} }
this.setRemoteCopyData(response);
this.handleResponse(action, response, true); this.handleResponse(action, response, true);
resolve(response); resolve(response);
}).catch(response => { }).catch(response => {
...@@ -540,7 +549,46 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi ...@@ -540,7 +549,46 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi
}); });
}); });
} }
/**
* 设置远端数据
*
* @param result 远端请求结果
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public setRemoteCopyData(result:any){
if (result && result.status === 200) {
this.remoteCopyData = Util.deepCopy(result.data);
}
}
/**
* 获取远端数据
*
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public getRemoteCopyData(){
return this.remoteCopyData;
}
/**
* 设置备份原生数据
*
* @param data 远端请求结果
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public setCopynativeData(data:any){
this.copynativeData = Util.deepCopy(data);
}
/**
* 获取备份原生数据
*
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public getCopynativeData(){
return this.copynativeData;
}
<#ibizinclude> <#ibizinclude>
../@MACRO/SERVICE/SERVICE_BOTTOM.ts.ftl ../@MACRO/SERVICE/SERVICE_BOTTOM.ts.ftl
</#ibizinclude> </#ibizinclude>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册