import { Http,Util } from '@/utils';
import EntityService from '../entity-service';



/**
 * 计划服务对象基类
 *
 * @export
 * @class EMPlanServiceBase
 * @extends {EntityServie}
 */
export default class EMPlanServiceBase extends EntityService {

    /**
     * Creates an instance of  EMPlanServiceBase.
     * 
     * @param {*} [opts={}]
     * @memberof  EMPlanServiceBase
     */
    constructor(opts: any = {}) {
        super(opts);
    }

    /**
     * 初始化基础数据
     *
     * @memberof EMPlanServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='emplan';
        this.APPDEKEY = 'emplanid';
        this.APPDENAME = 'emplans';
        this.APPDETEXT = 'emplanname';
        this.APPNAME = 'eamweb';
        this.SYSTEMNAME = 'eam_practice03';
    }

// 实体接口

    /**
     * Select接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMPlanServiceBase
     */
    public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.pfemp && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/pfemps/${context.pfemp}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.pfdept && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/pfdepts/${context.pfdept}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.emservice && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/emservices/${context.emservice}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.emacclass && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/emacclasses/${context.emacclass}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.pfteam && context.emequip && context.emplan){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.emeqtype && context.emequip && context.emplan){
            return Http.getInstance().get(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.pfteam && context.emplan){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.pfemp && context.emplan){
            return Http.getInstance().get(`/pfemps/${context.pfemp}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.pfdept && context.emplan){
            return Http.getInstance().get(`/pfdepts/${context.pfdept}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.emservice && context.emplan){
            return Http.getInstance().get(`/emservices/${context.emservice}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.emplantempl && context.emplan){
            return Http.getInstance().get(`/emplantempls/${context.emplantempl}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.emequip && context.emplan){
            return Http.getInstance().get(`/emequips/${context.emequip}/emplans/${context.emplan}/select`,isloading);
        }
        if(context.emacclass && context.emplan){
            return Http.getInstance().get(`/emacclasses/${context.emacclass}/emplans/${context.emplan}/select`,isloading);
        }
            return Http.getInstance().get(`/emplans/${context.emplan}/select`,isloading);
    }

    /**
     * Create接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMPlanServiceBase
     */
    public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emplantempl && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emplantempls/${context.emplantempl}/emplans`,data,isloading);
        }
        if(context.pfemp && context.emplantempl && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/pfemps/${context.pfemp}/emplantempls/${context.emplantempl}/emplans`,data,isloading);
        }
        if(context.pfdept && context.emplantempl && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/pfdepts/${context.pfdept}/emplantempls/${context.emplantempl}/emplans`,data,isloading);
        }
        if(context.emservice && context.emplantempl && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/emservices/${context.emservice}/emplantempls/${context.emplantempl}/emplans`,data,isloading);
        }
        if(context.emacclass && context.emplantempl && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/emacclasses/${context.emacclass}/emplantempls/${context.emplantempl}/emplans`,data,isloading);
        }
        if(context.pfteam && context.emequip && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emplans`,data,isloading);
        }
        if(context.emeqtype && context.emequip && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emplans`,data,isloading);
        }
        if(context.pfteam && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emplans`,data,isloading);
        }
        if(context.pfemp && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/pfemps/${context.pfemp}/emplans`,data,isloading);
        }
        if(context.pfdept && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/pfdepts/${context.pfdept}/emplans`,data,isloading);
        }
        if(context.emservice && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/emservices/${context.emservice}/emplans`,data,isloading);
        }
        if(context.emplantempl && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/emplantempls/${context.emplantempl}/emplans`,data,isloading);
        }
        if(context.emequip && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/emequips/${context.emequip}/emplans`,data,isloading);
        }
        if(context.emacclass && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/emacclasses/${context.emacclass}/emplans`,data,isloading);
        }
        let masterData:any = {};
        let emplandetailsData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_emplandetails'),'undefined')){
            emplandetailsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_emplandetails') as any);
            if(emplandetailsData && emplandetailsData.length && emplandetailsData.length > 0){
                emplandetailsData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.emplandetailid = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.emplandetails = emplandetailsData;
        let emplancdtsData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_emplancdts'),'undefined')){
            emplancdtsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_emplancdts') as any);
            if(emplancdtsData && emplancdtsData.length && emplancdtsData.length > 0){
                emplancdtsData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.emplancdtid = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.emplancdts = emplancdtsData;
        Object.assign(data,masterData);
        if(!data.srffrontuf || data.srffrontuf !== "1"){
            data[this.APPDEKEY] = null;
        }
        if(data.srffrontuf){
            delete data.srffrontuf;
        }
        let tempContext:any = JSON.parse(JSON.stringify(context));
        let res:any = await Http.getInstance().post(`/emplans`,data,isloading);
        this.tempStorage.setItem(tempContext.srfsessionkey+'_emplandetails',JSON.stringify(res.data.emplandetails));
        this.tempStorage.setItem(tempContext.srfsessionkey+'_emplancdts',JSON.stringify(res.data.emplancdts));
        return res;
    }

    /**
     * Update接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMPlanServiceBase
     */
    public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emplantempl && context.emplan){
            return Http.getInstance().put(`/pfteams/${context.pfteam}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.pfemp && context.emplantempl && context.emplan){
            return Http.getInstance().put(`/pfemps/${context.pfemp}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.pfdept && context.emplantempl && context.emplan){
            return Http.getInstance().put(`/pfdepts/${context.pfdept}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.emservice && context.emplantempl && context.emplan){
            return Http.getInstance().put(`/emservices/${context.emservice}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.emacclass && context.emplantempl && context.emplan){
            return Http.getInstance().put(`/emacclasses/${context.emacclass}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.pfteam && context.emequip && context.emplan){
            return Http.getInstance().put(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.emeqtype && context.emequip && context.emplan){
            return Http.getInstance().put(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.pfteam && context.emplan){
            return Http.getInstance().put(`/pfteams/${context.pfteam}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.pfemp && context.emplan){
            return Http.getInstance().put(`/pfemps/${context.pfemp}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.pfdept && context.emplan){
            return Http.getInstance().put(`/pfdepts/${context.pfdept}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.emservice && context.emplan){
            return Http.getInstance().put(`/emservices/${context.emservice}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.emplantempl && context.emplan){
            return Http.getInstance().put(`/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.emequip && context.emplan){
            return Http.getInstance().put(`/emequips/${context.emequip}/emplans/${context.emplan}`,data,isloading);
        }
        if(context.emacclass && context.emplan){
            return Http.getInstance().put(`/emacclasses/${context.emacclass}/emplans/${context.emplan}`,data,isloading);
        }
        let masterData:any = {};
        let emplandetailsData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_emplandetails'),'undefined')){
            emplandetailsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_emplandetails') as any);
            if(emplandetailsData && emplandetailsData.length && emplandetailsData.length > 0){
                emplandetailsData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.emplandetailid = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.emplandetails = emplandetailsData;
        let emplancdtsData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_emplancdts'),'undefined')){
            emplancdtsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_emplancdts') as any);
            if(emplancdtsData && emplancdtsData.length && emplancdtsData.length > 0){
                emplancdtsData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.emplancdtid = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.emplancdts = emplancdtsData;
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().put(`/emplans/${context.emplan}`,data,isloading);
            this.tempStorage.setItem(context.srfsessionkey+'_emplandetails',JSON.stringify(res.data.emplandetails));
            this.tempStorage.setItem(context.srfsessionkey+'_emplancdts',JSON.stringify(res.data.emplancdts));
            return res;
    }

    /**
     * Get接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMPlanServiceBase
     */
    public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfemp && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/pfemps/${context.pfemp}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfdept && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/pfdepts/${context.pfdept}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.emservice && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/emservices/${context.emservice}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.emacclass && context.emplantempl && context.emplan){
            return Http.getInstance().get(`/emacclasses/${context.emacclass}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfteam && context.emequip && context.emplan){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emplans/${context.emplan}`,isloading);
        }
        if(context.emeqtype && context.emequip && context.emplan){
            return Http.getInstance().get(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfteam && context.emplan){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfemp && context.emplan){
            return Http.getInstance().get(`/pfemps/${context.pfemp}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfdept && context.emplan){
            return Http.getInstance().get(`/pfdepts/${context.pfdept}/emplans/${context.emplan}`,isloading);
        }
        if(context.emservice && context.emplan){
            return Http.getInstance().get(`/emservices/${context.emservice}/emplans/${context.emplan}`,isloading);
        }
        if(context.emplantempl && context.emplan){
            return Http.getInstance().get(`/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.emequip && context.emplan){
            return Http.getInstance().get(`/emequips/${context.emequip}/emplans/${context.emplan}`,isloading);
        }
        if(context.emacclass && context.emplan){
            return Http.getInstance().get(`/emacclasses/${context.emacclass}/emplans/${context.emplan}`,isloading);
        }
            let res:any = await Http.getInstance().get(`/emplans/${context.emplan}`,isloading);
            this.tempStorage.setItem(context.srfsessionkey+'_emplandetails',JSON.stringify(res.data.emplandetails));
            this.tempStorage.setItem(context.srfsessionkey+'_emplancdts',JSON.stringify(res.data.emplancdts));
            return res;

    }

    /**
     * Remove接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMPlanServiceBase
     */
    public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emplantempl && context.emplan){
            return Http.getInstance().delete(`/pfteams/${context.pfteam}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfemp && context.emplantempl && context.emplan){
            return Http.getInstance().delete(`/pfemps/${context.pfemp}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfdept && context.emplantempl && context.emplan){
            return Http.getInstance().delete(`/pfdepts/${context.pfdept}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.emservice && context.emplantempl && context.emplan){
            return Http.getInstance().delete(`/emservices/${context.emservice}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.emacclass && context.emplantempl && context.emplan){
            return Http.getInstance().delete(`/emacclasses/${context.emacclass}/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfteam && context.emequip && context.emplan){
            return Http.getInstance().delete(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emplans/${context.emplan}`,isloading);
        }
        if(context.emeqtype && context.emequip && context.emplan){
            return Http.getInstance().delete(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfteam && context.emplan){
            return Http.getInstance().delete(`/pfteams/${context.pfteam}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfemp && context.emplan){
            return Http.getInstance().delete(`/pfemps/${context.pfemp}/emplans/${context.emplan}`,isloading);
        }
        if(context.pfdept && context.emplan){
            return Http.getInstance().delete(`/pfdepts/${context.pfdept}/emplans/${context.emplan}`,isloading);
        }
        if(context.emservice && context.emplan){
            return Http.getInstance().delete(`/emservices/${context.emservice}/emplans/${context.emplan}`,isloading);
        }
        if(context.emplantempl && context.emplan){
            return Http.getInstance().delete(`/emplantempls/${context.emplantempl}/emplans/${context.emplan}`,isloading);
        }
        if(context.emequip && context.emplan){
            return Http.getInstance().delete(`/emequips/${context.emequip}/emplans/${context.emplan}`,isloading);
        }
        if(context.emacclass && context.emplan){
            return Http.getInstance().delete(`/emacclasses/${context.emacclass}/emplans/${context.emplan}`,isloading);
        }
            return Http.getInstance().delete(`/emplans/${context.emplan}`,isloading);

    }

    /**
     * GetDraft接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMPlanServiceBase
     */
    public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emplantempl && true){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emplantempls/${context.emplantempl}/emplans/getdraft`,isloading);
        }
        if(context.pfemp && context.emplantempl && true){
            return Http.getInstance().get(`/pfemps/${context.pfemp}/emplantempls/${context.emplantempl}/emplans/getdraft`,isloading);
        }
        if(context.pfdept && context.emplantempl && true){
            return Http.getInstance().get(`/pfdepts/${context.pfdept}/emplantempls/${context.emplantempl}/emplans/getdraft`,isloading);
        }
        if(context.emservice && context.emplantempl && true){
            return Http.getInstance().get(`/emservices/${context.emservice}/emplantempls/${context.emplantempl}/emplans/getdraft`,isloading);
        }
        if(context.emacclass && context.emplantempl && true){
            return Http.getInstance().get(`/emacclasses/${context.emacclass}/emplantempls/${context.emplantempl}/emplans/getdraft`,isloading);
        }
        if(context.pfteam && context.emequip && true){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emplans/getdraft`,isloading);
        }
        if(context.emeqtype && context.emequip && true){
            return Http.getInstance().get(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emplans/getdraft`,isloading);
        }
        if(context.pfteam && true){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emplans/getdraft`,isloading);
        }
        if(context.pfemp && true){
            return Http.getInstance().get(`/pfemps/${context.pfemp}/emplans/getdraft`,isloading);
        }
        if(context.pfdept && true){
            return Http.getInstance().get(`/pfdepts/${context.pfdept}/emplans/getdraft`,isloading);
        }
        if(context.emservice && true){
            return Http.getInstance().get(`/emservices/${context.emservice}/emplans/getdraft`,isloading);
        }
        if(context.emplantempl && true){
            return Http.getInstance().get(`/emplantempls/${context.emplantempl}/emplans/getdraft`,isloading);
        }
        if(context.emequip && true){
            return Http.getInstance().get(`/emequips/${context.emequip}/emplans/getdraft`,isloading);
        }
        if(context.emacclass && true){
            return Http.getInstance().get(`/emacclasses/${context.emacclass}/emplans/getdraft`,isloading);
        }
        let res:any = await  Http.getInstance().get(`/emplans/getdraft`,isloading);
        res.data.emplan = data.emplan;
            this.tempStorage.setItem(context.srfsessionkey+'_emplandetails',JSON.stringify(res.data.emplandetails));
            this.tempStorage.setItem(context.srfsessionkey+'_emplancdts',JSON.stringify(res.data.emplancdts));
        return res;
    }

    /**
     * CheckKey接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMPlanServiceBase
     */
    public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.pfemp && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/pfemps/${context.pfemp}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.pfdept && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/pfdepts/${context.pfdept}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.emservice && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/emservices/${context.emservice}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.emacclass && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/emacclasses/${context.emacclass}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.pfteam && context.emequip && context.emplan){
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.emeqtype && context.emequip && context.emplan){
            return Http.getInstance().post(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.pfteam && context.emplan){
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.pfemp && context.emplan){
            return Http.getInstance().post(`/pfemps/${context.pfemp}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.pfdept && context.emplan){
            return Http.getInstance().post(`/pfdepts/${context.pfdept}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.emservice && context.emplan){
            return Http.getInstance().post(`/emservices/${context.emservice}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.emplantempl && context.emplan){
            return Http.getInstance().post(`/emplantempls/${context.emplantempl}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.emequip && context.emplan){
            return Http.getInstance().post(`/emequips/${context.emequip}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
        if(context.emacclass && context.emplan){
            return Http.getInstance().post(`/emacclasses/${context.emacclass}/emplans/${context.emplan}/checkkey`,data,isloading);
        }
            return Http.getInstance().post(`/emplans/${context.emplan}/checkkey`,data,isloading);
    }

    /**
     * Save接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMPlanServiceBase
     */
    public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.pfemp && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/pfemps/${context.pfemp}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.pfdept && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/pfdepts/${context.pfdept}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.emservice && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/emservices/${context.emservice}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.emacclass && context.emplantempl && context.emplan){
            return Http.getInstance().post(`/emacclasses/${context.emacclass}/emplantempls/${context.emplantempl}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.pfteam && context.emequip && context.emplan){
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.emeqtype && context.emequip && context.emplan){
            return Http.getInstance().post(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.pfteam && context.emplan){
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.pfemp && context.emplan){
            return Http.getInstance().post(`/pfemps/${context.pfemp}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.pfdept && context.emplan){
            return Http.getInstance().post(`/pfdepts/${context.pfdept}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.emservice && context.emplan){
            return Http.getInstance().post(`/emservices/${context.emservice}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.emplantempl && context.emplan){
            return Http.getInstance().post(`/emplantempls/${context.emplantempl}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.emequip && context.emplan){
            return Http.getInstance().post(`/emequips/${context.emequip}/emplans/${context.emplan}/save`,data,isloading);
        }
        if(context.emacclass && context.emplan){
            return Http.getInstance().post(`/emacclasses/${context.emacclass}/emplans/${context.emplan}/save`,data,isloading);
        }
        let masterData:any = {};
        let emplandetailsData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_emplandetails'),'undefined')){
            emplandetailsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_emplandetails') as any);
            if(emplandetailsData && emplandetailsData.length && emplandetailsData.length > 0){
                emplandetailsData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.emplandetailid = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.emplandetails = emplandetailsData;
        let emplancdtsData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_emplancdts'),'undefined')){
            emplancdtsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_emplancdts') as any);
            if(emplancdtsData && emplancdtsData.length && emplancdtsData.length > 0){
                emplancdtsData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.emplancdtid = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.emplancdts = emplancdtsData;
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().post(`/emplans/${context.emplan}/save`,data,isloading);
            this.tempStorage.setItem(context.srfsessionkey+'_emplandetails',JSON.stringify(res.data.emplandetails));
            this.tempStorage.setItem(context.srfsessionkey+'_emplancdts',JSON.stringify(res.data.emplancdts));
            return res;
    }

    /**
     * FetchDefault接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMPlanServiceBase
     */
    public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emplantempl && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emplantempls/${context.emplantempl}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.pfemp && context.emplantempl && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/pfemps/${context.pfemp}/emplantempls/${context.emplantempl}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.pfdept && context.emplantempl && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/pfdepts/${context.pfdept}/emplantempls/${context.emplantempl}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.emservice && context.emplantempl && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emservices/${context.emservice}/emplantempls/${context.emplantempl}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.emacclass && context.emplantempl && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emacclasses/${context.emacclass}/emplantempls/${context.emplantempl}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.pfteam && context.emequip && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.emeqtype && context.emequip && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.pfteam && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.pfemp && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/pfemps/${context.pfemp}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.pfdept && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/pfdepts/${context.pfdept}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.emservice && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emservices/${context.emservice}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.emplantempl && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emplantempls/${context.emplantempl}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.emequip && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emequips/${context.emequip}/emplans/fetchdefault`,tempData,isloading);
        }
        if(context.emacclass && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emacclasses/${context.emacclass}/emplans/fetchdefault`,tempData,isloading);
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        return Http.getInstance().get(`/emplans/fetchdefault`,tempData,isloading);
    }
}