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



/**
 * 合同信息服务对象基类
 *
 * @export
 * @class HRContractServiceBase
 * @extends {EntityServie}
 */
export default class HRContractServiceBase extends EntityService {

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

    /**
     * 初始化基础数据
     *
     * @memberof HRContractServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='hrcontract';
        this.APPDEKEY = 'hrcontractid';
        this.APPDENAME = 'hrcontracts';
        this.APPDETEXT = 'hrcontractname';
        this.APPNAME = 'pim';
        this.SYSTEMNAME = 'ibizhumanresources';
    }

// 实体接口

    /**
     * Select接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && context.hrcontract){
            let res:any = Http.getInstance().get(`/hremployees/${context.hremployee}/hrcontracts/${context.hrcontract}/select`,isloading);
            
            return res;
        }
            let res:any = Http.getInstance().get(`/hrcontracts/${context.hrcontract}/select`,isloading);
            
            return res;
    }

    /**
     * Create接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && true){
            let masterData:any = {};
            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(`/hremployees/${context.hremployee}/hrcontracts`,data,isloading);
            
            return res;
        }
        let masterData:any = {};
        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(`/hrcontracts`,data,isloading);
        
        return res;
    }

    /**
     * Update接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && context.hrcontract){
            let masterData:any = {};
            Object.assign(data,masterData);
            let res:any = await Http.getInstance().put(`/hremployees/${context.hremployee}/hrcontracts/${context.hrcontract}`,data,isloading);
            
            return res;
        }
        let masterData:any = {};
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().put(`/hrcontracts/${context.hrcontract}`,data,isloading);
            
            return res;
    }

    /**
     * Remove接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && context.hrcontract){
            let res:any = Http.getInstance().delete(`/hremployees/${context.hremployee}/hrcontracts/${context.hrcontract}`,isloading);
            return res;
        }
            let res:any = Http.getInstance().delete(`/hrcontracts/${context.hrcontract}`,isloading);
            return res;
    }

    /**
     * Get接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && context.hrcontract){
            let res:any = await Http.getInstance().get(`/hremployees/${context.hremployee}/hrcontracts/${context.hrcontract}`,isloading);
            
            return res;
        }
            let res:any = await Http.getInstance().get(`/hrcontracts/${context.hrcontract}`,isloading);
            
            return res;
    }

    /**
     * GetDraft接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && true){
            let res:any = await Http.getInstance().get(`/hremployees/${context.hremployee}/hrcontracts/getdraft`,isloading);
            res.data.hrcontract = data.hrcontract;
            
            return res;
        }
        let res:any = await  Http.getInstance().get(`/hrcontracts/getdraft`,isloading);
        res.data.hrcontract = data.hrcontract;
        
        return res;
    }

    /**
     * CheckKey接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && context.hrcontract){
            let masterData:any = {};
            Object.assign(data,masterData);
            let res:any = await Http.getInstance().post(`/hremployees/${context.hremployee}/hrcontracts/${context.hrcontract}/checkkey`,data,isloading);
            
            return res;
        }
            let res:any = Http.getInstance().post(`/hrcontracts/${context.hrcontract}/checkkey`,data,isloading);
            return res;
    }

    /**
     * Save接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && context.hrcontract){
            let masterData:any = {};
            Object.assign(data,masterData);
            let res:any = await Http.getInstance().post(`/hremployees/${context.hremployee}/hrcontracts/${context.hrcontract}/save`,data,isloading);
            
            return res;
        }
        let masterData:any = {};
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().post(`/hrcontracts/${context.hrcontract}/save`,data,isloading);
            
            return res;
    }

    /**
     * FetchActive接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async FetchActive(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            let res:any = Http.getInstance().get(`/hremployees/${context.hremployee}/hrcontracts/fetchactive`,tempData,isloading);
            return res;
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/hrcontracts/fetchactive`,tempData,isloading);
        return res;
    }

    /**
     * FetchDefault接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            let res:any = Http.getInstance().get(`/hremployees/${context.hremployee}/hrcontracts/fetchdefault`,tempData,isloading);
            return res;
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/hrcontracts/fetchdefault`,tempData,isloading);
        return res;
    }

    /**
     * FetchWaitSign接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async FetchWaitSign(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            let res:any = Http.getInstance().get(`/hremployees/${context.hremployee}/hrcontracts/fetchwaitsign`,tempData,isloading);
            return res;
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/hrcontracts/fetchwaitsign`,tempData,isloading);
        return res;
    }

    /**
     * FetchWaitStop接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRContractServiceBase
     */
    public async FetchWaitStop(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            let res:any = Http.getInstance().get(`/hremployees/${context.hremployee}/hrcontracts/fetchwaitstop`,tempData,isloading);
            return res;
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/hrcontracts/fetchwaitstop`,tempData,isloading);
        return res;
    }
}