std_bills_lib_lists_model.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * 标准清单库
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/8/4
  6. * @version
  7. */
  8. import BaseModel from "../../common/base/base_model";
  9. import STDBillsLibListsSchema from "./schemas/std_bills_lib_lists";
  10. class STDBillsLibListsModel extends BaseModel {
  11. /**
  12. * 构造函数
  13. *
  14. * @return {void}
  15. */
  16. constructor() {
  17. let parent = super();
  18. parent.model = STDBillsLibListsSchema;
  19. parent.init();
  20. }
  21. /**
  22. * 获取标准清单
  23. *
  24. * @param {String} compilationId
  25. * @return {Promise}
  26. */
  27. async getBillList(compilationId) {
  28. let result = false;
  29. let billLib = await this.findDataByCondition({deleted: false}, null, false);
  30. if (billLib.length <= 0) {
  31. return result;
  32. }
  33. // 整理数据
  34. let billList = [];
  35. for(let tmp of billLib) {
  36. let tmpRation = {id: tmp.billsLibId, name: tmp.billsLibName};
  37. if (compilationId !== tmp.compilationId) {
  38. continue;
  39. }
  40. if (billList.length <= 0) {
  41. billList = [tmpRation];
  42. } else {
  43. billList.push(tmpRation);
  44. }
  45. }
  46. result = billList;
  47. return result;
  48. }
  49. }
  50. export default STDBillsLibListsModel;