99e6d4272f38f46c59ded0776d9e18956ad85973.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. BemsWebApplication.SetChart = function (params, viewInfo) {
  2. "use strict";
  3. var facilityTypeDataSource = BemsWebApplication.db.createDataSource('BemsFacilityType', true);
  4. var ChartInfoDataSource = BemsWebApplication.db.createDataSource('BemsChartInfo', true);
  5. var facilityTypes = ko.observableArray();
  6. var ChartInfo = ko.observableArray();
  7. var searchfacilityTypes = ko.observableArray();
  8. var facilityTypeDeferred = new $.Deferred();
  9. var BemsFormulaBaseDataSource = BemsWebApplication.db.createDataSource('BemsFormulaBase', true, true);
  10. var formulaListByFacilityType = ko.observableArray();
  11. var palettes = ['Default', 'Soft Pastel', 'Harmony Light', 'Pastel', 'Bright', 'Soft', 'Ocean', 'Vintage', 'Violet'];
  12. var chartTypes = ['bar', 'line', 'spline', 'area', 'scatter', 'splinearea', 'stepline', 'steparea'];
  13. var dataSourceOptions = {
  14. select: [
  15. 'SiteId', 'FacilityTypeId', 'BemsFacilityType/Name',
  16. 'ChartId', 'Palette', 'Title',
  17. 'LAxTitle', 'UseLAxMinMax', 'LAxMin', 'LAxMax',
  18. 'RAxTitle', 'UseRAxMinMax', 'RAxMin', 'RAxMax',
  19. 'UseX', 'XAxTitle', 'XSFmId', 'XSType', 'UseXAxMinMax', 'XAxMin', 'XAxMax',
  20. 'LSFmId1', 'LSName1', 'LSType1',
  21. 'LSFmId2', 'LSName2', 'LSType2',
  22. 'LSFmId3', 'LSName3', 'LSType3',
  23. 'LSFmId4', 'LSName4', 'LSType4',
  24. 'RSFmId1', 'RSName1', 'RSType1',
  25. 'RSFmId2', 'RSName2', 'RSType2',
  26. 'RSFmId3', 'RSName3', 'RSType3',
  27. 'RSFmId4', 'RSName4', 'RSType4',
  28. 'UseChart',
  29. 'UseLCTLine', 'LCTLineTitle', 'LCTLineValue',
  30. 'UseRCTLine', 'RCTLineTitle', 'RCTLineValue',
  31. ],
  32. filter: [
  33. ['SiteId', '=', BWA.UserInfo.SiteId()]
  34. ],
  35. expand: [
  36. 'BemsFacilityType',
  37. ],
  38. extendOptions: {
  39. forceOriginalField: true
  40. },
  41. };
  42. var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'BemsChartInfo', {
  43. dataSourceOptions: dataSourceOptions,
  44. columns: [
  45. { dataField: 'SiteId', caption: '번호', width: '8%', alignment: 'center', sortOder: 'desc' },
  46. { dataField: 'BemsFacilityType/Name', caption: '설비타입', width: '15%', alignment: 'center' },
  47. { dataField: 'ChartId', caption: '차트ID', width: '10%', alignment: 'center' },
  48. { dataField: 'Title', caption: '차트타이틀', width: '15%', alignment: 'center' },
  49. { dataField: 'Palette', caption: '차트 색상', width: '15%', alignment: 'center' },
  50. { dataField: 'LAxTitle', caption: '좌Y축 타이틀', width: '20%', alignment: 'center' },
  51. { dataField: 'LSName1', caption: '좌Y축 항목1 타이틀', width: '20%', alignment: 'center' },
  52. /*{
  53. dataField: 'UseLAxMinMax', caption: '좌Y축 최대최소값 사용', width: '5%', alignment: 'center',
  54. customizeText: function (cellInfo) { return $G.isUse(cellInfo.value); }
  55. },*/
  56. { dataField: 'RAxTitle', caption: '우Y축 타이틀', width: '20%', alignment: 'center' },
  57. /*{
  58. dataField: 'UseRAxMinMax', caption: '우Y축 최대최소값 사용', width: '5%', alignment: 'center',
  59. customizeText: function (cellInfo) { return $G.isUse(cellInfo.value); }
  60. },*/
  61. { dataField: 'RSName1', caption: '우Y축 항목1 타이틀', width: '20%', alignment: 'center' },
  62. //{ dataField: 'Palette', caption: $G('phoneNo'), width: '20%', alignment: 'center' },
  63. /*
  64. {
  65. dataField: 'IsControlSchedule', caption: '제어스케줄', width: '15%', alignment: 'center',
  66. customizeText: function (cellInfo) {
  67. return $G.isUse(cellInfo.value);
  68. }
  69. },*/
  70. {
  71. dataField: 'UseChart', caption: '차트 사용', width: '15%', alignment: 'center',
  72. customizeText: function (cellInfo) {
  73. return $G.isUse(cellInfo.value);
  74. //return $G.isYes(cellInfo.value);
  75. }
  76. }
  77. //utils.datagrid.columnIsUse('10%'),
  78. ],
  79. // 2019.04.17 엑셀 출력 기능 추가 ~~~
  80. "export": {
  81. enabled: true,
  82. fileName: '성능분석 차트 설정 내용'
  83. },
  84. onExporting: function (e) {
  85. e.component.columnOption("SiteId", "visible", false);
  86. },
  87. onExported: function (e) {
  88. e.component.columnOption("SiteId", "visible", true);
  89. },
  90. // ~~~ 2019.04.17 엑셀 출력 기능 추가
  91. paging: {
  92. pageSize: 18,
  93. enabled: true
  94. },
  95. pager: {
  96. //showPageSizeSelector: false,
  97. //allowedPageSizes: 18,
  98. //showInfo: false
  99. },
  100. promiseDataInSearchView: facilityTypeDeferred.promise(),
  101. searchViewItems: [{ id: 'FacilityTypeId', ignoreValue: 0, defaultValue: 0, dataSource: searchfacilityTypes }, { id: 'Name' }],
  102. handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
  103. dataGrid.clearSelection();
  104. viewModel.isNewInPopup(false);
  105. var data = clickRow.data;
  106. viewModel.handleSelectBoxChangeFacilityType({ value: data.FacilityTypeId() });
  107. //var dataModel = viewModel.dataModel;
  108. /*
  109. dataModel.CompanyName = $KoSet(dataModel.CompanyName, data['CmCompany/Name']);
  110. dataModel.DepartmentName = $KoSet(dataModel.DepartmentName, data['CmDepartment/Name']);
  111. dataModel.BusinessFieldName = $KoSet(dataModel.BusinessFieldName, data['CmBusinessField/Name']);
  112. dataModel.UserGroupName = $KoSet(dataModel.UserGroupName, data['CmUserGroup/Name']);
  113. dataModel.IsScheduleUser = $KoSet(dataModel.IsScheduleUser, data.IsScheduleUser());
  114. dataModel.IsSI = $KoSet(dataModel.IsSI, data.IsSI());
  115. dataModel.IsMobile = $KoSet(dataModel.IsMobile, data.IsMobile());*/
  116. popupVisible(true);
  117. },
  118. handleViewShowing: function () {
  119. facilityTypeDataSource.filter([
  120. ['FacilityTypeId', '<', 50]/*,
  121. 'and',
  122. ['FacilityTypeId', '<>', 1],
  123. 'and',
  124. ['FacilityTypeId', '<>', 2],
  125. 'and',
  126. ['FacilityTypeId', '<>', 8],*/
  127. ]);
  128. facilityTypeDataSource.load().done(function (result) {
  129. facilityTypes(result);
  130. //searchfacilityTypes([{ facilityTypeId: 0, Name: $G('selectAll') }].concat(result));
  131. searchfacilityTypes(result);
  132. facilityTypeDeferred.resolve();
  133. });
  134. ChartInfoDataSource.load().done(function (result) {
  135. ChartInfo(result);
  136. });
  137. },
  138. handlePopupShowing: function (isNewInPopup, dataViewModel) {
  139. if (isNewInPopup()) {
  140. dataViewModel.ChartId(1);
  141. dataViewModel.UseChart(true);
  142. dataViewModel.UseX(false);
  143. dataViewModel.UseXAxMinMax(false);
  144. dataViewModel.UseLAxMinMax(false);
  145. dataViewModel.UseRAxMinMax(false);
  146. dataViewModel.Palette('Default');
  147. dataViewModel.UseLCTLine(false);
  148. dataViewModel.UseRCTLine(false);
  149. }
  150. },
  151. popupWidth: 1000,
  152. handleViewShown: function () {
  153. },
  154. //2015 12 21 hcLee
  155. isUseSiteId: (BWA.UserInfo.isAdmin() == false) ? true : false,
  156. beforeInsertingDataViewModel: function (dataModel, dbModelId) {
  157. var dfd = $.Deferred();
  158. var result;
  159. for (var i = 0; i < ChartInfo().length; i++) {
  160. if (viewModel.dataModel.ChartId() == ChartInfo()[i].ChartId()) {
  161. result = false;
  162. break;
  163. }
  164. else {
  165. result = true;
  166. }
  167. }
  168. if (result) {
  169. dfd.resolve(true);
  170. } else {
  171. dfd.resolve(false, '차트 ID가 중복되었습니다.');
  172. }
  173. return dfd.promise();
  174. },
  175. /*
  176. beforeInsertingDataViewModel: function (dataModel, dbModelId) {
  177. var dfd = $.Deferred();
  178. $.when(BWA.api.post('BemsMonitoringPoint/GetMaxSiteId', null))
  179. .done(function (newPid) {
  180. if (newPid > 0) {
  181. dataModel.SiteId(newPid);
  182. dfd.resolve(true); // hcLee OK good, (true, false 또는 객체로 리턴가능함) 2015 11 19
  183. }
  184. else dfd.resolve(false, 'SiteId 자동 생성에 실패하였습니다!'); // hcLee OK good, (true, false 또는 객체로 리턴가능함) 2015 11 19
  185. });
  186. return dfd.promise();
  187. },*/
  188. handleAfterLoadingModelByKey: function (data, dataViewModel, isNewInPopup) {
  189. // 사이트정보는 생성 후 삭제할 수 없음
  190. viewModel.visibleDeleteButton(true);
  191. }
  192. });
  193. viewModel.isEditModeInPopup.subscribe(function (value) {
  194. viewModel.visibleDeleteButton(true);
  195. });
  196. {
  197. viewModel.popupInsertButtonOptions.visible = true;
  198. }
  199. viewModel.facilityTypes = facilityTypes;
  200. viewModel.palettes = palettes;
  201. viewModel.chartTypes = chartTypes;
  202. viewModel.formulaListByFacilityType = formulaListByFacilityType;
  203. viewModel.handleSelectBoxChangeFacilityType = function (e) {
  204. // hcLee 2018 03 02
  205. //기존 setArrayDataSourceFilter 를 확장하여 추가한 함수이다.
  206. // 동기화 Deferred 때문에 이 함수 동기화 내부에서 formulaListByFacilityType에 외기온도,습도 를 강제로 추가하는 코드가 존재 해야만
  207. // 팝업 콤보에 정상으로 추가된 항목(외기온도,습도)이 보이게 된다.
  208. BWA.DataUtil.setArrayDataSourceFilterForChartSet(BemsFormulaBaseDataSource, 'FacilityTypeId', e.value, formulaListByFacilityType);
  209. var i = 0;
  210. }
  211. return viewModel;
  212. };