%DE_PKGPATH%-ui-action-base.ts.ftl 15.4 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3
<#ibiztemplate>
TARGET=PSAPPDATAENTITY
</#ibiztemplate>
KK's avatar
KK committed
4 5 6
<#macro getMainStateOPPrivs mainState >
<#compress>
<#if mainState.getPSDEMainStateOPPrivs?? && mainState.getPSDEMainStateOPPrivs()??>
KK's avatar
KK committed
7
{<#list mainState.getPSDEMainStateOPPrivs() as stateOPPriv><#if stateOPPriv.getPSDEOPPriv?? && stateOPPriv.getPSDEOPPriv()??>'${stateOPPriv.getName()}':<#if mainState.isOPPrivAllowMode?? && mainState.isOPPrivAllowMode()?? && mainState.isOPPrivAllowMode()>1<#else>0</#if>,</#if></#list>}
KK's avatar
KK committed
8 9 10 11 12
<#else>
{}
</#if>
</#compress>
</#macro>
KK's avatar
KK committed
13 14 15 16 17 18 19 20 21
<#macro getDataEntityMainStateOPPrivs mainState dataEntity>
<#compress>
<#if dataEntity.getAllPSDEOPPrivs?? && dataEntity.getAllPSDEOPPrivs()??>
{<#list dataEntity.getAllPSDEOPPrivs() as mainStateOPPriv>'${mainStateOPPriv.getName()}':<#if mainState.isOPPrivAllowMode()>0<#else>1</#if><#if mainStateOPPriv_has_next>,</#if></#list>}
<#else>
{}
</#if>
</#compress>
</#macro>
KK's avatar
KK committed
22 23
import ${srfclassname('${item.getCodeName()}')}Service from '@/app-core/service/${srffilepath2(item.getCodeName())}/${srffilepath2(item.getCodeName())}-service';
import ${srfclassname('${item.getCodeName()}')}AuthService from '@/app-core/auth-service/${srffilepath2(item.getCodeName())}/${srffilepath2(item.getCodeName())}-auth-service';
ibizdev's avatar
ibizdev committed
24 25
<#if item.getAllPSAppDEUIActions()??>
<#list item.getAllPSAppDEUIActions() as appdeUIAction>
KK's avatar
KK committed
26 27 28 29 30 31 32
<#if appdeUIAction.getPSAppDataEntity()??>
<#if !P.exists("importService", appdeUIAction.getPSAppDataEntity().getId(), "")>
<#if item.getId() != appdeUIAction.getPSAppDataEntity().getId() >
import ${srfclassname('${appdeUIAction.getPSAppDataEntity().getCodeName()}')}Service from '@/app-core/service/${srffilepath2(appdeUIAction.getPSAppDataEntity().getCodeName())}/${srffilepath2(appdeUIAction.getPSAppDataEntity().getCodeName())}-service';
</#if>
</#if>
</#if>
ibizdev's avatar
ibizdev committed
33 34
</#list>
</#if>
KK's avatar
KK committed
35 36 37 38 39 40 41 42 43 44
<#if item.getPSAppWF()?? && item.getPSAppWF().getPSWorkflow()??>
<#assign workflow = item.getPSAppWF().getPSWorkflow()/>
<#if workflow.getPSWFDEs()??>
<#list workflow.getPSWFDEs() as singleWFDE>
<#if singleWFDE.getWFProxyMode()?? && singleWFDE.getWFProxyMode() == 2 && singleWFDE.getPSDataEntity().getId() == de.getId()>
<#assign curWorkFlow = singleWFDE/>
</#if>
</#list>
</#if>
</#if>
ibizdev's avatar
ibizdev committed
45 46 47
import EntityUIActionBase from '@/utils/ui-service-base/entity-ui-action-base';
import { Util, Loading } from '@/ibiz-core/utils';
import { Notice } from '@/utils';
KK's avatar
KK committed
48
import { Environment } from '@/environments/environment';
KK's avatar
KK committed
49
import AppCenterService from "@/ibiz-core/app-service/app/app-center-service";
ibizdev's avatar
ibizdev committed
50 51 52 53 54 55 56 57
/**
 * ${item.getLogicName()}UI服务对象基类
 *
 * @export
 * @class ${srfclassname(item.getCodeName())}UIActionBase
 * @extends {UIActionBase}
 */
export default class ${srfclassname(item.getCodeName())}UIActionBase extends EntityUIActionBase {
KK's avatar
KK committed
58 59 60 61 62 63 64 65

    /**
     * 是否支持工作流
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */
    public isEnableWorkflow:boolean = false;

KK's avatar
KK committed
66 67 68 69 70 71 72
    /**
     * 当前UI服务对应的数据服务对象
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */
    public dataService:${srfclassname('${item.getCodeName()}')}Service = new ${srfclassname('${item.getCodeName()}')}Service();

KK's avatar
KK committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    /**
     * 所有关联视图
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */ 
    public allViewMap: Map<string, Object> = new Map();

    /**
     * 状态值
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */ 
    public stateValue: number = <#if curWorkFlow?? && curWorkFlow.getEntityWFState()??>${curWorkFlow.getEntityWFState()}<#else>0</#if>;

    /**
     * 状态属性
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */ 
    public stateField: string = "<#if curWorkFlow?? && curWorkFlow.getWFStatePSDEField()??>${curWorkFlow.getWFStatePSDEField().getCodeName()?lower_case}</#if>";

    /**
     * 主状态属性集合
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */  
    public mainStateFields:Array<any> = [<#if item.getPSDataEntity?? && item.getPSDataEntity()?? && item.getPSDataEntity().getDEMainStateDEFields()??><#list item.getPSDataEntity().getDEMainStateDEFields() as demsField>'${demsField.getCodeName()?lower_case}'<#if demsField_has_next>,</#if></#list></#if>];

    /**
     * 主状态集合Map
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */  
    public allDeMainStateMap:Map<string,string> = new Map();

    /**
     * 主状态操作标识Map
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */ 
    public allDeMainStateOPPrivsMap:Map<string,any> = new Map();

    /**
     * Creates an instance of  ${srfclassname('${item.getCodeName()}')}UIServiceBase.
     * 
     * @param {*} [opts={}]
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */
    constructor(opts: any = {}) {
KK's avatar
KK committed
122
        super();
KK's avatar
KK committed
123
        this.authService = new ${srfclassname('${item.getCodeName()}')}AuthService(opts);
KK's avatar
KK committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
        this.initViewMap();
        this.initDeMainStateMap();
        this.initDeMainStateOPPrivsMap();
    }

    /**
     * 初始化视图Map
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */  
    public initViewMap(){
    <#if item.getAllPSAppViews()??>
    <#list item.getAllPSAppViews() as singleView>
        this.allViewMap.set('<#if singleView.getFuncViewMode()??>${singleView.getFuncViewMode()}</#if>:<#if singleView.getFuncViewParam()??>${singleView.getFuncViewParam()}</#if>',{viewname:'${singleView.getPSDEViewCodeName()?lower_case}',srfappde:'${srfpluralize(item.codeName)?lower_case}'});
    </#list>
    </#if>
    }

    /**
     * 初始化主状态集合
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */  
    public initDeMainStateMap(){
        <#if item.getPSDataEntity?? && item.getPSDataEntity()?? && item.getPSDataEntity().getAllPSDEMainStates()??>
        <#list item.getPSDataEntity().getAllPSDEMainStates() as demState>
        <#if demState.getMSTag()??>
        this.allDeMainStateMap.set('${demState.getMSTag()}','${demState.getMSTag()}');
        </#if>
        </#list>
        </#if>
    }

    /**
     * 初始化主状态操作标识
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */  
    public initDeMainStateOPPrivsMap(){
        <#if item.getPSDataEntity?? && item.getPSDataEntity()?? && item.getPSDataEntity().getAllPSDEMainStates()??>
        <#list item.getPSDataEntity().getAllPSDEMainStates() as demState>
        <#if demState.getMSTag()??>
KK's avatar
KK committed
166
        this.allDeMainStateOPPrivsMap.set('${demState.getMSTag()}',Object.assign(<@getDataEntityMainStateOPPrivs mainState=demState dataEntity=item.getPSDataEntity() />,<@getMainStateOPPrivs mainState=demState />));
KK's avatar
KK committed
167 168 169 170 171
        </#if>
        </#list>
        </#if>
    }

KK's avatar
KK committed
172
    <#if item.getAllPSAppDEUIActions()??>
ibizdev's avatar
ibizdev committed
173 174 175
    <#list item.getAllPSAppDEUIActions() as appdeUIAction>
${P.getLogicCode(appdeUIAction, "LOGIC.vue").code}
    </#list>
KK's avatar
KK committed
176
    </#if>
ibizdev's avatar
ibizdev committed
177

KK's avatar
KK committed
178
    /**
KK's avatar
KK committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
     * 获取指定数据的重定向页面
     * 
     * @param srfkey 数据主键
     * @param isEnableWorkflow  重定向视图是否需要处理流程中的数据
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */
    public async getRDAppView(srfkey:string,isEnableWorkflow:boolean){
        this.isEnableWorkflow = isEnableWorkflow;
        // 进行数据查询
        let result:any = await this.dataService.Get({${item.getCodeName()?lower_case}:srfkey});
        const curData:any = result.data;
        //判断当前数据模式,默认为true,todo
        const iRealDEModel:boolean = true;

        let bDataInWF:boolean = false;
		let bWFMode:any = false;
		// 计算数据模式
		if (this.isEnableWorkflow) {
			bDataInWF = await this.dataService.testDataInWF({stateValue:this.stateValue,stateField:this.stateField},curData);
			if (bDataInWF) {
				bDataInWF = true;
				bWFMode = await this.dataService.testUserExistWorklist(null,curData);
			}
        }
        let strPDTViewParam:string = await this.getDESDDEViewPDTParam(curData, bDataInWF, bWFMode);
        //若不是当前数据模式,处理strPDTViewParam,todo

        //查找视图

        //返回视图
        return this.allViewMap.get(strPDTViewParam);
    }

    /**
	 * 获取实际的数据类型
     * 
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
	 */
	public getRealDEType(entity:any){

    }

    /**
     * 获取实体单数据实体视图预定义参数
     * 
     * @param curData 当前数据
     * @param bDataInWF 是否有数据在工作流中
     * @param bWFMode   是否工作流模式
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */
    public async getDESDDEViewPDTParam(curData:any, bDataInWF:boolean, bWFMode:boolean){
        let strPDTParam:string = '';
		if (bDataInWF) {
			// 判断数据是否在流程中
            <#if app.getAllPSAppWFVers?? && app.getAllPSAppWFVers()??>
            <#list app.getAllPSAppWFVers() as appWfVer>
            <#if appWfVer.getPSAppWF()?? && appWfVer.getPSAppWF().getPSWorkflow()??>
            <#assign workflow = appWfVer.getPSAppWF().getPSWorkflow() />
            <#if workflow.getPSWFDEs()??>
            <#list workflow.getPSWFDEs() as singleWFDE>
            <#if singleWFDE.getWFProxyMode()?? && singleWFDE.getWFProxyMode() == 2 && singleWFDE.getPSDataEntity().getId() == de.getId()>
            let strPDTParam:string = await this.get${appWfVer.getCodeName()}EditViewPDTParam(curData, bWFMode);
			if (strPDTParam) return strPDTParam;
            </#if>
            </#list>
            </#if>
            </#if>
            </#list>
            </#if>
        }
        //多表单,todo
KK's avatar
KK committed
250
        const multiFormDEField:string|null =<#if de.getFormTypePSDEField()??>"${de.getFormTypePSDEField().getCodeName()?lower_case}"<#else>null</#if>;
KK's avatar
KK committed
251

KK's avatar
KK committed
252
        if (multiFormDEField) {
KK's avatar
KK committed
253 254
			const objFormValue:string = curData[multiFormDEField];
			if(!Environment.isAppMode){
KK's avatar
KK committed
255
				return 'MOBEDITVIEW:'+objFormValue;
KK's avatar
KK committed
256
			}
KK's avatar
KK committed
257
			return 'EDITVIEW:'+objFormValue;
KK's avatar
KK committed
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
        }
		if(!Environment.isAppMode){
            if(this.getDEMainStateTag(curData)){
                <#noparse>return `MOBEDITVIEW:MSTAG:${ this.getDEMainStateTag(curData)}`;</#noparse>
            }
			return 'MOBEDITVIEW:';
        }
        if(this.getDEMainStateTag(curData)){
            <#noparse>return `EDITVIEW:MSTAG:${ this.getDEMainStateTag(curData)}`;</#noparse>
        }
		return 'EDITVIEW:';
    }
<#if app.getAllPSAppWFVers?? && app.getAllPSAppWFVers()??>
<#list app.getAllPSAppWFVers() as appWfVer>
<#if appWfVer.getPSAppWF()?? && appWfVer.getPSAppWF().getPSWorkflow()??>
<#assign workflow = appWfVer.getPSAppWF().getPSWorkflow() />
<#if workflow.getPSWFDEs()??>
<#list workflow.getPSWFDEs() as singleWFDE>
<#if singleWFDE.getWFProxyMode()?? && singleWFDE.getWFProxyMode() == 2 && singleWFDE.getPSDataEntity().getId() == de.getId()>
<#assign curWFDE = singleWFDE/>
<#if appWfVer.getPSWFVersion()?? && appWfVer.getPSWFVersion().getWFVersion()??>
<#assign wfversion>${appWfVer.getPSWFVersion().getWFVersion()}</#assign>
</#if>

    /**
     * 获取指定数据的流程数据界面预置参数
     * 
     * @param curData 当前数据
     * @param bWorkMode 是否为工作模式
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */
    public async get${appWfVer.getCodeName()}EditViewPDTParam(curData:any, bWorkMode:boolean){
        // 判断数据是否在流程中
        let bWorkFlow:boolean =await this.dataService.testDataInWF({stateValue:this.stateValue,stateField:this.stateField},curData);
        if (bWorkFlow) {
            // 多表单todo
            let multiFormValue:string|null = null;
            
            //工作流
			let wfStepValue:any = curData['<#if curWFDE.getWFStepPSDEField()?? && curWFDE.getWFStepPSDEField().getCodeName()??>${curWFDE.getWFStepPSDEField().getCodeName()?lower_case}<#else>wfstep</#if>'];
			let nVer:number = ${wfversion};
			if(!Environment.isAppMode){
				if (multiFormValue == null) {
					if (bWorkMode) {
						return  "MOBWFEDITVIEW:${curWFDE.getCodeName()}:" +((nVer == 1) ? "" : nVer) +"W:"+ wfStepValue;
					} else {
						return "MOBWFEDITVIEW:${curWFDE.getCodeName()}:D";
					}
				} else {
					if (bWorkMode) {
						return "MOBWFEDITVIEW:" + multiFormValue + "${curWFDE.getCodeName()}:" + ((nVer == 1) ? "" : nVer) +"W:"+ wfStepValue;
					} else {
						return "MOBWFEDITVIEW:" + multiFormValue + "${curWFDE.getCodeName()}:D";
					}
				}
			}
			else{
				if (multiFormValue == null) {
					if (bWorkMode) {
						return "WFEDITVIEW:${curWFDE.getCodeName()}:" + ((nVer == 1) ? "" : nVer) +"W:"+ wfStepValue;
					} else {
						return "WFEDITVIEW:${curWFDE.getCodeName()}:D";
					}
				} else {
					if (bWorkMode) {
						return "WFEDITVIEW:" + multiFormValue + "${curWFDE.getCodeName()}:" + ((nVer == 1) ? "" : nVer) +"W:"+ wfStepValue;
					} else {
						return "WFEDITVIEW:" + multiFormValue + "${curWFDE.getCodeName()}:D";
					}
				}
			}
        }
        return '';
    }
</#if>
</#list>
</#if>
</#if>
</#list>
</#if>

    /**
     * 获取数据对象的主状态标识
     * 
     * @param curData 当前数据
     * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
     */  
    public getDEMainStateTag(curData:any){
        if(this.mainStateFields.length === 0) return null;

        this.mainStateFields.forEach((singleMainField:any) =>{
            if(!(singleMainField in curData)){
                <#noparse>console.warn(`当前数据对象不包含属性${singleMainField},可能会发生错误`);</#noparse>
            }
        })
        for (let i = 0; i <= 1; i++) {
KK's avatar
KK committed
354
            let strTag:string = (curData[this.mainStateFields[0]] != null && curData[this.mainStateFields[0]] !== "")?(i == 0) ? curData[this.mainStateFields[0]] : "":"";
KK's avatar
KK committed
355 356
            if (this.mainStateFields.length >= 2) {
                for (let j = 0; j <= 1; j++) {
KK's avatar
KK committed
357
                    <#noparse>let strTag2:string = (curData[this.mainStateFields[1]] != null && curData[this.mainStateFields[1]] !== "")?`${strTag}__${(j == 0) ? curData[this.mainStateFields[1]] : ""}`:strTag;</#noparse>
KK's avatar
KK committed
358 359
                    if (this.mainStateFields.length >= 3) {
                        for (let k = 0; k <= 1; k++) {
KK's avatar
KK committed
360
                            <#noparse>let strTag3:string = (curData[this.mainStateFields[2]] != null && curData[this.mainStateFields[2]] !== "")?`${strTag2}__${(k == 0) ? curData[this.mainStateFields[2]] : ""}`:strTag2;</#noparse>
KK's avatar
KK committed
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
                            // 判断是否存在
                            return this.allDeMainStateMap.get(strTag3);
                        }
                    }else{
                        return this.allDeMainStateMap.get(strTag2);
                    }
                }
            }else{
                return this.allDeMainStateMap.get(strTag);
            }
        }
        return null;
    }

    /**
    * 获取数据对象当前操作标识
    * 
    * @param data 当前数据
    * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
    */  
   public getDEMainStateOPPrivs(data:any){
        if(this.getDEMainStateTag(data)){
            return this.allDeMainStateOPPrivsMap.get((this.getDEMainStateTag(data) as string));
        }else{
            return null;
        }
   }

    /**
    * 获取数据对象所有的操作标识
    * 
    * @param data 当前数据
    * @memberof  ${srfclassname('${item.getCodeName()}')}UIServiceBase
    */ 
   public getAllOPPrivs(data:any){
       return this.authService.getOPPrivs(this.getDEMainStateOPPrivs(data));
   }

KK's avatar
KK committed
399
}