12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622 |
- BemsWebApplication.AlarmSetting = function (params, viewInfo) {
- 'use strict';
- var now = new Date();
- var row_btn = false;
- var enroll_btn = false;
- var visiblePopup = ko.observable(false);
- var loadvisiblePopup = ko.observable(false);
- var popupInit = false;
- var ControlPoint_temp = 0;
- var virtualFacility = 99;
- var gridData = new Array();
- var upperLimitCnt = 0;
- var lowerLimitCnt = 0;
- var alarmYNCnt = 0;
- var smsYNCnt = 0;
- var emailYNCnt = 0;
- var ControlPoint = 0;
- var FacilityCode = 0;
- var FacilityName = "";
- var facilityTypeId = 0;
- var FormulaId = 0;
- var LowerLimit = "";
- var UpperLimit = "";
- var PropertyId = 0;
- var UseSMS = false;
- var UseEmail = false;
- var UseAlarm = false;
- var UseLowerLimit = false;
- var UseUpperLimit = false;
- var Point_Type_Id = "";
- var Content = "";
- var AlarmGroupName = "";
- var changed = false;
- var endpointSelector = "";
- if (BemsWebApplication.config.mode == "production") {
- endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
- } else {
- endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
- }
- var FacilityCode_id_temp = 0;
- var facility_type = ko.observableArray();
- var facility_id = ko.observableArray();
- var setDataSource1, alarmgroup;
- var allowedChars = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.'];
- var treeViewData = [
- {
- id: 1,
- text: "성능분석",
- items: [],
- visualFlag: false
- },
- {
- id: 2,
- text: "가상 시설",
- items: [],
- visualFlag: false
- },
- {
- id: 3,
- text: "일반 시설",
- items: [],
- visualFlag: false
- }
- ];
- var excnt = 0;
- var facilityTypeId_fin = 0, facilityCode_fin = 0, parentId_fin = 0, propertyId_fin = 0, facilityName_fin = "", formulaId_fin = 0, controlPoint_fin = "";
- 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 = "";
- var LowerLimit_Id_text = "", UpperLimit_Id_text = "";
- var selectData = {
- FacilityTypeId: 0,
- FacilityCode: 0,
- PropertyId: 0,
- FormulaId: 0,
- FacilityName: "",
- PointTypeId: "",
- ControlPoint: "",
- UpperLimit_ONOFF: false,
- UpperLimit: 0,
- LowerLimit_ONOFF: false,
- LowerLimit: 0,
- UseAlarm: false,
- UseSMS: false,
- UseEmail: false,
- AlarmGroupId: 0,
- text: ""
- }
- //권한설정
- var hasnotModificationPermission = ko.observable(true);
- function GetPopupTreeViewData() {
- treeViewData = [
- {
- id: 1,
- text: "성능분석",
- items: [],
- visualFlag: false
- },
- {
- id: 2,
- text: "가상 시설",
- items: [],
- visualFlag: false
- },
- {
- id: 3,
- text: "일반 시설",
- items: [],
- visualFlag: false
- }
- ];
- excnt = 4;
- var facilityIdIndex = 4;
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsFacilityType",
- },
- requireTotalCount: true,
- pageSize: 100
- });
- dataSource.sort({ getter: "FacilityTypeId", asc: true });
- dataSource.load()
- .done(function (result) {
- for (var i = 0; i < result.length; i++) {
- if (result[i].FacilityTypeId < 100) { //성능분석
- if (result[i].FacilityTypeId != virtualFacility) {
- treeViewData[0].items.push({ id: facilityIdIndex, facilityTypeId: result[i].FacilityTypeId, text: result[i].Name, items: [], visualFlag: false });
- facilityIdIndex++;
- excnt++;
- }
- }
- }
- for (var i = 0; i < result.length; i++) {
- if (result[i].FacilityTypeId < 100) { //가상
- if (result[i].FacilityTypeId != virtualFacility) {
- treeViewData[2].items.push({ id: facilityIdIndex, facilityTypeId: result[i].FacilityTypeId, text: result[i].Name, items: [], visualFlag: false });
- facilityIdIndex++;
- } else { //일반
- treeViewData[1].items.push({ id: facilityIdIndex, facilityTypeId: result[i].FacilityTypeId, text: result[i].Name, items: [], visualFlag: false });
- facilityIdIndex++;
- }
- }
- }
- var dataSource2 = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/CmFacility",
- },
- requireTotalCount: true,
- pageSize: 5000
- });
- dataSource2.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()]
- ]);
- dataSource2.sort({ getter: "Name", asc: true });
- dataSource2.load()
- .done(function (result2) {
- for (var i = 0; i < result2.length; i++) {
- for (var j = 0; j < treeViewData[0].items.length; j++) {
- if (treeViewData[0].items[j].facilityTypeId == result2[i].FacilityTypeId) {
- treeViewData[0].items[j].items.push({ id: facilityIdIndex, facilityTypeId: result2[i].FacilityTypeId, facilityCode: result2[i].FacilityCode, text: result2[i].Name, visualFlag: true, parentId: 0 });
- facilityIdIndex++;
- treeViewData[2].items[j].items.push({ id: facilityIdIndex, facilityTypeId: result2[i].FacilityTypeId, facilityCode: result2[i].FacilityCode, text: result2[i].Name, visualFlag: true, parentId: 2 });
- facilityIdIndex++;
- break;
- }
- }
- if (result2[i].FacilityTypeId == virtualFacility) {
- treeViewData[1].items[0].items.push({ id: facilityIdIndex, facilityTypeId: result2[i].FacilityTypeId, facilityCode: result2[i].FacilityCode, text: result2[i].Name, visualFlag: true, parentId: 1 });
- facilityIdIndex++;
- }
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- function GetPopupGridData(facilityTypeId, facilityCode, parentId) {
- if (parentId != 0) {
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsMonitoringPointConfig",
- },
- requireTotalCount: true,
- pageSize: 5000,
- expand: ["BemsMonitoringPoint"]
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["FacilityTypeId", "=", facilityTypeId],
- "and",
- ["FacilityCode", "=", facilityCode]
- ]);
- dataSource.sort({ getter: "BemsMonitoringPoint/PropertyId", asc: true });
- dataSource.load()
- .done(function (result) {
- setDataSource1 = new Array();
- for (var i = 0; i < result.length; i++) {
- var setData = { "ControlPoint": "", "FuelType": 0, "FacilityTypeId": 0, "FacilityCode": 0, "PropertyId": 0, "FormulaId": 0 };
- setData.ControlPoint = result[i].BemsMonitoringPoint.Name;
- var fuelName = result[i].BemsMonitoringPoint.FuelTypeId;
- if (fuelName == 0) {
- fuelName = "-";
- } else if (fuelName == 1) {
- fuelName = "전기";
- } else if (fuelName == 2) {
- fuelName = "가스";
- } else {
- fuelName = "수도";
- }
- setData.FuelType = fuelName;
- setData.FacilityTypeId = result[i].FacilityTypeId;
- setData.FacilityCode = result[i].FacilityCode;
- setData.PropertyId = result[i].PropertyId;
- setDataSource1.push(setData);
- }
- $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
- $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
- placeholder: "관제점 이름",
- dataSource: setDataSource1,
- displayExpr: "ControlPoint",
- valueExpr: "PropertyId",
- onValueChanged: function () {
- var value = $("#Control_Id").dxSelectBox('instance').option('value');
- if (value != null) {
- for (var i = 0; i < setDataSource1.length; i++) {
- if (setDataSource1[i].PropertyId == value) {
- propertyId_fin = setDataSource1[i].PropertyId;
- controlPoint_fin = setDataSource1[i].ControlPoint;
- formulaId_fin = setDataSource1[i].FormulaId;
- break;
- }
- }
- }
- }
- });
- if (changed) {
- $("#Facility_Id").dxSelectBox('instance').option('value', FacilityCode_id_temp);
- $("#UpperLimit_ONOFF").dxSwitch('instance').option('value', UseUpperLimit);
- $("#UpperLimit_Id").dxTextBox('instance').option('value', UpperLimit);
- $("#LowerLimit_ONOFF").dxSwitch('instance').option('value', UseLowerLimit);
- $("#LowerLimit_Id").dxTextBox('instance').option('value', LowerLimit);
- $("#AlarmYN_Id").dxSwitch('instance').option('value', UseAlarm);
- $("#SMSYN_Id").dxSwitch('instance').option('value', UseSMS);
- $("#EmailYN_Id").dxSwitch('instance').option('value', UseEmail);
- $("#text_Id").dxTextArea('instance').option('value', Content);
- var group = true;
- for (i = 0; i < alarmgroup.length; i++) {
- if (AlarmGroupName == alarmgroup[i].Name) {
- $("#Users_Id").dxSelectBox('instance').option('value', alarmgroup[i].Name);
- group = false;
- break;
- }
- }
- if (group) {
- $("#Users_Id").dxSelectBox('instance').option('value', null);
- }
- if (setDataSource1 == "") {
- changed = true;
- }
- else {
- for (var i = 0; i <= setDataSource1.length; i++) {
- if (FormulaId == 0) {
- if (setDataSource1[i].PropertyId == PropertyId) {
- $("#Control_Id").dxSelectBox('instance').option('value', setDataSource1[i].PropertyId);
- break;
- }
- }
- else {
- if (setDataSource1[i].FormulaId == FormulaId) {
- $("#Control_Id").dxSelectBox('instance').option('value', setDataSource1[i].FormulaId);
- break;
- }
- }
- }
- changed = false;
- }
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- } else {
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsFormula",
- },
- requireTotalCount: true,
- pageSize: 5000,
- expand: ["BemsFormulaBase"]
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["FacilityTypeId", "=", facilityTypeId],
- "and",
- ["FacilityCode", "=", facilityCode]
- ]);
- dataSource.sort({ getter: "BemsFormulaBase/Name", asc: true });
- dataSource.load()
- .done(function (result) {
- setDataSource1 = new Array();
- for (var i = 0; i < result.length; i++) {
- var setData = { "ControlPoint": "", "FuelType": 0, "FacilityTypeId": 0, "FacilityCode": 0, "PropertyId": 0, "FormulaId": 0 };
- setData.ControlPoint = result[i].BemsFormulaBase.Name;
- setData.FuelType = "-";
- setData.FacilityTypeId = result[i].FacilityTypeId;
- setData.FacilityCode = result[i].FacilityCode;
- setData.FormulaId = result[i].FormulaId;
- setDataSource1.push(setData);
- }
- $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
- $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
- placeholder: "관제점 이름",
- dataSource: setDataSource1,
- displayExpr: "ControlPoint",
- valueExpr: "FormulaId",
- onValueChanged: function () {
- var value = $("#Control_Id").dxSelectBox('instance').option('value');
- if (value != null) {
- for (var i = 0; i < setDataSource1.length; i++) {
- if (setDataSource1[i].FormulaId == value) {
- propertyId_fin = setDataSource1[i].PropertyId;
- controlPoint_fin = setDataSource1[i].ControlPoint;
- formulaId_fin = setDataSource1[i].FormulaId;
- break;
- }
- }
- }
- }
- });
- if (changed) {
- $("#Facility_Id").dxSelectBox('instance').option('value', FacilityCode_id_temp);
- $("#UpperLimit_Id").dxTextBox('instance').option('value', UpperLimit);
- $("#LowerLimit_Id").dxTextBox('instance').option('value', LowerLimit);
- $("#UpperLimit_ONOFF").dxSwitch('instance').option('value', UseUpperLimit);
- $("#LowerLimit_ONOFF").dxSwitch('instance').option('value', UseLowerLimit);
- $("#AlarmYN_Id").dxSwitch('instance').option('value', UseAlarm);
- $("#SMSYN_Id").dxSwitch('instance').option('value', UseSMS);
- $("#EmailYN_Id").dxSwitch('instance').option('value', UseEmail);
- $("#text_Id").dxTextArea('instance').option('value', Content);
- var group = true;
- for (i = 0; i < alarmgroup.length; i++) {
- if (AlarmGroupName == alarmgroup[i].Name) {
- $("#Users_Id").dxSelectBox('instance').option('value', alarmgroup[i].Name);
- group = false;
- break;
- }
- }
- if (group) {
- $("#Users_Id").dxSelectBox('instance').option('value', null);
- }
- if (setDataSource1 == "") {
- changed = true;
- }
- else {
- for (var i = 0; i < setDataSource1.length; i++) {
- if (FormulaId == 0) {
- if (setDataSource1[i].PropertyId == PropertyId) {
- $("#Control_Id").dxSelectBox('instance').option('value', setDataSource1[i].PropertyId);
- break;
- }
- }
- else {
- if (setDataSource1[i].FormulaId == FormulaId) {
- $("#Control_Id").dxSelectBox('instance').option('value', setDataSource1[i].FormulaId);
- break;
- }
- }
- }
- changed = false;
- }
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- }
- function AddSelectPoint() {
- //초기화
- selectData.FacilityTypeId = 0;
- selectData.FacilityCode = 0;
- selectData.PropertyId = 0;
- selectData.FormulaId = 0;
- selectData.FacilityName = "";
- selectData.ControlPoint = "";
- selectData.LowerLimit_ONOFF = false;
- selectData.LowerLimit = "";
- selectData.UpperLimit_ONOFF = false;
- selectData.UpperLimit = 0;
- selectData.UseAlarm = false;
- selectData.UseSMS = false;
- selectData.UseEmail = false;
- selectData.AlarmGroupName = "";
- selectData.text = "";
- //입력
- selectData.FacilityTypeId = facilityTypeId_fin;
- selectData.FacilityCode = facilityCode_fin;
- selectData.PropertyId = propertyId_fin;
- selectData.FormulaId = formulaId_fin;
- if (selectData.FormulaId == null) {
- selectData.FormulaId = 0;
- }
- selectData.FacilityName = facilityName_fin;
- selectData.ControlPoint = controlPoint_fin;
- selectData.LowerLimit_ONOFF = LowerLimit_ONOFF_value;
- LowerLimit_Id_text = $("#LowerLimit_Id").dxTextBox('instance').option('value');
- if (LowerLimit_Id_text == "")
- selectData.LowerLimit = 0;
- else
- selectData.LowerLimit = parseFloat(LowerLimit_Id_text);
- selectData.UpperLimit_ONOFF = UpperLimit_ONOFF_value;
- UpperLimit_Id_text = $("#UpperLimit_Id").dxTextBox('instance').option('value');
- if (UpperLimit_Id_text == "")
- selectData.UpperLimit = 0;
- else
- selectData.UpperLimit = parseFloat(UpperLimit_Id_text);
- selectData.UseAlarm = AlarmYN_Id_value;
- selectData.UseSMS = SMSYN_Id_Id_value;
- selectData.UseEmail = EmailYN_Id_Id_value;
- selectData.AlarmGroupName = Users_Id_text;
- selectData.text = text_Id_text;
- if (selectData.length == 0) {
- utils.toast.show("선택된 데이터가 없습니다.", 'error');
- return;
- }
- if (selectData.FacilityTypeId == 0 || selectData.FacilityCode == 0 || selectData.FacilityName == "" || selectData.ControlPoint == "" || selectData.AlarmGroupName == "" || selectData.AlarmGroupName == null) {
- utils.toast.show("필수 데이터가 부족합니다.", 'error');
- return;
- }
- if (gridData.length != 0) {
- for (var i = 0; i < gridData.length; i++) {
- if (gridData[i].FacilityTypeId == selectData.FacilityTypeId && gridData[i].FacilityCode == selectData.FacilityCode
- && gridData[i].PropertyId == selectData.PropertyId && gridData[i].FormulaId == selectData.FormulaId) {
- utils.toast.show("선택한 목록 중 이미 추가되어 있는 항목이 있습니다.", 'error');
- return;
- }
- }
- }
- if (selectData.UpperLimit_ONOFF == true) {
- if (selectData.UpperLimit == 0) {
- utils.toast.show("0은 상한값이 될수 없습니다.", 'error');
- //visiblePopup(false);
- return;
- }
- }
- if (selectData.LowerLimit_ONOFF == true) {
- if (selectData.LowerLimit == 0) {
- utils.toast.show("0은 하한값이 될수 없습니다.", 'error');
- //visiblePopup(false);
- return;
- }
- }
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/CmFacility",
- },
- requireTotalCount: true,
- pageSize: 1,
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()],
- "and",
- ["FacilityTypeId", "=", selectData.FacilityTypeId],
- "and",
- ["FacilityCode", "=", selectData.FacilityCode]
- ]);
- dataSource.load()
- .done(function (result) {
- if (selectData.FacilityTypeId == result[0].FacilityTypeId && selectData.FacilityCode == result[0].FacilityCode) {
- selectData.FacilityName = result[0].Name;
- var store = new DevExpress.data.ODataStore({
- url: endpointSelector + "/BemsAlarmSetting",
- key: ["SiteId", "FacilityTypeId", "FacilityCode", "PropertyId", "FormulaId"],
- keyType: {
- SiteId: "Int32",
- FacilityTypeId: "Int32",
- FacilityCode: "Int32",
- PropertyId: "Int32",
- FormulaId: "Int32"
- }
- });
- var insertData = {
- SiteId: BWA.UserInfo.SiteId(), FacilityTypeId: selectData.FacilityTypeId, FacilityCode: selectData.FacilityCode,
- PropertyId: selectData.PropertyId, FormulaId: selectData.FormulaId, FacilityName: selectData.FacilityName,
- PointName: selectData.ControlPoint, UseUpperLimit: selectData.UpperLimit_ONOFF, UpperLimit: selectData.UpperLimit,
- UseLowerLimit: selectData.LowerLimit_ONOFF, LowerLimit: selectData.LowerLimit,
- UseAlarm: selectData.UseAlarm, UseSMS: selectData.UseSMS, UseEmail: selectData.UseEmail, AlarmGroupName: selectData.AlarmGroupName,
- Content: selectData.text
- };
- store.insert(insertData)
- .done(function (values, key) {
- setTimeout(function () {
- utils.toast.show("저장 되었습니다.");
- GetGridData();
- visiblePopup(false);
- }, 1500);
- })
- .fail(function (error) {
- });
- }
- })
- }
- function GetGridData() {
- gridData = new Array();
- var dataSource = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsAlarmSetting",
- },
- requireTotalCount: true,
- pageSize: 9999,
- });
- dataSource.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()]
- ]);
- dataSource.sort({ getter: "FacilityTypeId", asc: true });
- dataSource.load()
- .done(function (result) {
- for (var i = 0; i < result.length; i++) {
- var cnt = 0;
- upperLimitCnt = 0;
- lowerLimitCnt = 0;
- alarmYNCnt = 0;
- smsYNCnt = 0;
- emailYNCnt = 0;
- var setData = {
- "PointTypeId": "",
- "FacilityTypeId": 0, "FacilityCode": 0, "PropertyId": 0, "FormulaId": 0,
- "FacilityName": "", "ControlPoint": "", "UseUpperLimit": "N", "UseLowerLimit": "N",
- "UpperLimit": "", "LowerLimit": "", "UseAlarm": "N", "UseSMS": "N",
- "UseEmail": "N", "AlarmGroupName": "", "Content": ""
- };
- setData.FacilityTypeId = result[i].FacilityTypeId;
- setData.FacilityCode = result[i].FacilityCode;
- setData.PropertyId = result[i].PropertyId;
- setData.FormulaId = result[i].FormulaId;
- if (setData.FormulaId != 0) {
- setData.PointTypeId = "성능분석";
- }
- else {
- if (setData.FacilityTypeId == 99)
- setData.PointTypeId = "가상 시설";
- else
- setData.PointTypeId = "일반 시설";
- }
- setData.FormulaId = result[i].FormulaId;
- setData.FacilityName = result[i].FacilityName;
- setData.ControlPoint = result[i].PointName;
- setData.UseUpperLimit = result[i].UseUpperLimit;
- if (setData.UseUpperLimit == 0)
- setData.UseUpperLimit = "N";
- else
- setData.UseUpperLimit = "Y";
- setData.UpperLimit = result[i].UpperLimit;
- setData.UseLowerLimit = result[i].UseLowerLimit;
- if (setData.UseLowerLimit == 0)
- setData.UseLowerLimit = "N";
- else
- setData.UseLowerLimit = "Y";
- setData.LowerLimit = result[i].LowerLimit;
- setData.UseAlarm = result[i].UseAlarm;
- if (setData.UseAlarm == 0)
- setData.UseAlarm = "N";
- else
- setData.UseAlarm = "Y";
- setData.UseSMS = result[i].UseSMS;
- if (setData.UseSMS == 0)
- setData.UseSMS = "N";
- else
- setData.UseSMS = "Y";
- setData.UseEmail = result[i].UseEmail;
- if (setData.UseEmail == 0)
- setData.UseEmail = "N";
- else
- setData.UseEmail = "Y";
- for (var j = 0; j < alarmgroup.length; j++) {
- if (result[i].AlarmGroupName == alarmgroup[j].Name) {
- setData.AlarmGroupName = result[i].AlarmGroupName;
- break;
- } else {
- cnt++;
- }
- if (cnt == alarmgroup.length) {
- setData.AlarmGroupName = "없음";
- }
- }
- setData.Content = result[i].Content;
- gridData.push(setData);
- }
- $("#dataGrid").dxDataGrid("instance").option('dataSource', gridData);
- var dg = $("#dataGrid").dxDataGrid("instance");
- dg.refresh();
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- function UpdateGridData() {
- var dg = $("#dataGrid").dxDataGrid("instance");
- var store = new DevExpress.data.ODataStore({
- url: endpointSelector + "/BemsAlarmSetting",
- key: ["SiteId", "FacilityTypeId", "FacilityCode", "PropertyId", "FormulaId"],
- keyType: {
- SiteId: "Int32",
- FacilityTypeId: "Int32",
- FacilityCode: "Int32",
- PropertyId: "Int32",
- FormulaId: "Int32"
- }
- });
- selectData.FacilityTypeId = 0;
- selectData.FacilityCode = 0;
- selectData.PropertyId = 0;
- selectData.FormulaId = 0;
- selectData.FacilityName = "";
- selectData.ControlPoint = "";
- selectData.UpperLimit_ONOFF = false;
- selectData.UpperLimit = "";
- selectData.LowerLimit_ONOFF = false;
- selectData.LowerLimit = "";
- selectData.UseAlarm = false;
- selectData.UseSMS = false;
- selectData.UseEmail = false;
- selectData.AlarmGroupName = "";
- selectData.text = "";
- //입력
- selectData.FacilityTypeId = facilityTypeId_fin;
- selectData.FacilityCode = facilityCode_fin;
- selectData.PropertyId = propertyId_fin;
- selectData.FormulaId = formulaId_fin;
- if (selectData.FormulaId == null) {
- selectData.FormulaId = 0;
- }
- selectData.FacilityName = facilityName_fin;
- selectData.ControlPoint = controlPoint_fin;
- UpperLimit_ONOFF_value = $("#UpperLimit_ONOFF").dxSwitch('instance').option('value');
- selectData.UpperLimit_ONOFF = UpperLimit_ONOFF_value;
- UpperLimit_Id_text = $("#UpperLimit_Id").dxTextBox('instance').option('value');
- if (UpperLimit_Id_text == "")
- selectData.UpperLimit = 0;
- else
- selectData.UpperLimit = parseFloat(UpperLimit_Id_text);
- LowerLimit_ONOFF_value = $("#LowerLimit_ONOFF").dxSwitch('instance').option('value');
- selectData.LowerLimit_ONOFF = LowerLimit_ONOFF_value;
- LowerLimit_Id_text = $("#LowerLimit_Id").dxTextBox('instance').option('value');
- if (LowerLimit_Id_text == "")
- selectData.LowerLimit = 0;
- else
- selectData.LowerLimit = parseFloat(LowerLimit_Id_text);
- selectData.UseAlarm = AlarmYN_Id_value;
- selectData.UseSMS = SMSYN_Id_Id_value;
- selectData.UseEmail = EmailYN_Id_Id_value;
- selectData.AlarmGroupName = Users_Id_text;
- selectData.text = text_Id_text;
- if (selectData.length == 0) {
- utils.toast.show("선택된 데이터가 없습니다.", 'error');
- return;
- }
- if (selectData.FacilityTypeId == 0 || selectData.FacilityCode == 0 || selectData.FacilityName == "" || selectData.ControlPoint == "" || selectData.AlarmGroupName == "" || selectData.AlarmGroupName == null) {
- utils.toast.show("필수 데이터가 부족합니다.", 'error');
- return;
- }
- if (selectData.UpperLimit_ONOFF == true) {
- if (selectData.UpperLimit == 0) {
- utils.toast.show("0은 상한값이 될수 없습니다.", 'error');
- //visiblePopup(false);
- return;
- }
- }
- if (selectData.LowerLimit_ONOFF == true) {
- if (selectData.LowerLimit == 0) {
- utils.toast.show("0은 하한값이 될수 없습니다.", 'error');
- //visiblePopup(false);
- return;
- }
- }
- store.update({
- SiteId: BWA.UserInfo.SiteId(),
- FacilityTypeId: selectData.FacilityTypeId,
- FacilityCode: selectData.FacilityCode,
- PropertyId: selectData.PropertyId,
- FormulaId: selectData.FormulaId
- }, {
- FacilityName: selectData.FacilityName,
- PointName: selectData.ControlPoint,
- UseUpperLimit: selectData.UpperLimit_ONOFF,
- UpperLimit: selectData.UpperLimit,
- UseLowerLimit: selectData.LowerLimit_ONOFF,
- LowerLimit: selectData.LowerLimit,
- UseAlarm: selectData.UseAlarm,
- UseSMS: selectData.UseSMS,
- UseEmail: selectData.UseEmail,
- AlarmGroupName: selectData.AlarmGroupName,
- Content: selectData.text
- })
- .done(function (values, key) {
- utils.toast.show("수정 되었습니다.");
- setTimeout(function () {
- visiblePopup(false);
- }, 1000);
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- function DeleteGridData() {
- var store = new DevExpress.data.ODataStore({
- url: endpointSelector + "/BemsAlarmSetting",
- key: ["SiteId", "FacilityTypeId", "FacilityCode", "PropertyId", "FormulaId"],
- keyType: {
- SiteId: "Int32",
- FacilityTypeId: "Int32",
- FacilityCode: "Int32",
- PropertyId: "Int32",
- FormulaId: "Int32"
- }
- });
- //초기화
- selectData.FacilityTypeId = 0;
- selectData.FacilityCode = 0;
- selectData.PropertyId = 0;
- selectData.FormulaId = 0;
- //입력
- selectData.FacilityTypeId = facilityTypeId_fin;
- selectData.FacilityCode = facilityCode_fin;
- selectData.PropertyId = propertyId_fin;
- selectData.FormulaId = formulaId_fin;
- if (selectData.FormulaId == null) {
- selectData.FormulaId = 0;
- }
- var removeData = {
- SiteId: BWA.UserInfo.SiteId(), FacilityTypeId: selectData.FacilityTypeId, FacilityCode: selectData.FacilityCode,
- PropertyId: selectData.PropertyId, FormulaId: selectData.FormulaId
- };
- store.remove(removeData)
- .done(function (values, key) {
- utils.toast.show("삭제 되었습니다.");
- setTimeout(function () {
- visiblePopup(false);
- }, 1000);
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- }
- function handleViewShowing() {
- //권한설정
- hasnotModificationPermission(!BWA.UserInfo.hasPermissionOfModification(viewInfo.viewName));
- $("#large-indicator").dxLoadIndicator({
- height: 60,
- width: 60
- });
- var AlarmGroup = new DevExpress.data.DataSource({
- store: {
- type: "odata",
- url: endpointSelector + "/BemsAlarmGroup",
- },
- requireTotalCount: true,
- pageSize: 5000
- });
- AlarmGroup.filter([
- ["SiteId", "=", BWA.UserInfo.SiteId()]
- ]);
- AlarmGroup.sort({ getter: "AlarmGroupId", asc: true });
- AlarmGroup.load()
- .done(function (result2) {
- alarmgroup = new Array();
- for (var i = 0; i < result2.length; i++) {
- var setData = { "AlarmGroupId": 0, "Name": "" };
- setData.AlarmGroupId = result2[i].AlarmGroupId;
- setData.Name = result2[i].Name;
- alarmgroup.push(setData);
- }
- })
- .fail(function (error) {
- utils.toast.show(error);
- });
- GetPopupTreeViewData();
- }
- function handleViewShown() {
- $("#updateSaveBtn").dxButton({
- visible: false
- });
- $("#delBtn").dxButton({
- visible: false
- });
- $("#selectSaveBtn").dxButton({
- visible: false
- });
- $("#dataGrid").dxDataGrid({
- paging: {
- pageSize: 17,
- enabled: true
- }
- });
- GetGridData();
- }
- var searchViewOptions = {
- }
- function PopupChange(data) {
- }
- function handleSearchInSearchView() {
- }
- var viewModel = $.extend(BWA.CommonView.create(params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null, handleSearchInSearchView),
- {
- viewShowing: handleViewShowing,
- dataGrid: utils.datagrid.defaultOptions({
- selection: {
- mode: 'single'
- },
- height: 660,
- columns: [
- {
- dataField: 'PointTypeId',
- width: 120,
- caption: "타입",
- alignment: 'center'
- },
- {
- dataField: 'FacilityName',
- width: 200,
- caption: "설비 이름",
- alignment: 'center'
- }
- , {
- dataField: 'ControlPoint',
- width: 200,
- caption: "관제점(분석요소)",
- alignment: 'center',
- }
- , {
- dataField: 'UseUpperLimit',
- width: 120,
- caption: "기준 상한값 설정",
- alignment: 'center'
- }
- , {
- dataField: 'UpperLimit',
- width: 120,
- caption: "기준 상한값",
- alignment: 'center'
- }
- , {
- dataField: 'UseLowerLimit',
- width: 120,
- caption: "기준 하한값 설정",
- alignment: 'center'
- }
- , {
- dataField: 'LowerLimit',
- width: 120,
- caption: "기준 하한값",
- alignment: 'center'
- }
- , {
- dataField: 'UseAlarm',
- width: 90,
- caption: "경보 여부",
- alignment: 'center'
- }
- , {
- dataField: 'UseSMS',
- width: 90,
- caption: "SMS 여부",
- alignment: 'center'
- }
- , {
- dataField: 'UseEmail',
- width: 90,
- caption: "Email 여부",
- alignment: 'center'
- }
- , {
- dataField: 'AlarmGroupName',
- width: 90,
- caption: "발송 그룹",
- alignment: 'center'
- },
- {
- dataField: 'FacilityTypeId',
- visible: false
- }, {
- dataField: 'FacilityCode',
- visible: false
- }, {
- dataField: 'PropertyId',
- visible: false
- }, {
- dataField: 'FormulaId',
- visible: false
- }
- ],
- // 2019.04.17 엑셀 출력 기능 추가 ~~~
- "export": {
- enabled: true,
- fileName: '알람 설정 내역'
- },
- // ~~~ 2019.04.17 엑셀 출력 기능 추가
- rowClick: function (row) {
- loadvisiblePopup(true);
- row_btn = true;
- var data = row.data;
- Point_Type_Id = data.PointTypeId;
- facilityTypeId = data.FacilityTypeId;
- FacilityCode = data.FacilityCode;
- PropertyId = data.PropertyId;
- FormulaId = data.FormulaId;
- FacilityName = data.FacilityName;
- ControlPoint = data.ControlPoint;
- if (data.UseUpperLimit == "N") {
- UseUpperLimit = false;
- $("#UpperLimit_Id").dxTextBox({
- disabled: true
- });
- }
- else {
- UseUpperLimit = true;
- $("#UpperLimit_Id").dxTextBox({
- disabled: false
- });
- }
- UpperLimit = data.UpperLimit;
- if (data.UseLowerLimit == "N") {
- UseLowerLimit = false;
- $("#LowerLimit_Id").dxTextBox({
- disabled: true
- });
- }
- else {
- UseLowerLimit = true;
- $("#LowerLimit_Id").dxTextBox({
- disabled: false
- });
- }
- LowerLimit = data.LowerLimit;
- if (data.UseAlarm == "N")
- UseAlarm = false;
- else
- UseAlarm = true;
- if (data.UseSMS == "N")
- UseSMS = false;
- else
- UseSMS = true;
- if (data.UseEmail == "N")
- UseEmail = false;
- else
- UseEmail = true;
- AlarmGroupName = data.AlarmGroupName;
- Content = data.Content;
- changed = true;
- setTimeout(function () {
- visiblePopup(true);
- loadvisiblePopup(false);
- }, 500);
- },
- }),
- selectDataGrid: {
- selection: {
- mode: 'multiple',
- allowSelectAll: true,
- },
- columns: [
- {
- dataField: 'ControlPoint',
- width: 340,
- caption: "관제점 이름",
- alignment: 'center',
- }
- , {
- dataField: 'FuelType',
- width: 140,
- caption: "에너지원",
- alignment: 'center'
- }
- , {
- dataField: 'FacilityTypeId',
- visible: false
- }, {
- dataField: 'FacilityCode',
- visible: false
- }, {
- dataField: 'PropertyId',
- visible: false
- }, {
- dataField: 'FormulaId',
- visible: false
- }
- ]
- //, paging: { pageSize: 20, enabled: true }
- },
- updateButtonClicked: function () {
- UpdateGridData();
- setTimeout(function () {
- GetGridData();
- }, 1000);
- },
- delButtonClicked: function () {
- DeleteGridData();
- setTimeout(function () {
- GetGridData();
- }, 1000);
- },
- selectButtonClicked: function () {
- enroll_btn = true;
- facilityTypeId_fin = 0, facilityCode_fin = 0, parentId_fin = 0, propertyId_fin = 0, facilityName_fin = "", formulaId_fin = 0, controlPoint_fin = "";
- 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 = "";
- LowerLimit_Id_text = "", UpperLimit_Id_text = "";
- $("#Point_Type_Id").dxSelectBox({
- placeholder: "관제점 타입",
- dataSource: treeViewData,
- displayExpr: "text",
- valueExpr: "id"
- });
- $("#Facility_Type_Id").dxSelectBox({
- placeholder: "설비 타입"
- });
- $("#Facility_Id").dxSelectBox({
- placeholder: "설비 이름"
- });
- $("#Control_Id").dxSelectBox({
- placeholder: "관제점 이름"
- });
- $("#UpperLimit_Id").dxTextBox({
- placeholder: "기준 상한값"
- });
- $("#LowerLimit_Id").dxTextBox({
- placeholder: "기준 하한값"
- });
- $("#UpperLimit_ONOFF").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false
- });
- $("#LowerLimit_ONOFF").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false
- });
- $("#AlarmYN_Id").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false
- });
- $("#SMSYN_Id").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false
- });
- $("#EmailYN_Id").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false
- });
- $("#Users_Id").dxSelectBox({
- placeholder: "발송 그룹",
- dataSource: alarmgroup,
- displayExpr: "Name",
- valueExpr: "Name"
- });
- $("#text_Id").dxTextArea({
- placeholder: "조치 방법"
- });
- if ($("#Point_Type_Id").dxSelectBox('instance') != null)
- $("#Point_Type_Id").dxSelectBox('instance').option('value', null);// 관제점 타입 클리어
- if ($("#Facility_Type_Id").dxSelectBox('instance') != null)
- $("#Facility_Type_Id").dxSelectBox('instance').option('value', null);// 설비 타입 클리어
- if ($("#Facility_Id").dxSelectBox('instance') != null)
- $("#Facility_Id").dxSelectBox('instance').option('value', null);// 설비 이름 클리어
- if ($("#Control_Id").dxSelectBox('instance') != null)
- $("#Control_Id").dxSelectBox('instance').option('value', null);// 관제점 이름 클리어
- if ($("#UpperLimit_Id").dxTextBox('instance') != null)
- $("#UpperLimit_Id").dxTextBox('instance').option('value', "");// 기준 상한값 클리어
- if ($("#LowerLimit_Id").dxTextBox('instance') != null)
- $("#LowerLimit_Id").dxTextBox('instance').option('value', "");// 기준 하한값 클리어
- if ($("#Users_Id").dxSelectBox('instance') != null)
- $("#Users_Id").dxSelectBox('instance').option('value', null);// 발송그룹 클리어
- if ($("#text_Id").dxTextArea('instance') != null)
- $("#text_Id").dxTextArea('instance').option('value', "");// 조치방법 클리어
- visiblePopup(true);
- },
- selectSaveButtonClicked: function () {
- AddSelectPoint();
- }
- });
- viewModel.loadpopupOptions = {
- width: 300,
- height: 140,
- contentTemplate: "info",
- showTitle: false,
- title: "작업중",
- visible: loadvisiblePopup,
- dragEnabled: false,
- shading: false,
- closeOnOutsideClick: false
- };
- viewModel.popupOptions = {
- width: 680,
- height: 630,
- visible: visiblePopup,
- dragEnabled: true,
- shading: true,
- closeOnOutsideClick: true,
- shadingColor: 'transparent',
- showTitle: true,
- title: "항목 선택",
- showCloseButton: true,
- onShowing: function () {
- },
- onShown: function (t, tt) {
- popupInit = true;
- facility_type = "";
- facility_id = "";
- $("#Point_Type_Id").dxSelectBox({
- placeholder: "관제점 타입",
- dataSource: treeViewData,
- displayExpr: "text",
- valueExpr: "id"
- });
- $("#Facility_Type_Id").dxSelectBox({
- placeholder: "설비 타입"
- });
- $("#Facility_Id").dxSelectBox({
- placeholder: "설비 이름"
- });
- $("#Control_Id").dxSelectBox({
- placeholder: "관제점 이름"
- });
- $("#UpperLimit_Id").dxTextBox({
- placeholder: "기준 상한값",
- onValueChanged: function (e) {
- var temp = e.value;
- if (temp.length == null) {
- }
- else {
- var total = 0;
- for (var i = 0; i < temp.length; i++) {
- for (var j = 0; j < allowedChars.length; j++) {
- if (temp[i] == allowedChars[j]) {
- total++;
- }
- }
- }
- if (total != temp.length) {
- utils.toast.show("숫자와 소수점만 입력가능합니다.", 'error');
- $("#UpperLimit_Id").dxTextBox('instance').option('value', "");
- return;
- }
- }
- if ($("#UpperLimit_ONOFF").dxSwitch('instance').option('value') == true) {
- if ($("#LowerLimit_ONOFF").dxSwitch('instance').option('value') == true) {
- if ($("#LowerLimit_Id").dxTextBox('instance').option('value') <= e.value) {
- UpperLimit_Id_text = e.value;
- $("#UpperLimit_Id").dxTextBox('instance').option('value', UpperLimit_Id_text);
- }
- else {
- utils.toast.show("기준 상한값은 기준 하한값보다 작을수 없습니다.", 'error');
- $("#UpperLimit_Id").dxTextBox('instance').option('value', "");
- return;
- }
- }
- else {
- UpperLimit_Id_text = e.value;
- $("#UpperLimit_Id").dxTextBox('instance').option('value', UpperLimit_Id_text);
- }
- }
- }
- });
- $("#LowerLimit_Id").dxTextBox({
- placeholder: "기준 하한값",
- onValueChanged: function (e) {
- var temp = e.value;
- if (temp.length == null) {
- }
- else {
- var total = 0;
- for (var i = 0; i < temp.length; i++) {
- for (var j = 0; j < allowedChars.length; j++) {
- if (temp[i] == allowedChars[j]) {
- total++;
- }
- }
- }
- if (total != temp.length) {
- utils.toast.show("숫자와 소수점만 입력가능합니다.", 'error');
- $("#LowerLimit_Id").dxTextBox('instance').option('value', "");
- return;
- }
- }
- if ($("#UpperLimit_ONOFF").dxSwitch('instance').option('value') == true) {
- if ($("#LowerLimit_ONOFF").dxSwitch('instance').option('value') == true) {
- if ($("#UpperLimit_Id").dxTextBox('instance').option('value') >= e.value) {
- LowerLimit_Id_text = e.value;
- $("#LowerLimit_Id").dxTextBox('instance').option('value', LowerLimit_Id_text);
- }
- else {
- utils.toast.show("기준 하한값은 기준 상한값보다 클수 없습니다.", 'error');
- $("#LowerLimit_Id").dxTextBox('instance').option('value', "");
- return;
- }
- }
- else {
- LowerLimit_Id_text = e.value;
- $("#LowerLimit_Id").dxTextBox('instance').option('value', LowerLimit_Id_text);
- }
- }
- }
- });
- $("#UpperLimit_ONOFF").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false,
- onValueChanged: function (e) {
- if (e.value == true) {
- $("#UpperLimit_Id").dxTextBox({
- disabled: false
- });
- if ($("#UpperLimit_ONOFF").dxSwitch('instance').option('value') == true && $("#LowerLimit_ONOFF").dxSwitch('instance').option('value') == true) {
- if ($("#UpperLimit_Id").dxTextBox('instance').option('value') >= $("#LowerLimit_Id").dxTextBox('instance').option('value')) {
- }
- else {
- utils.toast.show("기준 상한값은 기준 하한값보다 작을수 없습니다.", 'error');
- $("#UpperLimit_Id").dxTextBox('instance').option('value', "");
- return;
- }
- }
- }
- else {
- $("#UpperLimit_Id").dxTextBox({
- disabled: true
- });
- }
- UpperLimit_ONOFF_value = e.value;
- }
- });
- $("#LowerLimit_ONOFF").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false,
- onValueChanged: function (e) {
- LowerLimit_ONOFF_value = e.value;
- if (e.value == true) {
- $("#LowerLimit_Id").dxTextBox({
- disabled: false
- });
- if ($("#UpperLimit_ONOFF").dxSwitch('instance').option('value') == true && $("#LowerLimit_ONOFF").dxSwitch('instance').option('value') == true) {
- if ($("#UpperLimit_Id").dxTextBox('instance').option('value') >= $("#LowerLimit_Id").dxTextBox('instance').option('value')) {
- }
- else {
- utils.toast.show("기준 하한값은 기준 상한값보다 클수 없습니다.", 'error');
- $("#LowerLimit_Id").dxTextBox('instance').option('value', "");
- return;
- }
- }
- }
- else {
- $("#LowerLimit_Id").dxTextBox({
- disabled: true
- });
- }
- }
- });
- $("#AlarmYN_Id").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false,
- onValueChanged: function (e) {
- AlarmYN_Id_value = e.value;
- }
- });
- $("#SMSYN_Id").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false,
- onValueChanged: function (e) {
- SMSYN_Id_Id_value = e.value;
- }
- });
- $("#EmailYN_Id").dxSwitch({
- onText: 'On',
- offText: 'Off',
- value: false,
- onValueChanged: function (e) {
- EmailYN_Id_Id_value = e.value;
- }
- });
- $("#Users_Id").dxSelectBox({
- placeholder: "발송 그룹",
- dataSource: alarmgroup,
- displayExpr: "Name",
- valueExpr: "Name",
- onValueChanged: function (e) {
- var value = $("#Users_Id").dxSelectBox('instance').option('value');
- Users_Id_text = value;
- }
- });
- $("#text_Id").dxTextArea({
- placeholder: "조치 방법",
- onValueChanged: function (e) {
- text_Id_text = e.value;
- }
- });
- $("#Point_Type_Id").dxSelectBox({
- onValueChanged: function () {
- facility_type = "";
- facility_id = "";
- setDataSource1 = "";
- var value = $("#Point_Type_Id").dxSelectBox('instance').option('value');
- if (value == null)
- facility_type = "";
- else
- facility_type = treeViewData[value - 1].items;
- $("#Facility_Type_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
- $("#Facility_Type_Id").dxSelectBox({// 두번째 콤보 바인딩
- placeholder: "설비 타입",
- dataSource: facility_type,
- displayExpr: "text",
- valueExpr: "id"
- });
- $("#Facility_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
- $("#Facility_Id").dxSelectBox({// 두번째 콤보 바인딩
- placeholder: "설비 이름",
- dataSource: facility_id,
- displayExpr: "text",
- valueExpr: "id"
- });
- $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
- $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
- placeholder: "관제점 이름",
- dataSource: setDataSource1,
- displayExpr: "ControlPoint",
- valueExpr: "FormulaId"
- });
- }
- });
- $("#Facility_Type_Id").dxSelectBox({
- onValueChanged: function () {
- if (facility_type == "") {
- var value1 = $("#Point_Type_Id").dxSelectBox('instance').option('value');
- if (value1 == null)
- facility_type = "";
- else
- facility_type = treeViewData[value1 - 1].items;
- }
- facility_id = "";
- setDataSource1 = "";
- var Pointtype = $("#Point_Type_Id").dxSelectBox('instance').option('value');
- var value = $("#Facility_Type_Id").dxSelectBox('instance').option('value');
- if (Pointtype == 1)//성능분석
- {
- if (value != null) {
- facility_id = facility_type[value - 4].items;
- }
- }
- else if (Pointtype == 2) { //가상
- if (value != null) {
- facility_id = facility_type[0].items;
- }
- }
- else { //일반
- if (value != null) {
- facility_id = facility_type[value - excnt].items;
- }
- }
- $("#Facility_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
- $("#Facility_Id").dxSelectBox({// 두번째 콤보 바인딩
- placeholder: "설비 이름",
- dataSource: facility_id,
- displayExpr: "text",
- valueExpr: "id"
- });
- $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
- $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
- placeholder: "관제점 이름",
- dataSource: setDataSource1,
- displayExpr: "ControlPoint",
- valueExpr: "FormulaId"
- });
- }
- });
- $("#Facility_Id").dxSelectBox({
- onValueChanged: function () {
- if (facility_id == "") {
- if (facility_type == "") {
- var value1 = $("#Point_Type_Id").dxSelectBox('instance').option('value');
- if (value1 == null)
- facility_type = "";
- else
- facility_type = treeViewData[value1 - 1].items;
- }
- var Pointtype = $("#Point_Type_Id").dxSelectBox('instance').option('value');
- var value = $("#Facility_Type_Id").dxSelectBox('instance').option('value');
- if (Pointtype == 1)//성능분석
- {
- if (value != null) {
- facility_id = facility_type[value - 4].items;
- }
- }
- else if (Pointtype == 2) { //가상
- if (value != null) {
- facility_id = facility_type[0].items;
- }
- }
- else { //일반
- if (value != null) {
- facility_id = facility_type[value - excnt].items;
- }
- }
- }
- setDataSource1 = "";
- var value = $("#Facility_Id").dxSelectBox('instance').option('value');
- facilityTypeId_fin = 0, facilityCode_fin = 0, parentId_fin = 0;
- if (value != null) {
- for (var i = 0; i < facility_id.length; i++) {
- if (facility_id[i].id == value) {
- facilityTypeId_fin = facility_id[i].facilityTypeId;
- facilityCode_fin = facility_id[i].facilityCode;
- parentId_fin = facility_id[i].parentId;
- facilityName_fin = facility_id[i].text;
- break;
- }
- }
- GetPopupGridData(facilityTypeId_fin, facilityCode_fin, parentId_fin);
- }
- $("#Control_Id").dxSelectBox('instance').option('value', null);// 텍스트 클리어
- $("#Control_Id").dxSelectBox({// 두번째 콤보 바인딩
- placeholder: "관제점 이름",
- dataSource: setDataSource1,
- displayExpr: "ControlPoint",
- valueExpr: "FormulaId",
- });
- }
- });
- $("#Control_Id").dxSelectBox({
- onValueChanged: function () {
- var value = $("#Control_Id").dxSelectBox('instance').option('text');
- if (value != null) {
- for (var i = 0; i < setDataSource1.length; i++) {
- if (setDataSource1[i].ControlPoint == value) {
- propertyId_fin = setDataSource1[i].PropertyId;
- controlPoint_fin = setDataSource1[i].ControlPoint;
- formulaId_fin = setDataSource1[i].FormulaId;
- break;
- }
- }
- }
- }
- });
- var j = 0;
- if (changed) {
- var Point_Type_Id_temp = 0;
- for (var i = 0; i < treeViewData.length; i++) {
- if (treeViewData[i].text == Point_Type_Id) {
- Point_Type_Id_temp = treeViewData[i].id;
- break;
- }
- }
- $("#Point_Type_Id").dxSelectBox('instance').option('value', Point_Type_Id_temp);
- var facility_type_Id_temp = 0;
- for (j = 0; j < treeViewData[Point_Type_Id_temp - 1].items.length; j++) {
- if (treeViewData[Point_Type_Id_temp - 1].items[j].facilityTypeId == facilityTypeId) {
- facility_type_Id_temp = treeViewData[Point_Type_Id_temp - 1].items[j].id;
- break;
- }
- }
- $("#Facility_Type_Id").dxSelectBox('instance').option('value', facility_type_Id_temp);
- var FacilityCode_temp = 0;
- var facilityTypeId_temp = 0;
- var parentId_temp = 0;
- FacilityCode_id_temp = 0;
- if (Point_Type_Id_temp == 1) {
- var delete_value = 4;
- }
- else if (Point_Type_Id_temp == 2) {
- delete_value = facility_type_Id_temp;
- }
- else {
- delete_value = excnt;
- }
- for (var k = 0; k < treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items.length; k++) {
- if (treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].facilityCode == FacilityCode) {
- FacilityCode_id_temp = treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].id;
- FacilityCode_temp = treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].facilityCode;
- facilityTypeId_temp = treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].facilityTypeId;
- parentId_temp = treeViewData[Point_Type_Id_temp - 1].items[facility_type_Id_temp - delete_value].items[k].parentId;
- break;
- }
- }
- GetPopupGridData(facilityTypeId_temp, FacilityCode_temp, parentId_temp);
- }
- if (row_btn) {
- $("#updateSaveBtn").dxButton({
- visible: true
- });
- $("#delBtn").dxButton({
- visible: false
- });
- $("#selectSaveBtn").dxButton({
- visible: false
- });
- $("#Point_Type_Id").dxSelectBox({
- disabled: true
- });
- $("#Facility_Type_Id").dxSelectBox({
- disabled: true
- });
- $("#Facility_Id").dxSelectBox({
- disabled: true
- });
- $("#Control_Id").dxSelectBox({
- disabled: true
- });
- row_btn = false;
- }
- if (enroll_btn) {
- $("#Point_Type_Id").dxSelectBox({
- disabled: false
- });
- $("#Facility_Type_Id").dxSelectBox({
- disabled: false
- });
- $("#Facility_Id").dxSelectBox({
- disabled: false
- });
- $("#Control_Id").dxSelectBox({
- disabled: false
- });
- $("#updateSaveBtn").dxButton({
- visible: false
- });
- $("#delBtn").dxButton({
- visible: false
- });
- $("#selectSaveBtn").dxButton({
- visible: true
- });
- enroll_btn = false;
- }
- },
- onHidden: function () {
- },
- hasnotModificationPermission: hasnotModificationPermission //권한설정
- };
- return viewModel;
- };
|