07b356c55063afa89e5702fd32c87d2f994cdae7.svn-base 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622
  1. BemsWebApplication.AlarmSetting = function (params, viewInfo) {
  2. 'use strict';
  3. var now = new Date();
  4. var row_btn = false;
  5. var enroll_btn = false;
  6. var visiblePopup = ko.observable(false);
  7. var loadvisiblePopup = ko.observable(false);
  8. var popupInit = false;
  9. var ControlPoint_temp = 0;
  10. var virtualFacility = 99;
  11. var gridData = new Array();
  12. var upperLimitCnt = 0;
  13. var lowerLimitCnt = 0;
  14. var alarmYNCnt = 0;
  15. var smsYNCnt = 0;
  16. var emailYNCnt = 0;
  17. var ControlPoint = 0;
  18. var FacilityCode = 0;
  19. var FacilityName = "";
  20. var facilityTypeId = 0;
  21. var FormulaId = 0;
  22. var LowerLimit = "";
  23. var UpperLimit = "";
  24. var PropertyId = 0;
  25. var UseSMS = false;
  26. var UseEmail = false;
  27. var UseAlarm = false;
  28. var UseLowerLimit = false;
  29. var UseUpperLimit = false;
  30. var Point_Type_Id = "";
  31. var Content = "";
  32. var AlarmGroupName = "";
  33. var changed = false;
  34. var endpointSelector = "";
  35. if (BemsWebApplication.config.mode == "production") {
  36. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
  37. } else {
  38. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
  39. }
  40. var FacilityCode_id_temp = 0;
  41. var facility_type = ko.observableArray();
  42. var facility_id = ko.observableArray();
  43. var setDataSource1, alarmgroup;
  44. var allowedChars = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.'];
  45. var treeViewData = [
  46. {
  47. id: 1,
  48. text: "성능분석",
  49. items: [],
  50. visualFlag: false
  51. },
  52. {
  53. id: 2,
  54. text: "가상 시설",
  55. items: [],
  56. visualFlag: false
  57. },
  58. {
  59. id: 3,
  60. text: "일반 시설",
  61. items: [],
  62. visualFlag: false
  63. }
  64. ];
  65. var excnt = 0;
  66. var facilityTypeId_fin = 0, facilityCode_fin = 0, parentId_fin = 0, propertyId_fin = 0, facilityName_fin = "", formulaId_fin = 0, controlPoint_fin = "";
  67. var UpperLimit_ONOFF_value = false, LowerLimit_ONOFF_value = false, AlarmYN_Id_value = false, EmailYN_Id_Id_value = false, SMSYN_Id_Id_value = false, Users_Id_text = "", text_Id_text = "";
  68. var LowerLimit_Id_text = "", UpperLimit_Id_text = "";
  69. var selectData = {
  70. FacilityTypeId: 0,
  71. FacilityCode: 0,
  72. PropertyId: 0,
  73. FormulaId: 0,
  74. FacilityName: "",
  75. PointTypeId: "",
  76. ControlPoint: "",
  77. UpperLimit_ONOFF: false,
  78. UpperLimit: 0,
  79. LowerLimit_ONOFF: false,
  80. LowerLimit: 0,
  81. UseAlarm: false,
  82. UseSMS: false,
  83. UseEmail: false,
  84. AlarmGroupId: 0,
  85. text: ""
  86. }
  87. //권한설정
  88. var hasnotModificationPermission = ko.observable(true);
  89. function GetPopupTreeViewData() {
  90. treeViewData = [
  91. {
  92. id: 1,
  93. text: "성능분석",
  94. items: [],
  95. visualFlag: false
  96. },
  97. {
  98. id: 2,
  99. text: "가상 시설",
  100. items: [],
  101. visualFlag: false
  102. },
  103. {
  104. id: 3,
  105. text: "일반 시설",
  106. items: [],
  107. visualFlag: false
  108. }
  109. ];
  110. excnt = 4;
  111. var facilityIdIndex = 4;
  112. var dataSource = new DevExpress.data.DataSource({
  113. store: {
  114. type: "odata",
  115. url: endpointSelector + "/BemsFacilityType",
  116. },
  117. requireTotalCount: true,
  118. pageSize: 100
  119. });
  120. dataSource.sort({ getter: "FacilityTypeId", asc: true });
  121. dataSource.load()
  122. .done(function (result) {
  123. for (var i = 0; i < result.length; i++) {
  124. if (result[i].FacilityTypeId < 100) { //성능분석
  125. if (result[i].FacilityTypeId != virtualFacility) {
  126. treeViewData[0].items.push({ id: facilityIdIndex, facilityTypeId: result[i].FacilityTypeId, text: result[i].Name, items: [], visualFlag: false });
  127. facilityIdIndex++;
  128. excnt++;
  129. }
  130. }
  131. }
  132. for (var i = 0; i < result.length; i++) {
  133. if (result[i].FacilityTypeId < 100) { //가상
  134. if (result[i].FacilityTypeId != virtualFacility) {
  135. treeViewData[2].items.push({ id: facilityIdIndex, facilityTypeId: result[i].FacilityTypeId, text: result[i].Name, items: [], visualFlag: false });
  136. facilityIdIndex++;
  137. } else { //일반
  138. treeViewData[1].items.push({ id: facilityIdIndex, facilityTypeId: result[i].FacilityTypeId, text: result[i].Name, items: [], visualFlag: false });
  139. facilityIdIndex++;
  140. }
  141. }
  142. }
  143. var dataSource2 = new DevExpress.data.DataSource({
  144. store: {
  145. type: "odata",
  146. url: endpointSelector + "/CmFacility",
  147. },
  148. requireTotalCount: true,
  149. pageSize: 5000
  150. });
  151. dataSource2.filter([
  152. ["SiteId", "=", BWA.UserInfo.SiteId()]
  153. ]);
  154. dataSource2.sort({ getter: "Name", asc: true });
  155. dataSource2.load()
  156. .done(function (result2) {
  157. for (var i = 0; i < result2.length; i++) {
  158. for (var j = 0; j < treeViewData[0].items.length; j++) {
  159. if (treeViewData[0].items[j].facilityTypeId == result2[i].FacilityTypeId) {
  160. treeViewData[0].items[j].items.push({ id: facilityIdIndex, facilityTypeId: result2[i].FacilityTypeId, facilityCode: result2[i].FacilityCode, text: result2[i].Name, visualFlag: true, parentId: 0 });
  161. facilityIdIndex++;
  162. treeViewData[2].items[j].items.push({ id: facilityIdIndex, facilityTypeId: result2[i].FacilityTypeId, facilityCode: result2[i].FacilityCode, text: result2[i].Name, visualFlag: true, parentId: 2 });
  163. facilityIdIndex++;
  164. break;
  165. }
  166. }
  167. if (result2[i].FacilityTypeId == virtualFacility) {
  168. treeViewData[1].items[0].items.push({ id: facilityIdIndex, facilityTypeId: result2[i].FacilityTypeId, facilityCode: result2[i].FacilityCode, text: result2[i].Name, visualFlag: true, parentId: 1 });
  169. facilityIdIndex++;
  170. }
  171. }
  172. })
  173. .fail(function (error) {
  174. utils.toast.show(error);
  175. });
  176. })
  177. .fail(function (error) {
  178. utils.toast.show(error);
  179. });
  180. }
  181. function GetPopupGridData(facilityTypeId, facilityCode, parentId) {
  182. if (parentId != 0) {
  183. var dataSource = new DevExpress.data.DataSource({
  184. store: {
  185. type: "odata",
  186. url: endpointSelector + "/BemsMonitoringPointConfig",
  187. },
  188. requireTotalCount: true,
  189. pageSize: 5000,
  190. expand: ["BemsMonitoringPoint"]
  191. });
  192. dataSource.filter([
  193. ["SiteId", "=", BWA.UserInfo.SiteId()],
  194. "and",
  195. ["FacilityTypeId", "=", facilityTypeId],
  196. "and",
  197. ["FacilityCode", "=", facilityCode]
  198. ]);
  199. dataSource.sort({ getter: "BemsMonitoringPoint/PropertyId", asc: true });
  200. dataSource.load()
  201. .done(function (result) {
  202. setDataSource1 = new Array();
  203. for (var i = 0; i < result.length; i++) {
  204. var setData = { "ControlPoint": "", "FuelType": 0, "FacilityTypeId": 0, "FacilityCode": 0, "PropertyId": 0, "FormulaId": 0 };
  205. setData.ControlPoint = result[i].BemsMonitoringPoint.Name;
  206. var fuelName = result[i].BemsMonitoringPoint.FuelTypeId;
  207. if (fuelName == 0) {
  208. fuelName = "-";
  209. } else if (fuelName == 1) {
  210. fuelName = "전기";
  211. } else if (fuelName == 2) {
  212. fuelName = "가스";
  213. } else {
  214. fuelName = "수도";
  215. }
  216. setData.FuelType = fuelName;
  217. setData.FacilityTypeId = result[i].FacilityTypeId;
  218. setData.FacilityCode = result[i].FacilityCode;
  219. setData.PropertyId = result[i].PropertyId;
  220. setDataSource1.push(setData);
  221. }
  222. $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
  223. $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
  224. placeholder: "관제점 이름",
  225. dataSource: setDataSource1,
  226. displayExpr: "ControlPoint",
  227. valueExpr: "PropertyId",
  228. onValueChanged: function () {
  229. var value = $("#Control_Id").dxSelectBox('instance').option('value');
  230. if (value != null) {
  231. for (var i = 0; i < setDataSource1.length; i++) {
  232. if (setDataSource1[i].PropertyId == value) {
  233. propertyId_fin = setDataSource1[i].PropertyId;
  234. controlPoint_fin = setDataSource1[i].ControlPoint;
  235. formulaId_fin = setDataSource1[i].FormulaId;
  236. break;
  237. }
  238. }
  239. }
  240. }
  241. });
  242. if (changed) {
  243. $("#Facility_Id").dxSelectBox('instance').option('value', FacilityCode_id_temp);
  244. $("#UpperLimit_ONOFF").dxSwitch('instance').option('value', UseUpperLimit);
  245. $("#UpperLimit_Id").dxTextBox('instance').option('value', UpperLimit);
  246. $("#LowerLimit_ONOFF").dxSwitch('instance').option('value', UseLowerLimit);
  247. $("#LowerLimit_Id").dxTextBox('instance').option('value', LowerLimit);
  248. $("#AlarmYN_Id").dxSwitch('instance').option('value', UseAlarm);
  249. $("#SMSYN_Id").dxSwitch('instance').option('value', UseSMS);
  250. $("#EmailYN_Id").dxSwitch('instance').option('value', UseEmail);
  251. $("#text_Id").dxTextArea('instance').option('value', Content);
  252. var group = true;
  253. for (i = 0; i < alarmgroup.length; i++) {
  254. if (AlarmGroupName == alarmgroup[i].Name) {
  255. $("#Users_Id").dxSelectBox('instance').option('value', alarmgroup[i].Name);
  256. group = false;
  257. break;
  258. }
  259. }
  260. if (group) {
  261. $("#Users_Id").dxSelectBox('instance').option('value', null);
  262. }
  263. if (setDataSource1 == "") {
  264. changed = true;
  265. }
  266. else {
  267. for (var i = 0; i <= setDataSource1.length; i++) {
  268. if (FormulaId == 0) {
  269. if (setDataSource1[i].PropertyId == PropertyId) {
  270. $("#Control_Id").dxSelectBox('instance').option('value', setDataSource1[i].PropertyId);
  271. break;
  272. }
  273. }
  274. else {
  275. if (setDataSource1[i].FormulaId == FormulaId) {
  276. $("#Control_Id").dxSelectBox('instance').option('value', setDataSource1[i].FormulaId);
  277. break;
  278. }
  279. }
  280. }
  281. changed = false;
  282. }
  283. }
  284. })
  285. .fail(function (error) {
  286. utils.toast.show(error);
  287. });
  288. } else {
  289. var dataSource = new DevExpress.data.DataSource({
  290. store: {
  291. type: "odata",
  292. url: endpointSelector + "/BemsFormula",
  293. },
  294. requireTotalCount: true,
  295. pageSize: 5000,
  296. expand: ["BemsFormulaBase"]
  297. });
  298. dataSource.filter([
  299. ["SiteId", "=", BWA.UserInfo.SiteId()],
  300. "and",
  301. ["FacilityTypeId", "=", facilityTypeId],
  302. "and",
  303. ["FacilityCode", "=", facilityCode]
  304. ]);
  305. dataSource.sort({ getter: "BemsFormulaBase/Name", asc: true });
  306. dataSource.load()
  307. .done(function (result) {
  308. setDataSource1 = new Array();
  309. for (var i = 0; i < result.length; i++) {
  310. var setData = { "ControlPoint": "", "FuelType": 0, "FacilityTypeId": 0, "FacilityCode": 0, "PropertyId": 0, "FormulaId": 0 };
  311. setData.ControlPoint = result[i].BemsFormulaBase.Name;
  312. setData.FuelType = "-";
  313. setData.FacilityTypeId = result[i].FacilityTypeId;
  314. setData.FacilityCode = result[i].FacilityCode;
  315. setData.FormulaId = result[i].FormulaId;
  316. setDataSource1.push(setData);
  317. }
  318. $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
  319. $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
  320. placeholder: "관제점 이름",
  321. dataSource: setDataSource1,
  322. displayExpr: "ControlPoint",
  323. valueExpr: "FormulaId",
  324. onValueChanged: function () {
  325. var value = $("#Control_Id").dxSelectBox('instance').option('value');
  326. if (value != null) {
  327. for (var i = 0; i < setDataSource1.length; i++) {
  328. if (setDataSource1[i].FormulaId == value) {
  329. propertyId_fin = setDataSource1[i].PropertyId;
  330. controlPoint_fin = setDataSource1[i].ControlPoint;
  331. formulaId_fin = setDataSource1[i].FormulaId;
  332. break;
  333. }
  334. }
  335. }
  336. }
  337. });
  338. if (changed) {
  339. $("#Facility_Id").dxSelectBox('instance').option('value', FacilityCode_id_temp);
  340. $("#UpperLimit_Id").dxTextBox('instance').option('value', UpperLimit);
  341. $("#LowerLimit_Id").dxTextBox('instance').option('value', LowerLimit);
  342. $("#UpperLimit_ONOFF").dxSwitch('instance').option('value', UseUpperLimit);
  343. $("#LowerLimit_ONOFF").dxSwitch('instance').option('value', UseLowerLimit);
  344. $("#AlarmYN_Id").dxSwitch('instance').option('value', UseAlarm);
  345. $("#SMSYN_Id").dxSwitch('instance').option('value', UseSMS);
  346. $("#EmailYN_Id").dxSwitch('instance').option('value', UseEmail);
  347. $("#text_Id").dxTextArea('instance').option('value', Content);
  348. var group = true;
  349. for (i = 0; i < alarmgroup.length; i++) {
  350. if (AlarmGroupName == alarmgroup[i].Name) {
  351. $("#Users_Id").dxSelectBox('instance').option('value', alarmgroup[i].Name);
  352. group = false;
  353. break;
  354. }
  355. }
  356. if (group) {
  357. $("#Users_Id").dxSelectBox('instance').option('value', null);
  358. }
  359. if (setDataSource1 == "") {
  360. changed = true;
  361. }
  362. else {
  363. for (var i = 0; i < setDataSource1.length; i++) {
  364. if (FormulaId == 0) {
  365. if (setDataSource1[i].PropertyId == PropertyId) {
  366. $("#Control_Id").dxSelectBox('instance').option('value', setDataSource1[i].PropertyId);
  367. break;
  368. }
  369. }
  370. else {
  371. if (setDataSource1[i].FormulaId == FormulaId) {
  372. $("#Control_Id").dxSelectBox('instance').option('value', setDataSource1[i].FormulaId);
  373. break;
  374. }
  375. }
  376. }
  377. changed = false;
  378. }
  379. }
  380. })
  381. .fail(function (error) {
  382. utils.toast.show(error);
  383. });
  384. }
  385. }
  386. function AddSelectPoint() {
  387. //초기화
  388. selectData.FacilityTypeId = 0;
  389. selectData.FacilityCode = 0;
  390. selectData.PropertyId = 0;
  391. selectData.FormulaId = 0;
  392. selectData.FacilityName = "";
  393. selectData.ControlPoint = "";
  394. selectData.LowerLimit_ONOFF = false;
  395. selectData.LowerLimit = "";
  396. selectData.UpperLimit_ONOFF = false;
  397. selectData.UpperLimit = 0;
  398. selectData.UseAlarm = false;
  399. selectData.UseSMS = false;
  400. selectData.UseEmail = false;
  401. selectData.AlarmGroupName = "";
  402. selectData.text = "";
  403. //입력
  404. selectData.FacilityTypeId = facilityTypeId_fin;
  405. selectData.FacilityCode = facilityCode_fin;
  406. selectData.PropertyId = propertyId_fin;
  407. selectData.FormulaId = formulaId_fin;
  408. if (selectData.FormulaId == null) {
  409. selectData.FormulaId = 0;
  410. }
  411. selectData.FacilityName = facilityName_fin;
  412. selectData.ControlPoint = controlPoint_fin;
  413. selectData.LowerLimit_ONOFF = LowerLimit_ONOFF_value;
  414. LowerLimit_Id_text = $("#LowerLimit_Id").dxTextBox('instance').option('value');
  415. if (LowerLimit_Id_text == "")
  416. selectData.LowerLimit = 0;
  417. else
  418. selectData.LowerLimit = parseFloat(LowerLimit_Id_text);
  419. selectData.UpperLimit_ONOFF = UpperLimit_ONOFF_value;
  420. UpperLimit_Id_text = $("#UpperLimit_Id").dxTextBox('instance').option('value');
  421. if (UpperLimit_Id_text == "")
  422. selectData.UpperLimit = 0;
  423. else
  424. selectData.UpperLimit = parseFloat(UpperLimit_Id_text);
  425. selectData.UseAlarm = AlarmYN_Id_value;
  426. selectData.UseSMS = SMSYN_Id_Id_value;
  427. selectData.UseEmail = EmailYN_Id_Id_value;
  428. selectData.AlarmGroupName = Users_Id_text;
  429. selectData.text = text_Id_text;
  430. if (selectData.length == 0) {
  431. utils.toast.show("선택된 데이터가 없습니다.", 'error');
  432. return;
  433. }
  434. if (selectData.FacilityTypeId == 0 || selectData.FacilityCode == 0 || selectData.FacilityName == "" || selectData.ControlPoint == "" || selectData.AlarmGroupName == "" || selectData.AlarmGroupName == null) {
  435. utils.toast.show("필수 데이터가 부족합니다.", 'error');
  436. return;
  437. }
  438. if (gridData.length != 0) {
  439. for (var i = 0; i < gridData.length; i++) {
  440. if (gridData[i].FacilityTypeId == selectData.FacilityTypeId && gridData[i].FacilityCode == selectData.FacilityCode
  441. && gridData[i].PropertyId == selectData.PropertyId && gridData[i].FormulaId == selectData.FormulaId) {
  442. utils.toast.show("선택한 목록 중 이미 추가되어 있는 항목이 있습니다.", 'error');
  443. return;
  444. }
  445. }
  446. }
  447. if (selectData.UpperLimit_ONOFF == true) {
  448. if (selectData.UpperLimit == 0) {
  449. utils.toast.show("0은 상한값이 될수 없습니다.", 'error');
  450. //visiblePopup(false);
  451. return;
  452. }
  453. }
  454. if (selectData.LowerLimit_ONOFF == true) {
  455. if (selectData.LowerLimit == 0) {
  456. utils.toast.show("0은 하한값이 될수 없습니다.", 'error');
  457. //visiblePopup(false);
  458. return;
  459. }
  460. }
  461. var dataSource = new DevExpress.data.DataSource({
  462. store: {
  463. type: "odata",
  464. url: endpointSelector + "/CmFacility",
  465. },
  466. requireTotalCount: true,
  467. pageSize: 1,
  468. });
  469. dataSource.filter([
  470. ["SiteId", "=", BWA.UserInfo.SiteId()],
  471. "and",
  472. ["FacilityTypeId", "=", selectData.FacilityTypeId],
  473. "and",
  474. ["FacilityCode", "=", selectData.FacilityCode]
  475. ]);
  476. dataSource.load()
  477. .done(function (result) {
  478. if (selectData.FacilityTypeId == result[0].FacilityTypeId && selectData.FacilityCode == result[0].FacilityCode) {
  479. selectData.FacilityName = result[0].Name;
  480. var store = new DevExpress.data.ODataStore({
  481. url: endpointSelector + "/BemsAlarmSetting",
  482. key: ["SiteId", "FacilityTypeId", "FacilityCode", "PropertyId", "FormulaId"],
  483. keyType: {
  484. SiteId: "Int32",
  485. FacilityTypeId: "Int32",
  486. FacilityCode: "Int32",
  487. PropertyId: "Int32",
  488. FormulaId: "Int32"
  489. }
  490. });
  491. var insertData = {
  492. SiteId: BWA.UserInfo.SiteId(), FacilityTypeId: selectData.FacilityTypeId, FacilityCode: selectData.FacilityCode,
  493. PropertyId: selectData.PropertyId, FormulaId: selectData.FormulaId, FacilityName: selectData.FacilityName,
  494. PointName: selectData.ControlPoint, UseUpperLimit: selectData.UpperLimit_ONOFF, UpperLimit: selectData.UpperLimit,
  495. UseLowerLimit: selectData.LowerLimit_ONOFF, LowerLimit: selectData.LowerLimit,
  496. UseAlarm: selectData.UseAlarm, UseSMS: selectData.UseSMS, UseEmail: selectData.UseEmail, AlarmGroupName: selectData.AlarmGroupName,
  497. Content: selectData.text
  498. };
  499. store.insert(insertData)
  500. .done(function (values, key) {
  501. setTimeout(function () {
  502. utils.toast.show("저장 되었습니다.");
  503. GetGridData();
  504. visiblePopup(false);
  505. }, 1500);
  506. })
  507. .fail(function (error) {
  508. });
  509. }
  510. })
  511. }
  512. function GetGridData() {
  513. gridData = new Array();
  514. var dataSource = new DevExpress.data.DataSource({
  515. store: {
  516. type: "odata",
  517. url: endpointSelector + "/BemsAlarmSetting",
  518. },
  519. requireTotalCount: true,
  520. pageSize: 9999,
  521. });
  522. dataSource.filter([
  523. ["SiteId", "=", BWA.UserInfo.SiteId()]
  524. ]);
  525. dataSource.sort({ getter: "FacilityTypeId", asc: true });
  526. dataSource.load()
  527. .done(function (result) {
  528. for (var i = 0; i < result.length; i++) {
  529. var cnt = 0;
  530. upperLimitCnt = 0;
  531. lowerLimitCnt = 0;
  532. alarmYNCnt = 0;
  533. smsYNCnt = 0;
  534. emailYNCnt = 0;
  535. var setData = {
  536. "PointTypeId": "",
  537. "FacilityTypeId": 0, "FacilityCode": 0, "PropertyId": 0, "FormulaId": 0,
  538. "FacilityName": "", "ControlPoint": "", "UseUpperLimit": "N", "UseLowerLimit": "N",
  539. "UpperLimit": "", "LowerLimit": "", "UseAlarm": "N", "UseSMS": "N",
  540. "UseEmail": "N", "AlarmGroupName": "", "Content": ""
  541. };
  542. setData.FacilityTypeId = result[i].FacilityTypeId;
  543. setData.FacilityCode = result[i].FacilityCode;
  544. setData.PropertyId = result[i].PropertyId;
  545. setData.FormulaId = result[i].FormulaId;
  546. if (setData.FormulaId != 0) {
  547. setData.PointTypeId = "성능분석";
  548. }
  549. else {
  550. if (setData.FacilityTypeId == 99)
  551. setData.PointTypeId = "가상 시설";
  552. else
  553. setData.PointTypeId = "일반 시설";
  554. }
  555. setData.FormulaId = result[i].FormulaId;
  556. setData.FacilityName = result[i].FacilityName;
  557. setData.ControlPoint = result[i].PointName;
  558. setData.UseUpperLimit = result[i].UseUpperLimit;
  559. if (setData.UseUpperLimit == 0)
  560. setData.UseUpperLimit = "N";
  561. else
  562. setData.UseUpperLimit = "Y";
  563. setData.UpperLimit = result[i].UpperLimit;
  564. setData.UseLowerLimit = result[i].UseLowerLimit;
  565. if (setData.UseLowerLimit == 0)
  566. setData.UseLowerLimit = "N";
  567. else
  568. setData.UseLowerLimit = "Y";
  569. setData.LowerLimit = result[i].LowerLimit;
  570. setData.UseAlarm = result[i].UseAlarm;
  571. if (setData.UseAlarm == 0)
  572. setData.UseAlarm = "N";
  573. else
  574. setData.UseAlarm = "Y";
  575. setData.UseSMS = result[i].UseSMS;
  576. if (setData.UseSMS == 0)
  577. setData.UseSMS = "N";
  578. else
  579. setData.UseSMS = "Y";
  580. setData.UseEmail = result[i].UseEmail;
  581. if (setData.UseEmail == 0)
  582. setData.UseEmail = "N";
  583. else
  584. setData.UseEmail = "Y";
  585. for (var j = 0; j < alarmgroup.length; j++) {
  586. if (result[i].AlarmGroupName == alarmgroup[j].Name) {
  587. setData.AlarmGroupName = result[i].AlarmGroupName;
  588. break;
  589. } else {
  590. cnt++;
  591. }
  592. if (cnt == alarmgroup.length) {
  593. setData.AlarmGroupName = "없음";
  594. }
  595. }
  596. setData.Content = result[i].Content;
  597. gridData.push(setData);
  598. }
  599. $("#dataGrid").dxDataGrid("instance").option('dataSource', gridData);
  600. var dg = $("#dataGrid").dxDataGrid("instance");
  601. dg.refresh();
  602. })
  603. .fail(function (error) {
  604. utils.toast.show(error);
  605. });
  606. }
  607. function UpdateGridData() {
  608. var dg = $("#dataGrid").dxDataGrid("instance");
  609. var store = new DevExpress.data.ODataStore({
  610. url: endpointSelector + "/BemsAlarmSetting",
  611. key: ["SiteId", "FacilityTypeId", "FacilityCode", "PropertyId", "FormulaId"],
  612. keyType: {
  613. SiteId: "Int32",
  614. FacilityTypeId: "Int32",
  615. FacilityCode: "Int32",
  616. PropertyId: "Int32",
  617. FormulaId: "Int32"
  618. }
  619. });
  620. selectData.FacilityTypeId = 0;
  621. selectData.FacilityCode = 0;
  622. selectData.PropertyId = 0;
  623. selectData.FormulaId = 0;
  624. selectData.FacilityName = "";
  625. selectData.ControlPoint = "";
  626. selectData.UpperLimit_ONOFF = false;
  627. selectData.UpperLimit = "";
  628. selectData.LowerLimit_ONOFF = false;
  629. selectData.LowerLimit = "";
  630. selectData.UseAlarm = false;
  631. selectData.UseSMS = false;
  632. selectData.UseEmail = false;
  633. selectData.AlarmGroupName = "";
  634. selectData.text = "";
  635. //입력
  636. selectData.FacilityTypeId = facilityTypeId_fin;
  637. selectData.FacilityCode = facilityCode_fin;
  638. selectData.PropertyId = propertyId_fin;
  639. selectData.FormulaId = formulaId_fin;
  640. if (selectData.FormulaId == null) {
  641. selectData.FormulaId = 0;
  642. }
  643. selectData.FacilityName = facilityName_fin;
  644. selectData.ControlPoint = controlPoint_fin;
  645. UpperLimit_ONOFF_value = $("#UpperLimit_ONOFF").dxSwitch('instance').option('value');
  646. selectData.UpperLimit_ONOFF = UpperLimit_ONOFF_value;
  647. UpperLimit_Id_text = $("#UpperLimit_Id").dxTextBox('instance').option('value');
  648. if (UpperLimit_Id_text == "")
  649. selectData.UpperLimit = 0;
  650. else
  651. selectData.UpperLimit = parseFloat(UpperLimit_Id_text);
  652. LowerLimit_ONOFF_value = $("#LowerLimit_ONOFF").dxSwitch('instance').option('value');
  653. selectData.LowerLimit_ONOFF = LowerLimit_ONOFF_value;
  654. LowerLimit_Id_text = $("#LowerLimit_Id").dxTextBox('instance').option('value');
  655. if (LowerLimit_Id_text == "")
  656. selectData.LowerLimit = 0;
  657. else
  658. selectData.LowerLimit = parseFloat(LowerLimit_Id_text);
  659. selectData.UseAlarm = AlarmYN_Id_value;
  660. selectData.UseSMS = SMSYN_Id_Id_value;
  661. selectData.UseEmail = EmailYN_Id_Id_value;
  662. selectData.AlarmGroupName = Users_Id_text;
  663. selectData.text = text_Id_text;
  664. if (selectData.length == 0) {
  665. utils.toast.show("선택된 데이터가 없습니다.", 'error');
  666. return;
  667. }
  668. if (selectData.FacilityTypeId == 0 || selectData.FacilityCode == 0 || selectData.FacilityName == "" || selectData.ControlPoint == "" || selectData.AlarmGroupName == "" || selectData.AlarmGroupName == null) {
  669. utils.toast.show("필수 데이터가 부족합니다.", 'error');
  670. return;
  671. }
  672. if (selectData.UpperLimit_ONOFF == true) {
  673. if (selectData.UpperLimit == 0) {
  674. utils.toast.show("0은 상한값이 될수 없습니다.", 'error');
  675. //visiblePopup(false);
  676. return;
  677. }
  678. }
  679. if (selectData.LowerLimit_ONOFF == true) {
  680. if (selectData.LowerLimit == 0) {
  681. utils.toast.show("0은 하한값이 될수 없습니다.", 'error');
  682. //visiblePopup(false);
  683. return;
  684. }
  685. }
  686. store.update({
  687. SiteId: BWA.UserInfo.SiteId(),
  688. FacilityTypeId: selectData.FacilityTypeId,
  689. FacilityCode: selectData.FacilityCode,
  690. PropertyId: selectData.PropertyId,
  691. FormulaId: selectData.FormulaId
  692. }, {
  693. FacilityName: selectData.FacilityName,
  694. PointName: selectData.ControlPoint,
  695. UseUpperLimit: selectData.UpperLimit_ONOFF,
  696. UpperLimit: selectData.UpperLimit,
  697. UseLowerLimit: selectData.LowerLimit_ONOFF,
  698. LowerLimit: selectData.LowerLimit,
  699. UseAlarm: selectData.UseAlarm,
  700. UseSMS: selectData.UseSMS,
  701. UseEmail: selectData.UseEmail,
  702. AlarmGroupName: selectData.AlarmGroupName,
  703. Content: selectData.text
  704. })
  705. .done(function (values, key) {
  706. utils.toast.show("수정 되었습니다.");
  707. setTimeout(function () {
  708. visiblePopup(false);
  709. }, 1000);
  710. })
  711. .fail(function (error) {
  712. utils.toast.show(error);
  713. });
  714. }
  715. function DeleteGridData() {
  716. var store = new DevExpress.data.ODataStore({
  717. url: endpointSelector + "/BemsAlarmSetting",
  718. key: ["SiteId", "FacilityTypeId", "FacilityCode", "PropertyId", "FormulaId"],
  719. keyType: {
  720. SiteId: "Int32",
  721. FacilityTypeId: "Int32",
  722. FacilityCode: "Int32",
  723. PropertyId: "Int32",
  724. FormulaId: "Int32"
  725. }
  726. });
  727. //초기화
  728. selectData.FacilityTypeId = 0;
  729. selectData.FacilityCode = 0;
  730. selectData.PropertyId = 0;
  731. selectData.FormulaId = 0;
  732. //입력
  733. selectData.FacilityTypeId = facilityTypeId_fin;
  734. selectData.FacilityCode = facilityCode_fin;
  735. selectData.PropertyId = propertyId_fin;
  736. selectData.FormulaId = formulaId_fin;
  737. if (selectData.FormulaId == null) {
  738. selectData.FormulaId = 0;
  739. }
  740. var removeData = {
  741. SiteId: BWA.UserInfo.SiteId(), FacilityTypeId: selectData.FacilityTypeId, FacilityCode: selectData.FacilityCode,
  742. PropertyId: selectData.PropertyId, FormulaId: selectData.FormulaId
  743. };
  744. store.remove(removeData)
  745. .done(function (values, key) {
  746. utils.toast.show("삭제 되었습니다.");
  747. setTimeout(function () {
  748. visiblePopup(false);
  749. }, 1000);
  750. })
  751. .fail(function (error) {
  752. utils.toast.show(error);
  753. });
  754. }
  755. function handleViewShowing() {
  756. //권한설정
  757. hasnotModificationPermission(!BWA.UserInfo.hasPermissionOfModification(viewInfo.viewName));
  758. $("#large-indicator").dxLoadIndicator({
  759. height: 60,
  760. width: 60
  761. });
  762. var AlarmGroup = new DevExpress.data.DataSource({
  763. store: {
  764. type: "odata",
  765. url: endpointSelector + "/BemsAlarmGroup",
  766. },
  767. requireTotalCount: true,
  768. pageSize: 5000
  769. });
  770. AlarmGroup.filter([
  771. ["SiteId", "=", BWA.UserInfo.SiteId()]
  772. ]);
  773. AlarmGroup.sort({ getter: "AlarmGroupId", asc: true });
  774. AlarmGroup.load()
  775. .done(function (result2) {
  776. alarmgroup = new Array();
  777. for (var i = 0; i < result2.length; i++) {
  778. var setData = { "AlarmGroupId": 0, "Name": "" };
  779. setData.AlarmGroupId = result2[i].AlarmGroupId;
  780. setData.Name = result2[i].Name;
  781. alarmgroup.push(setData);
  782. }
  783. })
  784. .fail(function (error) {
  785. utils.toast.show(error);
  786. });
  787. GetPopupTreeViewData();
  788. }
  789. function handleViewShown() {
  790. $("#updateSaveBtn").dxButton({
  791. visible: false
  792. });
  793. $("#delBtn").dxButton({
  794. visible: false
  795. });
  796. $("#selectSaveBtn").dxButton({
  797. visible: false
  798. });
  799. $("#dataGrid").dxDataGrid({
  800. paging: {
  801. pageSize: 17,
  802. enabled: true
  803. }
  804. });
  805. GetGridData();
  806. }
  807. var searchViewOptions = {
  808. }
  809. function PopupChange(data) {
  810. }
  811. function handleSearchInSearchView() {
  812. }
  813. var viewModel = $.extend(BWA.CommonView.create(params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null, handleSearchInSearchView),
  814. {
  815. viewShowing: handleViewShowing,
  816. dataGrid: utils.datagrid.defaultOptions({
  817. selection: {
  818. mode: 'single'
  819. },
  820. height: 660,
  821. columns: [
  822. {
  823. dataField: 'PointTypeId',
  824. width: 120,
  825. caption: "타입",
  826. alignment: 'center'
  827. },
  828. {
  829. dataField: 'FacilityName',
  830. width: 200,
  831. caption: "설비 이름",
  832. alignment: 'center'
  833. }
  834. , {
  835. dataField: 'ControlPoint',
  836. width: 200,
  837. caption: "관제점(분석요소)",
  838. alignment: 'center',
  839. }
  840. , {
  841. dataField: 'UseUpperLimit',
  842. width: 120,
  843. caption: "기준 상한값 설정",
  844. alignment: 'center'
  845. }
  846. , {
  847. dataField: 'UpperLimit',
  848. width: 120,
  849. caption: "기준 상한값",
  850. alignment: 'center'
  851. }
  852. , {
  853. dataField: 'UseLowerLimit',
  854. width: 120,
  855. caption: "기준 하한값 설정",
  856. alignment: 'center'
  857. }
  858. , {
  859. dataField: 'LowerLimit',
  860. width: 120,
  861. caption: "기준 하한값",
  862. alignment: 'center'
  863. }
  864. , {
  865. dataField: 'UseAlarm',
  866. width: 90,
  867. caption: "경보 여부",
  868. alignment: 'center'
  869. }
  870. , {
  871. dataField: 'UseSMS',
  872. width: 90,
  873. caption: "SMS 여부",
  874. alignment: 'center'
  875. }
  876. , {
  877. dataField: 'UseEmail',
  878. width: 90,
  879. caption: "Email 여부",
  880. alignment: 'center'
  881. }
  882. , {
  883. dataField: 'AlarmGroupName',
  884. width: 90,
  885. caption: "발송 그룹",
  886. alignment: 'center'
  887. },
  888. {
  889. dataField: 'FacilityTypeId',
  890. visible: false
  891. }, {
  892. dataField: 'FacilityCode',
  893. visible: false
  894. }, {
  895. dataField: 'PropertyId',
  896. visible: false
  897. }, {
  898. dataField: 'FormulaId',
  899. visible: false
  900. }
  901. ],
  902. // 2019.04.17 엑셀 출력 기능 추가 ~~~
  903. "export": {
  904. enabled: true,
  905. fileName: '알람 설정 내역'
  906. },
  907. // ~~~ 2019.04.17 엑셀 출력 기능 추가
  908. rowClick: function (row) {
  909. loadvisiblePopup(true);
  910. row_btn = true;
  911. var data = row.data;
  912. Point_Type_Id = data.PointTypeId;
  913. facilityTypeId = data.FacilityTypeId;
  914. FacilityCode = data.FacilityCode;
  915. PropertyId = data.PropertyId;
  916. FormulaId = data.FormulaId;
  917. FacilityName = data.FacilityName;
  918. ControlPoint = data.ControlPoint;
  919. if (data.UseUpperLimit == "N") {
  920. UseUpperLimit = false;
  921. $("#UpperLimit_Id").dxTextBox({
  922. disabled: true
  923. });
  924. }
  925. else {
  926. UseUpperLimit = true;
  927. $("#UpperLimit_Id").dxTextBox({
  928. disabled: false
  929. });
  930. }
  931. UpperLimit = data.UpperLimit;
  932. if (data.UseLowerLimit == "N") {
  933. UseLowerLimit = false;
  934. $("#LowerLimit_Id").dxTextBox({
  935. disabled: true
  936. });
  937. }
  938. else {
  939. UseLowerLimit = true;
  940. $("#LowerLimit_Id").dxTextBox({
  941. disabled: false
  942. });
  943. }
  944. LowerLimit = data.LowerLimit;
  945. if (data.UseAlarm == "N")
  946. UseAlarm = false;
  947. else
  948. UseAlarm = true;
  949. if (data.UseSMS == "N")
  950. UseSMS = false;
  951. else
  952. UseSMS = true;
  953. if (data.UseEmail == "N")
  954. UseEmail = false;
  955. else
  956. UseEmail = true;
  957. AlarmGroupName = data.AlarmGroupName;
  958. Content = data.Content;
  959. changed = true;
  960. setTimeout(function () {
  961. visiblePopup(true);
  962. loadvisiblePopup(false);
  963. }, 500);
  964. },
  965. }),
  966. selectDataGrid: {
  967. selection: {
  968. mode: 'multiple',
  969. allowSelectAll: true,
  970. },
  971. columns: [
  972. {
  973. dataField: 'ControlPoint',
  974. width: 340,
  975. caption: "관제점 이름",
  976. alignment: 'center',
  977. }
  978. , {
  979. dataField: 'FuelType',
  980. width: 140,
  981. caption: "에너지원",
  982. alignment: 'center'
  983. }
  984. , {
  985. dataField: 'FacilityTypeId',
  986. visible: false
  987. }, {
  988. dataField: 'FacilityCode',
  989. visible: false
  990. }, {
  991. dataField: 'PropertyId',
  992. visible: false
  993. }, {
  994. dataField: 'FormulaId',
  995. visible: false
  996. }
  997. ]
  998. //, paging: { pageSize: 20, enabled: true }
  999. },
  1000. updateButtonClicked: function () {
  1001. UpdateGridData();
  1002. setTimeout(function () {
  1003. GetGridData();
  1004. }, 1000);
  1005. },
  1006. delButtonClicked: function () {
  1007. DeleteGridData();
  1008. setTimeout(function () {
  1009. GetGridData();
  1010. }, 1000);
  1011. },
  1012. selectButtonClicked: function () {
  1013. enroll_btn = true;
  1014. facilityTypeId_fin = 0, facilityCode_fin = 0, parentId_fin = 0, propertyId_fin = 0, facilityName_fin = "", formulaId_fin = 0, controlPoint_fin = "";
  1015. UpperLimit_ONOFF_value = false, LowerLimit_ONOFF_value = false, AlarmYN_Id_value = false, EmailYN_Id_Id_value = false, SMSYN_Id_Id_value = false, Users_Id_text = "", text_Id_text = "";
  1016. LowerLimit_Id_text = "", UpperLimit_Id_text = "";
  1017. $("#Point_Type_Id").dxSelectBox({
  1018. placeholder: "관제점 타입",
  1019. dataSource: treeViewData,
  1020. displayExpr: "text",
  1021. valueExpr: "id"
  1022. });
  1023. $("#Facility_Type_Id").dxSelectBox({
  1024. placeholder: "설비 타입"
  1025. });
  1026. $("#Facility_Id").dxSelectBox({
  1027. placeholder: "설비 이름"
  1028. });
  1029. $("#Control_Id").dxSelectBox({
  1030. placeholder: "관제점 이름"
  1031. });
  1032. $("#UpperLimit_Id").dxTextBox({
  1033. placeholder: "기준 상한값"
  1034. });
  1035. $("#LowerLimit_Id").dxTextBox({
  1036. placeholder: "기준 하한값"
  1037. });
  1038. $("#UpperLimit_ONOFF").dxSwitch({
  1039. onText: 'On',
  1040. offText: 'Off',
  1041. value: false
  1042. });
  1043. $("#LowerLimit_ONOFF").dxSwitch({
  1044. onText: 'On',
  1045. offText: 'Off',
  1046. value: false
  1047. });
  1048. $("#AlarmYN_Id").dxSwitch({
  1049. onText: 'On',
  1050. offText: 'Off',
  1051. value: false
  1052. });
  1053. $("#SMSYN_Id").dxSwitch({
  1054. onText: 'On',
  1055. offText: 'Off',
  1056. value: false
  1057. });
  1058. $("#EmailYN_Id").dxSwitch({
  1059. onText: 'On',
  1060. offText: 'Off',
  1061. value: false
  1062. });
  1063. $("#Users_Id").dxSelectBox({
  1064. placeholder: "발송 그룹",
  1065. dataSource: alarmgroup,
  1066. displayExpr: "Name",
  1067. valueExpr: "Name"
  1068. });
  1069. $("#text_Id").dxTextArea({
  1070. placeholder: "조치 방법"
  1071. });
  1072. if ($("#Point_Type_Id").dxSelectBox('instance') != null)
  1073. $("#Point_Type_Id").dxSelectBox('instance').option('value', null);// 관제점 타입 클리어
  1074. if ($("#Facility_Type_Id").dxSelectBox('instance') != null)
  1075. $("#Facility_Type_Id").dxSelectBox('instance').option('value', null);// 설비 타입 클리어
  1076. if ($("#Facility_Id").dxSelectBox('instance') != null)
  1077. $("#Facility_Id").dxSelectBox('instance').option('value', null);// 설비 이름 클리어
  1078. if ($("#Control_Id").dxSelectBox('instance') != null)
  1079. $("#Control_Id").dxSelectBox('instance').option('value', null);// 관제점 이름 클리어
  1080. if ($("#UpperLimit_Id").dxTextBox('instance') != null)
  1081. $("#UpperLimit_Id").dxTextBox('instance').option('value', "");// 기준 상한값 클리어
  1082. if ($("#LowerLimit_Id").dxTextBox('instance') != null)
  1083. $("#LowerLimit_Id").dxTextBox('instance').option('value', "");// 기준 하한값 클리어
  1084. if ($("#Users_Id").dxSelectBox('instance') != null)
  1085. $("#Users_Id").dxSelectBox('instance').option('value', null);// 발송그룹 클리어
  1086. if ($("#text_Id").dxTextArea('instance') != null)
  1087. $("#text_Id").dxTextArea('instance').option('value', "");// 조치방법 클리어
  1088. visiblePopup(true);
  1089. },
  1090. selectSaveButtonClicked: function () {
  1091. AddSelectPoint();
  1092. }
  1093. });
  1094. viewModel.loadpopupOptions = {
  1095. width: 300,
  1096. height: 140,
  1097. contentTemplate: "info",
  1098. showTitle: false,
  1099. title: "작업중",
  1100. visible: loadvisiblePopup,
  1101. dragEnabled: false,
  1102. shading: false,
  1103. closeOnOutsideClick: false
  1104. };
  1105. viewModel.popupOptions = {
  1106. width: 680,
  1107. height: 630,
  1108. visible: visiblePopup,
  1109. dragEnabled: true,
  1110. shading: true,
  1111. closeOnOutsideClick: true,
  1112. shadingColor: 'transparent',
  1113. showTitle: true,
  1114. title: "항목 선택",
  1115. showCloseButton: true,
  1116. onShowing: function () {
  1117. },
  1118. onShown: function (t, tt) {
  1119. popupInit = true;
  1120. facility_type = "";
  1121. facility_id = "";
  1122. $("#Point_Type_Id").dxSelectBox({
  1123. placeholder: "관제점 타입",
  1124. dataSource: treeViewData,
  1125. displayExpr: "text",
  1126. valueExpr: "id"
  1127. });
  1128. $("#Facility_Type_Id").dxSelectBox({
  1129. placeholder: "설비 타입"
  1130. });
  1131. $("#Facility_Id").dxSelectBox({
  1132. placeholder: "설비 이름"
  1133. });
  1134. $("#Control_Id").dxSelectBox({
  1135. placeholder: "관제점 이름"
  1136. });
  1137. $("#UpperLimit_Id").dxTextBox({
  1138. placeholder: "기준 상한값",
  1139. onValueChanged: function (e) {
  1140. var temp = e.value;
  1141. if (temp.length == null) {
  1142. }
  1143. else {
  1144. var total = 0;
  1145. for (var i = 0; i < temp.length; i++) {
  1146. for (var j = 0; j < allowedChars.length; j++) {
  1147. if (temp[i] == allowedChars[j]) {
  1148. total++;
  1149. }
  1150. }
  1151. }
  1152. if (total != temp.length) {
  1153. utils.toast.show("숫자와 소수점만 입력가능합니다.", 'error');
  1154. $("#UpperLimit_Id").dxTextBox('instance').option('value', "");
  1155. return;
  1156. }
  1157. }
  1158. if ($("#UpperLimit_ONOFF").dxSwitch('instance').option('value') == true) {
  1159. if ($("#LowerLimit_ONOFF").dxSwitch('instance').option('value') == true) {
  1160. if ($("#LowerLimit_Id").dxTextBox('instance').option('value') <= e.value) {
  1161. UpperLimit_Id_text = e.value;
  1162. $("#UpperLimit_Id").dxTextBox('instance').option('value', UpperLimit_Id_text);
  1163. }
  1164. else {
  1165. utils.toast.show("기준 상한값은 기준 하한값보다 작을수 없습니다.", 'error');
  1166. $("#UpperLimit_Id").dxTextBox('instance').option('value', "");
  1167. return;
  1168. }
  1169. }
  1170. else {
  1171. UpperLimit_Id_text = e.value;
  1172. $("#UpperLimit_Id").dxTextBox('instance').option('value', UpperLimit_Id_text);
  1173. }
  1174. }
  1175. }
  1176. });
  1177. $("#LowerLimit_Id").dxTextBox({
  1178. placeholder: "기준 하한값",
  1179. onValueChanged: function (e) {
  1180. var temp = e.value;
  1181. if (temp.length == null) {
  1182. }
  1183. else {
  1184. var total = 0;
  1185. for (var i = 0; i < temp.length; i++) {
  1186. for (var j = 0; j < allowedChars.length; j++) {
  1187. if (temp[i] == allowedChars[j]) {
  1188. total++;
  1189. }
  1190. }
  1191. }
  1192. if (total != temp.length) {
  1193. utils.toast.show("숫자와 소수점만 입력가능합니다.", 'error');
  1194. $("#LowerLimit_Id").dxTextBox('instance').option('value', "");
  1195. return;
  1196. }
  1197. }
  1198. if ($("#UpperLimit_ONOFF").dxSwitch('instance').option('value') == true) {
  1199. if ($("#LowerLimit_ONOFF").dxSwitch('instance').option('value') == true) {
  1200. if ($("#UpperLimit_Id").dxTextBox('instance').option('value') >= e.value) {
  1201. LowerLimit_Id_text = e.value;
  1202. $("#LowerLimit_Id").dxTextBox('instance').option('value', LowerLimit_Id_text);
  1203. }
  1204. else {
  1205. utils.toast.show("기준 하한값은 기준 상한값보다 클수 없습니다.", 'error');
  1206. $("#LowerLimit_Id").dxTextBox('instance').option('value', "");
  1207. return;
  1208. }
  1209. }
  1210. else {
  1211. LowerLimit_Id_text = e.value;
  1212. $("#LowerLimit_Id").dxTextBox('instance').option('value', LowerLimit_Id_text);
  1213. }
  1214. }
  1215. }
  1216. });
  1217. $("#UpperLimit_ONOFF").dxSwitch({
  1218. onText: 'On',
  1219. offText: 'Off',
  1220. value: false,
  1221. onValueChanged: function (e) {
  1222. if (e.value == true) {
  1223. $("#UpperLimit_Id").dxTextBox({
  1224. disabled: false
  1225. });
  1226. if ($("#UpperLimit_ONOFF").dxSwitch('instance').option('value') == true && $("#LowerLimit_ONOFF").dxSwitch('instance').option('value') == true) {
  1227. if ($("#UpperLimit_Id").dxTextBox('instance').option('value') >= $("#LowerLimit_Id").dxTextBox('instance').option('value')) {
  1228. }
  1229. else {
  1230. utils.toast.show("기준 상한값은 기준 하한값보다 작을수 없습니다.", 'error');
  1231. $("#UpperLimit_Id").dxTextBox('instance').option('value', "");
  1232. return;
  1233. }
  1234. }
  1235. }
  1236. else {
  1237. $("#UpperLimit_Id").dxTextBox({
  1238. disabled: true
  1239. });
  1240. }
  1241. UpperLimit_ONOFF_value = e.value;
  1242. }
  1243. });
  1244. $("#LowerLimit_ONOFF").dxSwitch({
  1245. onText: 'On',
  1246. offText: 'Off',
  1247. value: false,
  1248. onValueChanged: function (e) {
  1249. LowerLimit_ONOFF_value = e.value;
  1250. if (e.value == true) {
  1251. $("#LowerLimit_Id").dxTextBox({
  1252. disabled: false
  1253. });
  1254. if ($("#UpperLimit_ONOFF").dxSwitch('instance').option('value') == true && $("#LowerLimit_ONOFF").dxSwitch('instance').option('value') == true) {
  1255. if ($("#UpperLimit_Id").dxTextBox('instance').option('value') >= $("#LowerLimit_Id").dxTextBox('instance').option('value')) {
  1256. }
  1257. else {
  1258. utils.toast.show("기준 하한값은 기준 상한값보다 클수 없습니다.", 'error');
  1259. $("#LowerLimit_Id").dxTextBox('instance').option('value', "");
  1260. return;
  1261. }
  1262. }
  1263. }
  1264. else {
  1265. $("#LowerLimit_Id").dxTextBox({
  1266. disabled: true
  1267. });
  1268. }
  1269. }
  1270. });
  1271. $("#AlarmYN_Id").dxSwitch({
  1272. onText: 'On',
  1273. offText: 'Off',
  1274. value: false,
  1275. onValueChanged: function (e) {
  1276. AlarmYN_Id_value = e.value;
  1277. }
  1278. });
  1279. $("#SMSYN_Id").dxSwitch({
  1280. onText: 'On',
  1281. offText: 'Off',
  1282. value: false,
  1283. onValueChanged: function (e) {
  1284. SMSYN_Id_Id_value = e.value;
  1285. }
  1286. });
  1287. $("#EmailYN_Id").dxSwitch({
  1288. onText: 'On',
  1289. offText: 'Off',
  1290. value: false,
  1291. onValueChanged: function (e) {
  1292. EmailYN_Id_Id_value = e.value;
  1293. }
  1294. });
  1295. $("#Users_Id").dxSelectBox({
  1296. placeholder: "발송 그룹",
  1297. dataSource: alarmgroup,
  1298. displayExpr: "Name",
  1299. valueExpr: "Name",
  1300. onValueChanged: function (e) {
  1301. var value = $("#Users_Id").dxSelectBox('instance').option('value');
  1302. Users_Id_text = value;
  1303. }
  1304. });
  1305. $("#text_Id").dxTextArea({
  1306. placeholder: "조치 방법",
  1307. onValueChanged: function (e) {
  1308. text_Id_text = e.value;
  1309. }
  1310. });
  1311. $("#Point_Type_Id").dxSelectBox({
  1312. onValueChanged: function () {
  1313. facility_type = "";
  1314. facility_id = "";
  1315. setDataSource1 = "";
  1316. var value = $("#Point_Type_Id").dxSelectBox('instance').option('value');
  1317. if (value == null)
  1318. facility_type = "";
  1319. else
  1320. facility_type = treeViewData[value - 1].items;
  1321. $("#Facility_Type_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
  1322. $("#Facility_Type_Id").dxSelectBox({// 두번째 콤보 바인딩
  1323. placeholder: "설비 타입",
  1324. dataSource: facility_type,
  1325. displayExpr: "text",
  1326. valueExpr: "id"
  1327. });
  1328. $("#Facility_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
  1329. $("#Facility_Id").dxSelectBox({// 두번째 콤보 바인딩
  1330. placeholder: "설비 이름",
  1331. dataSource: facility_id,
  1332. displayExpr: "text",
  1333. valueExpr: "id"
  1334. });
  1335. $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
  1336. $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
  1337. placeholder: "관제점 이름",
  1338. dataSource: setDataSource1,
  1339. displayExpr: "ControlPoint",
  1340. valueExpr: "FormulaId"
  1341. });
  1342. }
  1343. });
  1344. $("#Facility_Type_Id").dxSelectBox({
  1345. onValueChanged: function () {
  1346. if (facility_type == "") {
  1347. var value1 = $("#Point_Type_Id").dxSelectBox('instance').option('value');
  1348. if (value1 == null)
  1349. facility_type = "";
  1350. else
  1351. facility_type = treeViewData[value1 - 1].items;
  1352. }
  1353. facility_id = "";
  1354. setDataSource1 = "";
  1355. var Pointtype = $("#Point_Type_Id").dxSelectBox('instance').option('value');
  1356. var value = $("#Facility_Type_Id").dxSelectBox('instance').option('value');
  1357. if (Pointtype == 1)//성능분석
  1358. {
  1359. if (value != null) {
  1360. facility_id = facility_type[value - 4].items;
  1361. }
  1362. }
  1363. else if (Pointtype == 2) { //가상
  1364. if (value != null) {
  1365. facility_id = facility_type[0].items;
  1366. }
  1367. }
  1368. else { //일반
  1369. if (value != null) {
  1370. facility_id = facility_type[value - excnt].items;
  1371. }
  1372. }
  1373. $("#Facility_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
  1374. $("#Facility_Id").dxSelectBox({// 두번째 콤보 바인딩
  1375. placeholder: "설비 이름",
  1376. dataSource: facility_id,
  1377. displayExpr: "text",
  1378. valueExpr: "id"
  1379. });
  1380. $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
  1381. $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
  1382. placeholder: "관제점 이름",
  1383. dataSource: setDataSource1,
  1384. displayExpr: "ControlPoint",
  1385. valueExpr: "FormulaId"
  1386. });
  1387. }
  1388. });
  1389. $("#Facility_Id").dxSelectBox({
  1390. onValueChanged: function () {
  1391. if (facility_id == "") {
  1392. if (facility_type == "") {
  1393. var value1 = $("#Point_Type_Id").dxSelectBox('instance').option('value');
  1394. if (value1 == null)
  1395. facility_type = "";
  1396. else
  1397. facility_type = treeViewData[value1 - 1].items;
  1398. }
  1399. var Pointtype = $("#Point_Type_Id").dxSelectBox('instance').option('value');
  1400. var value = $("#Facility_Type_Id").dxSelectBox('instance').option('value');
  1401. if (Pointtype == 1)//성능분석
  1402. {
  1403. if (value != null) {
  1404. facility_id = facility_type[value - 4].items;
  1405. }
  1406. }
  1407. else if (Pointtype == 2) { //가상
  1408. if (value != null) {
  1409. facility_id = facility_type[0].items;
  1410. }
  1411. }
  1412. else { //일반
  1413. if (value != null) {
  1414. facility_id = facility_type[value - excnt].items;
  1415. }
  1416. }
  1417. }
  1418. setDataSource1 = "";
  1419. var value = $("#Facility_Id").dxSelectBox('instance').option('value');
  1420. facilityTypeId_fin = 0, facilityCode_fin = 0, parentId_fin = 0;
  1421. if (value != null) {
  1422. for (var i = 0; i < facility_id.length; i++) {
  1423. if (facility_id[i].id == value) {
  1424. facilityTypeId_fin = facility_id[i].facilityTypeId;
  1425. facilityCode_fin = facility_id[i].facilityCode;
  1426. parentId_fin = facility_id[i].parentId;
  1427. facilityName_fin = facility_id[i].text;
  1428. break;
  1429. }
  1430. }
  1431. GetPopupGridData(facilityTypeId_fin, facilityCode_fin, parentId_fin);
  1432. }
  1433. $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
  1434. $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
  1435. placeholder: "관제점 이름",
  1436. dataSource: setDataSource1,
  1437. displayExpr: "ControlPoint",
  1438. valueExpr: "FormulaId",
  1439. });
  1440. }
  1441. });
  1442. $("#Control_Id").dxSelectBox({
  1443. onValueChanged: function () {
  1444. var value = $("#Control_Id").dxSelectBox('instance').option('text');
  1445. if (value != null) {
  1446. for (var i = 0; i < setDataSource1.length; i++) {
  1447. if (setDataSource1[i].ControlPoint == value) {
  1448. propertyId_fin = setDataSource1[i].PropertyId;
  1449. controlPoint_fin = setDataSource1[i].ControlPoint;
  1450. formulaId_fin = setDataSource1[i].FormulaId;
  1451. break;
  1452. }
  1453. }
  1454. }
  1455. }
  1456. });
  1457. var j = 0;
  1458. if (changed) {
  1459. var Point_Type_Id_temp = 0;
  1460. for (var i = 0; i < treeViewData.length; i++) {
  1461. if (treeViewData[i].text == Point_Type_Id) {
  1462. Point_Type_Id_temp = treeViewData[i].id;
  1463. break;
  1464. }
  1465. }
  1466. $("#Point_Type_Id").dxSelectBox('instance').option('value', Point_Type_Id_temp);
  1467. var facility_type_Id_temp = 0;
  1468. for (j = 0; j < treeViewData[Point_Type_Id_temp - 1].items.length; j++) {
  1469. if (treeViewData[Point_Type_Id_temp - 1].items[j].facilityTypeId == facilityTypeId) {
  1470. facility_type_Id_temp = treeViewData[Point_Type_Id_temp - 1].items[j].id;
  1471. break;
  1472. }
  1473. }
  1474. $("#Facility_Type_Id").dxSelectBox('instance').option('value', facility_type_Id_temp);
  1475. var FacilityCode_temp = 0;
  1476. var facilityTypeId_temp = 0;
  1477. var parentId_temp = 0;
  1478. FacilityCode_id_temp = 0;
  1479. if (Point_Type_Id_temp == 1) {
  1480. var delete_value = 4;
  1481. }
  1482. else if (Point_Type_Id_temp == 2) {
  1483. delete_value = facility_type_Id_temp;
  1484. }
  1485. else {
  1486. delete_value = excnt;
  1487. }
  1488. for (var k = 0; k < treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items.length; k++) {
  1489. if (treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].facilityCode == FacilityCode) {
  1490. FacilityCode_id_temp = treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].id;
  1491. FacilityCode_temp = treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].facilityCode;
  1492. facilityTypeId_temp = treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].facilityTypeId;
  1493. parentId_temp = treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].parentId;
  1494. break;
  1495. }
  1496. }
  1497. GetPopupGridData(facilityTypeId_temp, FacilityCode_temp, parentId_temp);
  1498. }
  1499. if (row_btn) {
  1500. $("#updateSaveBtn").dxButton({
  1501. visible: true
  1502. });
  1503. $("#delBtn").dxButton({
  1504. visible: false
  1505. });
  1506. $("#selectSaveBtn").dxButton({
  1507. visible: false
  1508. });
  1509. $("#Point_Type_Id").dxSelectBox({
  1510. disabled: true
  1511. });
  1512. $("#Facility_Type_Id").dxSelectBox({
  1513. disabled: true
  1514. });
  1515. $("#Facility_Id").dxSelectBox({
  1516. disabled: true
  1517. });
  1518. $("#Control_Id").dxSelectBox({
  1519. disabled: true
  1520. });
  1521. row_btn = false;
  1522. }
  1523. if (enroll_btn) {
  1524. $("#Point_Type_Id").dxSelectBox({
  1525. disabled: false
  1526. });
  1527. $("#Facility_Type_Id").dxSelectBox({
  1528. disabled: false
  1529. });
  1530. $("#Facility_Id").dxSelectBox({
  1531. disabled: false
  1532. });
  1533. $("#Control_Id").dxSelectBox({
  1534. disabled: false
  1535. });
  1536. $("#updateSaveBtn").dxButton({
  1537. visible: false
  1538. });
  1539. $("#delBtn").dxButton({
  1540. visible: false
  1541. });
  1542. $("#selectSaveBtn").dxButton({
  1543. visible: true
  1544. });
  1545. enroll_btn = false;
  1546. }
  1547. },
  1548. onHidden: function () {
  1549. },
  1550. hasnotModificationPermission: hasnotModificationPermission //권한설정
  1551. };
  1552. return viewModel;
  1553. };