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



/**
 * 统一产品（索引主实体）服务对象基类
 *
 * @export
 * @class IBIZUNIProductServiceBase
 * @extends {EntityServie}
 */
export default class IBIZUNIProductServiceBase extends EntityService {

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

    /**
     * 初始化基础数据
     *
     * @memberof IBIZUNIProductServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='ibizuniproduct';
        this.APPDEKEY = 'ibizuniproductid';
        this.APPDENAME = 'ibizuniproducts';
        this.APPDETEXT = 'ibizuniproductname';
        this.APPNAME = 'web';
        this.SYSTEMNAME = 'demosys';
    }

// 实体接口

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

            return res;
    }

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

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