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



/**
 * 硬件服务对象基类
 *
 * @export
 * @class IBIZHardwareServiceBase
 * @extends {EntityServie}
 */
export default class IBIZHardwareServiceBase extends EntityService {

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

    /**
     * 初始化基础数据
     *
     * @memberof IBIZHardwareServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='ibizhardware';
        this.APPDEKEY = 'ibizhardwareid';
        this.APPDENAME = 'ibizhardwares';
        this.APPDETEXT = 'ibizhardwarename';
        this.APPNAME = 'web';
        this.SYSTEMNAME = 'demosys';
    }

// 实体接口

    /**
     * Select接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof IBIZHardwareServiceBase
     */
    public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
            let res:any = Http.getInstance().post(`/ibizhardwares/${context.ibizhardware}/select`,data,isloading);

            return res;
    }

    /**
     * FetchDefault接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof IBIZHardwareServiceBase
     */
    public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
    }

    /**
     * FetchIndexDER接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof IBIZHardwareServiceBase
     */
    public async FetchIndexDER(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        let codelistModel:any = {tag:'HARDWARETYPE',codelistType:'STATIC'};
        let res:any = await this.getCodeList(codelistModel.tag,codelistModel.codelistType,context,data);
        if(res && res.length > 0){
            res.forEach((ele:any) => {
                // 仿真返回数据集
                ele.ibizhardwareid = ele.value;
                ele.ibizhardwarename = ele.text
            });
        } 
        return {status:200,data:res};
    }
}