f864c42c3575696ac5c07da5daa5cc5968c7220c.svn-base 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. $(function () {
  2. 'use strict';
  3. var eq = BWA.DataUtil.constructEqualFilter,
  4. and = BWA.DataUtil.andFilter;
  5. var visible = ko.observable(false),
  6. newInfo = ko.observable(false);
  7. var userDataSource = BWA.DataUtil.createDataSource({
  8. dataSourceOptions: {
  9. select: ['SiteId', 'CompanyId', 'DepartmentId', 'UserId', 'Name', 'EmploymentType', 'Email', 'MobilePhoneNo', 'EmploymentStatus', 'CmPosition/Name', 'CmDepartment/Name', 'CmCompany/Name'],
  10. expand: ["CmPosition", "CmDepartment", "CmCompany"],
  11. extendOptions: {
  12. alterNames: {
  13. 'CmPosition/Name': 'PositionName',
  14. 'CmDepartment/Name': 'DepartmentName',
  15. 'CmCompany/Name': 'CompanyName'
  16. }
  17. }
  18. }
  19. }, 'CmUser'),
  20. userInfo = {
  21. SiteId: ko.observable(),
  22. UserId: ko.observable(),
  23. Name: ko.observable(),
  24. CompanyName: ko.observable(),
  25. PositionName: ko.observable(),
  26. DepartmentName: ko.observable(),
  27. MobilePhoneNo: ko.observable(),
  28. Email: ko.observable()
  29. };
  30. /*
  31. var facilityClassDataSource = BemsWebApplication.db.createDataSource('FmsFacilityCodeClass');
  32. var buildingDataSource = BemsWebApplication.db.createDataSource('CmBuilding', true),
  33. floorDataSource = BemsWebApplication.db.createDataSource('CmFloor'),
  34. zoneDataSource = BemsWebApplication.db.createDataSource('CmZone');
  35. // 설비분류 데이터소스
  36. var facilityTypeDataSource = BemsWebApplication.db.createDataSource('BemsFacilityType');
  37. var facilityTypes = ko.observableArray();
  38. var facilityClasses = [ko.observableArray(), ko.observableArray(), ko.observableArray()];
  39. var buildings = ko.observableArray(),
  40. floors = ko.observableArray(),
  41. zones = ko.observableArray();
  42. */
  43. var workDataSource = BWA.DataUtil.createDataSource({
  44. dataSourceOptions: {
  45. select: ['SiteId', 'CmFacility/FacilityTypeId', 'FacilityCode', 'CmFacility/Name', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'T10', 'T11', 'T12'],
  46. expand: ['CmFacility'],
  47. extendOptions: {
  48. forceOriginalField: true
  49. },
  50. //filter: [
  51. // eq('SiteId', BWA.UserInfo.SiteId()),
  52. // and,
  53. // ['FmsWorkRequest/WorkProgressId', '=', $Code.WorkProgress.WORKING] // 4
  54. // //, and, ['FmsWorkRequest/WorkProgressId', '<=', 5]
  55. //]
  56. }
  57. }, 'CmFacilityTempSet');
  58. var works = ko.observableArray();
  59. var datas;
  60. BWA.ControlPanel = {
  61. newInfo: newInfo,
  62. UserInfo: userInfo,
  63. workDataGridOptions: utils.datagrid.defaultOptions({
  64. dataSource: works,
  65. rowAlternationEnabled: true,
  66. handleDataGridRowClick: function (rowdata) {
  67. alert();
  68. },
  69. editing: {
  70. editMode: 'cell', // 14.1은 batch, row 두가지 밖에 없다. cell->row로 동작중이다. 2015 07 15 hcLee
  71. editEnabled: true,
  72. },
  73. columns: [
  74. //{ dataField: 'FacilityCode', caption: $G('number'), width: '14%', alignment: 'center' }, // ?
  75. { dataField: 'FacilityCode', caption: '설비코드', width: '14%', alignment: 'center' }, // ? 2015 07 30 왜 1,2,3 번호가 안나올까? utils.datagrid.defaultOptions 으로 생성했는데.....
  76. { dataField: 'CmFacility/Name', caption: '공조기명', width: '50%', alignment: 'center', allowEditing: false },
  77. { dataField: 'TN', caption: '이달의 설정온도', width: '18%', alignment: 'center' },
  78. ],
  79. //height: 220
  80. }),
  81. /*
  82. notificationDataGridOptions: utils.datagrid.defaultOptions({
  83. //dxDataSource: announcements,
  84. dataSource: announcements,
  85. handleDataGridRowClick: function () {
  86. },
  87. columns: [
  88. { dataField: 'AnnouncementId', caption: $G('number'), width: '15%', alignment: 'center', sortOrder: 'desc' },
  89. { dataField: 'Title', caption: '제목', width: '40%', alignment: 'center' },
  90. ],
  91. height: 220,
  92. }),*/
  93. options: {
  94. width: '1400',
  95. //height: '670',
  96. height: '700',
  97. visible: visible,
  98. position: { my: 'top', at: 'top', of: window },
  99. animation: {
  100. show: { type: "slide", easing: 'ease-in-out', duration: 400, from: { top: -649 }, to: { top: 0 } },
  101. hide: { type: "slide", easing: 'ease-in-out', duration: 400, from: { top: 1 }, to: { top: -649 } }
  102. },
  103. showingAction: function () {
  104. userDataSource.filter([
  105. eq('SiteId', BWA.UserInfo.SiteId()),
  106. and,
  107. eq('UserId', BWA.UserInfo.UserId())
  108. ]);
  109. userDataSource.load().done(function(users) {
  110. if (_.isEmpty(users)) {
  111. return; // logout 처리 필요
  112. }
  113. BWA.DataUtil.copyViewModel(users[0], userInfo);
  114. });
  115. var now = new Date();
  116. workDataSource.load().done(function (workResult) {
  117. _.each(workResult, function(x) {
  118. x[15] = 'TN';
  119. x.TN = BWA.Bems.refineGetMonthAirTempSetValue(now.getMonth(), x);
  120. });
  121. datas = workResult;
  122. works(workResult);
  123. });
  124. },
  125. contentReadyAction: function(e) {
  126. },
  127. shading: false,
  128. closeOnOutsideClick: true
  129. },
  130. handleControl: function () {
  131. var param;
  132. var promises = [];
  133. _.each(BWA.ControlPanel.workDataGridOptions.dataSource(), function (x) {
  134. //alert(x.TN());
  135. //alert(x.FacilityCode());
  136. //alert(x["CmFacility/Name"]());
  137. var v = (jQuery.isFunction(x.TN)) ? x.TN() : x.TN;
  138. param = {
  139. SiteId: BWA.UserInfo.SiteId(),
  140. FacilityTypeId: x["CmFacility/FacilityTypeId"](),
  141. FacilityCode: x.FacilityCode(),
  142. FormulaId: $Code.Formula[$Code.FacilityType.AIR_HANDLING].TEMP_SET,
  143. //ControlValue: x.TN(),
  144. //ControlValue: 100,
  145. ControlValue: (jQuery.isFunction(x.TN)) ? x.TN() : x.TN,
  146. };
  147. promises.push(BWA.api.post('BemsFormula/ControlPoint', null, param));
  148. //BWA.api.post('BemsFormula/ControlPoint', null, param).done(function () {
  149. // utils.toast.show('온도제어 완료');
  150. //});
  151. });
  152. $.when.apply(this, promises).done(function () {
  153. utils.toast.show('온도제어 완료');
  154. })
  155. },
  156. handleToggleOpenClose: function() {
  157. visible(!visible());
  158. },
  159. show: function() {
  160. visible(true);
  161. },
  162. hide: function() {
  163. visible(false);
  164. },
  165. };
  166. });