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

适配动态表单数据提交和填充

上级 3a3a6c56
......@@ -388,6 +388,10 @@ import ${srfclassname('${_appde.getCodeName()}')}Service from '@/service/${srffi
}else{
if(item && item.prop){
requestData[item.prop] = data[item.name];
}else{
if(item.dataType && Object.is(item.dataType,"FORMPART")){
Object.assign(requestData,data[item.name]);
}
}
}
});
......@@ -420,6 +424,42 @@ import ${srfclassname('${_appde.getCodeName()}')}Service from '@/service/${srffi
return itemName.trim();
}
/**
* 重写处理返回数据
*
* @param {string} action
* @param {*} response
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public handleResponseData(action: string, data: any = {},isCreate?:boolean,codelistArray?:any){
let model: any = this.getMode();
if (!model && model.getDataItems instanceof Function) {
return data;
}
let item: any = {};
let dataItems: any[] = model.getDataItems();
dataItems.forEach(dataitem => {
let val = data.hasOwnProperty(dataitem.prop) ? data[dataitem.prop] : null;
if (val === null) {
val = data.hasOwnProperty(dataitem.name) ? data[dataitem.name] : null;
}
if((isCreate === undefined || isCreate === null ) && Object.is(dataitem.dataType, 'GUID') && Object.is(dataitem.name, 'srfkey') && (val && !Object.is(val, ''))){
isCreate = true;
}
item[dataitem.name] = val;
// 转化代码表
if(codelistArray && dataitem.codelist){
if(codelistArray.get(dataitem.codelist.tag) && codelistArray.get(dataitem.codelist.tag).get(val)){
item[dataitem.name] = codelistArray.get(dataitem.codelist.tag).get(val);
}
}
});
item.srfuf = data.srfuf ? data.srfuf : (isCreate ? "0" : "1");
item = Object.assign(data,item);
return item;
}
<#ibizinclude>
./SERVICE_BOTTOM.ts.ftl
</#ibizinclude>
\ No newline at end of file
<#if item.getFormPartType()?? && item.getFormPartType() == "DYNASYS">
<app-form-part name="${item.name}" :context="context" :viewparams="viewparams" :data="data" :formState="formState" appCodeName="${app.getCodeName()}" deCodeName="${de.getCodeName()}" formCodeName="${ctrl.getCodeName()}" formDetailCodeName="${item.getCodeName()}"></app-form-part>
<app-form-part name="${item.name}" :context="context" :viewparams="viewparams" :data="data" :formState="formState" appCodeName="${app.getCodeName()}" deCodeName="${de.getCodeName()}" formCodeName="${ctrl.getCodeName()}" formDetailCodeName="${item.getCodeName()}" @change="onFormItemValueChange"></app-form-part>
</#if>
\ No newline at end of file
......@@ -197,6 +197,14 @@ import { Environment } from '@/environments/environment';
*/
public oldData: any = {};
/**
* 混入表单数据对象
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public mixinData:any = {};
/**
* 表单数据对象
*
......@@ -583,6 +591,7 @@ import { Environment } from '@/environments/environment';
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public fillForm(_datas: any = {},action:string): void {
this.mixinData = _datas;
this.ignorefieldvaluechange = true;
Object.keys(_datas).forEach((name: string) => {
if (this.data.hasOwnProperty(name)) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册