cmpatrolplan-view-model.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (function () {
  2. BemsWebApplication.CmPatrolPlanViewModel = function (data) {
  3. this.SiteId = ko.observable();
  4. this.PatrolPlanId = ko.observable();
  5. this.GroupId = ko.observable();
  6. this.CourseId = ko.observable();
  7. this.Name = ko.observable();
  8. this.PlanDesc = ko.observable();
  9. this.term = ko.observable();
  10. this.inDate = ko.observable();
  11. if (data)
  12. this.fromJS(data);
  13. };
  14. $.extend(BemsWebApplication.CmPatrolPlanViewModel.prototype, {
  15. toJS: function () {
  16. return {
  17. SiteId: this.SiteId(),
  18. PatrolPlanId: this.PatrolPlanId(),
  19. GroupId: this.GroupId(),
  20. CourseId: this.CourseId(),
  21. Name: this.Name(),
  22. PlanDesc: this.PlanDesc(),
  23. term: this.term(),
  24. inDate: this.inDate(),
  25. };
  26. },
  27. fromJS: function (data) {
  28. if (data) {
  29. this.SiteId(data.SiteId);
  30. this.PatrolPlanId(data.PatrolPlanId);
  31. this.GroupId(data.GroupId);
  32. this.CourseId(data.CourseId);
  33. this.Name(data.Name);
  34. this.PlanDesc(data.PlanDesc);
  35. this.term(data.term);
  36. this.inDate(data.inDate);
  37. }
  38. }
  39. });
  40. })();