ration_template.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * Created by zhang on 2018/11/26.
  3. */
  4. let ration_template = {
  5. createNew: function (project) {
  6. let ration_template = function (proj){
  7. this.datas = [];
  8. var sourceType = ModuleNames.ration_template;
  9. this.getSourceType = function () {
  10. return sourceType;
  11. }
  12. proj.registerModule(ModuleNames.ration_template, this);
  13. };
  14. // prototype用于定义public方法
  15. ration_template.prototype.loadData = function (datas) {
  16. this.datas = datas;
  17. };
  18. ration_template.prototype.addDatasToList = function (datas) {
  19. let me = this;
  20. if(datas&&datas.length>0){
  21. if (me.datas && Array.isArray(me.datas)) {
  22. me.datas = me.datas.concat(datas);
  23. } else {
  24. me.datas = datas;
  25. }
  26. }
  27. };
  28. ration_template.prototype.getTemplateByRationID = function (rationID) {
  29. return _.find(this.datas, {'rationID': rationID});
  30. };
  31. ration_template.prototype.deleteByRation = function(ration){
  32. _.remove(this.datas,{'rationID':ration.ID});
  33. };
  34. return new ration_template(project);
  35. }
  36. }