/** * 定额库业务逻辑模型 * * @author CaiAoLin * @date 2017/8/1 * @version */ import BaseModel from "../base/base_model"; import STDRationLibMapSchema from "./schemas/std_ration_lib_map"; class STDRationLibMapModel extends BaseModel { /** * 构造函数 * * @return {void} */ constructor() { let parent = super(); parent.model = STDRationLibMapSchema; parent.init(); } /** * 获取定额库 * * @param {String} compilationId * @return {Promise} */ async getRationLib(compilationId) { let result = false; let rationLib = await this.findDataByCondition({deleted: false}, null, false); if (rationLib.length <= 0) { return result; } // 整理数据 let rationData = []; for(let tmp of rationLib) { let tmpRation = {id: tmp.ID, name: tmp.dispName}; if (compilationId !== tmp.compilationId) { continue; } if (rationData.length <= 0) { rationData = [tmpRation]; } else { rationData.push(tmpRation); } } result = rationData; return result; } // 获取所有费用定额的所有定额库 async getAllRationLibs() { const libs = await this.findDataByCondition({deleted: false}, null, false); return libs.map(libData => ({ id: libData.ID, name: libData.dispName })); } } export default STDRationLibMapModel;