/**
 * 人工系数业务模型
 *
 * @author CaiAoLin
 * @date 2017/9/11
 * @version
 */
import BaseModel from "../base/base_model";
import STDLabourCoesSchema from "./schemas/std_labour_coes";

class STDLabourCoesModel extends BaseModel {

    /**
     * 构造函数
     *
     * @return {void}
     */
    constructor() {
        let parent = super();
        parent.model = STDLabourCoesSchema;
        parent.init();
    }

    /**
     * 获取人工系数列表
     *
     * @return {Promise}
     */
    async getLabourCoesList() {
        let result = [];
        let field = {ID: 1, libName: 1};
        let feeRateList = await this.findDataByCondition({ID: {$ne: ''}}, field, false);

        if (feeRateList === null) {
            return result;
        }
        // 整理数据
        for(let feeRate of feeRateList) {
            let tmpData = {
                id: feeRate.ID,
                name: feeRate.libName
            };
            result.push(tmpData);
        }
        return result;
    }

}

export default STDLabourCoesModel;
