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

新增实体工作流动态导航表格视图批量提交流程数据

上级 23f86f4d
......@@ -2034,6 +2034,44 @@ import { FormItemModel } from '@/model/form-detail';
return falg;
}
/**
* 工作流提交
*
* @param {*} [data={}]
* @param {*} [localdata={}]
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public async submitbatch(data: any,localdata:any): Promise<any> {
return new Promise((resolve: any, reject: any) => {
const _this: any = this;
const arg: any = data;
const result: Promise<any> = this.service.submitbatch(_this.WFSubmitAction, JSON.parse(JSON.stringify(this.context)),arg,localdata,this.showBusyIndicator);
result.then((response: any) => {
if (!response || response.status !== 200) {
if(response.data){
this.$Notice.error({ title: '', desc: (this.$t('app.formpage.workflow.submiterror') as string) + ', ' + response.data.message });
}
return;
}
this.$Notice.info({ title: '', desc: (this.$t('app.formpage.workflow.submitsuccess') as string) });
resolve(response);
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
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);
});
})
}
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>
......
......@@ -18,6 +18,14 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi
../@MACRO/SERVICE/SERVICE_HEADER.ts.ftl
</#ibizinclude>
/**
* 备份原生数据
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public copynativeData:any;
<#list ctrl.getPSDEGridEditItems() as deItem>
<#if deItem.getPSEditor()?? && deItem.getPSEditor().getPSAppDataEntity?? && deItem.getPSEditor().getPSAppDataEntity()??>
<#assign _appde = deItem.getPSEditor().getPSAppDataEntity()/>
......@@ -242,6 +250,7 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi
result =_appEntityService.FetchDefault(Context,Data, isloading);
}
result.then((response) => {
this.copynativeData = Util.deepCopy(response.data);
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
......@@ -418,6 +427,98 @@ import ${srfclassname('${aggAppDataEntity.getCodeName()}')}Service from '@/servi
}
return {context:tempContext,data:requestData};
}
/**
* 处理工作流数据
*
* @param data 传入数据
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public handleWFData(data:any, isMerge:boolean = false){
let model: any = this.getMode();
if (!model && model.getDataItems instanceof Function) {
return data;
}
let dataItems: any[] = model.getDataItems();
let requestData:any = {};
dataItems.forEach((item:any) =>{
if(item && item.prop){
if(item.dataType){
if(!Object.is(item.dataType,'QUERYPARAM')){
requestData[item.prop] = data[item.name];
}
}else{
requestData[item.prop] = data[item.name];
}
}
});
if(isMerge && (data.viewparams && Object.keys(data.viewparams).length > 0)){
Object.assign(requestData,data.viewparams);
}
// 删除前端srffrontuf标识
if(requestData.hasOwnProperty('srffrontuf')){
delete requestData.srffrontuf;
}
//补充工作流所需主键
requestData.srfkey = data.${appde.getCodeName()?lower_case};
//补充全量数据
requestData = this.fillNativeData(requestData);
return requestData;
}
/**
* 补充全量数据
*
* @param {*} [data]
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public fillNativeData(data:any){
if(this.copynativeData && this.copynativeData.length >0){
let targetData:any = this.copynativeData.find((item:any) =>{
return item.${appde.getKeyPSAppDEField().getCodeName()?lower_case} === data.srfkey;
})
data = Object.assign(targetData,data);
return data;
}
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
@Errorlog
public submitbatch(action: string,context: any = {}, data: any,localdata:any,isloading?: boolean): Promise<any> {
let tempData:any = [];
if(data && data.length > 0){
data.forEach((item:any) => {
let data:any = this.handleWFData(item,true);
tempData.push(data);
});
}
context = this.handleRequestData(action,context,data,true).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,tempData, localdata,isloading);
} else {
result = this.appEntityService.wfSubmitBatch(context,tempData,localdata,isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
<#ibizinclude>
../@MACRO/SERVICE/SERVICE_BOTTOM.ts.ftl
......
......@@ -130,7 +130,21 @@
* @memberof ${srfclassname('${view.codeName}')}Base
*/
public dynamic_toolbar_click(linkItem:any, $event:any){
let datas: any[] = [];
let xData: any = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
xData.submitbatch(datas,linkItem).then((response: any) => {
if (!response || response.status !== 200) {
return;
}
const { data: _data } = response;
this.engine.load();
if (this.viewdata) {
this.$emit('viewdataschange', [{ ..._data }]);
}
});
}
/**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册