rations.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * Created by Mai on 2017/4/1.
  3. */
  4. var Rations = {
  5. createNew: function (project) {
  6. // 用户定义private方法
  7. var tools = {};
  8. // 所有通过this访问的属性,都不应在此单元外部进行写入操作
  9. var rations = function (proj) {
  10. this.project = proj;
  11. this.datas = null;
  12. var sourceType = 'ration';
  13. this.getSourceType = function () {
  14. return sourceType;
  15. }
  16. };
  17. // prototype用于定义public方法
  18. rations.prototype.loadDatas = function (datas) {
  19. this.datas = datas;
  20. // generate Fees & Flags Index,For View & Calculate
  21. this.datas.forEach(function (data) {
  22. data.FeesIndex = {};
  23. data.fees.forEach(function (fee) {
  24. data.FeesIndex[fee.fieldName] = fee;
  25. });
  26. data.FlagsIndex = {};
  27. data.flags.forEach(function (flag) {
  28. data.FlagsIndex[flag.fieldName] = flag;
  29. });
  30. });
  31. };
  32. return new rations(project);
  33. }
  34. };