std_ration_lib_map_model.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * 定额库业务逻辑模型
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/8/1
  6. * @version
  7. */
  8. import BaseModel from "../base/base_model";
  9. import STDRationLibMapSchema from "./schemas/std_ration_lib_map";
  10. class STDRationLibMapModel extends BaseModel {
  11. /**
  12. * 构造函数
  13. *
  14. * @return {void}
  15. */
  16. constructor() {
  17. let parent = super();
  18. parent.model = STDRationLibMapSchema;
  19. parent.init();
  20. }
  21. /**
  22. * 获取定额库
  23. *
  24. * @return {Promise}
  25. */
  26. async getRationLib() {
  27. let result = false;
  28. let rationLib = await this.findDataByCondition({deleted: false}, null, false);
  29. if (rationLib.length <= 0) {
  30. return result;
  31. }
  32. // 整理数据
  33. let rationData = {};
  34. for(let tmp of rationLib) {
  35. let tmpRation = {id: tmp.ID, name: tmp.dispName};
  36. if (rationData[tmp.localeType] === undefined) {
  37. rationData[tmp.localeType] = [tmpRation];
  38. } else {
  39. rationData[tmp.localeType].push(tmpRation);
  40. }
  41. }
  42. result = rationData;
  43. return result;
  44. }
  45. }
  46. export default STDRationLibMapModel;