bemsnoticepricebase-view-model.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. (function() {
  2. BemsWebApplication.BemsNoticePriceBaseViewModel = function(data) {
  3. this.SiteId = ko.observable();
  4. this.FuelTypeId = ko.observable();
  5. this.ApplyDate = ko.observable();
  6. this.ContractType = ko.observable();
  7. this.PrimaryPrice = ko.observable();
  8. this.SecondaryPrice = ko.observable();
  9. if(data)
  10. this.fromJS(data);
  11. };
  12. $.extend(BemsWebApplication.BemsNoticePriceBaseViewModel.prototype, {
  13. toJS: function() {
  14. return {
  15. SiteId: this.SiteId(),
  16. FuelTypeId: this.FuelTypeId(),
  17. ApplyDate: this.ApplyDate(),
  18. ContractType: this.ContractType(),
  19. PrimaryPrice: this.PrimaryPrice(),
  20. SecondaryPrice: this.SecondaryPrice(),
  21. };
  22. },
  23. fromJS: function(data) {
  24. if(data) {
  25. this.SiteId(data.SiteId);
  26. this.FuelTypeId(data.FuelTypeId);
  27. this.ApplyDate(data.ApplyDate);
  28. this.ContractType(data.ContractType);
  29. this.PrimaryPrice(data.PrimaryPrice);
  30. this.SecondaryPrice(data.SecondaryPrice);
  31. }
  32. }
  33. });
  34. })();