alarmservice.js 197 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413
  1. // io.sails.autoConnect = false;
  2. // io.sails.url = "http://" + alarmServiceIP + ":" + alarmServicePort + "";
  3. // socket="";
  4. // if(alarmServiceIP!=""&&alarmServicePort!=""){
  5. // socket = io.sails.connect();
  6. // }
  7. //socket = io.sails.connect();
  8. /**
  9. * Created by han on 2017/1/8.
  10. */
  11. //var alarmServiceURL="http://"+alarmServiceIP+":"+alarmServicePort+"/";
  12. //socket = io.connect(io.sails.url);
  13. var socket;
  14. (function () {
  15. var socketOption = {
  16. path: '/wsaccess/socket.io/'
  17. };
  18. if (isAuthEnable != "True") {
  19. socketOption.reconnection = false;
  20. }
  21. if (!socket) {
  22. socket = GD.io("http://" + authServiceIP + ":" + authServicePort, socketOption);
  23. socket.socketio.on('connect', function (e) {
  24. alarmInit();
  25. });
  26. // socket.on('message', function (result) { });
  27. // socket.on('disconnect', function () {
  28. // });
  29. // socket.on('error', function (data) {
  30. // console.log(data);
  31. // // alert('后台服务连接失败');
  32. // // return;
  33. // })
  34. }
  35. })();
  36. (function (W) {
  37. var GD = W.GD || {};
  38. function setAlarmTableStyle(borderPaneReal, tablePane, topToolbar, bottomToolBar, leftBar, tablestyle) {
  39. var tableHeader = tablePane.getTableHeader(),
  40. tableView = tablePane.getTableView();
  41. var $tableHeader = $(tableHeader.getView()),
  42. $bottomToolBarView = $(bottomToolBar.getView());
  43. function setTableHeaderStyle() {
  44. // tableHeader.setHeight((tablestyle.headheight || 63)*ratio.ratioY);
  45. // tableHeader.getLabelFont = function () {
  46. // return tablystyle.headerfontstyle + tablestyle.headerfontsize*ratio.ratioY + 'px ' + tablestyle.headerfontfamily;
  47. // }
  48. // tablestyle.headBackImage = tablestyle.headBackImage || 'Script/image/title背景.png';
  49. // if (tablestyle.headBackImage) {
  50. // $tableHeader.css({
  51. // background: 'url('+ PAGEROOTDIR + tablestyle.headBackImage +') center center no-repeat',
  52. // backgroundSize: '100% 100%'
  53. // })
  54. // } else {
  55. // $tableHeader.css({
  56. // background: 'liner-gradient(to bottom, '+ tablestyle.headcolor +', '+ tablestyle.headGradientcolor + ')',
  57. // })
  58. // }
  59. }
  60. function setTableBodyStyle() {
  61. (function (unSelData, selData) {
  62. var dm = tablePane.getDataModel(),
  63. sm = dm.getSelectionModel(),
  64. drawColumn = tableHeader.drawColumn;
  65. tablePane.getTableView().getCheckIcon = function (d) {
  66. if (sm.contains(d)) {
  67. return selData
  68. }
  69. return unSelData;
  70. }
  71. tableHeader.drawColumn = function (g, column, x, y, width, height) {
  72. var img;
  73. if (!(column.getName() || column.getDisplayName())) {
  74. if (sm.getSelection()._as.length > 0) {
  75. img = selData;
  76. } else {
  77. img = unSelData;
  78. }
  79. ht.Default.drawImage(g, img, x + 0.5 * width - 6, y + height * 0.5 - 6, 12, 12);
  80. } else {
  81. drawColumn.apply(this, arguments);
  82. }
  83. }
  84. })(
  85. {
  86. width: 12,
  87. height: 12,
  88. comps: [
  89. {
  90. type: 'rect',
  91. background: 'rgb(255,255,255)',
  92. borderWidth: 2,
  93. borderColor: 'rgb(204,214,215)'
  94. }
  95. ]
  96. },
  97. {
  98. width: 12,
  99. height: 12,
  100. comps: [
  101. {
  102. type: 'rect',
  103. background: 'rgb(255,255,255)',
  104. borderWidth: 2,
  105. borderColor: 'rgb(204,214,215)',
  106. rect: [0, 0, 12, 12]
  107. },
  108. {
  109. type: 'shape',
  110. shadow: false,
  111. points: [2, 6, 6, 10, 10, 2],
  112. segments: [1, 2, 2],
  113. borderWidth: 2,
  114. borderColor: 'rgb(186,118,81)'
  115. }
  116. ]
  117. }
  118. );
  119. }
  120. function setLeftBarStyle() {
  121. if (!leftBar) return;
  122. var $leftBarView = $(leftBar.getView());
  123. $leftBarView.css({
  124. background: 'linear-gradient(to bottom, ' + tablestyle.backcolor + ', rgb(7, 45, 110))',
  125. }).find('div').css({
  126. cursor: 'pointer'
  127. })
  128. }
  129. function setBorderPaneStyle() {
  130. borderPaneReal.setBottomHeight(60 * ratio.ratioY);
  131. borderPaneReal.setTopHeight(60 * ratio.ratioY);
  132. borderPaneReal.setLeftWidth(45 * ratio.ratioX);
  133. $(borderPaneReal.getView()).css({
  134. border: '1px solid rgb(14,37,79)'
  135. })
  136. }
  137. function setBottomToolBarStyle() {
  138. if (!bottomToolBar) return;
  139. $bottomToolBarView.css({
  140. borderTop: '5px solid rgb(27,51,95)',
  141. backgroundColor: 'rgb(11,32,89)'
  142. }).find('div').css({
  143. left: 0
  144. })
  145. bottomToolBar.setLabelFont(16 * ratio.ratioY + 'px "苹方 粗体"');
  146. bottomToolBar.setLabelColor('rgb(7,192,255)');
  147. var confirmButton = bottomToolBar.getItemById('confirm'),
  148. confirmAllButton = bottomToolBar.getItemById('confirmAll');
  149. var cssobj = {
  150. borderRadius: 0,
  151. cursor: 'pointer',
  152. boxShadow: '1px 1px 4px rgb(20,20,20)',
  153. backgroundImage: 'url(' + PAGEROOTDIR + 'Script/image/f4button.png)',
  154. backgroundSize: '100% 100%',
  155. backgroundPosition: 'center',
  156. backgroundRepeat: 'no-repeat',
  157. marginLeft: -20
  158. }
  159. function setButtonStyle(button) {
  160. var $buttonView = $(button.element.getView());
  161. button.element.setBorderColor('rgba(0,0,0,0)');
  162. button.element.setBackground('rgba(0,0,0,0)');
  163. button.element.setSelectBackground('rgba(0,0,0,0)');
  164. button.element.setLabelFont(16 * ratio.ratioY + 'px "苹方 粗体"');
  165. button.element.setWidth(80 * ratio.ratioX);
  166. button.element.setHeight(30 * ratio.ratioY);
  167. $buttonView.css(cssobj).hover(function () {
  168. $(this).css({
  169. boxShadow: '0 0 10px rgb(200, 200, 200)'
  170. })
  171. }, function () {
  172. $(this).css({
  173. boxShadow: '1px 1px 4px rgb(20,20,20)',
  174. })
  175. }).mousedown(function () {
  176. $(this).css({
  177. marginTop: 1,
  178. marginLeft: 1
  179. })
  180. }).mouseup(function () {
  181. $(this).css({
  182. marginTop: 0,
  183. marginLeft: 0
  184. })
  185. });
  186. }
  187. if (confirmButton) {
  188. setButtonStyle(confirmButton);
  189. }
  190. if (confirmAllButton) {
  191. setButtonStyle(confirmAllButton);
  192. }
  193. }
  194. function setTopToolBarStyle() {
  195. if (!topToolbar) return;
  196. topToolbar.setLabelColor('rgb(160,160,160)');
  197. topToolbar.setLabelFont('bold ' + 21 * ratio.ratioY + 'px "苹方 特粗"')
  198. topToolbar.setItemGap(20 * ratio.ratioX);
  199. var items = topToolbar.getItems(),
  200. element, item, values, icons;
  201. for (var i = 0, len = items.length; i < len; i++) {
  202. item = items[i] || {};
  203. element = item.element;
  204. if (!element) continue;
  205. if (element instanceof ht.widget.ComboBox) {
  206. (function (element) {
  207. // element.setBackground('url('+ PAGEROOTDIR +'Script/image/alarmComboboxBG.png) center center no-repeat');
  208. element.getLabelColor = function (u, i) {
  209. if (!this.isOpened() && !i) {
  210. return 'rgb(218,219,172)';
  211. } else {
  212. return i ? 'rgb(0,0,0)' : 'rgb(0,0,0)';
  213. }
  214. }
  215. element.setLabelFont('bold ' + 18 * ratio.ratioY + 'px "苹方 特粗"')
  216. element.onOpened = function () {
  217. var view = this._listView.getView(),
  218. $view = $(view);
  219. $view.css({
  220. // background: 'rgb(255,255,255)'
  221. maxHeight: 500 * ratio.ratioY,
  222. cursor: 'pointer'
  223. });
  224. $(this.getView()).find('input').css({
  225. 'display': 'none'
  226. })
  227. }
  228. // element.setDropDownWidth(140);
  229. element._dropDownBackground = 'rgb(255,255,255)';
  230. element.setSelectBackground('rgb(104,216,255)');
  231. $(element.getView()).css({
  232. border: '1px solid rgba(0,0,0,0)',
  233. height: 36 * ratio.ratioY,
  234. cursor: 'pointer'
  235. }).addClass('back-size100');
  236. element.setDropDownIcon({
  237. width: 9,
  238. height: 6,
  239. comps: [
  240. {
  241. type: 'triangle',
  242. borderJoin: 'miter',
  243. background: 'rgba(35,213,91,0)',
  244. rotation: Math.PI
  245. }
  246. ]
  247. });
  248. var drawValue = element.drawValue;
  249. element.drawValue = function (g, value, c, x, y, w, h) {
  250. var args = Array.prototype.slice.call(arguments, 0);
  251. args[3] = 20 * ratio.ratioX;
  252. drawValue.apply(this, args);
  253. }
  254. })(element);
  255. } else if (element instanceof ht.widget.MultiComboBox) {
  256. (function () {
  257. element.setDropDownIcon(null);
  258. $(element.getView()).css({
  259. border: '1px solid rgba(0,0,0,0)',
  260. height: 36 * ratio.ratioY,
  261. cursor: 'pointer'
  262. }).addClass('back-size100');
  263. element.getLabelColor = function (u, i) {
  264. if (!this.isOpened() && !i) {
  265. return 'rgb(218,219,172)';
  266. } else {
  267. return i ? 'rgb(0,0,0)' : 'rgb(0,0,0)';
  268. }
  269. }
  270. element.setLabelFont(18 * ratio.ratioY + 'px "苹方 粗体"')
  271. var drawValue = element.drawValue;
  272. element.drawValue = function (g, x, y, w, h) {
  273. var args = Array.prototype.slice.call(arguments, 0);
  274. args[1] = 20 * ratio.ratioY;
  275. drawValue.apply(this, args);
  276. }
  277. })();
  278. } else if (element instanceof ht.widget.Button) {
  279. element.setBorderColor('rgba(0,0,0,0)');
  280. element.setLabelColor('rgb(255,255,255)');
  281. element.setSelectBackground('rgba(0,0,0,0)');
  282. element.setLabelFont(18 * ratio.ratioY + 'px "苹方 粗体"');
  283. element.setBackground('rgba(0,0,0,0)');
  284. $(element.getView()).css({
  285. width: 69 * ratio.ratioX,
  286. height: 30 * ratio.ratioY,
  287. cursor: 'pointer',
  288. backgroundImage: 'url(' + PAGEROOTDIR + 'Script/image/f2button.png)',
  289. backgroundPosition: 'center',
  290. backgroundSize: '100%'
  291. }).on('mousedown', function () {
  292. $(this).css({
  293. margin: '1px 0 0 1px'
  294. })
  295. }).on('mouseup', function () {
  296. $(this).css({
  297. margin: 0
  298. })
  299. })
  300. } else if (element) {
  301. $(element).css({
  302. fontSize: 18 * ratio.ratioY + 'px',
  303. color: 'rgb(218,219,172)',
  304. fontWeight: 'normal'
  305. })
  306. }
  307. }
  308. }
  309. if (tablestyle.IsHeadVisible) {
  310. setBorderPaneStyle();
  311. setTableHeaderStyle();
  312. setTableBodyStyle();
  313. setTopToolBarStyle();
  314. setBottomToolBarStyle();
  315. setLeftBarStyle();
  316. }
  317. }
  318. function setAreaTreeViewStyle(treeView) {
  319. treeView.getLabelColor = function () {
  320. return 'rgba(0,0,0,1)';
  321. }
  322. treeView.getLabelFont = function () {
  323. return 18 * ratio.ratioY + 'px "苹方 粗体"';
  324. }
  325. treeView.setSelectBackground('rgb(104,216,255)');
  326. treeView.setRowHeight(36 * ratio.ratioY);
  327. treeView.getView().style.background = '#FCFCFC';
  328. treeView.setIndent(24 * ratio.ratioX);
  329. treeView.setAutoHideScrollBar(false);
  330. }
  331. GD.setAlarmTableStyle = setAlarmTableStyle;
  332. GD.setAreaTreeViewStyle = setAreaTreeViewStyle;
  333. W.GD = GD;
  334. })(window);
  335. //自定义字段 state0 报警级别id state1区域id state2组id state3系统id
  336. var alarmLevelDic = {};
  337. var GoldenAlarm = {};
  338. // var flag = 1; //报警声音 0静音 1播放
  339. var alarmCategoryDic = {};
  340. var alarmCategoryDicName = {};
  341. var alarmAreasDic = {};
  342. var alarmLevelDicName = {};
  343. var alarmGroupDic = {};
  344. var alarmGroupDicName = {};
  345. var dataAreaNameReal = {};
  346. var alarmAreaDicName = {};
  347. var alarmAreaDicNameId = {};
  348. var currentAreaName = "*";
  349. var audio = new Audio();
  350. var alarmSystem = [];
  351. var alarmAreaIds = [];
  352. var alarmAreaData = [];
  353. var alarmSystemObj = {};
  354. var allUnsureAlarm = [];
  355. var alarmGroupValueReal,
  356. alarmLevelValueReal,
  357. alarmStateValueReal,
  358. alarmAreaValueReal,
  359. realdataModelReal,
  360. formRealLeft,
  361. formHisLeft,
  362. toolbar2His,
  363. toolbar2Real,
  364. alarmFilterState = false,
  365. alarmAreaFilter = function () { return true; };
  366. var isRealFirst = null; // 实时判断是否是首出故障
  367. var isHisFirst = null; // 历史判断是否是首出故障
  368. if (typeof (localStorage) != "undefined" || localStorage != null) {
  369. currentAreaName = localStorage.getItem("currentAreaName") == null ? "*" : localStorage.getItem("currentAreaName");
  370. }
  371. var alarmAreas;
  372. var currentControlContent = "";
  373. var areaIds = "";
  374. var alarmInfoDialog;
  375. var alarmData = [];
  376. var alarmCateReal;
  377. var alarmLevelArray = [],
  378. _alarmLevelArray = [];
  379. var alarmLevelVisible;
  380. var alarmStates = ['*', '未确认', '已确认', '未恢复', '已恢复'];
  381. var alarmStatesDic = { '未确认': 'is_ensure=0', '已确认': 'is_ensure=1', '未恢复': 'is_reset=0', '已恢复': 'is_reset=1' };
  382. var alarmHisTableColumnDic = {
  383. 'alarmtime': 'trigger_time',
  384. 'area': 'state1',
  385. 'tagName': 'tag_name',
  386. 'isFirst': 'is_first',
  387. 'alarmlevel': 'state0',
  388. 'levelId': 'level',
  389. 'ensureinfo': 'is_ensure',
  390. 'resetinfo': 'is_reset',
  391. 'state': '',
  392. 'alarmshuoming': 'alarm_message',
  393. 'alarmGroup': 'group_name',
  394. 'desc': 'user_data0',
  395. 'value': 'value',
  396. }
  397. function getFlag() {
  398. // 获取当前时间戳(以ms为单位)
  399. var timestamp = new Date().getTime().toString();
  400. return timestamp;
  401. }
  402. //获取报警组
  403. function getAlarmGroups(callback) {
  404. callback = callback || function () { };
  405. var reqData = {
  406. "method": "GetGroups",
  407. "param": {}
  408. };
  409. var flagnum = "group";
  410. var eventName = "/alarm/doservice?" + flagnum;
  411. var dataTypes = [];
  412. dataTypes.push("*");
  413. //console.log('报警组----'+flagnum);
  414. if (!GD.isEmptyObj(alarmGroupDic)) {
  415. callback(alarmGroupDic);
  416. return;
  417. }
  418. socket.alarmPost(eventName, reqData, function (data) {
  419. if (data.success) {
  420. var DataType = data.data.data;
  421. for (var i = 0; i < DataType.length; i++) {
  422. alarmGroupDic[DataType[i].group_name] = DataType[i];
  423. alarmGroupDicName[DataType[i].id] = DataType[i];
  424. dataTypes.push(DataType[i].group_name);
  425. }
  426. }
  427. callback(alarmGroupDic);
  428. });
  429. return dataTypes;
  430. }
  431. //根据组名称获取组ID
  432. /*function getAlarmGroupNameByName(groupName){
  433. return alarmGroupDic[groupName].id;
  434. }
  435. getAlarmGroupNameByName();*/
  436. //根据报警类型名称获取报警类型ID
  437. function getAlarmCateByName(cateName) {
  438. if (cateName == null || cateName.length <= 0) return 0;
  439. for (var key in alarmCategoryDicName) {
  440. return alarmCategoryDicName[key].id;
  441. }
  442. }
  443. function getAlarmSnapshort(flagnum, callback, isAll) {
  444. callback = callback || function () { };
  445. var extra = GD.getParams('extra') || {},//获取用户所属区域
  446. userArea = extra.area || '*';
  447. var condition = getFilterCondition(userArea, "*", null, null, null);
  448. var reqData = {
  449. page_no: 0,
  450. page_size: 500,
  451. "condition": condition
  452. };
  453. var eventName = "/alarm/getSnapshots?" + flagnum;
  454. socket.alarmPost(eventName, reqData, function (data) {
  455. if (!isAll) {
  456. callback(data);
  457. return ;
  458. }
  459. if (data && data.success) {
  460. var total = data.data.total;
  461. if (total < 500) {
  462. callback(data);
  463. return ;
  464. }
  465. reqData.page_size = total;
  466. socket.alarmPost(eventName, reqData, function (_data) {
  467. callback(_data);
  468. })
  469. } else {
  470. callback(data);
  471. }
  472. })
  473. }
  474. function refreshAlarmInfoWindow() {
  475. var flagnum = 'snapshotwindow';
  476. getAlarmSnapshort(flagnum, function (data) {
  477. if (data && data.success) {
  478. var total = data.data.total;
  479. alarmData = data.data.data || [];
  480. // 弹窗 条件:(popup || is_first===1) && is_ensure === 0
  481. (function (alarmData, total) {
  482. var ad = [], d, state0;
  483. for (var i = 0, len = alarmData.length; i < len; i++) {
  484. d = alarmData[i] || {};
  485. state0 = d.state0 || '0';
  486. if (d.is_first === 1 || alarmLevelDic[state0] && alarmLevelDic[state0].popup == 1) {
  487. if (d.is_ensure === 0)
  488. ad.push(d);
  489. }
  490. }
  491. setTimeout(function () {
  492. if (typeof (alarmAreasDic) != "undefined") {
  493. AlarmInfoShow(ad, ad.length, alarmDialogStyle);
  494. }
  495. }, 100);
  496. })(alarmData, total);
  497. }
  498. }, true)
  499. }
  500. var dataTypes = [];
  501. dataTypes.push("*");
  502. var DataType;
  503. //获取报警级别
  504. function getAlarmLevels() {
  505. var reqData = {
  506. "method": "GetLevels",
  507. "param": {}
  508. };
  509. // var flagnum = getFlag();
  510. var flagnum = "level";
  511. var eventName = "/alarm/doservice?" + flagnum;
  512. socket.alarmPost(eventName, reqData, function (data) {
  513. if (data && data.success) {
  514. _alarmLevelArray = [];
  515. DataType = data.data.data;
  516. for (var i = 0; i < DataType.length; i++) {
  517. alarmId = i + 1;
  518. alarmLevelDic[DataType[i].level] = DataType[i];
  519. alarmLevelDicName[DataType[i].level_name] = DataType[i];
  520. dataTypes.push(DataType[i].level_name);
  521. _alarmLevelArray.push(DataType[i].level_name);
  522. }
  523. alarmFilterState = true;
  524. isRealFirst = 1;
  525. //获取实时页面上的故障信息
  526. isRealFirst = null;
  527. flagnum = 'snapshotgz';
  528. getAlarmSnapshort(flagnum, function (data) {
  529. if (data && data.success) {
  530. var total = data.data.total;
  531. alarmData = data.data.data || [];
  532. // 弹窗 条件:(popup || is_first===1) && is_ensure === 0
  533. (function (alarmData, total) {
  534. var ad = [], d, state0;
  535. for (var i = 0, len = alarmData.length; i < len; i++) {
  536. d = alarmData[i] || {};
  537. state0 = d.state0 || '';
  538. if (d.is_first === 1 || alarmLevelDic[state0] && alarmLevelDic[state0].popup == 1) {
  539. if (d.is_ensure === 0)
  540. ad.push(d);
  541. }
  542. }
  543. setTimeout(function () {
  544. if (typeof (alarmAreasDic) != "undefined") {
  545. AlarmInfoShow(ad, ad.length, alarmDialogStyle);
  546. }
  547. }, 500);
  548. })(alarmData, total);
  549. var timenum = getFlag();
  550. socket.alarmPost("/alarm/SubscribeNotify?" + timenum, function (data) {
  551. if (data[0] == "alarm_notify") {
  552. var aladata = data[1];
  553. var refreshWindowFlag = false,
  554. refreshListFlag = false;
  555. var len = alarmData.length, state0, d;
  556. for (var j = 0; j < aladata.length; j++) {
  557. d = aladata[j] || {};
  558. // if (typeof realdataModelReal != "undefined") {
  559. // var b = true;
  560. // attrobject = aladata[j];
  561. // if (alarmStateValueReal != "*") {
  562. // var fieldValue = alarmStatesDic[alarmStateValueReal];
  563. // if (fieldValue.split('=')[0] == "is_ensure") {
  564. // b = (attrobject.is_ensure == fieldValue.split('=')[1]);
  565. // } else if (fieldValue.split('=')[0] == "is_reset") {
  566. // b = (attrobject.is_reset == fieldValue.split('=')[1]);
  567. // }
  568. // }
  569. // if (dataAreaNameReal == "*" || attrobject.state1 == alarmAreaDicName[dataAreaNameReal].id) {
  570. // if (alarmGroupValueReal == "*" || attrobject.state2 == alarmGroupDic[alarmGroupValueReal].id) {
  571. // if ((alarmLevelValueReal.indexOf(alarmLevelDic[attrobject.state0].level_name) != -1 || alarmLevelValueReal == "*") && isRealFirst == attrobject.is_first) {
  572. // if (alarmStateValueReal == "*" || b) {
  573. // pageinputReal.value = 1;
  574. // getRealAlarmInfos(realdataModelReal, tablePaneReal, pageinputReal.value, rowssizeReal.getValue(), pageCountReal, dataAreaNameReal, alarmGroupValueReal, alarmLevelValueReal, alarmStateValueReal);
  575. // }
  576. // }
  577. // }
  578. // }
  579. // }
  580. //弹窗的条件
  581. //未确认未恢复 并且(在报警客户端设置了弹窗或者首出故障)
  582. state0 = d.state0;
  583. if (((alarmLevelDic[state0] && alarmLevelDic[state0].popup === 1) || d.is_first === 1)) {
  584. /*
  585. if (d.is_ensure === 0 && d.is_reset === 0) { // 未确认未恢复
  586. alarmData = alarmData.concat(d);
  587. AlarmInfoShow(alarmData, len, alarmDialogStyle);
  588. }
  589. else if (d.is_ensure === 1) {
  590. for (var k = 0; k < alarmData.length; k++) {
  591. if (alarmData[k].tag_name == d.tag_name) {
  592. alarmData.splice(k, 1);
  593. }
  594. }
  595. if (alarmData.length != 0) {
  596. len = alarmData.length - 1;
  597. } else {
  598. len = 0;
  599. }
  600. AlarmInfoShow(alarmData, len, alarmDialogStyle);
  601. }
  602. */
  603. !refreshWindowFlag && (refreshWindowFlag = true);
  604. }
  605. }
  606. refreshWindowFlag && refreshAlarmInfoWindow();
  607. if (refreshWindowFlag) {
  608. } else {
  609. realdataModelReal && getRealAlarmInfos(realdataModelReal, tablePaneReal, pageinputReal.value, rowssizeReal.getValue(), pageCountReal, dataAreaNameReal, alarmGroupValueReal, alarmLevelValueReal, alarmStateValueReal);
  610. }
  611. }
  612. });
  613. }
  614. }, true)
  615. }
  616. });
  617. // return dataTypes;
  618. }
  619. function getAlarmLevelsData(callback) {
  620. callback = callback || function () { };
  621. if (!GD.isEmptyObj(alarmLevelDic)) {
  622. callback(alarmLevelDic);
  623. return;
  624. }
  625. var reqData = {
  626. "method": "GetLevels",
  627. "param": {}
  628. };
  629. // var flagnum = getFlag();
  630. var flagnum = "level";
  631. var eventName = "/alarm/doservice?" + flagnum;
  632. socket.alarmPost(eventName, reqData, function (data) {
  633. if (data && data.success) {
  634. DataType = data.data.data;
  635. for (var i = 0; i < DataType.length; i++) {
  636. alarmId = i + 1;
  637. alarmLevelDic[DataType[i].level] = DataType[i];
  638. alarmLevelDicName[DataType[i].level_name] = DataType[i];
  639. dataTypes.push(DataType[i].level_name);
  640. }
  641. callback(alarmLevelDic);
  642. } else {
  643. callback({});
  644. }
  645. });
  646. }
  647. // 获取系统信息
  648. function getAlarmSystem(cb) {
  649. var reqData = {
  650. "method": "GetSystem",
  651. "param": {}
  652. };
  653. //var flagnum = getFlag();
  654. var flagnum = "system";
  655. //console.log("系统信息----"+flagnum);
  656. var eventName = "/alarm/doservice?" + flagnum;
  657. socket.alarmPost(eventName, reqData, function (data) {
  658. if (data && data.success && data.data) {
  659. return cb(data.data.data);
  660. }
  661. cb([]);
  662. })
  663. }
  664. //根据等级名称获取等级ID
  665. function getAlarmLevelNameByName(levelName) {
  666. for (var key in alarmLevelDicName) {
  667. return alarmLevelDicName[key].level;
  668. }
  669. }
  670. //获取报警等级表
  671. function getAlarmLevelTables(model, node) {
  672. model.clear();
  673. var reqData = {
  674. "method": "GetLevels",
  675. "param": {}
  676. };
  677. // var flagnum = getFlag();
  678. var flagnum = "levels";
  679. var eventName = "/alarm/doservice?" + flagnum;;
  680. socket.alarmPost(eventName, reqData, function (data) {
  681. if (data && data.success) {
  682. var alarmLevels = data.data.data;
  683. var values = [];
  684. var datalen = alarmLevels.length;
  685. var lineColor = [];
  686. for (var i = 0; i < datalen; i++) {
  687. data = new ht.Data();
  688. data.setId(i + 1);
  689. data.a('alarmName', alarmLevels[i].level_name);
  690. data.a('wavName', alarmLevels[i].wave_file);
  691. data.a('alarmColor', ARGB2HexString(alarmLevels[i].alarm_color));
  692. data.a('resetColor', ARGB2HexString(alarmLevels[i].reset_color));
  693. data.a('confirmColor', ARGB2HexString(alarmLevels[i].ensure_color));
  694. data.a('normalColor', ARGB2HexString(alarmLevels[i].normal_color));
  695. data.a('islight', alarmLevels[i].popup == 1 ? "是" : "否");
  696. data.a('alarmLevel', alarmLevels[i].level);
  697. model.add(data);
  698. }
  699. model.sm().ss(data);
  700. }
  701. });
  702. }
  703. //删除报警等级
  704. function deleteAlarmLevels(levelIds) {
  705. var reqData = {
  706. "method": "DeleteLevel",
  707. "param": {
  708. level: Number(levelIds)
  709. }
  710. };
  711. // var flagnum = getFlag();
  712. var flagnum = "deletelevel";
  713. var eventName = "/alarm/doservice?" + flagnum;;
  714. socket.alarmPost(eventName, reqData, function (data) { })
  715. }
  716. //批量添加/修改报警等级
  717. function updateAlarmLevels(alarmLevels) {
  718. var reqData = {
  719. "method": "UpdateLevel",
  720. "param": alarmLevels
  721. };
  722. // var flagnum = getFlag();
  723. var flagnum = "updatelevel";
  724. var eventName = "/alarm/doservice?" + flagnum;;
  725. socket.alarmPost(eventName, reqData, function (data) { })
  726. }
  727. //获取报警类别
  728. function getAlarmCategories(callback) {
  729. callback = callback || function () { };
  730. var reqData = {
  731. "method": "GetCategories",
  732. "param": {}
  733. };
  734. // var flagnum = getFlag();
  735. var flagnum = "category";
  736. var eventName = "/alarm/doservice?" + flagnum;;
  737. var dataTypes = [];
  738. dataTypes.push("*");
  739. if (!GD.isEmptyObj(alarmCategoryDic)) {
  740. callback(alarmCategoryDic);
  741. return;
  742. }
  743. socket.alarmPost(eventName, reqData, function (data) {
  744. if (data && data.success) {
  745. var DataType = data.data.data;
  746. for (var i = 0; i < DataType.length; i++) {
  747. alarmCategoryDic[DataType[i].id] = DataType[i];
  748. alarmCategoryDicName[DataType[i].category_name] = DataType[i];
  749. dataTypes.push(DataType[i].category_name);
  750. }
  751. callback(alarmCategoryDic);
  752. } else {
  753. callback({});
  754. }
  755. });
  756. return dataTypes;
  757. }
  758. //获取报警类型列表
  759. function getAlarmCateTables(model) {
  760. model.clear();
  761. var reqData = {
  762. "method": "GetCategories",
  763. "param": {}
  764. };
  765. // var flagnum = getFlag();
  766. var flagnum = "categories";
  767. var eventName = "/alarm/doservice?" + flagnum;
  768. socket.alarmPost(eventName, reqData, function (data) {
  769. if (data && data.success) {
  770. var alarmCates = data.data.data;
  771. var datalen = alarmCates.length;
  772. for (var i = 0; i < datalen; i++) {
  773. data = new ht.Data();
  774. data.a('alarmCateId', alarmCates[i].id);
  775. data.a('alarmCateName', alarmCates[i].category_name);
  776. model.add(data);
  777. }
  778. model.sm().ss(data);
  779. }
  780. });
  781. }
  782. //批量修改报警类型
  783. function updateAlarmCates(alarmCates) {
  784. var reqData = {
  785. "method": "UpdateCategory",
  786. "param": alarmCates
  787. };
  788. //var flagnum = getFlag();
  789. var flagnum = "updatecategory";
  790. var eventName = "/alarm/doservice?" + flagnum;
  791. socket.alarmPost(eventName, reqData, function (data) { })
  792. }
  793. //删除报警类型
  794. function deleteAlarmCates(cateIds) {
  795. var reqData = {
  796. "method": "DeleteCategory",
  797. "param": {
  798. id: Number(cateIds)
  799. }
  800. };
  801. //var flagnum = getFlag();
  802. var flagnum = "deletecategory";
  803. var eventName = "/alarm/doservice?" + flagnum;
  804. socket.alarmPost(eventName, reqData, function (data) { })
  805. }
  806. //获取报警分组表
  807. function getAlarmGropTables(model) {
  808. var reqData = {
  809. "method": "GetGroups",
  810. "param": {}
  811. };
  812. // var flagnum = getFlag();
  813. var flagnum = "groups";
  814. var eventName = "/alarm/doservice?" + flagnum;
  815. socket.alarmPost(eventName, reqData, function (data) {
  816. if (!data) return;
  817. model.clear();
  818. var alarmGroup = data && data.data.data || [];
  819. var values = [];
  820. var datalen = alarmGroup.length;
  821. for (var i = 0; i < datalen; i++) {
  822. data = new ht.Data();
  823. data.setId(alarmGroup[i].id);
  824. data.a('groupName', alarmGroup[i].group_name);
  825. model.add(data);
  826. }
  827. // model.sm().ss(data);
  828. });
  829. }
  830. //添加或更新报警组信息
  831. function updateAlarmGroup(alarmGroups) {
  832. var reqData = {
  833. "method": "UpdateGroup",
  834. "param": alarmGroups
  835. };
  836. // var flagnum = getFlag();
  837. var flagnum = "updategroup";
  838. var eventName = "/alarm/doservice?" + flagnum;;
  839. socket.alarmPost(eventName, reqData, function (data) { })
  840. }
  841. //删除分组
  842. function deleteAlarmGrop(gropIds) {
  843. var reqData = {
  844. "method": "DeleteGroup",
  845. "param": {
  846. id: Number(gropIds)
  847. }
  848. };
  849. //var flagnum = getFlag();
  850. var flagnum = "deletegroup";
  851. var eventName = "/alarm/doservice?" + flagnum;;
  852. socket.alarmPost(eventName, reqData, function (data) { })
  853. }
  854. //获取报警区域
  855. function getAlarmAreas(callback) {
  856. callback = callback || function () { };
  857. var reqData = {
  858. "method": "GetAreas",
  859. "param": {}
  860. };
  861. // var flagnum = getFlag();
  862. var flagnum = "areas";
  863. // console.log("报警区域---"+flagnum);
  864. var eventName = "/alarm/doservice?" + flagnum;;
  865. var dataTypes = [];
  866. dataTypes.push("*");
  867. socket.alarmPost(eventName, reqData, function (data) {
  868. if (data && data.success) {
  869. var DataType = data.data.data;
  870. var nameid;
  871. for (var i = 0; i < DataType.length; i++) {
  872. nameid=DataType[i].area_name+DataType[i].id;
  873. dataTypes.push(DataType[i].area_name);
  874. alarmAreaDicName[DataType[i].area_name] = DataType[i];
  875. alarmAreaDicNameId[nameid] = DataType[i];
  876. alarmAreasDic[DataType[i].id] = DataType[i].area_name;
  877. }
  878. callback(DataType);
  879. }
  880. else {
  881. callback({});
  882. }
  883. /*getAlarmAreasDicName(DataType);
  884. if(currentControlContent.indexOf("realalarm")!=-1){
  885. getRealAlarmInfos(realdataModelReal,tablePaneReal,1,20,pageCountReal,currentAreaName,pointtypeReal,alarmCateValueReal,alarmLevelValueReal);
  886. }
  887. if(currentControlContent.indexOf("alarmpointconfig")!=-1){
  888. getAlarmPoints(dataModelPointConfig,1,20,pageCountPointConfig,currentAreaName,pointtypePointConfig);
  889. }
  890. if(currentControlContent.indexOf("hisalarm")!=-1){
  891. getHisAlarmInfos(hisdataModelHis,tablePaneHis,1,20,pageCountHis,currentAreaName,pointtypeHis,alarmCateValueHis,alarmLevelValueHis);
  892. }*/
  893. });
  894. return dataTypes;
  895. }
  896. //添加或更新报警区域信息
  897. function updateAlarmArea(alarmAreas) {
  898. var reqData = {
  899. "method": "UpdateArea",
  900. "param": alarmAreas
  901. };
  902. //var flagnum = getFlag();
  903. var flagnum = "updatearea";
  904. var eventName = "/alarm/doservice?" + flagnum;;
  905. socket.alarmPost(eventName, reqData, function (data) { })
  906. }
  907. //删除报警区域信息
  908. function deleteAlarmArea(areaId) {
  909. var reqData = {
  910. "method": "DeleteArea",
  911. "param": {
  912. id: Number(areaId)
  913. }
  914. };
  915. // var flagnum = getFlag();
  916. var flagnum = "deletearea";
  917. var eventName = "/alarm/doservice?" + flagnum;;
  918. socket.alarmPost(eventName, reqData, function (data) { })
  919. }
  920. //获取报警区域表
  921. function getAlarmAreaTables(model) {
  922. var reqData = {
  923. "method": "GetAreas",
  924. "param": {}
  925. };
  926. // var flagnum = getFlag();
  927. var flagnum = "getareas";
  928. var eventName = "/alarm/doservice?" + flagnum;;
  929. socket.alarmPost(eventName, reqData, function (data) {
  930. if (!data) return;
  931. model.clear();
  932. var alarmArea = data.data && data.data.data || [];
  933. var values = [];
  934. var datalen = alarmArea.length;
  935. for (var i = 0; i < datalen; i++) {
  936. data = new ht.Data();
  937. data.setId(alarmArea[i].id);
  938. data.a('areaName', alarmArea[i].area_name);
  939. data.a('parentId', alarmArea[i].parent_id);
  940. model.add(data);
  941. }
  942. // model.sm().ss(data);
  943. });
  944. }
  945. //获取区域字典信息
  946. function getAlarmAreasDicName(children) {
  947. if (children.length > 0) {
  948. for (var i = 0; i < children.length; i++) {
  949. if (alarmAreaDicName[children[i].area_name] > 0) {
  950. continue;
  951. }
  952. alarmAreaDicName[children[i].area_name] = children[i].id;
  953. // if(children[i].Children.length>0){
  954. // getAlarmAreasDicName(children[i].Children);
  955. // }
  956. }
  957. }
  958. }
  959. function getAreaDic(areaInfos) {
  960. if (areaInfos.length > 0) {
  961. for (var i = 0; i < areaInfos.length; i++) {
  962. if (alarmAreasDic[areaInfos[i].Id] == areaInfos[i].Id) {
  963. continue;
  964. }
  965. alarmAreasDic[areaInfos[i].Id] = areaInfos[i];
  966. if (areaInfos[i].Children.length) {
  967. getAreaDic(areaInfos[i].Children);
  968. }
  969. }
  970. }
  971. }
  972. //等待
  973. function sleep(numberMillis) {
  974. var now = new Date();
  975. var exitTime = now.getTime() + numberMillis;
  976. while (true) {
  977. now = new Date();
  978. if (now.getTime() > exitTime)
  979. return;
  980. }
  981. }
  982. //获取条件搜索集合
  983. function getFilterCondition(dataAreaName, alarmlevel, alarmgroup, startTime, endTime, alarmstate) {
  984. var condition = [];
  985. if (dataAreaName != null && dataAreaName != "*") {
  986. // var conditionAreaId = new FieldCondition();
  987. // conditionAreaId.field = "state1";
  988. // conditionAreaId.value = alarmAreaDicName[dataAreaName].id;
  989. // conditionAreaId.method = 0;
  990. // condition.push(conditionAreaId);
  991. // getAreaIds(alarmAreaDicName[dataAreaName].id);
  992. if (typeof (alarmAreaDicName[dataAreaName]) == "undefined") {
  993. var conditionAreaId = new FieldCondition();
  994. conditionAreaId.field = "state1";
  995. conditionAreaId.value = -1;
  996. conditionAreaId.method = 0;
  997. condition.push(conditionAreaId);
  998. } else {
  999. for (var i = 0; i < alarmAreaIds.length; i++) {
  1000. var conditionAreaId = new FieldCondition();
  1001. conditionAreaId.field = "state1";
  1002. conditionAreaId.value = alarmAreaIds[i];
  1003. conditionAreaId.method = 0;
  1004. condition.push(conditionAreaId);
  1005. }
  1006. }
  1007. // console.log(alarmAreaIds);
  1008. }
  1009. /*if(pointtype!=null && pointtype!="*"){
  1010. var conditionPointType=new FieldCondition();
  1011. conditionPointType.field="TagType";
  1012. conditionPointType.value=DataType[pointtype];
  1013. conditionPointType.method=0;
  1014. condition.push(conditionPointType);
  1015. }*/
  1016. /*if(alarmcate!=null && alarmcate!="*"){
  1017. var conditionPointType=new FieldCondition();
  1018. conditionPointType.field="AlarmCategoryId";
  1019. conditionPointType.value=alarmCategoryDicName[alarmcate].Id;
  1020. conditionPointType.method=0;
  1021. condition.push(conditionPointType);
  1022. }*/
  1023. if (alarmlevel != null && alarmlevel != "*") {
  1024. // if (alarmLevelVisible) {
  1025. // var conditionLevelInfo = new FieldCondition();
  1026. // conditionLevelInfo.field = "state0";
  1027. // conditionLevelInfo.value = alarmLevelDicName[alarmlevel].level;
  1028. // conditionLevelInfo.method = 0;
  1029. // condition.push(conditionLevelInfo);
  1030. // } else {
  1031. // for (var i = 0; i < alarmlevel.length; i++) {
  1032. // var conditionLevelInfo = new FieldCondition();
  1033. // conditionLevelInfo.field = "state0";
  1034. // if (JSON.stringify(alarmLevelDicName) != "{}") {
  1035. // conditionLevelInfo.value = alarmLevelDicName[alarmlevel[i]].level; //getAlarmLevelNameByName(alarmlevel);
  1036. // }
  1037. // conditionLevelInfo.method = 0;
  1038. // condition.push(conditionLevelInfo);
  1039. // }
  1040. // }
  1041. for (var i = 0; i < alarmlevel.length; i++) {
  1042. if (alarmlevel[i] != "*") {
  1043. var conditionLevelInfo = new FieldCondition();
  1044. conditionLevelInfo.field = "state0";
  1045. if (JSON.stringify(alarmLevelDicName) != "{}") {
  1046. conditionLevelInfo.value = alarmLevelDicName[alarmlevel[i]] && alarmLevelDicName[alarmlevel[i]].level; //getAlarmLevelNameByName(alarmlevel);
  1047. }
  1048. conditionLevelInfo.method = 0;
  1049. condition.push(conditionLevelInfo);
  1050. }
  1051. }
  1052. }
  1053. if (alarmgroup != null && alarmgroup != "*") {
  1054. var contionGroupInfo = new FieldCondition();
  1055. contionGroupInfo.field = "state2";
  1056. contionGroupInfo.value = alarmGroupDic[alarmgroup] && alarmGroupDic[alarmgroup].id || "*";
  1057. contionGroupInfo.method = 0;
  1058. condition.push(contionGroupInfo);
  1059. }
  1060. if (startTime) {
  1061. var contionTimeInfo = new FieldCondition();
  1062. contionTimeInfo.field = "alarm_time";
  1063. contionTimeInfo.value = new Date(startTime).getTime(); //new Date(startTime).getTime()/1000;
  1064. contionTimeInfo.method = 1;
  1065. condition.push(contionTimeInfo);
  1066. }
  1067. if (endTime) {
  1068. var contionTimeInfo = new FieldCondition();
  1069. contionTimeInfo.field = "alarm_time";
  1070. contionTimeInfo.value = new Date(endTime).getTime(); //new Date(endTime).getTime()/1000;
  1071. contionTimeInfo.method = 2;
  1072. condition.push(contionTimeInfo);
  1073. }
  1074. if (isHisFirst != null && (endTime != null || startTime != null)) {
  1075. var contionInfo = new FieldCondition();
  1076. contionInfo.field = "is_first";
  1077. contionInfo.value = isHisFirst; //new Date(endTime).getTime()/1000;
  1078. contionInfo.method = 0;
  1079. condition.push(contionInfo);
  1080. }
  1081. if (isRealFirst != null && endTime == null && startTime == null) {
  1082. var contionInfo = new FieldCondition();
  1083. contionInfo.field = "is_first";
  1084. contionInfo.value = isRealFirst; //new Date(endTime).getTime()/1000;
  1085. contionInfo.method = 0;
  1086. condition.push(contionInfo);
  1087. }
  1088. if (alarmstate != null && alarmstate != "*") {
  1089. var contionStateInfo = new FieldCondition();
  1090. contionStateInfo.field = alarmStatesDic[alarmstate].split('=')[0];
  1091. contionStateInfo.value = alarmStatesDic[alarmstate].split('=')[1];
  1092. contionStateInfo.method = 0;
  1093. condition.push(contionStateInfo);
  1094. }
  1095. return condition;
  1096. }
  1097. //设置报警点屏蔽属性
  1098. function setAlarmShield(tagName, value) {
  1099. var tagnames = tagName.split(',');
  1100. socket.emit('goldenalarm.setAlarmShield', {
  1101. "TagNames": tagnames,
  1102. "IsShield": value
  1103. });
  1104. socket.once('goldenalarm.setAlarmShield', function (data) {
  1105. if (data.result.ecode == "Ok") { }
  1106. });
  1107. }
  1108. //删除报警点
  1109. function deleteAlarmPoints(tagaName) {
  1110. var reqData = tagaName;
  1111. var eventName = "/alarm/deleteTags";
  1112. socket.alarmPost(eventName, reqData, function (data) { })
  1113. }
  1114. //添加或更新报警点
  1115. function updateAlarmPoints(alarmPoints) {
  1116. var reqData = alarmPoints;
  1117. var eventName = "/alarm/appendTags";
  1118. socket.alarmPost(eventName, reqData, function (data) { })
  1119. }
  1120. //获取实时报警信息
  1121. //realdataModelReal,tablePaneReal,pageinputReal.value,rowssizeReal.getValue(),pageCountReal,dataAreaNameReal,pointtypeReal,alarmCateValueReal,alarmLevelValueReal
  1122. function getRealAlarmInfos(model, node, pageIndex, pageSize, pageCount, dataAreaName, alarmGroup, alarmlevel, alarmstate) {
  1123. var condition = getFilterCondition(dataAreaName, alarmlevel, alarmGroup, null, null, alarmstate);
  1124. var reqData = {
  1125. page_no: pageIndex - 1,
  1126. page_size: pageSize,
  1127. "condition": condition
  1128. };
  1129. // var flagnum = getFlag();
  1130. var flagnum = "snapshot";
  1131. var eventName = "/alarm/getSnapshots?" + flagnum;
  1132. socket.alarmPost(eventName, reqData, function (data) {
  1133. if (data && data.success) {
  1134. model.clear();
  1135. var alarmRealInfos = data.data.data;
  1136. pageCount.setValue(Math.ceil(data.data.page_count));
  1137. var pageNumData = toolbar2Real && toolbar2Real.getItemById('realAlarmTotalPageNum') || {};
  1138. pageNumData.label = '共 '+ (data.data.page_count || 1) +' 页';
  1139. toolbar2Real && toolbar2Real.redraw();
  1140. var datalen = alarmRealInfos.length;
  1141. var lineColor = [];
  1142. var resetColor = [];
  1143. var ensureColor = [];
  1144. var isEnsures = [];
  1145. var isResets = [];
  1146. for (var i = 0; i < datalen; i++) {
  1147. data = new ht.Data();
  1148. data.setId(i + 1);
  1149. data.a('tagName', alarmRealInfos[i].tag_name);
  1150. data.a('groupName', alarmGroupDicName[alarmRealInfos[i].state2] && alarmGroupDicName[alarmRealInfos[i].state2].group_name);
  1151. data.a('desc', alarmRealInfos[i].user_data0);
  1152. data.a('value', GetDital(alarmRealInfos[i].value, 2));
  1153. data.a('ensureinfo', alarmRealInfos[i].is_ensure);
  1154. data.a('resetinfo', alarmRealInfos[i].is_reset);
  1155. data.a('isFirst', alarmRealInfos[i].is_first);
  1156. var date = new Date();
  1157. // date.setTime(alarmRealInfos[i].alarm_time);
  1158. date.setTime(alarmRealInfos[i].trigger_time);
  1159. data.a('alarmtime', moment(date).format("YYYY-MM-DD HH:mm:ss"));
  1160. data.a('area', alarmAreasDic[alarmRealInfos[i].state1]);
  1161. if (typeof alarmLevelDic[alarmRealInfos[i].state0] != "undefined") {
  1162. data.a('alarmlevel', alarmLevelDic[alarmRealInfos[i].state0].level_name);
  1163. }
  1164. data.a("levelId", alarmRealInfos[i].state0);
  1165. if (!alarmRealInfos[i].is_ensure) {
  1166. if (alarmRealInfos[i].is_reset) {
  1167. data.a('state', "未确认|已恢复");
  1168. } else {
  1169. data.a('state', "未确认|未恢复");
  1170. }
  1171. } else {
  1172. if (!alarmRealInfos[i].is_reset) {
  1173. data.a('state', "已确认|未恢复");
  1174. } else {
  1175. data.a('state', "已确认|已恢复");
  1176. }
  1177. }
  1178. data.a('alarmshuoming', alarmRealInfos[i].alarm_message);
  1179. if (typeof alarmGroupDicName[alarmRealInfos[i].state2] != "undefined") {
  1180. data.a('alarmGroup', alarmGroupDicName[alarmRealInfos[i].state2].group_name);
  1181. }
  1182. model.add(data);
  1183. isEnsures.push(alarmRealInfos[i].is_ensure);
  1184. isResets.push(alarmRealInfos[i].is_reset);
  1185. }
  1186. setTimeout(function () {
  1187. node && node.getTableView && node.getTableView().redraw();
  1188. }, 100);
  1189. }
  1190. });
  1191. }
  1192. // 获取实时报警数据
  1193. function getRealAlarmData(callback) {
  1194. callback = callback || function () { };
  1195. var reqData = {
  1196. page_no: pageIndex - 1,
  1197. page_size: pageSize,
  1198. "condition": condition
  1199. };
  1200. // var flagnum = getFlag();
  1201. var flagnum = "snapshot";
  1202. var eventName = "/alarm/getSnapshots?" + flagnum;
  1203. socket.alarmPost(eventName, reqData, callback);
  1204. }
  1205. //获取历史报警信息
  1206. function getHisAlarmInfos(model, node, pageIndex, pageSize, pageCountHis, dataAreaName, dataareaGroup, alarmlevel, startTime, endTime, alarmStateValueHis) {
  1207. searchHisAlarmInfos(pageIndex, pageSize, dataAreaName, dataareaGroup, alarmlevel, startTime, endTime, alarmStateValueHis, function (_data) {
  1208. if (!GD.isEmptyObj(_data)) {
  1209. var alarmHisInfos = _data.data;
  1210. pageCountHis.setValue && pageCountHis.setValue(_data.page_count);
  1211. var pageNumData = toolbar2His && toolbar2His.getItemById('hisAlarmTotalPageNum') || {};
  1212. pageNumData.label = '共 '+ (_data.page_count || 1) +' 页';
  1213. toolbar2His && toolbar2His.redraw();
  1214. var datalen = alarmHisInfos.length,
  1215. alarmnHisInfo;
  1216. model.clear();
  1217. for (var i = 0; i < datalen; i++) {
  1218. data = new ht.Data();
  1219. data.setId(i + 1);
  1220. var date = new Date();
  1221. alarmnHisInfo = alarmHisInfos[i];
  1222. // date.setTime(alarmHisInfos[i].alarm_time);
  1223. date.setTime(alarmnHisInfo.trigger_time);
  1224. data.a('alarmtime', moment(date).format("YYYY-MM-DD HH:mm:ss"));
  1225. data.a('area', alarmAreasDic[alarmnHisInfo.state1]);
  1226. data.a('tagName', alarmnHisInfo.tag_name);
  1227. data.a('isFirst', alarmnHisInfo.is_first);
  1228. if (alarmLevelDic[alarmnHisInfo.state0]) {
  1229. data.a('alarmlevel', alarmLevelDic[alarmnHisInfo.state0].level_name);
  1230. }
  1231. /*if(typeof alarmLevelDic[alarmnHisInfo.state0]!="undefined"){
  1232. data.a('alarmlevel',alarmLevelDic[alarmnHisInfo.state0].level_name);
  1233. }*/
  1234. //alarmlevelId
  1235. data.a('levelId', alarmLevelDic[alarmnHisInfo.state0] && alarmLevelDic[alarmnHisInfo.state0].level);
  1236. data.a('ensureinfo', alarmnHisInfo.is_ensure);
  1237. data.a('resetinfo', alarmnHisInfo.is_reset);
  1238. // if (!alarmnHisInfo.is_ensure) {
  1239. // data.a('state', "未确认");
  1240. // } else {
  1241. // if (!alarmnHisInfo.is_ensure) {
  1242. // data.a('state', "已确认");
  1243. // } else {
  1244. // data.a('state', "已复位");
  1245. // }
  1246. // }
  1247. if (!alarmnHisInfo.is_ensure) {
  1248. if (alarmnHisInfo.is_reset) {
  1249. data.a('state', "未确认|已恢复");
  1250. } else {
  1251. data.a('state', "未确认|未恢复");
  1252. }
  1253. } else {
  1254. if (!alarmnHisInfo.is_reset) {
  1255. data.a('state', "已确认|未恢复");
  1256. } else {
  1257. data.a('state', "已确认|已恢复");
  1258. }
  1259. }
  1260. data.a('alarmshuoming', alarmnHisInfo.alarm_message);
  1261. if (alarmGroupDicName[alarmnHisInfo.state2]) {
  1262. data.a('alarmGroup', alarmGroupDicName[alarmnHisInfo.state2].group_name);
  1263. }
  1264. data.a('desc', alarmnHisInfo.user_data0);
  1265. data.a('value', GetDital(alarmnHisInfo.value, 2));
  1266. data.a('', alarmnHisInfo.message);
  1267. //data.a('alarmtime', alarmnHisInfo.alarm_time);
  1268. //data.a('alarmRecoveTime', alarmnHisInfo.trigger_time);
  1269. //data.a('alarmlevel', alarmnHisInfo.state0);
  1270. //data.a('alarmOper', alarmnHisInfo.user_data0==null?"无":alarmnHisInfo.user_data0);
  1271. model.add(data);
  1272. }
  1273. }
  1274. })
  1275. }
  1276. // 查询报警历史信息
  1277. function searchHisAlarmInfos(pageIndex, pageSize, dataAreaName, dataareaGroup, alarmlevel, startTime, endTime, alarmStateValueHis, callback) {
  1278. callback = callback || function () { };
  1279. if (!GD.testSearchTime(startTime, endTime)) {
  1280. return;
  1281. }
  1282. var condition = getFilterCondition(dataAreaName, alarmlevel, dataareaGroup, startTime, endTime, alarmStateValueHis);
  1283. var reqData = {
  1284. page_no: Number(pageIndex - 1),
  1285. page_size: pageSize,
  1286. "condition": condition
  1287. };
  1288. var flagnum = "searchhistory";
  1289. //var reqData = {page_no:pageIndex,page_size:pageSize,"condition":condition};
  1290. var eventName = "/alarm/getHistories?" + flagnum;
  1291. socket.alarmPost(eventName, reqData, function (data) {
  1292. if (data && data.success) {
  1293. callback(data.data || {});
  1294. } else {
  1295. callback({});
  1296. }
  1297. })
  1298. }
  1299. /*确认报警信息*/
  1300. function ensureAlarm(tagnames, callback) {
  1301. callback = callback || function () { };
  1302. var arr = tagnames;
  1303. // var flagnum = getFlag();
  1304. var flagnum = "ensure";
  1305. var eventName = "/alarm/ensure?" + flagnum;
  1306. socket.alarmPost(eventName, arr, function (data) {
  1307. callback(data)
  1308. });
  1309. }
  1310. //获取报警点
  1311. function getAlarmPoints(model, node, pageIndex, pageSize, pageCount, dataAreaName, pointtype) {
  1312. model.clear();
  1313. var condition = [];
  1314. if (dataAreaName != null && dataAreaName != "*") {
  1315. var conditionAreaId = new FieldCondition();
  1316. conditionAreaId.field = "AlarmAreaId";
  1317. conditionAreaId.value = alarmAreaDicName[dataAreaName];
  1318. conditionAreaId.method = 0;
  1319. condition.push(conditionAreaId);
  1320. }
  1321. if (pointtype != null && pointtype != "*") {
  1322. var conditionPointType = new FieldCondition();
  1323. conditionPointType.field = "TagType";
  1324. conditionPointType.value = DataType[pointtype];
  1325. conditionPointType.method = 0;
  1326. condition.push(conditionPointType);
  1327. }
  1328. var reqData = {
  1329. page_no: 0,
  1330. page_size: pageSize
  1331. };
  1332. //var flagnum = getFlag();
  1333. var flagnum = "gettags";
  1334. var eventName = "/alarm/getTags?" + flagnum;
  1335. socket.alarmPost(eventName, reqData, function (data) {
  1336. if (data && data.success) {
  1337. var alarmtagInfos = data.data.data;
  1338. //pageCount.setValue(Math.ceil(data.data.pageCount/pageSize));
  1339. var datalen = alarmtagInfos.length;
  1340. for (var i = 0; i < datalen; i++) {
  1341. data = new ht.Data();
  1342. data.setId(i + 1);
  1343. data.a('tagName', alarmtagInfos[i].tag_name);
  1344. data.a('desc', alarmtagInfos[i].description);
  1345. model.add(data);
  1346. }
  1347. // model.sm().ss(data);
  1348. }
  1349. })
  1350. }
  1351. //获取标签点名称
  1352. function getTags(tagDataType, tagName, tagDesc, dataModel) {
  1353. str = "http://" + webServiceIP + ":" + webServicePort + "/api/Point?tagType=" + tagDataType + "&tagNameFilter=" + tagName + "&tagDescFilter=" + tagDesc;
  1354. str = encodeURI(str);
  1355. $.ajax({
  1356. url: str,
  1357. type: 'GET',
  1358. dataType: 'json',
  1359. cache: false,
  1360. success: function (data) {
  1361. var datalen = data.length;
  1362. for (var i = 0; i < datalen; i++) {
  1363. datas = new ht.Data();
  1364. datas.setId(data[i].Id);
  1365. datas.a('configPointName', data[i].TableDotTag);
  1366. datas.a('configPointDesc', data[i].Desc);
  1367. dataModel.add(datas);
  1368. }
  1369. dataModel.sm().ss(data);
  1370. },
  1371. complete: function (XHR, TS) {
  1372. XHR = null;
  1373. }
  1374. });
  1375. }
  1376. /* 质朴长存法*/
  1377. function pad(num, radix, n) {
  1378. var hexStr = num.toString(radix)
  1379. var len = hexStr.length;
  1380. while (len < n) {
  1381. hexStr = "0" + hexStr;
  1382. len++;
  1383. }
  1384. return hexStr;
  1385. }
  1386. /*
  1387. 32位颜色值转16进制字符串
  1388. */
  1389. function ARGB2HexString(argbValue) {
  1390. var argbValue = parseInt(argbValue, 10);
  1391. var colorValue = argbValue.toString(16);
  1392. var cstr = "";
  1393. if (colorValue.length < 6) {
  1394. for (var i = 0; i < 6 - colorValue.length; i++) {
  1395. cstr += "0";
  1396. }
  1397. colorValue = cstr + colorValue;
  1398. }
  1399. return '#' + colorValue;
  1400. }
  1401. //16进制颜色转换为10进制
  1402. function ARGBToInt(argbValue) {
  1403. if (argbValue.length <= 0) return 0;
  1404. if (argbValue.indexOf("#") != -1) {
  1405. return parseInt(argbValue.substring(1, argbValue.length), 16);
  1406. }
  1407. if (argbValue.indexOf("rgb") != -1) {
  1408. var hex = argbValue.colorHex()
  1409. return parseInt(hex.substring(1, argbValue.length), 16);
  1410. }
  1411. }
  1412. GoldenAlarm.getGroupsByAreaID = function getGroupsByAreaID(id, multi, callback) {
  1413. if (arguments.length === 2 && typeof multi === 'function') {
  1414. callback = multi;
  1415. multi = false;
  1416. }
  1417. callback = callback || function () { };
  1418. var reqData = {
  1419. "method": "GetGroupsByAreaID",
  1420. "param": {
  1421. id: id,
  1422. multi: !!multi
  1423. }
  1424. };
  1425. var flagnum = "getGroupsByAreaId";
  1426. var eventName = "/alarm/doservice?" + flagnum;
  1427. socket.alarmPost(eventName, reqData, function (data) {
  1428. if (data && data.success) {
  1429. var result = data.data.data;
  1430. callback(result);
  1431. }
  1432. else {
  1433. callback({});
  1434. }
  1435. });
  1436. };
  1437. var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  1438. String.prototype.colorHex = function () {
  1439. var that = this;
  1440. if (/^(rgb|RGB)/.test(that)) {
  1441. var aColor = that.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
  1442. var strHex = "#";
  1443. for (var i = 0; i < aColor.length; i++) {
  1444. var hex = Number(aColor[i]).toString(16);
  1445. if (hex === "0") {
  1446. hex += hex;
  1447. }
  1448. strHex += hex;
  1449. }
  1450. if (strHex.length !== 7) {
  1451. strHex = that;
  1452. }
  1453. return strHex;
  1454. } else if (reg.test(that)) {
  1455. var aNum = that.replace(/#/, "").split("");
  1456. if (aNum.length === 6) {
  1457. return that;
  1458. } else if (aNum.length === 3) {
  1459. var numHex = "#";
  1460. for (var i = 0; i < aNum.length; i += 1) {
  1461. numHex += (aNum[i] + aNum[i]);
  1462. }
  1463. return numHex;
  1464. }
  1465. } else {
  1466. return that;
  1467. }
  1468. };
  1469. String.prototype.colorRgb = function () {
  1470. var sColor = this.toLowerCase();
  1471. if (sColor && reg.test(sColor)) {
  1472. if (sColor.length === 4) {
  1473. var sColorNew = "#";
  1474. for (var i = 1; i < 4; i += 1) {
  1475. sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
  1476. }
  1477. sColor = sColorNew;
  1478. }
  1479. var sColorChange = [];
  1480. for (var i = 1; i < 7; i += 2) {
  1481. sColorChange.push(parseInt("0x" + sColor.slice(i, i + 2)));
  1482. }
  1483. return "RGB(" + sColorChange.join(",") + ")";
  1484. } else {
  1485. return sColor;
  1486. }
  1487. };
  1488. //获取随机数
  1489. function GetRandomNum(Min, Max) {
  1490. var Range = Max - Min;
  1491. var Rand = Math.random();
  1492. return (Min + Math.round(Rand * Range));
  1493. }
  1494. var areaIds = "";
  1495. function DropDownBorderPane(master) {
  1496. DropDownBorderPane.superClass.constructor.call(this, master);
  1497. areaDataModel = new ht.DataModel();
  1498. var self = this,
  1499. areaborderPane = self._borderPane = new ht.widget.BorderPane(),
  1500. areatreeview = self._areatreeview = new ht.widget.TreeView(areaDataModel);
  1501. areaIds = ",";
  1502. for (var i = 0; i < alarmAreas.length; i++) {
  1503. var parent = new ht.Data();
  1504. parent.setName(alarmAreas[i].Name);
  1505. parent.setTag(name);
  1506. if (areaIds.indexOf("," + alarmAreas[i].Id + ",") == -1) {
  1507. areaIds += alarmAreas[i].Id + ",";
  1508. } else {
  1509. continue;
  1510. }
  1511. areaDataModel.add(parent);
  1512. getAreaTree(alarmAreas[i].Children, parent, areaDataModel);
  1513. }
  1514. areaborderPane.setCenterView(areatreeview);
  1515. areatreeview.getView().style.background = '#FCFCFC';
  1516. areatreeview.setAutoHideScrollBar(true);
  1517. areatreeview.onDataDoubleClicked = function (data) {
  1518. master.close();
  1519. }
  1520. self.bindingHandleInputValueChange = self.handleInputValueChange.bind(self);
  1521. }
  1522. ht.Default.def(DropDownBorderPane, ht.widget.BaseDropDownTemplate, {
  1523. getView: function () {
  1524. return this._borderPane.getView();
  1525. },
  1526. handleInputValueChange: function () {
  1527. },
  1528. initColumn: function () {
  1529. },
  1530. getValue: function () {
  1531. var names = "",
  1532. sm = this._areatreeview.dm().sm();
  1533. sm.each(function (data) {
  1534. names += data.getName() + ",";
  1535. });
  1536. if (names !== "") {
  1537. names = names.substr(0, names.length - 1);
  1538. } else {
  1539. names = currentAreaName;
  1540. }
  1541. return names;
  1542. },
  1543. onClosed: function () {
  1544. },
  1545. onOpened: function (v) {
  1546. },
  1547. getHeight: function () {
  1548. return 200;
  1549. }
  1550. });
  1551. //获取区域树结构
  1552. function getAreaTree(areaValue, parent, areaDataModel) {
  1553. if (areaValue.length > 0) {
  1554. for (var i = 0; i < areaValue.length; i++) {
  1555. areaIds += areaValue[i].Id + ",";
  1556. var children = areaValue[i];
  1557. var child = new ht.Data();
  1558. child.setName(areaValue[i].Name);
  1559. child.setParent(parent);
  1560. areaDataModel.add(child);
  1561. if (children.Children.length > 0) {
  1562. getAreaTree(children.Children, child, areaDataModel);
  1563. }
  1564. }
  1565. }
  1566. }
  1567. //获取标签点数据类型
  1568. function getDataTypes() {
  1569. var dataTypes = [];
  1570. dataTypes.push("*");
  1571. for (var key in DataType) {
  1572. dataTypes.push(key);
  1573. }
  1574. return dataTypes;
  1575. }
  1576. //开启订阅函数
  1577. //function startSubscribe(){
  1578. //socket.alarmPost("/alarm/SubscribeNotify", function (data) {
  1579. // if (data.success = "true") {
  1580. // socket.on("alarm_notify", function (data) {
  1581. // if (typeof realdataModelReal != "undefined") {
  1582. // var len=alarmData.length;
  1583. // alarmData=alarmData.concat(data);
  1584. // // alarmLevelDicName[DataType[i].level_name]=DataType[i];
  1585. // AlarmInfoShow(alarmData,len);
  1586. // getRealAlarmInfos(realdataModelReal, tablePaneReal, pageinputReal.value, rowssizeReal.getValue(), pageCountReal, dataAreaNameReal, alarmGroupValueReal, alarmLevelValueReal);
  1587. // }
  1588. // })
  1589. // }
  1590. //});
  1591. //}
  1592. var drawCell = function (g, data, str, selected, column, x, y, w, h, tablestyle) {
  1593. // if (data.a("levelId") == 0) {
  1594. // var color = tablestyle.fontcolor;
  1595. // var font = tablestyle.fontsize + "px " + tablestyle.fontfamily;
  1596. // ht.Default.drawText(g, str, font, color, x, y, w, h, 'center');
  1597. // } else {
  1598. var color = "";
  1599. // if (data.a("ensureinfo")) {
  1600. // if (data.a("resetinfo")) {
  1601. // color = alarmLevelDic[data.a("levelId")].normal_color;
  1602. // } else {
  1603. // color = alarmLevelDic[data.a("levelId")].reset_color;
  1604. // }
  1605. // } else if (data.a("resetinfo")) {
  1606. // if (data.a("ensureinfo")) {
  1607. // color = alarmLevelDic[data.a("levelId")].reset_color;
  1608. // } else {
  1609. // color = alarmLevelDic[data.a("levelId")].ensure_color;
  1610. // }
  1611. // //color=alarmLevelDic[data.a("levelId")].reset_color;
  1612. // } else {
  1613. // if (data.a("resetinfo")) {
  1614. // color = alarmLevelDic[data.a("levelId")].ensure_color;
  1615. // } else {
  1616. // // console.log(data.a("levelId")+" "+alarmLevelDic[data.a("levelId")]);
  1617. // color = alarmLevelDic[data.a("levelId")].alarm_color;
  1618. // }
  1619. // }
  1620. if (data.a("ensureinfo")) {
  1621. if (!data.a("resetinfo")) {
  1622. //已确认未恢复
  1623. color = alarmLevelDic[data.a("levelId")] && alarmLevelDic[data.a("levelId")].ensure_color || '0';
  1624. }
  1625. } else {
  1626. if (!data.a("resetinfo")) {
  1627. //未确认未恢复
  1628. color = alarmLevelDic[data.a("levelId")] && alarmLevelDic[data.a("levelId")].alarm_color || '0';
  1629. } else {
  1630. //未确认已恢复
  1631. color = alarmLevelDic[data.a("levelId")] && alarmLevelDic[data.a("levelId")].reset_color || '0';
  1632. }
  1633. }
  1634. var hexColor = ARGB2HexString(color); //16711680 65280 16776960 0 16777215
  1635. //console.log(ARGBToInt("#ff0000")) ; //#ff0000 红色 //绿色 #00ff00 //黄色:ffff00 //黑色:000000 //白色:ffffff
  1636. if (data.a('isFirst')) {
  1637. hexColor = 'rgb(239,55,68)';
  1638. }
  1639. var font = tablestyle.fontsize * ratio.ratioY + "px " + tablestyle.fontfamily;
  1640. var cellWidth = GD.measureCanvasText(str, font),
  1641. columnWidth = column.getWidth();
  1642. if (cellWidth > columnWidth) {
  1643. column.setWidth(cellWidth);
  1644. }
  1645. ht.Default.drawText(g, str, font, hexColor, x, y, w, h, 'center');
  1646. // }
  1647. }
  1648. // 点击时序事件时隐藏列,点击其它时显示出来
  1649. function toggleColumnDisplay(btnName, tablePane, topToolBar, bottomToolBar) {
  1650. if (!btnName) return;
  1651. var columnModel = tablePane.getColumnModel();
  1652. var nameArr, name, v, items, userOperateColumn, checkColumn;
  1653. if (btnName === '时序事件') {
  1654. nameArr = ['alarmlevel', 'alarmtime', 'area'];
  1655. if (topToolBar) {
  1656. topToolBar.getItemById('alarmlavel').label = '状态:';
  1657. topToolBar.getItemById('alarmstatus').visible = false;
  1658. topToolBar.getItemById('alarmlavel').visible = true;
  1659. topToolBar.getItemById('alarmgroup').visible = false;
  1660. topToolBar.redraw();
  1661. }
  1662. } else {
  1663. nameArr = ['state', 'alarmtime', 'area', "desc", "value", "alarmGroup", "alarmshuoming", "alarmlevel", 'tagName'];
  1664. if (btnName === '全部') {
  1665. topToolBar.getItemById('alarmstatus').visible = false;
  1666. topToolBar.getItemById('alarmlavel').visible = false;
  1667. topToolBar.getItemById('alarmgroup').visible = false;
  1668. topToolBar.redraw();
  1669. } else {
  1670. if (topToolBar) {
  1671. topToolBar.getItemById('alarmlavel').label = '级别:';
  1672. topToolBar.getItemById('alarmstatus').visible = false;
  1673. topToolBar.getItemById('alarmlavel').visible = true;
  1674. topToolBar.getItemById('alarmgroup').visible = true;
  1675. if (btnName === '首出故障') {
  1676. topToolBar.getItemById('alarmstatus').visible = true;
  1677. }
  1678. topToolBar.redraw();
  1679. }
  1680. }
  1681. }
  1682. // 实时报警只有点击首出故障时显示“确认”和“全部确认”按钮,其它隐藏。
  1683. ; (function () {
  1684. if (!bottomToolBar) return;
  1685. var confirmBtn = bottomToolBar.getItemById('confirm'),
  1686. confirmAllBtn = bottomToolBar.getItemById('confirmAll'),
  1687. f;
  1688. if (btnName === '首出故障') {
  1689. f = true;
  1690. } else {
  1691. f = false;
  1692. }
  1693. confirmBtn && (confirmBtn.visible = f);
  1694. confirmAllBtn && (confirmAllBtn.visible = f);
  1695. bottomToolBar.redraw();
  1696. })();
  1697. columnModel.each(function (data) {
  1698. name = data.getName();
  1699. if (nameArr.indexOf(name) === -1) {
  1700. v = false;
  1701. } else {
  1702. v = true;
  1703. }
  1704. if (name === undefined && data.isEditable()) { // checkcolumn
  1705. v = true;
  1706. }
  1707. if (name === 'alarmlevel') {
  1708. (btnName === '时序事件') ? data.setDisplayName('状态') : data.setDisplayName('报警级别');
  1709. }
  1710. data.setVisible(v);
  1711. if (name === 'state') {
  1712. userOperateColumn = data;
  1713. }
  1714. if (!name) {
  1715. checkColumn = data;
  1716. }
  1717. });
  1718. if (btnName === '首出故障') {
  1719. userOperateColumn && userOperateColumn.setVisible(true);
  1720. checkColumn && checkColumn.setVisible(true);
  1721. } else {
  1722. userOperateColumn && userOperateColumn.setVisible(false);
  1723. checkColumn && checkColumn.setVisible(false);
  1724. }
  1725. }
  1726. //实时报警信息控件
  1727. function createRealAlarm(x, y, width, height, tablestyle) {
  1728. //console.log(tablestyle);
  1729. currentControlContent += "realalarm";
  1730. alarmCateReal = tablestyle.alarmCategoryReal;
  1731. alarmLevelVisible = tablestyle.alarmLevelVisible;
  1732. var pageCount = 0;
  1733. var borderPaneReal = new ht.widget.BorderPane();
  1734. realdataModelReal = new ht.DataModel();
  1735. tablePaneReal = new ht.widget.TablePane(realdataModelReal);
  1736. tablePaneReal = createTableByObj(tablePaneReal, tablestyle);
  1737. borderPaneReal.setCenterView(tablePaneReal);
  1738. if (alarmLevelVisible) {
  1739. formRealLeft = new ht.widget.FormPane();
  1740. formRealLeft.getView().style.background = tablestyle.backcolor;
  1741. formRealLeft.setVGap(0);
  1742. formRealLeft.setHGap(0);
  1743. formRealLeft.setVPadding(0);
  1744. formRealLeft.setHPadding(0);
  1745. formRealLeft.setScrollBarSize(0);
  1746. var rowheight = Math.ceil((height - 100) / alarmCateReal.length);
  1747. (function () { // 左侧按钮排序
  1748. var d, rs = ['', '', '', ''];
  1749. for (var i = 0, len = alarmCateReal.length; i < len; i++) {
  1750. d = alarmCateReal[i];
  1751. if (d.name === '时序事件') {
  1752. rs[1] = d;
  1753. } else if (d.name === '告警提示') {
  1754. rs[2] = d;
  1755. } else if (d.name === '故障') {
  1756. rs[3] = d;
  1757. } else if (d.name === '全部') {
  1758. rs[0] = d;
  1759. } else {
  1760. rs.push(d);
  1761. }
  1762. }
  1763. alarmCateReal = rs;
  1764. })();
  1765. formRealLeft.addRow([{
  1766. image: {
  1767. width: 45 * ratio.ratioX,
  1768. id: 'levelimg' + 10,
  1769. name: 'aaa',
  1770. }
  1771. }], [45 * ratio.ratioX], 12 * ratio.ratioY);
  1772. for (var i = 0; i < alarmCateReal.length; i++) {
  1773. var curdata = alarmCateReal[i];
  1774. var imgsrc = imagePath + curdata.icon;
  1775. if (alarmCateReal[i].name == '故障') {
  1776. alarmLevelArray = curdata.alarmLevelList;
  1777. isRealFirst = null;
  1778. //alarmLevelValueReal = alarmLevelArray;
  1779. }
  1780. formRealLeft.addRow([{
  1781. image: {
  1782. width: 45 * ratio.ratioX,
  1783. icon: imgsrc,
  1784. // togglable: true,
  1785. id: 'levelimg' + i,
  1786. name: curdata.name,
  1787. data: curdata.alarmLevelList,
  1788. clickicon: imagePath + curdata.clickicon,
  1789. // stretch: 'fill',
  1790. onClicked: function () {
  1791. this.setIcon(this.clickicon);
  1792. var rows = formRealLeft._rows;
  1793. for (var j = 0; j < rows.length; j++) {
  1794. var curimg = rows[j].items[0].element;
  1795. if (curimg.id != this.id) {
  1796. curimg.setIcon(rows[j].items[0].image.icon);
  1797. }
  1798. }
  1799. pageinputReal.value = 1;
  1800. realdataModelReal.clear();
  1801. alarmLevelArray = this.data;
  1802. if (this.name == "首出故障") {
  1803. isRealFirst = 1;
  1804. } else if (this.name == "故障" || this.name == "全部") {
  1805. isRealFirst = null;
  1806. } else if (this.name === "时序事件") {
  1807. } else {
  1808. isRealFirst = 0;
  1809. }
  1810. if (alarmLevelArray != "*") {
  1811. if (alarmLevelArray[0] != "*") {
  1812. alarmLevelArray.unshift("*");
  1813. }
  1814. alarmLevelValueReal = alarmLevelArray;
  1815. alarmLevelReal.setValues(alarmLevelArray);
  1816. alarmLevelReal.setValue(alarmLevelArray[0]);
  1817. } else {
  1818. alarmLevelValueReal = alarmLevelArray;
  1819. alarmLevelReal.setValues(dataTypes);
  1820. alarmLevelReal.setValue(dataTypes[0]);
  1821. }
  1822. toggleColumnDisplay(this.name, tablePaneReal, toolbarReal, toolbar2Real);
  1823. searchRealInfo();
  1824. }
  1825. }
  1826. }], [45 * ratio.ratioX], 100 * ratio.ratioY);
  1827. var rows = formRealLeft._rows;
  1828. for (var j = 0; j < rows.length; j++) {
  1829. var curimg = rows[j].items[0].element;
  1830. if (curimg.name == '故障') {
  1831. curimg.setIcon(rows[j].items[0].image.clickicon);
  1832. }
  1833. }
  1834. }
  1835. borderPaneReal.setLeftView(formRealLeft, 28);
  1836. }
  1837. function initData(data) {
  1838. if (!data) return;
  1839. var arr = data.colStyles || [], a,
  1840. colStylesObj = {};
  1841. for (var i = 0, len = arr.length; i<len; i++) {
  1842. a = arr[i];
  1843. colStylesObj[a.Name] = a;
  1844. }
  1845. data.colStylesObj = colStylesObj;
  1846. };
  1847. initData(tablestyle);
  1848. /*区域*/
  1849. // var dataAreaInfoReal = new ht.widget.ComboBox();
  1850. // dataAreaInfoReal.setWidth(120);
  1851. // dataAreaInfoReal.setEditable(true);
  1852. // dataAreaInfoReal.setDropDownWidth(120);
  1853. // getAlarmAreas(dataAreaInfoReal);
  1854. // dataAreaNameReal = dataAreaInfoReal.getValue();
  1855. // dataAreaInfoReal.onValueChanged = function () {
  1856. // pageinputReal.value = 1;
  1857. // realdataModelReal.clear();
  1858. // searchRealInfo();
  1859. // }
  1860. var dataAreaInfoReal = new ht.widget.MultiComboBox();
  1861. // dataAreaInfoReal.setEditable(true);
  1862. // dataAreaInfoReal.setWidth(220 * ratio.ratioX); // 天铝
  1863. dataAreaInfoReal.setWidth(145 * ratio.ratioX);
  1864. // dataAreaNameReal = dataAreaInfoReal.getValue();
  1865. dataAreaInfoReal.setValue((JSON.parse(localStorage.getItem('extra')).area == "" || localStorage.getItem('extra') == "\"\"") ? "*" : JSON.parse(localStorage.getItem('extra')).area);
  1866. // dataAreaInfoReal.setDropDownWidth(240);
  1867. dataAreaInfoReal.setDropDownComponent(DropDownArea);
  1868. dataAreaInfoReal.setBackground('url(' + PAGEROOTDIR + 'Script/image/f3.png) no-repeat center center');
  1869. // dataAreaInfoReal.onValueChanged = function (data) {
  1870. // // pageinputReal.value = 1;
  1871. // // realdataModelReal.clear();
  1872. // // searchRealInfo();
  1873. // dataAreaInfoReal.setValue(data);
  1874. // }
  1875. /*点类型*/
  1876. pointDataTypeReal = new ht.widget.ComboBox(); //组合框
  1877. // pointDataTypeReal.setEditable(true);
  1878. pointDataTypeReal.setWidth(120 * ratio.ratioX);
  1879. pointDataTypeReal.setDropDownWidth(120 * ratio.ratioX);
  1880. pointTypesReal = getDataTypes();
  1881. pointDataTypeReal.setValues(pointTypesReal);
  1882. pointDataTypeReal.setValue(pointTypesReal[0]);
  1883. pointtypeReal = pointDataTypeReal.getValue();
  1884. /*报警类别*/
  1885. alarmCategoryReal = new ht.widget.ComboBox();
  1886. // alarmCategoryReal.setEditable(true);
  1887. alarmCategoryReal.setWidth(120 * ratio.ratioX);
  1888. alarmCategoryReal.setDropDownWidth(120 * ratio.ratioX);
  1889. alarmCateValueReal = alarmCategoryReal.getValue();
  1890. /*报警组*/
  1891. alarmGroupReal = new ht.widget.ComboBox();
  1892. // alarmGroupReal.setEditable(true);
  1893. alarmGroupReal.setWidth(127 * ratio.ratioX);
  1894. alarmGroupReal.setDropDownWidth(127 * ratio.ratioX);
  1895. alarmGroupReal.setBackground('url(' + PAGEROOTDIR + 'Script/image/f2.png) center center no-repeat');
  1896. alarmGroupValueReal = alarmGroupReal.getValue();
  1897. alarmGroupReal.onValueChanged = function () {
  1898. pageinputReal.value = 1;
  1899. realdataModelReal.clear();
  1900. searchRealInfo();
  1901. }
  1902. // /*报警级别*/
  1903. alarmLevelReal = new ht.widget.ComboBox();
  1904. // alarmLevelReal.setEditable(true);
  1905. alarmLevelReal.setWidth(163 * ratio.ratioX);
  1906. alarmLevelReal.setDropDownWidth(163 * ratio.ratioX);
  1907. alarmLevelReal.setBackground('url(' + PAGEROOTDIR + 'Script/image/f4.png) center center no-repeat');
  1908. // getAlarmLevels(alarmLevelReal);
  1909. if (alarmLevelArray.length != 0) {
  1910. if (alarmLevelArray[0] != "*") {
  1911. alarmLevelArray.unshift("*");
  1912. }
  1913. alarmLevelReal.setValues(alarmLevelArray);
  1914. alarmLevelReal.setValue(alarmLevelArray[0]);
  1915. alarmLevelValueReal = alarmLevelArray;
  1916. } else {
  1917. alarmLevelReal.setValues(dataTypes);
  1918. alarmLevelReal.setValue(dataTypes[0]);
  1919. alarmLevelValueReal = "*";
  1920. }
  1921. //alarmLevelValueReal = alarmLevelReal.getValue();
  1922. // if(alarmLevelArray.length!=0&&alarmLevelValueReal=="*"){
  1923. // alarmLevelArray.splice(0,1);
  1924. // alarmLevelValueReal=alarmLevelArray;
  1925. // }
  1926. // if (typeof (alarmLevelValueReal) == "undefined") {
  1927. // alarmLevelValueReal = "*";
  1928. // }
  1929. pageCountReal = new ht.widget.TextField();
  1930. alarmLevelReal.onValueChanged = function () {
  1931. var arr = [];
  1932. arr.push(alarmLevelReal.getValue());
  1933. alarmLevelValueReal = arr;
  1934. if (alarmLevelValueReal == "*" && alarmLevelArray.length != 0) {
  1935. alarmLevelValueReal = alarmLevelArray;
  1936. }
  1937. pageinputReal.value = 1;
  1938. realdataModelReal.clear();
  1939. searchRealInfo();
  1940. }
  1941. //报警状态
  1942. alarmStateReal = new ht.widget.ComboBox();
  1943. // alarmStateReal.setEditable(true);
  1944. alarmStateReal.setWidth(127 * ratio.ratioX);
  1945. alarmStateReal.setDropDownWidth(127 * ratio.ratioX);
  1946. alarmStateReal.setValues(alarmStates);
  1947. alarmStateReal.setValue(alarmStates[0]);
  1948. alarmStateReal.setBackground('url(' + PAGEROOTDIR + 'Script/image/f2.png) center center no-repeat');
  1949. alarmStateValueReal = alarmStateReal.getValue();
  1950. alarmStateReal.onValueChanged = function () {
  1951. pageinputReal.value = 1;
  1952. realdataModelReal.clear();
  1953. searchRealInfo();
  1954. }
  1955. //getRealAlarmInfos(realdataModelReal,tablePaneReal);
  1956. var toolbarReal = new ht.widget.Toolbar([{
  1957. label: ' '+(tablestyle.colStylesObj && tablestyle.colStylesObj['area'] && tablestyle.colStylesObj['area'].DisplayName || '设备')+':',
  1958. element: dataAreaInfoReal,
  1959. unfocusable: true
  1960. },
  1961. /*{
  1962. label: '点类型:',
  1963. element: pointDataTypeReal,
  1964. unfocusable: true
  1965. },
  1966. {
  1967. label: '报警类别:',
  1968. element: alarmCategoryReal,
  1969. unfocusable: true
  1970. },*/
  1971. {
  1972. // label: '设备:', // 天铝
  1973. label: '类别:',
  1974. id: 'alarmgroup',
  1975. element: alarmGroupReal,
  1976. unfocusable: true
  1977. },
  1978. {
  1979. label: '级别:',
  1980. id: 'alarmlavel',
  1981. element: alarmLevelReal,
  1982. unfocusable: true,
  1983. visible: true
  1984. // visible:true
  1985. },
  1986. {
  1987. label: '操作:',
  1988. id: 'alarmstatus',
  1989. element: alarmStateReal,
  1990. unfocusable: true,
  1991. visible: true
  1992. // visible:true
  1993. }
  1994. // ,{
  1995. // id: '时序事件',
  1996. // groupId: 'alarmCategory',
  1997. // type: 'toggle',
  1998. // label: '时序事件',
  1999. // selected: true,
  2000. // action: function(){
  2001. // // tableView.invalidateModel();
  2002. // }
  2003. // },
  2004. // {
  2005. // id: '告警提示',
  2006. // groupId: 'alarmCategory',
  2007. // type: 'toggle',
  2008. // label: '告警提示',
  2009. // action: function(){
  2010. // // tableView.invalidateModel();
  2011. // }
  2012. // },
  2013. // {
  2014. // id: '故障',
  2015. // groupId: 'alarmCategory',
  2016. // type: 'toggle',
  2017. // label: '故障',
  2018. // action: function(){
  2019. // // tableView.invalidateModel();
  2020. // }
  2021. // }
  2022. /*{
  2023. button: {
  2024. width: 70,
  2025. label: '查询',
  2026. borderColor: '#31647e',
  2027. background:'#52b4d7',
  2028. onClicked: function(){
  2029. }
  2030. }
  2031. }/*,*/
  2032. ]);
  2033. //报警级别分类
  2034. function createObject() {
  2035. var object = new Object();
  2036. object = {
  2037. id: '',
  2038. groupId: 'alarmCategory',
  2039. alarmids: '',
  2040. type: 'toggle',
  2041. label: '',
  2042. selected: true,
  2043. action: ''
  2044. };
  2045. return object;
  2046. }
  2047. function searchRealInfo() {
  2048. dataAreaNameReal = dataAreaInfoReal.getValue();
  2049. if (typeof (dataAreaNameReal) == "undefined") {
  2050. dataAreaNameReal = "*";
  2051. }
  2052. alarmGroupValueReal = alarmGroupReal.getValue();
  2053. if (typeof (alarmGroupValueReal) == "undefined") {
  2054. alarmGroupValueReal = "*";
  2055. }
  2056. // if (alarmLevelVisible) {
  2057. // alarmLevelValueReal = alarmLevelReal.getValue();
  2058. // if (typeof (alarmLevelValueReal) == "undefined") {
  2059. // alarmLevelValueReal = "*";
  2060. // }
  2061. // } else {
  2062. // alarmLevelValueReal = alarmLevelArray;
  2063. // }
  2064. alarmStateValueReal = alarmStateReal.getValue();
  2065. if (typeof (alarmStateValueReal) == "undefined") {
  2066. alarmStateValueReal = "*";
  2067. }
  2068. if (JSON.stringify(alarmGroupDic) != "{}" && JSON.stringify(alarmLevelDicName) != "{}" && JSON.stringify(alarmAreaDicName) != "{}") {
  2069. getRealAlarmInfos(realdataModelReal, tablePaneReal, pageinputReal.value, tablestyle.PageSize || 200, pageCountReal, dataAreaNameReal, alarmGroupValueReal, alarmLevelValueReal, alarmStateValueReal);
  2070. } else {
  2071. setTimeout(function () {
  2072. searchRealInfo();
  2073. }, 500);
  2074. }
  2075. }
  2076. function DropDownArea(master) {
  2077. var self = this;
  2078. DropDownArea.superClass.constructor.call(self, master);
  2079. var treeView = self._treeView = new ht.widget.TreeView();
  2080. treeView.sm().ms(function (e) {
  2081. master.setValue(self.getValue());
  2082. });
  2083. GD.setAreaTreeViewStyle(treeView);
  2084. treeView.onDataClicked = function (data) {
  2085. alarmAreaIds.length = 0;
  2086. alarmAreaIds.push(data._id);
  2087. getAreaIds(data);
  2088. //console.log(alarmAreaIds);
  2089. pageinputReal.value = 1;
  2090. realdataModelReal.clear();
  2091. if (data._id >= 0) {
  2092. GoldenAlarm.getGroupsByAreaID(data._id, function (groups) {
  2093. var values = ['*'];
  2094. for (var i = 0, group; group = groups[i++]; ) {
  2095. values.push(group.group_name);
  2096. }
  2097. alarmGroupReal.setValues(values);
  2098. alarmGroupReal.setValue(values[0]);
  2099. })
  2100. } else {
  2101. getAlarmGroups(function (groupData) {
  2102. var groupNamrArr = ['*'];
  2103. for (var key in groupData) {
  2104. if (groupData.hasOwnProperty(key)) {
  2105. groupNamrArr.push(key);
  2106. }
  2107. }
  2108. alarmGroupReal.setValues(groupNamrArr);
  2109. alarmGroupReal.setValue(groupNamrArr[0]);
  2110. });
  2111. }
  2112. searchRealInfo();
  2113. master.close();
  2114. }
  2115. if (JSON.parse(localStorage.getItem('extra')).area == "" || localStorage.getItem('extra') == "\"\"") {
  2116. var pdata = new ht.Data();
  2117. pdata.setName("*");
  2118. pdata.setTag("*");
  2119. pdata.setId(-1);
  2120. treeView.dm().add(pdata);
  2121. }
  2122. var reqData = {
  2123. "method": "GetAreas",
  2124. "param": {}
  2125. };
  2126. var flagnum = "areas";
  2127. var eventName = "/alarm/doservice?" + flagnum;
  2128. if (alarmAreaData.length === 0) {
  2129. socket.alarmPost(eventName, reqData, function (data) {
  2130. if (data && data.success) {
  2131. var DataType = data.data.data;
  2132. alarmAreaData = DataType;
  2133. setTreeViewData(DataType)
  2134. }
  2135. })
  2136. } else {
  2137. setTreeViewData(alarmAreaData);
  2138. }
  2139. function setTreeViewData(DataType) {
  2140. var map = {}, d;
  2141. var curid = -1;
  2142. // console.log(DataType);
  2143. for (var i = 0; i < DataType.length; i++) {
  2144. var curdata = DataType[i];
  2145. if (JSON.parse(localStorage.getItem('extra')).area == "" || localStorage.getItem('extra') == "\"\"") {
  2146. if (!map[curdata.id]) {
  2147. curid = curdata.id;
  2148. d = new ht.Data();
  2149. d._id = curdata.id;
  2150. d._pid = curdata.parent_id;
  2151. d.setName(curdata.area_name);
  2152. d.setTag(curdata.area_name);
  2153. d.setParent(map[curdata.parent_id]);
  2154. treeView.dm().add(d);
  2155. map[curdata.id] = d;
  2156. }
  2157. } else {
  2158. // if (!map[curdata.id]) {
  2159. if (curdata.area_name == JSON.parse(localStorage.getItem('extra')).area) {
  2160. curid = curdata.id;
  2161. d = new ht.Data();
  2162. d._id = curdata.id;
  2163. d._pid = curdata.parent_id;
  2164. d.setName(curdata.area_name);
  2165. d.setTag(curdata.area_name);
  2166. d.setParent(map[curdata.parent_id]);
  2167. treeView.dm().add(d);
  2168. map[curdata.id] = d;
  2169. }
  2170. // }
  2171. }
  2172. }
  2173. getAreaTreeData(treeView, DataType, curid, map);
  2174. treeView.expandAll();
  2175. }
  2176. }
  2177. function getAlarmFilterData(count) {
  2178. if (!(socket && socket.socketio && socket.socketio.connected)) {
  2179. count++;
  2180. if (count < 10) {
  2181. setTimeout('getAlarmFilterData(' + count + ')', 500);
  2182. } else {
  2183. count = 0;
  2184. }
  2185. return;
  2186. }
  2187. getAlarmGroups(function (groupData) {
  2188. var groupNamrArr = ['*'];
  2189. for (var key in groupData) {
  2190. if (groupData.hasOwnProperty(key)) {
  2191. groupNamrArr.push(key);
  2192. }
  2193. }
  2194. alarmGroupReal.setValues(groupNamrArr);
  2195. alarmGroupReal.setValue(groupNamrArr[0]);
  2196. });
  2197. getAlarmCategories(function (categroyData) {
  2198. if (!categroyData) return;
  2199. var categroyArr = ['*'];
  2200. for (var key in categroyData) {
  2201. if (categroyData.hasOwnProperty(key)) {
  2202. categroyArr.push(categroyArr[key]);
  2203. }
  2204. }
  2205. alarmCategoryReal.setValues(categroyArr);
  2206. alarmCategoryReal.setValue(categroyArr[0]);
  2207. });
  2208. }
  2209. ht.Default.def(DropDownArea, ht.widget.BaseDropDownTemplate, {
  2210. getView: function () {
  2211. return this._treeView.getView();
  2212. },
  2213. onOpened: function (v) {
  2214. if (v) {
  2215. var treeView = this._treeView,
  2216. nameArr = v.split(",");
  2217. treeView.dm().each(function (data) {
  2218. if (nameArr.indexOf(data.getName()) >= 0) {
  2219. treeView.sm().as(data);
  2220. }
  2221. });
  2222. // $(treeView.getView()).css({
  2223. // width: 320
  2224. // })
  2225. }
  2226. },
  2227. onClosed: function () { },
  2228. getValue: function () {
  2229. var name = "",
  2230. treeView = this._treeView;
  2231. treeView.sm().each(function (data) {
  2232. name = data.getName();
  2233. // localStorage.setItem(name,data.getId());
  2234. //console.log(data);
  2235. });
  2236. return name;
  2237. },
  2238. getHeight: function () {
  2239. // return this._treeView.getRowSize()*this._treeView.getRowHeight()+10;
  2240. return 300;
  2241. },
  2242. // getWidth: function () {
  2243. // return 320;
  2244. // }
  2245. });
  2246. // setInterval(function () {
  2247. // getRealAlarmInfos(realdataModelReal, tablePaneReal, pageinputReal.value, tablestyle.PageSize, pageCountReal, dataAreaNameReal, alarmGroupValueReal, alarmLevelValueReal);
  2248. // }, 5000)
  2249. //toolbarReal.getLabelColor = tablestyle.fontcolor;
  2250. toolbarReal.getView().style.background = tablestyle.backcolor;
  2251. toolbarReal.getView().style.padding = 10;
  2252. // borderPaneReal.setTopView(toolbarReal);
  2253. //设置表头是否可见
  2254. if (!tablestyle.IsHeadVisible) {
  2255. var tableheader = tablePaneReal.getTableHeader();
  2256. tableheader.setHeight(1);
  2257. tableheader.getView().style.display = "none";
  2258. }
  2259. //设置搜索条件是否可见
  2260. if (tablestyle.IsSearchVisible) {
  2261. borderPaneReal.setTopView(toolbarReal);
  2262. }
  2263. toolbarReal.setStickToRight(false);
  2264. pageinputReal = document.createElement('input');
  2265. pageinputReal.value = 1;
  2266. pageinputReal.style.position = 'absolute';
  2267. pageinputReal.style.margin = 0;
  2268. pageinputReal.style.padding = '0px 2px';
  2269. pageinputReal.style.outline = 0;
  2270. pageinputReal.style.border = 0;
  2271. pageinputReal.style.width = 60 * ratio.ratioX + 'px';
  2272. pageinputReal.style.height = ht.Default.widgetRowHeight + 'px';
  2273. pageinputReal.style.textAlign = 'center';
  2274. pageinputReal.style.fontFamily = '"苹方 粗体"';
  2275. pageinputReal.style.color = 'rgb(0,0,0)';
  2276. pageinputReal.style.fontSize = 17 * ratio.ratioY + 'px';
  2277. pageinputReal.style.fontWeight = 'bold';
  2278. pageinputReal.onfocus = function () {
  2279. pageinputReal.style.outline = '1px solid ' + ht.Color.highlight;
  2280. };
  2281. pageinputReal.onblur = function () {
  2282. pageinputReal.style.outline = 0;
  2283. };
  2284. pageinputReal.onkeydown = function (e) {
  2285. if (e.keyCode === 13) {
  2286. //self.request();
  2287. }
  2288. };
  2289. rowssizeReal = new ht.widget.ComboBox();
  2290. rowssizeReal.setValues([10, 20, 30, 50, 100]);
  2291. rowssizeReal.setValue(20);
  2292. // rowssizeReal.setEditable(true);
  2293. rowssizeReal.setWidth(50);
  2294. rowssizeReal.setDropDownWidth(140);
  2295. rowssizeReal.onValueChanged = function () {
  2296. pageinputReal.value = 1;
  2297. realdataModelReal.clear();
  2298. searchRealInfo();
  2299. //getRealAlarmInfos(realdataModelReal,tablePaneReal,pageinputReal.value,rowssizeReal.getValue(),pageCountReal,dataAreaNameReal,pointtypeReal,alarmCateValueReal,alarmLevelValueReal);
  2300. }
  2301. toolbar2Real = new ht.widget.Toolbar([
  2302. //{
  2303. // label: 'Rows:',
  2304. // element: rowssizeReal
  2305. // },
  2306. {
  2307. id: 'bottomtoolbarsepratorleft',
  2308. selected: false,
  2309. unfocusable: true,
  2310. button: {
  2311. width: ((width * 0.5) - 90),
  2312. editable: false,
  2313. background: 'rgba(0,0,0,0)',
  2314. selectBackground: 'rgba(0,0,0,0)',
  2315. borderColor: 'rgba(0,0,0,0)',
  2316. }
  2317. },
  2318. {
  2319. unfocusable: true,
  2320. label: "<<",
  2321. action: function () {
  2322. pageinputReal.value = 1;
  2323. realdataModelReal.clear();
  2324. searchRealInfo();
  2325. //getRealAlarmInfos(realdataModelReal,tablePaneReal,pageinputReal.value,rowssizeReal.getValue(),pageCountReal,dataAreaNameReal,pointtypeReal,alarmCateValueReal,alarmLevelValueReal);
  2326. }
  2327. },
  2328. {
  2329. unfocusable: true,
  2330. label: "<",
  2331. action: function () {
  2332. if (Number(pageinputReal.value) > 1) {
  2333. pageinputReal.value = Number(pageinputReal.value) - 1;
  2334. realdataModelReal.clear();
  2335. searchRealInfo();
  2336. //getRealAlarmInfos(realdataModelReal,tablePaneReal,pageinputReal.value,rowssizeReal.getValue(),pageCountReal,dataAreaNameReal,pointtypeReal,alarmCateValueReal,alarmLevelValueReal);
  2337. }
  2338. }
  2339. },
  2340. {
  2341. unfocusable: true,
  2342. label: '页:',
  2343. element: pageinputReal
  2344. },
  2345. {
  2346. unfocusable: true,
  2347. label: '>',
  2348. action: function () {
  2349. if (Number(pageinputReal.value) < Number(pageCountReal.getValue())) {
  2350. pageinputReal.value = Number(pageinputReal.value) + 1;
  2351. searchRealInfo();
  2352. //getRealAlarmInfos(realdataModelReal,tablePaneReal,pageinputReal.value,rowssizeReal.getValue(),pageCountReal,dataAreaNameReal,pointtypeReal,alarmCateValueReal,alarmLevelValueReal);
  2353. }
  2354. }
  2355. },
  2356. {
  2357. unfocusable: true,
  2358. label: ">>",
  2359. action: function () {
  2360. pageinputReal.value = pageCountReal.getValue();
  2361. searchRealInfo();
  2362. //getRealAlarmInfos(realdataModelReal,tablePaneReal,pageinputReal.value,rowssizeReal.getValue(),pageCountReal,dataAreaNameReal,pointtypeReal,alarmCateValueReal,alarmLevelValueReal);
  2363. }
  2364. },
  2365. {
  2366. unfocusable: true,
  2367. label: '共 1 页',
  2368. id: 'realAlarmTotalPageNum'
  2369. },
  2370. {
  2371. id: 'bottomtoolbarseprator',
  2372. selected: false,
  2373. unfocusable: true,
  2374. button: {
  2375. width: ((width * 0.5) - 360),
  2376. editable: false,
  2377. background: 'rgba(0,0,0,0)',
  2378. selectBackground: 'rgba(0,0,0,0)',
  2379. borderColor: 'rgba(0,0,0,0)',
  2380. }
  2381. },
  2382. {
  2383. unfocusable: true,
  2384. id: 'confirm',
  2385. visible: !alarmLevelVisible,
  2386. button: {
  2387. label: '确认',
  2388. width: tablestyle.btnWidth,
  2389. height: tablestyle.btnHeight,
  2390. labelColor: tablestyle.btnfontcolor,
  2391. labelFont: tablestyle.btnfontsize + "px " + tablestyle.btnfontfamily + "",
  2392. selectBackground: tablestyle.btnAfterClickBackColor,
  2393. border: 0,
  2394. background: tablestyle.btnBackgroundColor,
  2395. onClicked: function () {
  2396. var tagobj = {};
  2397. var dicmapReal = tablePaneReal.getTableView().sm()._map;
  2398. for (var key in dicmapReal) {
  2399. var tagnamesReal = [];
  2400. var EnsureUser = JSON.stringify(dicmapReal[key]._attrObject.desc);
  2401. var Ensuretag = dicmapReal[key]._attrObject.tagName;
  2402. tagobj = {
  2403. "tag_name": Ensuretag,
  2404. "ensure_info": EnsureUser
  2405. };
  2406. tagnamesReal.push(tagobj);
  2407. ensureAlarm(tagnamesReal);
  2408. }
  2409. // searchRealInfo();
  2410. //getRealAlarmInfos(realdataModelReal,tablePaneReal,pageinputReal.value,rowssizeReal.getValue(),pageCountReal,dataAreaNameReal,pointtypeReal,alarmCateValueReal,alarmLevelValueReal);
  2411. }
  2412. }
  2413. },
  2414. {
  2415. unfocusable: true,
  2416. id: 'confirmAll',
  2417. visible: !alarmLevelVisible,
  2418. button: {
  2419. label: '全部确认',
  2420. width: tablestyle.btnWidth,
  2421. height: tablestyle.btnHeight,
  2422. border: 0,
  2423. labelColor: tablestyle.btnfontcolor,
  2424. labelFont: tablestyle.btnfontsize + "px " + tablestyle.btnfontfamily + "",
  2425. selectBackground: tablestyle.btnAfterClickBackColor,
  2426. background: tablestyle.btnBackgroundColor,
  2427. onClicked: function () {
  2428. var tagobj = {};
  2429. var dicmapReal = realdataModelReal.getDatas()._as;
  2430. for (var i = 0; i < dicmapReal.length; i++) {
  2431. var tagnamesReal = [];
  2432. var EnsureUser = JSON.stringify(dicmapReal[i].a("desc"));
  2433. var Ensuretag = dicmapReal[i].a("tagName");
  2434. tagobj = {
  2435. "tag_name": Ensuretag,
  2436. "ensure_info": EnsureUser
  2437. };
  2438. tagnamesReal.push(tagobj);
  2439. ensureAlarm(tagnamesReal);
  2440. }
  2441. // searchRealInfo();
  2442. //getRealAlarmInfos(realdataModelReal,tablePaneReal,pageinputReal.value,rowssizeReal.getValue(),pageCountReal,dataAreaNameReal,pointtypeReal,alarmCateValueReal,alarmLevelValueReal);
  2443. }
  2444. }
  2445. }
  2446. ]);
  2447. //console.log(tablestyle.toolbarcolor);
  2448. // toolbar2Real.getLabelColor = toolbarReal.getLabelColor = function (item) {
  2449. // return tablestyle.toolbarcolor
  2450. // };
  2451. // toolbar2Real.getLabelFont = toolbarReal.getLabelFont = function (item) {
  2452. // return tablestyle.fontsize + "px " + tablestyle.fontfamily
  2453. // }
  2454. //toolbarReal.getLabelFont="20px Arial";
  2455. toolbar2Real.getView().style.background = tablestyle.backcolor;
  2456. toolbar2Real.setStickToRight(false);
  2457. window.addEventListener('resize', function (e) { }, false);
  2458. var _w = width / ratio.ratioX;
  2459. $(window).on('resizeOver', function (e) {
  2460. borderPaneReal.invalidate();
  2461. var toolbarsperator = toolbar2Real.getItemById('bottomtoolbarseprator');
  2462. var toolbarsperator2 = toolbar2Real.getItemById('bottomtoolbarsepratorleft');
  2463. toolbarsperator.element.setWidth((_w * 0.5 - 260) * ratio.ratioX);
  2464. toolbarsperator2.element.setWidth((_w * 0.5 - 90) * ratio.ratioX);
  2465. toolbar2Real.redraw();
  2466. })
  2467. //动态加载列
  2468. var columnModel = tablePaneReal.getColumnModel();
  2469. column = new ht.Column();
  2470. column.setAlign("center");
  2471. column.setName("levelId");
  2472. column.setDisplayName("等级ID");
  2473. column.setAccessType('attr');
  2474. column.setVisible(false);
  2475. columnModel.add(column);
  2476. column = new ht.Column();
  2477. column.setAlign("center");
  2478. column.setName("ensureinfo");
  2479. column.setDisplayName("确定状态");
  2480. column.setAccessType('attr');
  2481. column.setVisible(false);
  2482. columnModel.add(column);
  2483. column = new ht.Column();
  2484. column.setAlign("center");
  2485. column.setName("resetinfo");
  2486. column.setDisplayName("复位状态");
  2487. column.setAccessType('attr');
  2488. column.setVisible(false);
  2489. columnModel.add(column);
  2490. column = new ht.Column();
  2491. column.setAlign("center");
  2492. column.setName("accdata");
  2493. column.setDisplayName("事故追忆");
  2494. column.setAccessType('attr');
  2495. column.setVisible(false);
  2496. columnModel.add(column);
  2497. for (var i = 0; i < tablestyle.colStyles.length; i++) {
  2498. var column = new ht.Column();
  2499. column.setAlign("center");
  2500. column.setName(tablestyle.colStyles[i].Name);
  2501. column.setDisplayName(tablestyle.colStyles[i].DisplayName);
  2502. column.setAccessType('attr');
  2503. column.setWidth(tablestyle.colStyles[i].Width * ratio.ratioY);
  2504. column.drawCell = function (g, data, selected, column, x, y, w, h) {
  2505. drawCell(g, data, data.a(column.getName()), selected, column, x, y, w, h, tablestyle);
  2506. }
  2507. columnModel.add(column);
  2508. }
  2509. tableViewRealConfig = tablePaneReal.getTableView();
  2510. // tablePaneReal.getView().style.background = tablestyle.backcolor; //"Honeydew";
  2511. tableViewRealConfig.setRowLineColor('#54b7db');
  2512. tableViewRealConfig.setColumnLineColor('transparent');
  2513. tableViewRealConfig.setSelectBackground("#31647e");
  2514. //tableViewRealConfig.setRowHeight(tablestyle.rowheight);
  2515. // tableViewRealConfig.setRowHeight(25);
  2516. tableViewRealConfig.getLabelColor = function () {
  2517. return ("white")
  2518. };
  2519. tableViewRealConfig.setCheckMode(true);
  2520. borderPaneReal.getView().style.background = tablestyle.backcolor; //"Honeydew";
  2521. var tView = tableViewRealConfig.getView();
  2522. //右键菜单
  2523. var tempData = null;
  2524. var json = [{
  2525. label: '事故追忆',
  2526. action: function (item, e) {
  2527. if (tempData) {
  2528. var groupName = tempData.a("groupName");
  2529. var tag = tempData.a('tagName').split('.')[0] + ".";
  2530. var alarmtime = tempData.a("alarmtime") || Date.now();
  2531. getKeyValueData(groupName, function (data) {
  2532. if (data != "" && typeof (data) != "undefined") {
  2533. accdata = JSON.parse(data.replace(/'/g, "\""));
  2534. var timespan = accdata[0].split(";");
  2535. var date = new Date(alarmtime);
  2536. date.setMinutes(date.getMinutes() - parseInt(timespan[0]));
  2537. var beginTime = getDateString(date); //开始时间
  2538. date.setMinutes(date.getMinutes() + parseInt(timespan[1]) + parseInt(timespan[0]));
  2539. var endTime = getDateString(date); //结束时间
  2540. beginTime = beginTime || moment(new Date()).format("YYYY-MM-DD H:mm:ss");
  2541. endTime = endTime || moment(new Date(beginTime)).add(30, 'seconds').format("YYYY-MM-DD H:mm:ss");
  2542. var interval = parseInt(timespan[2]); //时间间隔
  2543. var tagName = ''; //标签点
  2544. for (var i = 1; i < accdata.length; i++) {
  2545. // tagName += tag + groupName + accdata[i].name + ',';
  2546. tagName += tag + accdata[i].name + ',';
  2547. }
  2548. tagName = tagName.substring(0, tagName.length - 1);
  2549. exportDataExcel(tagName, beginTime, endTime, interval, 0);
  2550. } else {
  2551. alert('请设置相关联的指标');
  2552. return;
  2553. }
  2554. tempData = null;
  2555. })
  2556. // if (accdata.length != 0) {
  2557. // date = new Date();
  2558. // var accarray = accdata.split(";");
  2559. // date.setMinutes(date.getMinutes() - parseInt(accarray[0]));
  2560. // var beginTime = getDateString(date); //开始时间
  2561. // // console.log(starttime);
  2562. // date.setMinutes(date.getMinutes() + parseInt(accarray[1]) + parseInt(accarray[0]));
  2563. // var endTime = getDateString(date); //结束时间
  2564. // beginTime = beginTime || moment(new Date()).format("YYYY-MM-DD H:mm:ss");
  2565. // endTime = endTime || moment(new Date(beginTime)).add(30, 'seconds').format("YYYY-MM-DD H:mm:ss");
  2566. // // console.log(endtime);
  2567. // var interval = parseInt(accarray[2]); //时间间隔
  2568. // var tagName = accarray[3]; //标签点
  2569. // exportDataExcel(tagName, beginTime, endTime, interval, 0);
  2570. // // exportInterExcelNew("",endTime,interval,"","");
  2571. // }
  2572. }
  2573. }
  2574. }];
  2575. var contextmenu = new ht.widget.ContextMenu(json);
  2576. contextmenu.beforeShow = function (e) {
  2577. // 获取右键点击行的数据
  2578. tempData = tableViewRealConfig.getDataAt(e);
  2579. }
  2580. /* 事故追忆暂时隐藏
  2581. contextmenu.addTo(tView);
  2582. */
  2583. borderPaneReal.getView().style.background = tablestyle.backcolor; //"Honeydew";
  2584. //设置分页是否可见
  2585. if (tablestyle.IsPageVisible) {
  2586. borderPaneReal.setBottomView(toolbar2Real);
  2587. } else {
  2588. tableViewRealConfig.setCheckMode(false);
  2589. }
  2590. var borderPaneRealNode = new ht.HtmlNode();
  2591. borderPaneRealNode.setScalable(false);
  2592. borderPaneRealNode.s({
  2593. '2d.selectable': true,
  2594. '2d.movable': false
  2595. });
  2596. borderPaneRealNode.setHtml(borderPaneReal);
  2597. borderPaneRealNode.setPosition({
  2598. x: x,
  2599. y: y
  2600. });
  2601. borderPaneRealNode.setWidth(width);
  2602. borderPaneRealNode.setHeight(height);
  2603. borderPaneRealNode.setPadding(0);
  2604. /*startSubscribe();*/
  2605. /*getSnapshotCallback();*/
  2606. getAlarmFilterData(0);
  2607. searchRealInfo();
  2608. GD.setAlarmTableStyle(borderPaneReal, tablePaneReal, toolbarReal, toolbar2Real, formRealLeft, tablestyle);
  2609. if (alarmLevelVisible) {
  2610. toggleColumnDisplay('故障', tablePaneReal, toolbarReal, toolbar2Real);
  2611. }
  2612. return borderPaneRealNode;
  2613. }
  2614. //事故追忆数据导出
  2615. function exportDataExcel(tagName, beginTime, eneTime, interval, valueType) {
  2616. var uri = "tagName=" + tagName;
  2617. uri += "&beginTime=" + beginTime;
  2618. uri += "&endTime=" + eneTime;
  2619. uri += "&interval=" + interval;
  2620. uri += "&valueType=" + valueType;
  2621. var link = document.createElement("a");
  2622. link.download = "exportExcel";
  2623. link.href = "http://" + webServiceIP + ":" + webServicePort +
  2624. "/api/ExportToExcelInterpo?" + encodeURI(uri);
  2625. link.click();
  2626. }
  2627. //报警等级信息配置
  2628. function createAlarmConfig(x, y, width, height) {
  2629. dataModelLevel = new ht.DataModel();
  2630. tablePaneLevel = new ht.widget.TablePane(dataModelLevel);
  2631. borderPaneAlarmLevel = new ht.widget.BorderPane();
  2632. borderPaneAlarmLevel.setCenterView(tablePaneLevel);
  2633. var levelAddState = false;
  2634. getAlarmLevelTables(dataModelLevel, tablePaneLevel);
  2635. var attributesLevel = [{
  2636. name: 'id',
  2637. displayName: '编号',
  2638. color: "#ceae42",
  2639. align: 'center',
  2640. width: 50
  2641. },
  2642. {
  2643. name: 'alarmName',
  2644. displayName: '等级名称',
  2645. color: "#ceae42",
  2646. editable: true,
  2647. align: 'center',
  2648. accessType: 'attr',
  2649. width: 80
  2650. },
  2651. {
  2652. name: 'wavName',
  2653. displayName: '声音文件名',
  2654. color: "#ceae42",
  2655. align: 'center',
  2656. accessType: 'attr',
  2657. width: 150
  2658. },
  2659. {
  2660. name: 'alarmColor',
  2661. displayName: '报警颜色',
  2662. color: "#ceae42",
  2663. align: 'center',
  2664. accessType: 'attr',
  2665. colorPicker: {
  2666. instant: false
  2667. },
  2668. editable: true,
  2669. width: 150
  2670. },
  2671. {
  2672. name: 'resetColor',
  2673. displayName: '恢复颜色',
  2674. color: "#ceae42",
  2675. align: 'center',
  2676. accessType: 'attr',
  2677. colorPicker: {
  2678. instant: false
  2679. },
  2680. editable: true,
  2681. width: 150
  2682. },
  2683. {
  2684. name: 'confirmColor',
  2685. displayName: '确认颜色',
  2686. color: "#ceae42",
  2687. align: 'center',
  2688. colorPicker: {
  2689. instant: false
  2690. },
  2691. editable: true,
  2692. accessType: 'attr',
  2693. width: 150
  2694. },
  2695. {
  2696. name: 'normalColor',
  2697. displayName: '默认颜色',
  2698. color: "#ceae42",
  2699. align: 'center',
  2700. colorPicker: {
  2701. instant: false
  2702. },
  2703. editable: true,
  2704. accessType: 'attr',
  2705. width: 150
  2706. },
  2707. {
  2708. name: 'islight',
  2709. displayName: '是否闪烁',
  2710. color: "#ceae42",
  2711. align: 'center',
  2712. editable: true,
  2713. accessType: 'attr',
  2714. width: 170,
  2715. enum: ['是', '否']
  2716. },
  2717. {
  2718. name: 'alarmLevel',
  2719. displayName: '优先级',
  2720. color: "#ceae42",
  2721. align: 'center',
  2722. editable: true,
  2723. accessType: 'attr',
  2724. width: 170
  2725. }
  2726. ];
  2727. tablePaneLevel.addColumns(attributesLevel);
  2728. tableLevelView = tablePaneLevel.getTableView();
  2729. tablePaneLevel.getView().style.background = "#0C152A";
  2730. tableLevelView.setRowLineColor('#54b7db');
  2731. tableLevelView.setColumnLineColor('transparent');
  2732. tableLevelView.setSelectBackground("#31647e");
  2733. tableLevelView.setRowHeight(25);
  2734. tableLevelView.getLabelColor = function () {
  2735. return ("white")
  2736. };
  2737. tableLevelView.setCheckMode(true);
  2738. var changeLevelId = ",";
  2739. dataModelLevel.onDataPropertyChanged = function (data, e) { /*图元属性变化回调函数,可重载做后续处理*/
  2740. if (changeLevelId.indexOf(',' + data._id + ',') == -1) {
  2741. changeLevelId += data._id + ",";
  2742. }
  2743. };
  2744. var toolbarLevel = new ht.widget.Toolbar([{
  2745. button: {
  2746. width: 50,
  2747. label: '添加',
  2748. borderColor: '#31647e',
  2749. background: '#52b4d7',
  2750. onClicked: function () {
  2751. addLevelData();
  2752. }
  2753. }
  2754. },
  2755. {
  2756. button: {
  2757. width: 50,
  2758. label: '删除',
  2759. borderColor: '#31647e',
  2760. background: '#52b4d7',
  2761. onClicked: function () {
  2762. var levelIds;
  2763. var dicmap = tableLevelView.sm()._map;
  2764. for (var key in dicmap) {
  2765. levelIds = key;
  2766. dataModelLevel.removeDataById(key);
  2767. deleteAlarmLevels(levelIds);
  2768. }
  2769. }
  2770. }
  2771. },
  2772. {
  2773. button: {
  2774. width: 50,
  2775. label: '保存',
  2776. borderColor: '#31647e',
  2777. background: '#52b4d7',
  2778. onClicked: function () {
  2779. updateLevelData();
  2780. }
  2781. }
  2782. }
  2783. ]);
  2784. function updateLevelData() {
  2785. if (changeLevelId === ',') {
  2786. getAlarmLevelTables(dataModelLevel, tablePaneLevel);
  2787. } else {
  2788. var updateLevels;
  2789. var ids = changeLevelId.split(",");
  2790. for (var i = 0; i < ids.length; i++) {
  2791. if (ids[i].length != 0) {
  2792. var dataModel = dataModelLevel.getDataById(ids[i]);
  2793. var alarmLevel = dataModel._attrObject;
  2794. var alarmLevels = new AlarmLevels();
  2795. alarmLevels.level = {
  2796. "value": Number(ids[i])
  2797. };
  2798. alarmLevels.level_name = {
  2799. "value": alarmLevel.alarmName
  2800. };
  2801. alarmLevels.wave_file = {
  2802. "value": alarmLevel.wavName
  2803. };
  2804. alarmLevels.alarm_color = {
  2805. "value": ARGBToInt(alarmLevel.alarmColor)
  2806. };
  2807. alarmLevels.reset_color = {
  2808. "value": ARGBToInt(alarmLevel.resetColor)
  2809. };
  2810. alarmLevels.ensure_color = {
  2811. "value": ARGBToInt(alarmLevel.confirmColor)
  2812. };
  2813. alarmLevels.normal_color = {
  2814. "value": ARGBToInt(alarmLevel.normalColor)
  2815. };
  2816. alarmLevels.popup = {
  2817. "value": alarmLevel.islight == "是" ? 1 : 0
  2818. };
  2819. alarmLevels.wave_count = {
  2820. "value": alarmLevel.alarmLevel
  2821. };
  2822. updateLevels = alarmLevels;
  2823. }
  2824. }
  2825. changeLevelId = ",";
  2826. updateAlarmLevels(updateLevels);
  2827. getAlarmLevelTables(dataModelLevel, tablePaneLevel);
  2828. }
  2829. }
  2830. function addLevelData() {
  2831. data = new ht.Data();
  2832. data.setId(GetRandomNum(0, 99999));
  2833. data.a('alarmName', "test");
  2834. data.a('wavName', "wavName");
  2835. data.a('alarmColor', "#0000001");
  2836. data.a('resetColor', "#0000001");
  2837. data.a('confirmColor', "#0000001");
  2838. data.a('islight', "是");
  2839. data.a('alarmLevel', "20");
  2840. dataModelLevel.add(data);
  2841. dataModelLevel.sm().ss(data);
  2842. tableLevelView.setFocusDataById(data.getId());
  2843. }
  2844. toolbarLevel.getLabelColor = function (item) {
  2845. return 'white';
  2846. };
  2847. toolbarLevel.getView().style.background = '#3D3D3D';
  2848. borderPaneAlarmLevel.setTopView(toolbarLevel);
  2849. var borderPaneAlarmLevelNode = new ht.HtmlNode();
  2850. borderPaneAlarmLevelNode.setScalable(false);
  2851. borderPaneAlarmLevelNode.s({
  2852. '2d.selectable': true,
  2853. '2d.movable': false
  2854. });
  2855. borderPaneAlarmLevelNode.setHtml(borderPaneAlarmLevel);
  2856. borderPaneAlarmLevelNode.setPosition({
  2857. x: x,
  2858. y: y
  2859. });
  2860. borderPaneAlarmLevelNode.setWidth(width);
  2861. borderPaneAlarmLevelNode.setHeight(height);
  2862. borderPaneAlarmLevelNode.setPadding(0);
  2863. dataModel.add(borderPaneAlarmLevelNode);
  2864. }
  2865. function add(tabView, name, color, selected) {
  2866. // create view
  2867. var div = document.createElement('div');
  2868. div.style.background = color;
  2869. // create tab
  2870. var tab = new ht.Tab();
  2871. tab.setName(name);
  2872. tab.setView(div);
  2873. // add to model
  2874. var tabModel = tabView.getTabModel();
  2875. tabModel.add(tab);
  2876. if (selected) {
  2877. tabModel.getSelectionModel().setSelection(tab);
  2878. }
  2879. return tab;
  2880. }
  2881. //历史数据信息
  2882. function createHisAlarm(x, y, width, height, tablestyle) {
  2883. currentControlContent += "hisalarm";
  2884. var pageCount = 0;
  2885. borderPaneHis = new ht.widget.BorderPane();
  2886. alarmCateHis = tablestyle.alarmCategoryReal;
  2887. alarmLevelVisible = tablestyle.alarmLevelVisible;
  2888. hisdataModelHis = new ht.DataModel();
  2889. tablePaneHis = new ht.widget.TablePane(hisdataModelHis);
  2890. tablePaneHis = createTableByObj(tablePaneHis, tablestyle);
  2891. borderPaneHis.setCenterView(tablePaneHis);
  2892. if (alarmLevelVisible) {
  2893. formHisLeft = new ht.widget.FormPane();
  2894. formHisLeft.getView().style.background = tablestyle.backcolor;
  2895. formHisLeft.setVGap(0);
  2896. formHisLeft.setVPadding(0);
  2897. formHisLeft.setHPadding(0);
  2898. formHisLeft.setScrollBarSize(0);
  2899. formHisLeft.addRow([{
  2900. image: {
  2901. width: 45 * ratio.ratioX,
  2902. id: 'levelimg' + 10,
  2903. name: 'aaa',
  2904. }
  2905. }], [45 * ratio.ratioX], 12 * ratio.ratioY);
  2906. var rowheight = Math.ceil((height - 100) / alarmCateHis.length);
  2907. for (var i = 0; i < alarmCateHis.length; i++) {
  2908. var curdata = alarmCateHis[i];
  2909. var imgsrc = imagePath + curdata.icon;
  2910. if (alarmCateHis[i].name == '故障') {
  2911. alarmLevelArray = curdata.alarmLevelList;
  2912. }
  2913. formHisLeft.addRow([{
  2914. image: {
  2915. width: 45 * ratio.ratioX,
  2916. icon: imgsrc,
  2917. id: 'levelimg' + i,
  2918. name: curdata.name,
  2919. data: curdata.alarmLevelList,
  2920. clickicon: imagePath + curdata.clickicon,
  2921. // stretch: 'fill',
  2922. onClicked: function () {
  2923. this.setIcon(this.clickicon);
  2924. var rows = formHisLeft._rows;
  2925. for (var j = 0; j < rows.length; j++) {
  2926. var curimg = rows[j].items[0].element;
  2927. if (curimg.id != this.id) {
  2928. curimg.setIcon(rows[j].items[0].image.icon);
  2929. }
  2930. }
  2931. pageinputHis.value = 1;
  2932. hisdataModelHis.clear();
  2933. alarmLevelArray = this.data;
  2934. if (this.name == "首出故障") {
  2935. isHisFirst = 1;
  2936. } else if (this.name == "故障" || this.name == "全部") {
  2937. isHisFirst = null;
  2938. } else {
  2939. isHisFirst = 0;
  2940. }
  2941. if (alarmLevelArray != "*") {
  2942. if (alarmLevelArray[0] != "*") {
  2943. alarmLevelArray.unshift("*");
  2944. }
  2945. alarmLevelValueHis = alarmLevelArray;
  2946. alarmLevelHis.setValues(alarmLevelArray);
  2947. alarmLevelHis.setValue(alarmLevelArray[0]);
  2948. } else {
  2949. alarmLevelValueHis = alarmLevelArray;
  2950. alarmLevelHis.setValues(dataTypes);
  2951. alarmLevelHis.setValue(dataTypes[0]);
  2952. }
  2953. toggleColumnDisplay(this.name, tablePaneHis, toolbarHis);
  2954. alarmHisSearch();
  2955. }
  2956. }
  2957. },
  2958. ], [45 * ratio.ratioX], 100 * ratio.ratioY);
  2959. var rows = formHisLeft._rows;
  2960. for (var j = 0; j < rows.length; j++) {
  2961. var curimg = rows[j].items[0].element;
  2962. if (curimg.name == '故障') {
  2963. curimg.setIcon(rows[j].items[0].image.clickicon);
  2964. }
  2965. }
  2966. }
  2967. borderPaneHis.setLeftView(formHisLeft, 45 * ratio.ratioX);
  2968. }
  2969. function initData(data) {
  2970. if (!data) return;
  2971. var arr = data.colStyles || [], a,
  2972. colStylesObj = {};
  2973. for (var i = 0, len = arr.length; i<len; i++) {
  2974. a = arr[i];
  2975. colStylesObj[a.Name] = a;
  2976. }
  2977. data.colStylesObj = colStylesObj;
  2978. };
  2979. initData(tablestyle);
  2980. var borderPaneHisNode = new ht.HtmlNode();
  2981. borderPaneHisNode.setScalable(false);
  2982. borderPaneHisNode.s({
  2983. '2d.selectable': true,
  2984. '2d.movable': false
  2985. });
  2986. borderPaneHisNode.setHtml(borderPaneHis);
  2987. borderPaneHisNode.setPosition({
  2988. x: x,
  2989. y: y
  2990. });
  2991. borderPaneHisNode.setWidth(width);
  2992. borderPaneHisNode.setHeight(height);
  2993. borderPaneHisNode.setPadding(0);
  2994. dataModel.add(borderPaneHisNode);
  2995. pageinputHis = document.createElement('input');
  2996. pageinputHis.value = 1;
  2997. pageinputHis.style.position = 'absolute';
  2998. pageinputHis.style.margin = 0;
  2999. pageinputHis.style.padding = '0px 2px';
  3000. pageinputHis.style.outline = 0;
  3001. pageinputHis.style.border = 0;
  3002. pageinputHis.style.width = 60 * ratio.ratioX + 'px';
  3003. pageinputHis.style.height = ht.Default.widgetRowHeight + 'px';
  3004. pageinputHis.style.textAlign = 'center';
  3005. pageinputHis.style.fontFamily = '"苹方 粗体"';
  3006. pageinputHis.style.color = 'rgb(0,0,0)';
  3007. pageinputHis.style.fontSize = 17 * ratio.ratioY + 'px';
  3008. pageinputHis.style.fontWeight = 'bold';
  3009. pageinputHis.onfocus = function () {
  3010. pageinputHis.style.outline = '1px solid ' + ht.Color.highlight;
  3011. };
  3012. pageinputHis.onblur = function () {
  3013. pageinputHis.style.outline = 0;
  3014. };
  3015. pageinputHis.onkeydown = function (e) {
  3016. if (e.keyCode === 13) {
  3017. //self.request();
  3018. }
  3019. };
  3020. var dataAreaInfoHis = new ht.widget.MultiComboBox();
  3021. // dataAreaInfoHis.setEditable(true);
  3022. // dataAreaInfoHis.setWidth(220 * ratio.ratioX); // 天铝
  3023. dataAreaInfoHis.setWidth(145 * ratio.ratioX);
  3024. dataAreaInfoHis.setValue((JSON.parse(localStorage.getItem('extra')).area == "" || localStorage.getItem('extra') == "\"\"") ? "*" : JSON.parse(localStorage.getItem('extra')).area);
  3025. // dataAreaInfoHis.setDropDownWidth(240);
  3026. dataAreaInfoHis.setDropDownComponent(HisDropDownArea);
  3027. dataAreaInfoHis.setBackground('url(' + PAGEROOTDIR + 'Script/image/f3.png) no-repeat center center');
  3028. var pointDataTypeHis = new ht.widget.ComboBox();
  3029. pointDataTypeHis.setWidth(163 * ratio.ratioX);
  3030. pointDataTypeHis.setDropDownWidth(163 * ratio.ratioX);
  3031. var pointTypesHis = getDataTypes();
  3032. pointDataTypeHis.setValues(pointTypesHis);
  3033. pointDataTypeHis.setValue(pointTypesHis[0]);
  3034. pointtypeHis = pointDataTypeHis.getValue();
  3035. pointDataTypeHis.setBackground('url(' + PAGEROOTDIR + 'Script/image/f4.png) no-repeat center center');
  3036. var alarmCategoryHis = new ht.widget.ComboBox();
  3037. alarmCategoryHis.setWidth(181 * ratio.ratioX);
  3038. alarmCateValueHis = alarmCategoryHis.getValue();
  3039. alarmCategoryHis.setBackground('url(' + PAGEROOTDIR + 'Script/image/f5.png) no-repeat center center');
  3040. var alarmLevelHis = new ht.widget.ComboBox();
  3041. alarmLevelHis.setWidth(163 * ratio.ratioX);
  3042. alarmLevelHis.setBackground('url(' + PAGEROOTDIR + 'Script/image/f4.png) no-repeat center center');
  3043. if (alarmLevelArray.length != 0) {
  3044. if (alarmLevelArray[0] != "*") {
  3045. alarmLevelArray.unshift("*");
  3046. }
  3047. alarmLevelHis.setValues(alarmLevelArray);
  3048. alarmLevelHis.setValue(alarmLevelArray[0]);
  3049. alarmLevelValueHis = alarmLevelArray;
  3050. } else {
  3051. alarmLevelHis.setValues(dataTypes);
  3052. alarmLevelHis.setValue(dataTypes[0]);
  3053. alarmLevelValueHis = "*";
  3054. }
  3055. //getAlarmLevels(alarmLevelHis);
  3056. // alarmLevelValueHis = alarmLevelHis.getValue();
  3057. alarmLevelHis.onValueChanged = function () {
  3058. var arr = [];
  3059. arr.push(alarmLevelHis.getValue());
  3060. alarmLevelValueHis = arr;
  3061. if (alarmLevelValueHis == "*" && alarmLevelArray.length != 0) {
  3062. alarmLevelValueHis = alarmLevelArray;
  3063. }
  3064. }
  3065. /*报警组*/
  3066. alarmGroupHis = new ht.widget.ComboBox();
  3067. // alarmGroupHis.setEditable(true);
  3068. alarmGroupHis.setWidth(127 * ratio.ratioX);
  3069. alarmGroupHis.setBackground('url(' + PAGEROOTDIR + 'Script/image/f2.png) no-repeat center center');
  3070. alarmGroupValueHis = alarmGroupHis.getValue();
  3071. alarmGroupHis.onValueChanged = function () {
  3072. // pageinputHis.value = 1;
  3073. // hisdataModelHis.clear();
  3074. // alarmHisSearch();
  3075. }
  3076. //报警状态
  3077. alarmStateHis = new ht.widget.ComboBox();
  3078. // alarmStateHis.setEditable(true);
  3079. alarmStateHis.setWidth(127 * ratio.ratioX);
  3080. alarmStateHis.setValues(alarmStates);
  3081. alarmStateHis.setValue(alarmStates[0]);
  3082. alarmStateHis.setBackground('url(' + PAGEROOTDIR + 'Script/image/f2.png) no-repeat center center');
  3083. alarmStateValueHis = alarmStateHis.getValue();
  3084. alarmStateHis.onValueChanged = function () {
  3085. }
  3086. var endDate = new Date();
  3087. var beginDate = new Date(endDate.getTime() - 24 * 60 * 60 * 1000);
  3088. hisStartTime = beginDate;
  3089. hisEndTime = endDate;
  3090. var $startTimeDiv = $('<input id ="startTimeNode0" class = "dateTimePicker back-size100" style = "border: none; padding-left:' + 18 * ratio.ratioX + 'px;width:' + 235 * ratio.ratioX + 'px;height:' + 36 * ratio.ratioY + 'px;font-size:12px;background: url(' + PAGEROOTDIR + 'Script/image/f8.png) center center no-repeat;" />');
  3091. var startTimeDiv = $startTimeDiv[0];
  3092. document.body.appendChild(startTimeDiv);
  3093. var $endTimeDiv = $('<input id ="endTimeNode0" class = "dateTimePicker back-size100" style = "border: none; padding-left:' + 18 * ratio.ratioX + 'px;width:' + 235 * ratio.ratioX + 'px;height:' + 36 * ratio.ratioY + 'px;font-size:12px;background: url(' + PAGEROOTDIR + 'Script/image/f8.png) center center no-repeat;" />');
  3094. var endTimeDiv = $endTimeDiv[0];
  3095. document.body.appendChild(endTimeDiv);
  3096. (function () {
  3097. var currentStartValue,
  3098. currentEndValue;
  3099. var start = laydate.render({
  3100. elem: '#startTimeNode0',
  3101. istime: true,
  3102. type: 'datetime',
  3103. value: beginDate,
  3104. theme: 'blueblack',
  3105. format: 'yyyy-MM-dd HH:mm:ss',
  3106. done: function (value, date, endDate) {
  3107. hisStartTime = value;
  3108. // alarmHisSearch();
  3109. }
  3110. });
  3111. var end = laydate.render({
  3112. elem: '#endTimeNode0',
  3113. istime: true,
  3114. type: 'datetime',
  3115. value: endDate,
  3116. format: 'yyyy-MM-dd HH:mm:ss',
  3117. theme: 'blueblack',
  3118. done: function (value, date, endDate) {
  3119. hisEndTime = value;
  3120. // alarmHisSearch();
  3121. }
  3122. });
  3123. GD.setupDatePicker(startTimeDiv, start);
  3124. GD.setupDatePicker(endTimeDiv, end);
  3125. })();
  3126. function getAlarmFilterData() {
  3127. if (!(socket && socket.socketio && socket.socketio.connected)) {
  3128. getAlarmFilterData._count++;
  3129. if (getAlarmFilterData._count < 10) {
  3130. setTimeout(getAlarmFilterData, 500);
  3131. } else {
  3132. getAlarmFilterData._count = 0;
  3133. }
  3134. return;
  3135. }
  3136. getAlarmGroups(function (groupData) {
  3137. if (!groupData) return;
  3138. var groupDataArr = ['*'];
  3139. for (var key in groupData) {
  3140. if (groupData.hasOwnProperty(key)) {
  3141. groupDataArr.push(key);
  3142. }
  3143. }
  3144. alarmGroupHis.setValues(groupDataArr);
  3145. alarmGroupHis.setValue(groupDataArr[0]);
  3146. });
  3147. getAlarmCategories(function (categroyData) {
  3148. if (!categroyData) return;
  3149. var categroyArr = ['*'];
  3150. for (var key in categroyData) {
  3151. if (categroyData.hasOwnProperty(key)) {
  3152. categroyArr.push(categroyArr[key]);
  3153. }
  3154. }
  3155. alarmCategoryHis.setValues(categroyArr);
  3156. alarmCategoryHis.setValue(categroyArr[0]);
  3157. });
  3158. }
  3159. getAlarmFilterData._count = 0;
  3160. getAlarmFilterData();
  3161. //getHisAlarmInfos(hisdataModelHis,null);
  3162. var toolbarHis = new ht.widget.Toolbar([{
  3163. label: ' '+(tablestyle.colStylesObj && tablestyle.colStylesObj['area'] && tablestyle.colStylesObj['area'].DisplayName || '设备')+':',
  3164. element: dataAreaInfoHis,
  3165. unfocusable: true
  3166. },
  3167. /*{
  3168. label: '点类型:',
  3169. element: pointDataTypeHis,
  3170. unfocusable: true
  3171. },
  3172. {
  3173. label: '报警类别:',
  3174. element: alarmCategoryHis,
  3175. unfocusable: true
  3176. },*/
  3177. {
  3178. // label: '设备:', // 天铝
  3179. label: '类别:',
  3180. id: 'alarmgroup',
  3181. element: alarmGroupHis,
  3182. unfocusable: true
  3183. },
  3184. {
  3185. label: '级别:',
  3186. id: 'alarmlavel',
  3187. element: alarmLevelHis,
  3188. unfocusable: true,
  3189. visible: alarmLevelVisible
  3190. // visible:true
  3191. },
  3192. {
  3193. label: '操作:',
  3194. id: 'alarmstatus',
  3195. element: alarmStateHis,
  3196. unfocusable: true,
  3197. visible: true
  3198. // visible:true
  3199. },
  3200. {
  3201. label: '开始时间:',
  3202. element: startTimeDiv,
  3203. unfocusable: true
  3204. },
  3205. {
  3206. label: '结束时间:',
  3207. element: endTimeDiv,
  3208. unfocusable: true
  3209. },
  3210. {
  3211. button: {
  3212. width: 70,
  3213. label: '查询',
  3214. // borderColor: '#31647e',
  3215. // background: '#52b4d7',
  3216. width: tablestyle.btnWidth,
  3217. height: tablestyle.btnHeight,
  3218. labelColor: tablestyle.btnfontcolor,
  3219. labelFont: tablestyle.btnfontsize + "px " + tablestyle.btnfontfamily + "",
  3220. selectBackground: tablestyle.btnAfterClickBackColor,
  3221. background: tablestyle.btnBackgroundColor,
  3222. onClicked: function () {
  3223. pageinputHis.value = 1;
  3224. // alert(111);
  3225. alarmHisSearch();
  3226. }
  3227. },
  3228. unfocusable: true
  3229. },
  3230. {
  3231. button: {
  3232. width: 70,
  3233. label: '导出',
  3234. // borderColor: '#31647e',
  3235. // background: '#52b4d7',
  3236. width: tablestyle.btnWidth,
  3237. height: tablestyle.btnHeight,
  3238. labelColor: tablestyle.btnfontcolor,
  3239. labelFont: tablestyle.btnfontsize + "px " + tablestyle.btnfontfamily + "",
  3240. selectBackground: tablestyle.btnAfterClickBackColor,
  3241. background: tablestyle.btnBackgroundColor,
  3242. onClicked: function () {
  3243. exportHistoryAlarmData();
  3244. }
  3245. },
  3246. unfocusable: true
  3247. },
  3248. /*{
  3249. button: {
  3250. width: 70,
  3251. label: '查询',
  3252. borderColor: '#31647e',
  3253. background:'#52b4d7',
  3254. onClicked: function(){
  3255. pageinputHis.value=1;
  3256. dataAreaNameHis=dataAreaInfoHis.getValue();
  3257. pointtypeHis=pointDataTypeHis.getValue();
  3258. alarmCateValueHis=alarmCategoryHis.getValue();
  3259. alarmLevelValueHis=alarmLevelHis.getValue();
  3260. getHisAlarmInfos(hisdataModelHis,null,pageinputHis.value,rowssizeHis.getValue(),pageCountHis,dataAreaNameHis,pointtypeHis,alarmCateValueHis,alarmLevelValueHis);
  3261. }
  3262. }
  3263. }*/
  3264. ]);
  3265. //报警级别分类
  3266. function createObject() {
  3267. var object = new Object();
  3268. object = {
  3269. id: '',
  3270. groupId: 'alarmCategory',
  3271. alarmids: '',
  3272. type: 'toggle',
  3273. label: '',
  3274. selected: true,
  3275. action: ''
  3276. };
  3277. return object;
  3278. }
  3279. // if (!alarmLevelVisible) {
  3280. // for (var i = 0; i < alarmCateHis.length; i++) {
  3281. // var item = createObject();
  3282. // if (i != 0) {
  3283. // item.selected = false;
  3284. // }
  3285. // item.id = alarmCateHis[i].name;
  3286. // item.label = alarmCateHis[i].name;
  3287. // item.alarmids = alarmCateHis[i].alarmLevelList;
  3288. // if (i == 0) {
  3289. // alarmLevelArray = item.alarmids;
  3290. // }
  3291. // item.action = function (curarr) {
  3292. // pageinputHis.value = 1;
  3293. // hisdataModelHis.clear();
  3294. // alarmLevelArray = this.alarmids;
  3295. // console.log(alarmLevelArray);
  3296. // alarmHisSearch();
  3297. // };
  3298. // toolbarHis.getItems().push(item);
  3299. // }
  3300. // }
  3301. toolbarHis.getView().style.background = tablestyle.backcolor;
  3302. borderPaneHis.setTopView(toolbarHis);
  3303. toolbarHis.setStickToRight(false);
  3304. rowssizeHis = new ht.widget.ComboBox();
  3305. rowssizeHis.setValues([10, 20, 30, 50, 100]);
  3306. rowssizeHis.setValue(20);
  3307. rowssizeHis.setWidth(50);
  3308. rowssizeHis.setDropDownWidth(140);
  3309. rowssizeHis.onValueChanged = function () {
  3310. pageinputHis.value = 1;
  3311. alarmHisSearch();
  3312. };
  3313. var _alarmHisSearchCount = 0;
  3314. function alarmHisSearch() {
  3315. if (!alarmFilterState) {
  3316. _alarmHisSearchCount++;
  3317. if (_alarmHisSearchCount < 10) {
  3318. intervalTimers.push(setTimeout(alarmHisSearch, 800));
  3319. } else {
  3320. _alarmHisSearchCount = 0;
  3321. // GD.createErrorDialog(360, 240, '网络异常,点击确认按钮重新加载页面!', function () {
  3322. // window.location.reload();
  3323. // });
  3324. }
  3325. return;
  3326. }
  3327. dataAreaNameHis = dataAreaInfoHis.getValue() || '*';
  3328. alarmGroupValueHis = alarmGroupHis.getValue() || '*';
  3329. alarmStateValueHis = alarmStateHis.getValue() || '*';
  3330. getHisAlarmInfos(hisdataModelHis, null, pageinputHis.value, tablestyle.PageSize || 200, pageCountHis, dataAreaNameHis, alarmGroupValueHis, alarmLevelValueHis, hisStartTime, hisEndTime, alarmStateValueHis);
  3331. }
  3332. function HisDropDownArea(master) {
  3333. var self = this;
  3334. HisDropDownArea.superClass.constructor.call(self, master);
  3335. var treeView = self._treeView = new ht.widget.TreeView();
  3336. // var listView = self._listView = new ht.widget.ListView();
  3337. // listView.setCheckMode(true);
  3338. treeView.sm().ms(function (e) {
  3339. master.setValue(self.getValue());
  3340. });
  3341. GD.setAreaTreeViewStyle(treeView);
  3342. treeView.onDataClicked = function (data) {
  3343. alarmAreaIds.length = 0;
  3344. alarmAreaIds.push(data._id);
  3345. getAreaIds(data);
  3346. if (data._id >= 0) {
  3347. GoldenAlarm.getGroupsByAreaID(data._id, function (groups) {
  3348. var values = ['*'];
  3349. for (var i = 0, group; group = groups[i++]; ) {
  3350. values.push(group.group_name);
  3351. }
  3352. alarmGroupHis.setValues(values);
  3353. alarmGroupHis.setValue(values[0]);
  3354. })
  3355. } else {
  3356. getAlarmGroups(function (groupData) {
  3357. var groupNamrArr = ['*'];
  3358. for (var key in groupData) {
  3359. if (groupData.hasOwnProperty(key)) {
  3360. groupNamrArr.push(key);
  3361. }
  3362. }
  3363. alarmGroupHis.setValues(groupNamrArr);
  3364. alarmGroupHis.setValue(groupNamrArr[0]);
  3365. });
  3366. }
  3367. master.close();
  3368. }
  3369. var reqData = {
  3370. "method": "GetAreas",
  3371. "param": {}
  3372. };
  3373. var flagnum = "areas";
  3374. var eventName = "/alarm/doservice?" + flagnum;
  3375. if (JSON.parse(localStorage.getItem('extra')).area == "" || localStorage.getItem('extra') == "\"\"") {
  3376. var pdata = new ht.Data();
  3377. pdata.setName("*");
  3378. pdata.setTag("*");
  3379. pdata.setId(-1);
  3380. treeView.dm().add(pdata);
  3381. }
  3382. if (alarmAreaData.length === 0) {
  3383. socket.alarmPost(eventName, reqData, function (data) {
  3384. if (data && data.success) {
  3385. var DataType = data.data.data;
  3386. alarmAreaData = DataType;
  3387. setTreeViewData(DataType);
  3388. }
  3389. })
  3390. } else {
  3391. setTreeViewData(alarmAreaData);
  3392. }
  3393. function setTreeViewData(DataType) {
  3394. var map = {}, d;
  3395. var curid = -1;
  3396. // console.log(DataType);
  3397. for (var i = 0; i < DataType.length; i++) {
  3398. var curdata = DataType[i];
  3399. if (JSON.parse(localStorage.getItem('extra')).area == "" || localStorage.getItem('extra') == "\"\"") {
  3400. if (!map[curdata.id]) {
  3401. curid = curdata.id;
  3402. d = new ht.Data();
  3403. d._id = curdata.id;
  3404. d._pid = curdata.parent_id;
  3405. d.setName(curdata.area_name);
  3406. d.setTag(curdata.area_name);
  3407. d.setParent(map[curdata.parent_id]);
  3408. // if(curArea==curdata.id){
  3409. // }
  3410. treeView.dm().add(d);
  3411. map[curdata.id] = d;
  3412. // treeView.dm().toDatas().each(function (data) {
  3413. // if (map[data._pid]) {
  3414. // data.setParent(map[data._pid]);
  3415. // }
  3416. // });
  3417. }
  3418. } else {
  3419. // if (!map[curdata.id]) {
  3420. if (curdata.area_name == JSON.parse(localStorage.getItem('extra')).area) {
  3421. curid = curdata.id;
  3422. d = new ht.Data();
  3423. d._id = curdata.id;
  3424. d._pid = curdata.parent_id;
  3425. d.setName(curdata.area_name);
  3426. d.setTag(curdata.area_name);
  3427. d.setParent(map[curdata.parent_id]);
  3428. // if(curArea==curdata.id){
  3429. // }
  3430. treeView.dm().add(d);
  3431. map[curdata.id] = d;
  3432. }
  3433. // }
  3434. }
  3435. }
  3436. getAreaTreeData(treeView, DataType, curid, map);
  3437. treeView.expandAll();
  3438. }
  3439. }
  3440. ht.Default.def(HisDropDownArea, ht.widget.BaseDropDownTemplate, {
  3441. getView: function () {
  3442. return this._treeView.getView();
  3443. },
  3444. onOpened: function (v) {
  3445. if (v) {
  3446. var treeView = this._treeView,
  3447. nameArr = v.split(",");
  3448. treeView.dm().toDatas().each(function (data) {
  3449. if (nameArr.indexOf(data.getName()) >= 0) {
  3450. treeView.sm().as(data);
  3451. }
  3452. });
  3453. }
  3454. },
  3455. onClosed: function () { },
  3456. getValue: function () {
  3457. var name = "",
  3458. treeView = this._treeView;
  3459. treeView.sm().each(function (data) {
  3460. name += data.getName();
  3461. });
  3462. return name;
  3463. },
  3464. getHeight: function () {
  3465. // return this._treeView.getRowSize()*this._treeView.getRowHeight()+10;
  3466. return 300;
  3467. },
  3468. // getWidth: function () {
  3469. // return 320;
  3470. // }
  3471. });
  3472. toolbar2His = new ht.widget.Toolbar([
  3473. // {
  3474. // label: '行:',
  3475. // element: rowssizeHis,
  3476. // unfocusable: true
  3477. // },
  3478. {
  3479. id: 'bottomtoolbarseprator',
  3480. selected: false,
  3481. unfocusable: true,
  3482. button: {
  3483. width: ((width * 0.5) - 90),
  3484. editable: false,
  3485. background: 'rgba(0,0,0,0)',
  3486. selectBackground: 'rgba(0,0,0,0)',
  3487. borderColor: 'rgba(0,0,0,0)',
  3488. }
  3489. },
  3490. {
  3491. label: "<<",
  3492. action: function () {
  3493. pageinputHis.value = 1;
  3494. alarmHisSearch();
  3495. },
  3496. unfocusable: true
  3497. },
  3498. {
  3499. label: "<",
  3500. action: function () {
  3501. if (Number(pageinputHis.value) > 1) {
  3502. pageinputHis.value = Number(pageinputHis.value) - 1;
  3503. alarmHisSearch();
  3504. }
  3505. },
  3506. unfocusable: true
  3507. },
  3508. {
  3509. label: '页:',
  3510. element: pageinputHis,
  3511. unfocusable: true
  3512. },
  3513. {
  3514. label: '>',
  3515. action: function () {
  3516. if (Number(pageinputHis.value) < Number(pageCountHis.getValue())) {
  3517. pageinputHis.value = Number(pageinputHis.value) + 1;
  3518. alarmHisSearch();
  3519. }
  3520. },
  3521. unfocusable: true
  3522. },
  3523. {
  3524. label: ">>",
  3525. action: function () {
  3526. pageinputHis.value = pageCountHis.getValue();
  3527. alarmHisSearch();
  3528. },
  3529. unfocusable: true
  3530. },
  3531. {
  3532. unfocusable: true,
  3533. label: '共 1 页',
  3534. id: 'hisAlarmTotalPageNum'
  3535. }
  3536. ]);
  3537. //toolbar2His.getLabelColor = function(item){ return 'white'; };
  3538. toolbar2His.getView().style.background = tablestyle.backcolor;
  3539. borderPaneHis.setBottomView(toolbar2His);
  3540. toolbar2His.setStickToRight(false);
  3541. // toolbarHis.getLabelFont = toolbar2His.getLabelFont = function (item) {
  3542. // return tablestyle.fontsize + "px " + tablestyle.fontfamily;
  3543. // };
  3544. // toolbarHis.getLabelColor = toolbar2His.getLabelColor = function (item) {
  3545. // return tablestyle.toolbarcolor
  3546. // };
  3547. // viewHis = borderPaneHis.getView();
  3548. // viewHis.className = 'main';
  3549. // document.body.appendChild(viewHis);
  3550. // window.addEventListener('resize', function (e) {
  3551. // borderPaneHis.invalidate();
  3552. // }, false);
  3553. viewHis = borderPaneHis.getView();
  3554. viewHis.className = 'main';
  3555. document.body.appendChild(viewHis);
  3556. window.addEventListener('resize', function (e) {
  3557. borderPaneHis.invalidate();
  3558. }, false);
  3559. pageCountHis = new ht.widget.TextField();
  3560. //动态加载列
  3561. columnModel = tablePaneHis.getColumnModel();
  3562. column = new ht.Column();
  3563. column.setAlign("center");
  3564. column.setName("levelId");
  3565. column.setDisplayName("等级ID");
  3566. column.setAccessType('attr');
  3567. column.setVisible(false);
  3568. columnModel.add(column);
  3569. column = new ht.Column();
  3570. column.setAlign("center");
  3571. column.setName("ensureinfo");
  3572. column.setDisplayName("确定状态");
  3573. column.setAccessType('attr');
  3574. column.setVisible(false);
  3575. columnModel.add(column);
  3576. column = new ht.Column();
  3577. column.setAlign("center");
  3578. column.setName("resetinfo");
  3579. column.setDisplayName("复位状态");
  3580. column.setAccessType('attr');
  3581. column.setVisible(false);
  3582. columnModel.add(column);
  3583. for (var i = 0; i < tablestyle.colStyles.length; i++) {
  3584. var column = new ht.Column();
  3585. column.setAlign("center");
  3586. column.setName(tablestyle.colStyles[i].Name);
  3587. column.setDisplayName(tablestyle.colStyles[i].DisplayName);
  3588. column.setAccessType('attr');
  3589. column.setWidth(tablestyle.colStyles[i].Width);
  3590. column.drawCell = function (g, data, selected, column, x, y, w, h) {
  3591. drawCell(g, data, data.a(column.getName()), selected, column, x, y, w, h, tablestyle);
  3592. }
  3593. columnModel.add(column);
  3594. }
  3595. tableViewHis = tablePaneHis.getTableView();
  3596. tablePaneHis._toolbar2His = tablePaneHis._toolbar2His || toolbar2His;
  3597. setTimeout(function () {
  3598. alarmHisSearch();
  3599. }, 500);
  3600. tablePaneHis.getView().style.background = tablestyle.backcolor; //"Honeydew";
  3601. tableViewHis.setRowLineColor('#54b7db');
  3602. tableViewHis.setColumnLineColor('transparent');
  3603. tableViewHis.setSelectBackground("#31647e");
  3604. tableViewHis.getLabelColor = function () {
  3605. return ("white")
  3606. };
  3607. var _w = width / ratio.ratioX;
  3608. $(window).on('resizeOver', function (e) {
  3609. toolbar2His.invalidate();
  3610. var toolbarsperator = toolbar2His.getItemById('bottomtoolbarseprator');
  3611. toolbarsperator.element.setWidth((_w * 0.5 - 90) * ratio.ratioX);
  3612. toolbar2His.redraw();
  3613. })
  3614. GD.setAlarmTableStyle(borderPaneHis, tablePaneHis, toolbarHis, toolbar2His, formHisLeft, tablestyle);
  3615. if (alarmLevelVisible) {
  3616. toggleColumnDisplay('故障', tablePaneHis, toolbarHis, toolbar2His);
  3617. }
  3618. // 导出历史报警
  3619. function exportHistoryAlarmData() {
  3620. searchHisAlarmInfos(1, 1000, dataAreaInfoHis.getValue() || '*', alarmGroupHis.getValue() || '*', alarmLevelValueHis, hisStartTime, hisEndTime, alarmStateHis.getValue() || '*', function (data) {
  3621. if (data.total > 1000) { // 如果报警条数大于10000条,就重新再获取一次数据
  3622. searchHisAlarmInfos(1, data.total, dataAreaInfoHis.getValue() || '*', alarmGroupHis.getValue() || '*', alarmLevelValueHis, hisStartTime, hisEndTime, alarmStateHis.getValue() || '*', function (data) {
  3623. exportHisDataToCsv(data.data);
  3624. })
  3625. } else {
  3626. exportHisDataToCsv(data.data);
  3627. }
  3628. });
  3629. function exportHisDataToCsv(data) {
  3630. if (!data) return;
  3631. var columnData = tablePaneHis.getColumnModel();
  3632. var tempArr = [],
  3633. resultArr = [],
  3634. visibleColumnArr = [],
  3635. c, d, n, info;
  3636. columnData.each(function (data) {
  3637. if (data.isVisible()) {
  3638. visibleColumnArr.push(data);
  3639. tempArr.push(data.getDisplayName());
  3640. }
  3641. });
  3642. resultArr.push(tempArr);
  3643. for (var j = 0, leng = data.length; j < leng; j++) {
  3644. d = data[j];
  3645. tempArr = [];
  3646. for (var i = 0, len = visibleColumnArr.length; i < len; i++) {
  3647. c = visibleColumnArr[i];
  3648. n = c.getName();
  3649. info = d[alarmHisTableColumnDic[n]];
  3650. if (n === 'alarmtime') {
  3651. info = moment(info).format('YYYY-MM-DD HH:mm:ss');
  3652. }
  3653. if (n === 'area') {
  3654. info = alarmAreasDic[info] || '-';
  3655. }
  3656. if (n === 'alarmGroup') {
  3657. info = alarmGroupDicName[info] && alarmGroupDicName[info].group_name || '-';
  3658. }
  3659. if (n === 'alarmlevel') {
  3660. info = alarmLevelDic[info] && alarmLevelDic[info].level_name || '-';
  3661. }
  3662. if (n === 'state') {
  3663. if (d.is_ensure) {
  3664. if (d.is_reset) {
  3665. info = '已确认|已复归';
  3666. } else {
  3667. info = '已确认|未复归';
  3668. }
  3669. } else {
  3670. if (d.is_reset) {
  3671. info = '未确认|已复归';
  3672. } else {
  3673. info = '未确认|未复归';
  3674. }
  3675. }
  3676. }
  3677. tempArr.push(info);
  3678. }
  3679. resultArr.push(tempArr);
  3680. }
  3681. GD.exportArrToCsv(resultArr, '历史报警');
  3682. }
  3683. }
  3684. //tableViewHis.setCheckMode(true);
  3685. borderPaneHisNode.exportHistoryAlarmData = exportHistoryAlarmData;
  3686. return borderPaneHisNode;
  3687. }
  3688. //报警点配置
  3689. function createAlarmPointConfig(x, y, width, height) {
  3690. currentControlContent += "alarmpointconfig";
  3691. var pageCount = 0;
  3692. borderPanePointConfig = new ht.widget.BorderPane();
  3693. dataModelPointConfig = new ht.DataModel();
  3694. tablePanePointConfig = new ht.widget.TablePane(dataModelPointConfig);
  3695. borderPanePointConfig.setCenterView(tablePanePointConfig);
  3696. var borderPanePointConfigNode = new ht.HtmlNode();
  3697. borderPanePointConfigNode.setScalable(false);
  3698. borderPanePointConfigNode.s({
  3699. '2d.selectable': true,
  3700. '2d.movable': false
  3701. });
  3702. borderPanePointConfigNode.setHtml(borderPanePointConfig);
  3703. borderPanePointConfigNode.setPosition({
  3704. x: x,
  3705. y: y
  3706. });
  3707. borderPanePointConfigNode.setWidth(width);
  3708. borderPanePointConfigNode.setHeight(height);
  3709. borderPanePointConfigNode.setPadding(0);
  3710. dataModel.add(borderPanePointConfigNode);
  3711. var dataAreaInfoPointConfig = new ht.widget.ComboBox();
  3712. dataAreaInfoPointConfig.setWidth(120);
  3713. // dataAreaInfoPointConfig.setEditable(true);
  3714. dataAreaInfoPointConfig.setDropDownWidth(120);
  3715. getAlarmAreas(function (data) {
  3716. dataTypes = [];
  3717. if (GD.isEmptyObj(data)) {
  3718. dataTypes.push('*');
  3719. } else {
  3720. for (var i = 0; i < data.length; i++) {
  3721. dataTypes.push(data[i].area_name);
  3722. }
  3723. }
  3724. dataAreaInfoPointConfig.setValues(dataTypes);
  3725. dataAreaInfoPointConfig.setValue(dataTypes[0]);
  3726. });
  3727. dataAreaName = dataAreaInfoPointConfig.getValue();
  3728. var pointDataTypePointConfig = new ht.widget.ComboBox();
  3729. // pointDataTypePointConfig.setEditable(true);
  3730. pointDataTypePointConfig.setWidth(150);
  3731. pointDataTypePointConfig.setDropDownWidth(140);
  3732. var pointTypesPointConfig = getDataTypes();
  3733. pointDataTypePointConfig.setValues(pointTypesPointConfig);
  3734. pointDataTypePointConfig.setValue(pointTypesPointConfig[0]);
  3735. pointtypePointConfig = pointDataTypePointConfig.getValue();
  3736. var alarmCategoryPointConfig = new ht.widget.ComboBox();
  3737. var alarmCategoriesPointConfig = getAlarmCategories(function (categroyData) {
  3738. if (!categroyData) return;
  3739. var categroyArr = ['*'];
  3740. for (var key in categroyData) {
  3741. if (categroyData.hasOwnProperty(key)) {
  3742. categroyArr.push(categroyArr[key]);
  3743. }
  3744. }
  3745. alarmCategoryPointConfig.setValues(categroyArr);
  3746. alarmCategoryPointConfig.setValue(categroyArr[0]);
  3747. });
  3748. var alarmLevelPointConfig = new ht.widget.ComboBox();
  3749. getAlarmLevels(alarmLevelPointConfig);
  3750. var alarmPointConfigId = ",";
  3751. getAlarmPoints(dataModelPointConfig, tablePanePointConfig);
  3752. var toolbarPointConfig = new ht.widget.Toolbar([{
  3753. label: '区域:',
  3754. element: dataAreaInfoPointConfig,
  3755. unfocusable: true
  3756. },
  3757. {
  3758. label: '点类型:',
  3759. element: pointDataTypePointConfig,
  3760. unfocusable: true
  3761. },
  3762. {
  3763. button: {
  3764. width: 50,
  3765. label: '查询',
  3766. borderColor: '#31647e',
  3767. //labelColor: '#52b4d7',
  3768. background: '#52b4d7',
  3769. onClicked: function () {
  3770. pageinputPointConfig.value = 1;
  3771. dataAreaName = dataAreaInfoPointConfig.getValue();
  3772. pointtypePointConfig = pointDataTypePointConfig.getValue();
  3773. getAlarmPoints(dataModelPointConfig, tablePanePointConfig, pageinputPointConfig.value, rowssizePointConfig.getValue(), pageCountPointConfig, dataAreaName, pointtypePointConfig);
  3774. }
  3775. }
  3776. },
  3777. {
  3778. button: {
  3779. width: 50,
  3780. label: '添加',
  3781. borderColor: '#31647e',
  3782. background: '#52b4d7',
  3783. onClicked: function () {
  3784. addPointConfig();
  3785. }
  3786. }
  3787. },
  3788. {
  3789. button: {
  3790. width: 50,
  3791. label: '删除',
  3792. borderColor: '#31647e',
  3793. background: '#52b4d7',
  3794. onClicked: function () {
  3795. var alarmPointConfigIds;
  3796. var dicmap = tableViewPointConfig.sm()._map;
  3797. var alarmPointTagNames = {};
  3798. for (var key in dicmap) {
  3799. alarmPointConfigIds = key;
  3800. alarmPointTagNames = {
  3801. tag_name: dicmap[key]._attrObject.tagName
  3802. }
  3803. dataModelPointConfig.removeDataById(key);
  3804. }
  3805. deleteAlarmPoints(alarmPointTagNames);
  3806. }
  3807. }
  3808. },
  3809. {
  3810. button: {
  3811. width: 50,
  3812. label: '确认',
  3813. borderColor: '#31647e',
  3814. background: '#52b4d7',
  3815. onClicked: function () {
  3816. //alert(2)
  3817. var tagnamesPoint = [];
  3818. var tagobj = {};
  3819. var dicmapPoint = tablePanePointConfig.getTableView().sm()._map;
  3820. for (var key in dicmapPoint) {
  3821. EnsureUser = JSON.stringify(dicmapPoint[key]._attrObject.desc);
  3822. Ensuretag = dicmapPoint[key]._attrObject.tagName;
  3823. tagobj = {
  3824. "tag_name": Ensuretag,
  3825. "ensure_info": EnsureUser
  3826. };
  3827. tagnamesPoint.push(tagobj);
  3828. }
  3829. ensureAlarm(tagnamesPoint);
  3830. getAlarmPoints(dataModelPointConfig, tablePanePointConfig, pageinputPointConfig.value, rowssizePointConfig.getValue(), pageCountPointConfig, dataAreaName, pointtypePointConfig);
  3831. }
  3832. }
  3833. }
  3834. ]);
  3835. toolbarPointConfig.getLabelColor = function (item) {
  3836. return '#52b4d7';
  3837. };
  3838. toolbarPointConfig.getView().style.background = '#3D3D3D';
  3839. borderPanePointConfig.setTopView(toolbarPointConfig);
  3840. toolbarPointConfig.setStickToRight(false);
  3841. pageinputPointConfig = document.createElement('input');
  3842. pageinputPointConfig.value = 1;
  3843. pageinputPointConfig.style.position = 'absolute';
  3844. pageinputPointConfig.style.margin = 0;
  3845. pageinputPointConfig.style.padding = '0px 2px';
  3846. pageinputPointConfig.style.outline = 0;
  3847. pageinputPointConfig.style.border = 0;
  3848. pageinputPointConfig.style.width = '60px';
  3849. pageinputPointConfig.style.height = ht.Default.widgetRowHeight + 'px';
  3850. pageinputPointConfig.onfocus = function () {
  3851. pageinputPointConfig.style.outline = '1px solid ' + ht.Color.highlight;
  3852. };
  3853. pageinputPointConfig.onblur = function () {
  3854. pageinputPointConfig.style.outline = 0;
  3855. };
  3856. pageinputPointConfig.onkeydown = function (e) {
  3857. if (e.keyCode === 13) {
  3858. //self.request();
  3859. }
  3860. };
  3861. rowssizePointConfig = new ht.widget.ComboBox();
  3862. rowssizePointConfig.setValues([10, 20, 30, 50, 100]);
  3863. rowssizePointConfig.setValue(20);
  3864. // rowssizePointConfig.setEditable(true);
  3865. rowssizePointConfig.setWidth(50);
  3866. rowssizePointConfig.setDropDownWidth(140);
  3867. rowssizePointConfig.onValueChanged = function () {
  3868. pageinputPointConfig.value = 1;
  3869. dataModelPointConfig.clear();
  3870. getAlarmPoints(dataModelPointConfig, pageinputPointConfig.value, rowssizePointConfig.getValue(), pageCountPointConfig, dataAreaName, pointtypePointConfig);
  3871. };
  3872. var toolbar2PointConfig = new ht.widget.Toolbar([{
  3873. label: 'Rows:',
  3874. element: rowssizePointConfig
  3875. },
  3876. {
  3877. label: "<<",
  3878. action: function () {
  3879. pageinputPointConfig.value = 1;
  3880. getAlarmPoints(dataModelPointConfig, pageinputPointConfig.value, rowssizePointConfig.getValue(), pageCountPointConfig, dataAreaName, pointtypePointConfig);
  3881. }
  3882. },
  3883. {
  3884. label: "<",
  3885. action: function () {
  3886. if (Number(pageinputPointConfig.value) > 1) {
  3887. pageinputPointConfig.value = Number(pageinputPointConfig.value) - 1;
  3888. dataModelPointConfig.clear();
  3889. getAlarmPoints(dataModelPointConfig, pageinputPointConfig.value, rowssizePointConfig.getValue(), pageCountPointConfig, dataAreaName, pointtypePointConfig);
  3890. }
  3891. }
  3892. },
  3893. {
  3894. label: 'Page:',
  3895. element: pageinputPointConfig
  3896. },
  3897. {
  3898. label: '>',
  3899. action: function () {
  3900. if (Number(pageinputPointConfig.value) < Number(pageCountPointConfig.getValue())) {
  3901. pageinputPointConfig.value = Number(pageinputPointConfig.value) + 1;
  3902. dataModelPointConfig.clear();
  3903. getAlarmPoints(dataModelPointConfig, pageinputPointConfig.value, rowssizePointConfig.getValue(), pageCountPointConfig, dataAreaName, pointtypePointConfig);
  3904. }
  3905. }
  3906. },
  3907. {
  3908. label: ">>",
  3909. action: function () {
  3910. pageinputPointConfig.value = pageCountPointConfig.getValue();
  3911. dataModelPointConfig.clear();
  3912. getAlarmPoints(dataModelPointConfig, pageinputPointConfig.value, rowssizePointConfig.getValue(), pageCountPointConfig, dataAreaName, pointtypePointConfig);
  3913. }
  3914. }
  3915. ]);
  3916. toolbar2PointConfig.getLabelColor = function (item) {
  3917. return 'white';
  3918. };
  3919. toolbar2PointConfig.getView().style.background = '#3D3D3D';
  3920. borderPanePointConfig.setBottomView(toolbar2PointConfig);
  3921. toolbar2PointConfig.setStickToRight(true);
  3922. viewPointConfig = borderPanePointConfig.getView();
  3923. viewPointConfig.className = 'main';
  3924. document.body.appendChild(viewPointConfig);
  3925. window.addEventListener('resize', function (e) {
  3926. borderPanePointConfig.invalidate();
  3927. }, false);
  3928. dataModelPointConfig.onDataPropertyChanged = function (data, e) {
  3929. if (alarmPointConfigId.indexOf(',' + data._id + ',') == -1) {
  3930. alarmPointConfigId += data._id + ",";
  3931. }
  3932. };
  3933. var pointconfigAlarmGroups = getAlarmGroups();
  3934. var pointconfigAlarmLevels = getAlarmLevels();
  3935. function addPointConfig() {
  3936. var dialog = window.dialog = new ht.widget.Dialog();
  3937. formPanePointConfig = new ht.widget.FormPane();
  3938. dataModelTag = new ht.DataModel();
  3939. tablePointConfigPane = new ht.widget.TablePane(dataModelTag);
  3940. var pointConfigAttributes = [{
  3941. name: 'id',
  3942. displayName: 'Id',
  3943. align: 'center',
  3944. width: 50
  3945. },
  3946. {
  3947. name: 'configPointName',
  3948. displayName: '标签名',
  3949. align: 'center',
  3950. accessType: 'attr',
  3951. width: 180
  3952. },
  3953. {
  3954. name: 'configPointDesc',
  3955. displayName: '描述',
  3956. align: 'center',
  3957. accessType: 'attr',
  3958. width: 300
  3959. }
  3960. ];
  3961. tablePointConfigPane.addColumns(pointConfigAttributes);
  3962. tablePointCofigView = tablePointConfigPane.getTableView();
  3963. tablePointCofigView.setCheckMode(true);
  3964. document.body.appendChild(formPanePointConfig.getView());
  3965. var alarmType = -1; //0为模拟量 1为数字量
  3966. formPanePointConfig.addRow([
  3967. '测点类型:',
  3968. {
  3969. id: 'pointAlarmType',
  3970. comboBox: {
  3971. values: ['模拟量', '数字量'],
  3972. value: '模拟量',
  3973. onValueChanged: function () {
  3974. if (this.getValue() == "模拟量") {
  3975. if (alarmType == 1) {
  3976. formPanePointConfig.removeRow(3);
  3977. formPanePointConfig.removeRow(3); /*加1报时增*/
  3978. addAnalogRows(formPanePointConfig, pointconfigAlarmLevels, pointConfigLevelValue, alarmCategoriesPointConfig);
  3979. }
  3980. alarmType = 0;
  3981. } else {
  3982. if (alarmType == 0 || alarmType == -1) {
  3983. formPanePointConfig.removeRow(3);
  3984. formPanePointConfig.removeRow(3);
  3985. formPanePointConfig.removeRow(3);
  3986. }
  3987. alarmType = 1;
  3988. addDigitalRows(formPanePointConfig, pointconfigAlarmLevels, pointConfigLevelValue, alarmCategoriesPointConfig);
  3989. }
  3990. }
  3991. }
  3992. },
  3993. '标签名称:',
  3994. {
  3995. id: 'pointName',
  3996. textField: {
  3997. text: '*'
  3998. }
  3999. },
  4000. '标签描述:',
  4001. {
  4002. id: 'pointDesc',
  4003. textField: {
  4004. text: '*'
  4005. }
  4006. },
  4007. {
  4008. button: {
  4009. label: '查找',
  4010. onClicked: function () {
  4011. dataModelTag.clear();
  4012. var tagDataType = formPanePointConfig.v('pointAlarmType') == "模拟量" ? "false" : "true";
  4013. var tagName = formPanePointConfig.v('pointName');
  4014. var tagDesc = formPanePointConfig.v('pointDesc');
  4015. getTags(tagDataType, tagName, tagDesc, dataModelTag);
  4016. }
  4017. }
  4018. }
  4019. ], [60, 0.03, 60, 0.03, 60, 0.03, 60, 0.03]);
  4020. formPanePointConfig.addRow([tablePointConfigPane], [0.1], 0.1);
  4021. var alarmLevels = [];
  4022. for (var i in pointconfigAlarmLevels) {
  4023. if (pointconfigAlarmLevels[i] != "*") {
  4024. alarmLevels.push(pointconfigAlarmLevels[i]);
  4025. }
  4026. }
  4027. var pointConfigLevelValue = alarmLevels.length > 0 ? alarmLevels[0] : "";
  4028. formPanePointConfig.addRow([
  4029. '组:',
  4030. {
  4031. id: 'pointGroup',
  4032. comboBox: {
  4033. values: pointconfigAlarmGroups,
  4034. value: pointconfigAlarmGroups[0]
  4035. }
  4036. }
  4037. ], [60, 0.03]);
  4038. addAnalogRows(formPanePointConfig, alarmLevels, pointConfigLevelValue, alarmCategoriesPointConfig);
  4039. dialog.setConfig({
  4040. title: "报警规则添加",
  4041. titleIcon: 'node_image',
  4042. content: formPanePointConfig,
  4043. width: 600,
  4044. height: 450,
  4045. draggable: true,
  4046. closable: true,
  4047. maximizable: true,
  4048. resizeMode: "wh",
  4049. buttons: [{
  4050. label: "保存"
  4051. }, {
  4052. label: "取消",
  4053. className: "button-yes"
  4054. }],
  4055. buttonsAlign: "center",
  4056. action: function (item, e) {
  4057. if (item.label == "保存") {
  4058. //var alarmFilterSettings;
  4059. var alarmobj = {};
  4060. var groupName = formPanePointConfig.v('pointGroup');
  4061. if (alarmType == 0) {
  4062. if (checkNumber(formPanePointConfig.v('highvalue1'))) {
  4063. var alarmFilterSetting1 = new AlarmFilterSetting();
  4064. alarmFilterSetting1.message = formPanePointConfig.v('highdesc1');
  4065. alarmFilterSetting1.value = (Number(formPanePointConfig.v('highvalue1')));
  4066. var levelName1 = getAlarmLevelNameByName(formPanePointConfig.v('highlevel1'));
  4067. alarmFilterSetting1.level = levelName1;
  4068. alarmFilterSetting1;
  4069. }
  4070. if (checkNumber(formPanePointConfig.v('highvalue2'))) {
  4071. var alarmFilterSetting2 = new AlarmFilterSetting();
  4072. alarmFilterSetting2.message = formPanePointConfig.v('highdesc2');
  4073. alarmFilterSetting2.value = (Number(formPanePointConfig.v('highvalue2')));
  4074. var levelName2 = getAlarmLevelNameByName(formPanePointConfig.v('highlevel2'));
  4075. alarmFilterSetting2.level = levelName2;
  4076. alarmFilterSetting2;
  4077. }
  4078. if (checkNumber(formPanePointConfig.v('highvalue3'))) {
  4079. var alarmFilterSetting3 = new AlarmFilterSetting();
  4080. alarmFilterSetting3.message = formPanePointConfig.v('highdesc3');
  4081. alarmFilterSetting3.value = (Number(formPanePointConfig.v('highvalue3')));
  4082. var levelName3 = getAlarmLevelNameByName(formPanePointConfig.v('highlevel3'));
  4083. alarmFilterSetting3.level = levelName3;
  4084. alarmFilterSetting3;
  4085. }
  4086. if (checkNumber(formPanePointConfig.v('lowvalue1'))) {
  4087. var alarmFilterSetting4 = new AlarmFilterSetting();
  4088. alarmFilterSetting4.message = formPanePointConfig.v('lowdesc1');
  4089. alarmFilterSetting4.value = (Number(formPanePointConfig.v('lowvalue1')));
  4090. var levelName4 = getAlarmLevelNameByName(formPanePointConfig.v('lowlevel1'));
  4091. alarmFilterSetting4.level = levelName4;
  4092. alarmFilterSetting4;
  4093. }
  4094. if (checkNumber(formPanePointConfig.v('lowvalue2'))) {
  4095. var alarmFilterSetting5 = new AlarmFilterSetting();
  4096. alarmFilterSetting5.message = formPanePointConfig.v('lowdesc2');
  4097. alarmFilterSetting5.value = (Number(formPanePointConfig.v('lowvalue2')));
  4098. var levelName5 = getAlarmLevelNameByName(formPanePointConfig.v('lowlevel2'));
  4099. alarmFilterSetting5.level = levelName5;
  4100. alarmFilterSetting5;
  4101. }
  4102. if (checkNumber(formPanePointConfig.v('lowvalue3'))) {
  4103. var alarmFilterSetting6 = new AlarmFilterSetting();
  4104. alarmFilterSetting6.message = formPanePointConfig.v('lowdesc3');
  4105. alarmFilterSetting6.value = (Number(formPanePointConfig.v('lowvalue3')));
  4106. var levelName6 = getAlarmLevelNameByName(formPanePointConfig.v('lowlevel3'));
  4107. alarmFilterSetting6.level = levelName6;
  4108. alarmFilterSetting6;
  4109. }
  4110. alarmobj = {
  4111. h1: alarmFilterSetting1,
  4112. h2: alarmFilterSetting2,
  4113. h3: alarmFilterSetting3,
  4114. l1: alarmFilterSetting4,
  4115. l2: alarmFilterSetting5,
  4116. l3: alarmFilterSetting6
  4117. }
  4118. var dicmap = tablePointCofigView.sm()._map;
  4119. var alarmpoints = [];
  4120. for (var key in dicmap) {
  4121. var factag = {};
  4122. var tag = dataModelTag.getDataById(key);
  4123. var alarmPoint = new AlarmPoints();
  4124. alarmPoint.tag_name = tag._attrObject.configPointName;
  4125. alarmPoint.template = 'analog';
  4126. alarmPoint.description = tag._attrObject.configPointDesc;
  4127. alarmPoint.attributes = JSON.stringify(alarmobj);
  4128. factag = {
  4129. tag: tag._attrObject.configPointName
  4130. };
  4131. alarmPoint.factor_tags = JSON.stringify(factag);
  4132. alarmpoints.push(alarmPoint);
  4133. }
  4134. updateAlarmPoints(alarmpoints);
  4135. }
  4136. if (alarmType == 1) {
  4137. /*0报*/
  4138. var alarmFilterSettingDigital1 = new AlarmFilterSetting();
  4139. alarmFilterSettingDigital1.message = formPanePointConfig.v('shiftAlarmDesc1');
  4140. var levelName1 = getAlarmLevelNameByName(formPanePointConfig.v('shiftlevel1')); //shiftTo1
  4141. alarmFilterSettingDigital1.level = levelName1;
  4142. alarmFilterSettingDigital1;
  4143. /*1报*/
  4144. var alarmFilterSettingDigital2 = new AlarmFilterSetting();
  4145. alarmFilterSettingDigital2.message = formPanePointConfig.v('shiftAlarmDesc2');
  4146. var levelName2 = getAlarmLevelNameByName(formPanePointConfig.v('shiftlevel2')); //shiftTo1
  4147. alarmFilterSettingDigital2.level = levelName2;
  4148. alarmFilterSettingDigital2;
  4149. alarmobj = {
  4150. to0: alarmFilterSettingDigital1,
  4151. to1: alarmFilterSettingDigital2
  4152. }
  4153. var dicmap = tablePointCofigView.sm()._map;
  4154. var alarmpoints = [];
  4155. for (var key in dicmap) {
  4156. var factag = {};
  4157. var tag = dataModelTag.getDataById(key);
  4158. var alarmPoint = new AlarmPoints();
  4159. alarmPoint.tag_name = tag._attrObject.configPointName;
  4160. alarmPoint.template = 'boolean';
  4161. alarmPoint.description = tag._attrObject.configPointDesc;
  4162. alarmPoint.attributes = JSON.stringify(alarmobj);
  4163. factag = {
  4164. tag: tag._attrObject.configPointName
  4165. };
  4166. alarmPoint.factor_tags = JSON.stringify(factag);
  4167. alarmpoints.push(alarmPoint);
  4168. }
  4169. updateAlarmPoints(alarmpoints);
  4170. }
  4171. dialog.hide();
  4172. getAlarmPoints(dataModelPointConfig, 1, 20, pageCountPointConfig, dataAreaName, pointtypePointConfig);
  4173. }
  4174. if (item.label == "取消") {
  4175. dialog.hide();
  4176. }
  4177. }
  4178. });
  4179. dialog.show();
  4180. }
  4181. pageCountPointConfig = new ht.widget.TextField();
  4182. var attributes = [{
  4183. name: 'tagnum',
  4184. displayName: '序号',
  4185. color: "#ceae42",
  4186. align: 'center',
  4187. accessType: 'attr',
  4188. width: 150,
  4189. editable: false
  4190. },
  4191. {
  4192. name: 'area',
  4193. displayName: '区域',
  4194. color: "#ceae42",
  4195. align: 'center',
  4196. accessType: 'attr',
  4197. width: 150,
  4198. editable: false
  4199. },
  4200. {
  4201. name: 'tagName',
  4202. displayName: '标签名',
  4203. color: "#ceae42",
  4204. align: 'center',
  4205. accessType: 'attr',
  4206. width: 700,
  4207. editable: false
  4208. },
  4209. {
  4210. name: 'desc',
  4211. displayName: '描述',
  4212. color: "#ceae42",
  4213. align: 'center',
  4214. accessType: 'attr',
  4215. width: 60,
  4216. editable: false
  4217. },
  4218. {
  4219. name: 'rol',
  4220. displayName: '报警规则',
  4221. color: "#ceae42",
  4222. align: 'center',
  4223. accessType: 'attr',
  4224. width: 60,
  4225. editable: false
  4226. },
  4227. {
  4228. name: 'group',
  4229. displayName: '组',
  4230. color: "#ceae42",
  4231. align: 'center',
  4232. accessType: 'attr',
  4233. width: 60,
  4234. editable: false
  4235. },
  4236. {
  4237. name: 'issheild',
  4238. displayName: '是否屏蔽',
  4239. color: "#ceae42",
  4240. align: 'center',
  4241. accessType: 'attr',
  4242. width: 60,
  4243. editable: false,
  4244. enum: {
  4245. values: ["开", "关"],
  4246. editable: true,
  4247. maxHeight: 120
  4248. }
  4249. }
  4250. ];
  4251. tablePanePointConfig.addColumns(attributes);
  4252. tableViewPointConfig = tablePanePointConfig.getTableView();
  4253. tablePanePointConfig.getView().style.background = "#0C152A"; //"Honeydew";
  4254. tableViewPointConfig.setRowLineColor('#54b7db');
  4255. tableViewPointConfig.setColumnLineColor('transparent');
  4256. tableViewPointConfig.setSelectBackground("#31647e");
  4257. tableViewPointConfig.setRowHeight(25);
  4258. tableViewPointConfig.getLabelColor = function () {
  4259. return ("white")
  4260. };
  4261. tableViewPointConfig.setCheckMode(true);
  4262. var arrary = '';
  4263. //propertyView.addProperties(attributes);
  4264. }
  4265. //报警分组
  4266. function createAlarmGroup(x, y, width, height) {
  4267. dataModelGroup = new ht.DataModel();
  4268. tablePaneGroup = new ht.widget.TablePane(dataModelGroup);
  4269. borderPaneGroup = new ht.widget.BorderPane();
  4270. borderPaneGroup.setCenterView(tablePaneGroup)
  4271. getAlarmGropTables(dataModelGroup, tablePaneGroup);
  4272. var attributesAlarmGroup = [{
  4273. name: 'id',
  4274. displayName: '编号',
  4275. color: "#ceae42",
  4276. align: 'center',
  4277. width: 50
  4278. },
  4279. {
  4280. name: 'groupName',
  4281. displayName: '组名称',
  4282. color: "#ceae42",
  4283. align: 'center',
  4284. accessType: 'attr',
  4285. width: 500,
  4286. editable: true
  4287. },
  4288. {
  4289. name: 'groupDesc',
  4290. displayName: '说明',
  4291. color: "#ceae42",
  4292. align: 'center',
  4293. accessType: 'attr',
  4294. width: 550,
  4295. editable: true
  4296. }
  4297. ];
  4298. tablePaneGroup.addColumns(attributesAlarmGroup);
  4299. tableGroupView = tablePaneGroup.getTableView();
  4300. tablePaneGroup.getView().style.background = "#0C152A"; //"Honeydew";
  4301. tableGroupView.setRowLineColor('#54b7db');
  4302. tableGroupView.setColumnLineColor('transparent');
  4303. tableGroupView.setSelectBackground("#31647e");
  4304. tableGroupView.setRowHeight(25);
  4305. tableGroupView.getLabelColor = function () {
  4306. return ("white")
  4307. };
  4308. tableGroupView.setCheckMode(true);
  4309. var changeCateId = ",";
  4310. dataModelGroup.onDataPropertyChanged = function (data, e) {
  4311. if (changeCateId.indexOf(',' + data._id + ',') == -1) {
  4312. changeCateId += data._id + ",";
  4313. }
  4314. }
  4315. var toolbarAlarmGroup = new ht.widget.Toolbar([{
  4316. button: {
  4317. width: 50,
  4318. label: '添加',
  4319. borderColor: '#31647e',
  4320. background: '#52b4d7',
  4321. onClicked: function () {
  4322. addCateData();
  4323. }
  4324. }
  4325. },
  4326. {
  4327. button: {
  4328. width: 50,
  4329. label: '删除',
  4330. borderColor: '#31647e',
  4331. background: '#52b4d7',
  4332. onClicked: function () {
  4333. var cateIds;
  4334. var dicmap = tableGroupView.sm()._map;
  4335. for (var key in dicmap) {
  4336. cateIds = key;
  4337. dataModelGroup.removeDataById(key);
  4338. }
  4339. deleteAlarmGrop(cateIds);
  4340. }
  4341. }
  4342. }, {
  4343. button: {
  4344. width: 50,
  4345. label: '保存',
  4346. borderColor: '#31647e',
  4347. background: '#52b4d7',
  4348. onClicked: function () {
  4349. updateGroupData();
  4350. }
  4351. }
  4352. }
  4353. ]);
  4354. //修改报警组
  4355. function updateGroupData() {
  4356. if (changeCateId === ',') {
  4357. //getAlarmGropTables(dataModelGroup,tablePaneGroup);
  4358. } else {
  4359. var updateGroups;
  4360. var ids = changeCateId.split(",");
  4361. for (var i = 0; i < ids.length; i++) {
  4362. if (ids[i].length != 0) {
  4363. var dataModel = dataModelGroup.getDataById(ids[i]);
  4364. var alarmGroup = dataModel._attrObject;
  4365. var alarmGroups = new AlarmGroup();
  4366. alarmGroups.id = {
  4367. "value": Number(ids[i])
  4368. };
  4369. alarmGroups.group_name = {
  4370. "value": alarmGroup.groupName
  4371. };
  4372. updateGroups = alarmGroups;
  4373. }
  4374. }
  4375. updateAlarmGroup(updateGroups);
  4376. getAlarmGropTables(dataModelGroup, tablePaneGroup);
  4377. }
  4378. }
  4379. function addCateData() {
  4380. data = new ht.Data();
  4381. //data.setId(5);//改为随机数据
  4382. data.setId(GetRandomNum(0, 99999));
  4383. data.a('groupName', "组名称");
  4384. data.a('groupDesc', "说明");
  4385. dataModelGroup.add(data);
  4386. dataModelGroup.sm().ss(data);
  4387. tableGroupView.setFocusDataById(data.getId());
  4388. }
  4389. toolbarAlarmGroup.getLabelColor = function (item) {
  4390. return 'white';
  4391. };
  4392. toolbarAlarmGroup.getView().style.background = '#3D3D3D';
  4393. borderPaneGroup.setTopView(toolbarAlarmGroup);
  4394. var borderPaneGroupNode = new ht.HtmlNode();
  4395. borderPaneGroupNode.setScalable(false);
  4396. borderPaneGroupNode.s({
  4397. '2d.selectable': true,
  4398. '2d.movable': false
  4399. });
  4400. borderPaneGroupNode.setHtml(borderPaneGroup);
  4401. borderPaneGroupNode.setPosition({
  4402. x: x,
  4403. y: y
  4404. });
  4405. borderPaneGroupNode.setWidth(width);
  4406. borderPaneGroupNode.setHeight(height);
  4407. borderPaneGroupNode.setPadding(0);
  4408. dataModel.add(borderPaneGroupNode);
  4409. }
  4410. //报警区域
  4411. /*function createAlarmArea(x,y,width,height){
  4412. dataModelArea=new ht.DataModel();
  4413. tablePaneArea = new ht.widget.TablePane(dataModelArea);
  4414. borderPaneArea=new ht.widget.BorderPane();
  4415. borderPaneArea.setCenterView(tablePaneArea)
  4416. getAlarmAreaTables(dataModelArea);
  4417. var attributesAlarmArea=[
  4418. {
  4419. name: 'id',
  4420. displayName:'编号',
  4421. align: 'center',
  4422. width:50
  4423. },
  4424. {
  4425. name: 'areaName',
  4426. displayName:'区域',
  4427. align: 'center',
  4428. accessType:'attr',
  4429. width:500,
  4430. editable: true
  4431. },
  4432. {
  4433. name: 'parentId',
  4434. displayName:'父ID',
  4435. align: 'center',
  4436. accessType:'attr',
  4437. width:500,
  4438. editable: true
  4439. }
  4440. ];
  4441. tablePaneArea.addColumns(attributesAlarmArea);
  4442. var changeCateId=",";
  4443. dataModelArea.onDataPropertyChanged=function(data,e){
  4444. if(changeCateId.indexOf(','+data._id+',')==-1){
  4445. changeCateId+=data._id+",";
  4446. }
  4447. }
  4448. var toolbarAlarmArea=new ht.widget.Toolbar([
  4449. {
  4450. button: {
  4451. width: 50,
  4452. label: '添加',
  4453. onClicked: function(){
  4454. addAreaData();
  4455. }
  4456. }
  4457. },
  4458. {
  4459. button: {
  4460. width: 50,
  4461. label: '删除',
  4462. onClicked: function(){
  4463. var cateIds;
  4464. var dicmap=tableAreaView.sm()._map;
  4465. for(var key in dicmap){
  4466. console.log(key)
  4467. cateIds=key;
  4468. dataModelArea.removeDataById(key);
  4469. }
  4470. deleteAlarmArea(cateIds)
  4471. }
  4472. }
  4473. }, {
  4474. button: {
  4475. width: 50,
  4476. label: '保存',
  4477. onClicked: function(){
  4478. updateAreaData();
  4479. }
  4480. }
  4481. }
  4482. ]);
  4483. function updateAreaData() {
  4484. if (changeCateId === ',') {
  4485. //getAlarmAreaTables(dataModelArea);
  4486. }
  4487. else {
  4488. var updateAreas;
  4489. var ids = changeCateId.split(",");
  4490. for (var i = 0; i < ids.length; i++) {
  4491. if (ids[i].length != 0) {
  4492. var dataModel = dataModelArea.getDataById(ids[i]);
  4493. var alarmArea = dataModel._attrObject;
  4494. console.log(alarmArea)
  4495. var alarmAreas = new AlarmArea();
  4496. alarmAreas.id={"value":Number(ids[i])};
  4497. alarmAreas.area_name = {"value":alarmArea.areaName};
  4498. alarmAreas.parent_id={"value":alarmArea.parentId};
  4499. updateAreas=alarmAreas;
  4500. }
  4501. }
  4502. updateAlarmArea(updateAreas)
  4503. getAlarmAreaTables(dataModelArea);
  4504. }
  4505. }
  4506. function addAreaData(){
  4507. data = new ht.Data();
  4508. //data.setId(5);//改为随机数据
  4509. data.setId(GetRandomNum(0,99999));
  4510. data.a('areaName',"区域");
  4511. data.a('parentId',"父ID");
  4512. dataModelArea.add(data);
  4513. dataModelArea.sm().ss(data);
  4514. tableAreaView.setFocusDataById(data.getId());
  4515. }
  4516. tableAreaView=tablePaneArea.getTableView();
  4517. tableAreaView.setCheckMode(true);
  4518. toolbarAlarmArea.getLabelColor = function(item){ return 'white'; };
  4519. toolbarAlarmArea.getView().style.background = '#3D3D3D';
  4520. borderPaneArea.setTopView(toolbarAlarmArea);
  4521. var borderPaneAreaNode = new ht.HtmlNode();
  4522. borderPaneAreaNode.setScalable(false);
  4523. borderPaneAreaNode.s({
  4524. '2d.selectable': true,
  4525. '2d.movable': false
  4526. });
  4527. borderPaneAreaNode.setHtml(borderPaneArea);
  4528. borderPaneAreaNode.setPosition({x:x,y:y});
  4529. borderPaneAreaNode.setWidth(width);
  4530. borderPaneAreaNode.setHeight(height);
  4531. borderPaneAreaNode.setPadding(0);
  4532. dataModel.add(borderPaneAreaNode);
  4533. }*/
  4534. //添加模拟量报警规则
  4535. function addAnalogRows(node, pointconfigAlarmLevels, pointConfigLevelValue, alarmCategories) {
  4536. formPanePointConfig.addRow([
  4537. alarmCategories[1],
  4538. {
  4539. id: 'highvalue1', //高一
  4540. textField: {
  4541. text: '*'
  4542. }
  4543. },
  4544. {
  4545. id: 'highlevel1',
  4546. comboBox: {
  4547. values: pointconfigAlarmLevels,
  4548. value: pointConfigLevelValue
  4549. }
  4550. },
  4551. {
  4552. id: 'highdesc1',
  4553. textField: {
  4554. text: '*'
  4555. }
  4556. },
  4557. alarmCategories[4],
  4558. {
  4559. id: 'lowvalue1', //低一
  4560. textField: {
  4561. text: '*'
  4562. }
  4563. },
  4564. {
  4565. id: 'lowlevel1',
  4566. comboBox: {
  4567. values: pointconfigAlarmLevels,
  4568. value: pointConfigLevelValue
  4569. }
  4570. },
  4571. {
  4572. id: 'lowdesc1',
  4573. textField: {
  4574. text: '*'
  4575. }
  4576. }
  4577. ], [60, 0.03, 60, 0.03, 60, 0.03, 60, 0.03]);
  4578. formPanePointConfig.addRow([
  4579. alarmCategories[2],
  4580. {
  4581. id: 'highvalue2',
  4582. textField: {
  4583. text: '*'
  4584. }
  4585. },
  4586. {
  4587. id: 'highlevel2',
  4588. comboBox: {
  4589. values: pointconfigAlarmLevels,
  4590. value: pointConfigLevelValue
  4591. }
  4592. },
  4593. {
  4594. id: 'highdesc2',
  4595. textField: {
  4596. text: '*'
  4597. }
  4598. },
  4599. alarmCategories[5],
  4600. {
  4601. id: 'lowvalue2',
  4602. textField: {
  4603. text: '*'
  4604. }
  4605. },
  4606. {
  4607. id: 'lowlevel2',
  4608. comboBox: {
  4609. values: pointconfigAlarmLevels,
  4610. value: pointConfigLevelValue
  4611. }
  4612. },
  4613. {
  4614. id: 'lowdesc2',
  4615. textField: {
  4616. text: '*'
  4617. }
  4618. }
  4619. ], [60, 0.03, 60, 0.03, 60, 0.03, 60, 0.03]);
  4620. formPanePointConfig.addRow([
  4621. alarmCategories[3],
  4622. {
  4623. id: 'highvalue3',
  4624. textField: {
  4625. text: '*'
  4626. }
  4627. },
  4628. {
  4629. id: 'highlevel3',
  4630. comboBox: {
  4631. values: pointconfigAlarmLevels,
  4632. value: pointConfigLevelValue
  4633. }
  4634. },
  4635. {
  4636. id: 'highdesc3',
  4637. textField: {
  4638. text: '*'
  4639. }
  4640. },
  4641. alarmCategories[6],
  4642. {
  4643. id: 'lowvalue3',
  4644. textField: {
  4645. text: '*'
  4646. }
  4647. },
  4648. {
  4649. id: 'lowlevel3',
  4650. comboBox: {
  4651. values: pointconfigAlarmLevels,
  4652. value: pointConfigLevelValue
  4653. }
  4654. },
  4655. {
  4656. id: 'lowdesc3',
  4657. textField: {
  4658. text: '*'
  4659. }
  4660. }
  4661. ], [60, 0.03, 60, 0.03, 60, 0.03, 60, 0.03]);
  4662. }
  4663. //数字量报警设置
  4664. function addDigitalRows(node, pointconfigAlarmLevels, pointConfigLevelValue, alarmCategories) {
  4665. var digitalAlarmCates = [];
  4666. for (var i = 0; i < alarmCategories.length; i++) {
  4667. digitalAlarmCates.push(alarmCategories[i]);
  4668. }
  4669. formPanePointConfig.addRow([ /*0报*/
  4670. '报警设置:',
  4671. {
  4672. id: 'shiftTo1',
  4673. comboBox: {
  4674. values: digitalAlarmCates,
  4675. value: digitalAlarmCates[0]
  4676. }
  4677. },
  4678. {
  4679. id: 'shiftlevel1',
  4680. comboBox: {
  4681. values: pointconfigAlarmLevels,
  4682. value: pointConfigLevelValue
  4683. }
  4684. },
  4685. {
  4686. id: 'shiftAlarmDesc1',
  4687. textField: {
  4688. text: '*'
  4689. }
  4690. }
  4691. ], [60, 0.03, 60, 0.03, 60, 0.03, 60, 0.03]);
  4692. formPanePointConfig.addRow([ /*1报*/
  4693. '报警设置:',
  4694. {
  4695. id: 'shiftTo2',
  4696. comboBox: {
  4697. values: digitalAlarmCates,
  4698. value: digitalAlarmCates[0]
  4699. }
  4700. },
  4701. {
  4702. id: 'shiftlevel2',
  4703. comboBox: {
  4704. values: pointconfigAlarmLevels,
  4705. value: pointConfigLevelValue
  4706. }
  4707. },
  4708. {
  4709. id: 'shiftAlarmDesc2',
  4710. textField: {
  4711. text: '*'
  4712. }
  4713. }
  4714. ], [60, 0.03, 60, 0.03, 60, 0.03, 60, 0.03]);
  4715. }
  4716. //获取报警铃声
  4717. function getAlarmSound(curData) {
  4718. var wavfilename = "";
  4719. var playLen; //报警声音播放时长
  4720. var soundLen = 0; //记录播放的时间
  4721. if (alarmLevelDic[curData.state0] != null) {
  4722. wavfilename = alarmLevelDic[curData.state0].wave_file;
  4723. playLen = alarmLevelDic[curData.state0].duration;
  4724. // playLen = 10;
  4725. }
  4726. if (wavfilename != "") {
  4727. // audio.src = wavFile + wavfilename;
  4728. audio.src = "http://" + authServiceIP + ":" + authServicePort + "/html/audio/" + wavfilename;
  4729. audio.play();
  4730. audio.addEventListener("ended", function () {
  4731. soundLen += audio.duration;
  4732. if (soundLen <= playLen) {
  4733. audio.play();
  4734. } else {
  4735. // console.log(soundLen);
  4736. soundLen = 0;
  4737. audio.pause();
  4738. }
  4739. });
  4740. } else {
  4741. return;
  4742. }
  4743. }
  4744. var alarmTimer; // 定时器,每10秒翻动一次。
  4745. function AlarmInfoShow(_data, count) {
  4746. var d = _data && _data[0] || null,
  4747. fanNumber = '',
  4748. alarmWindowData = {},
  4749. alarmWindowFlag;
  4750. try {
  4751. if (window.parent && window.parent.showAlarmWindow === true) {
  4752. alarmWindowFlag = true;
  4753. } else {
  4754. alarmWindowFlag = false;
  4755. }
  4756. } catch (err) {
  4757. alarmWindowFlag = false;
  4758. }
  4759. if (alarmWindowFlag === true) {
  4760. return ;
  4761. }
  4762. function initData(_data) {
  4763. var td, currentData = {}, dataArr = [], af;
  4764. currentData.isCurrent = true;
  4765. currentData.trigger_time = 0;
  4766. for (var key in alarmSystemObj) {
  4767. alarmWindowData[key] = null;
  4768. }
  4769. alarmWindowData.count = 0;
  4770. for (var i = 0, len = _data.length; i < len; i++) {
  4771. td = _data[i];
  4772. td.systemName = alarmSystemObj[td.state3] && alarmSystemObj[td.state3]['system_name'] || '';
  4773. td.alarmDesc = td.user_data0;
  4774. td.alarmTime = moment(d.trigger_time).format('YYYY-MM-DD HH:mm:ss');
  4775. if (!!alarmAreasDic[td.state1]) {
  4776. td.alarmAreaName = alarmAreasDic[td.state1];
  4777. } else {
  4778. td.alarmAreaName = ' ';
  4779. }
  4780. af = alarmAreaFilter(td.alarmAreaName);
  4781. if (!af) continue;
  4782. if (td.trigger_time > currentData.trigger_time) {
  4783. currentData.isCurrent = false;
  4784. currentData = td;
  4785. currentData.isCurrent = true;
  4786. }
  4787. if (!alarmWindowData[td.state3]) {
  4788. alarmWindowData[td.state3] = td;
  4789. }
  4790. dataArr.push(td);
  4791. }
  4792. alarmWindowData.count = count || dataArr.length;
  4793. }
  4794. function addData() {
  4795. initData(_data);
  4796. alarmInfoWindow.refreshData(alarmWindowData);
  4797. }
  4798. var alarmInfoWindow = AlarmInfoShow.alarmInfoWindow || GD.createAlarmWindow(function () {
  4799. var EnsureUser = alarmInfoWindow.currentData && alarmInfoWindow.currentData.ensure_info,
  4800. Ensuretag = alarmInfoWindow.currentData && alarmInfoWindow.currentData.tag_name;
  4801. var tagobj = {
  4802. "tag_name": Ensuretag,
  4803. "ensure_info": EnsureUser
  4804. };
  4805. ensureAlarm([tagobj], function (data) { });
  4806. });
  4807. if (!d) {
  4808. alarmInfoWindow.alarmWindowHide();
  4809. return;
  4810. } else {
  4811. if (alarmInfoWindow.isHide()) {
  4812. alarmInfoWindow.alarmWindowShow();
  4813. }
  4814. }
  4815. addData();
  4816. document.body.appendChild(alarmInfoWindow._dom);
  4817. alarmInfoWindow.addEventToDom(alarmInfoWindow._dom);
  4818. alarmInfoWindow.alarmWindowDragable(true);
  4819. alarmInfoWindow.setFlagShaly();
  4820. if (!AlarmInfoShow.alarmInfoWindow) {
  4821. AlarmInfoShow.alarmInfoWindow = alarmInfoWindow;
  4822. }
  4823. getAlarmSound(d);
  4824. }
  4825. function AlarmInfoShow1(_data, curAlarmIndex, tablestyle) {
  4826. tablestyle = tablestyle || {};
  4827. // console.log(data);
  4828. /*else{
  4829. if(alarmInfoDialog.isShowing()){
  4830. alarmInfoDialog.hide();
  4831. }
  4832. }*/
  4833. var myData = _data;
  4834. var curAlarmCount = _data.length;
  4835. // if(curAlarmIndex>curAlarmCount){
  4836. // curAlarmCount=curAlarmIndex;
  4837. // }else{
  4838. // curAlarmIndex=curAlarmIndex-1;
  4839. // }
  4840. if (curAlarmIndex == curAlarmCount && curAlarmCount != 0) {
  4841. curAlarmIndex = curAlarmIndex - 1;
  4842. }
  4843. if (curAlarmIndex > curAlarmCount) {
  4844. curAlarmCount = curAlarmIndex;
  4845. }
  4846. if (_data.length <= 0) {
  4847. if (typeof (alarmInfoDialog) != "undefined" && alarmInfoDialog.isShowing()) {
  4848. alarmInfoDialog.hide();
  4849. }
  4850. return;
  4851. }
  4852. // var curAlarmIndex = 1;
  4853. var currentData = _data[curAlarmIndex];
  4854. var currentDevice = alarmAreasDic[currentData.state1];
  4855. var currentAlarmTime = moment(Number(currentData.alarm_time)).format("YYYY-MM-DD HH:mm:ss");
  4856. var currentAlarmDesc = currentData.user_data0 || currentData.alarm_message;
  4857. var tagName = currentData.tag_name;
  4858. var alarmDialogPosition = {
  4859. x: document.body.clientWidth - 280,
  4860. y: graphView.getView().clientHeight - 200
  4861. };
  4862. // var content = "<div style='margin-top:0px;width:250px;height:180px;'><p style='height:30px;color:" + tablestyle.paneContentFontColor + ";font:15px 微软雅黑;'>" + currentAlarmTime + "</p><p style='height:30px;color:" + tablestyle.paneContentFontColor + ";font:15px 微软雅黑;'>" + tagName + "</p><p style='height:30px;color:" + tablestyle.paneContentFontColor + ";font: 15px 微软雅黑;'>" + currentAlarmDesc + "</p></div>";
  4863. var alarmSrc = imagePath + "alarm.png";
  4864. var pwidth = document.body.clientWidth * 0.22;
  4865. var pheight = graphView.getView().clientHeight * 0.35;
  4866. var content = "<div style='padding-right:15px;width:" + pwidth + "px;height:" + pheight + "px;background:" + tablestyle.paneContentBackColor + ";opacity:0.78;filter:Alpha(opacity=78);'>"
  4867. + "<p><img src=" + alarmSrc + " id='alarm_img' width='45px' height='50px'><span style='height:30px;color:" + tablestyle.paneUnEnsureFontColor + ";font:" + tablestyle.paneUnEnsureFontSize + "px " + tablestyle.paneUnEnsureFontFamily + " ;float:right;display:block;'>待确认故障"
  4868. + "<font color='" + tablestyle.paneCountFontColor + "' size='" + tablestyle.paneCountFontSize + "' face='" + tablestyle.paneCountFontFamily + "'>"
  4869. + curAlarmCount + "</font>项</span></p>"
  4870. + "<p style='height:23px;color:" + tablestyle.paneContentFontColor + ";font:" + tablestyle.paneContentFontSize + "px " + tablestyle.paneContentFontFamily + ";'>&nbsp;&nbsp;设备名称:" + currentDevice + "</p>"
  4871. + "<p style='height:23px;color:" + tablestyle.paneContentFontColor + ";font:" + tablestyle.paneContentFontSize + "px " + tablestyle.paneContentFontFamily + ";'>&nbsp;&nbsp;故障名称:" + currentAlarmDesc + "</p>"
  4872. + "<p style='height:23px;color:" + tablestyle.paneContentFontColor + ";font:" + tablestyle.paneContentFontSize + "px " + tablestyle.paneContentFontFamily + ";'>&nbsp;&nbsp;故障时间:" + currentAlarmTime + "</p>"
  4873. + "</p></div>";
  4874. // var content = "<div style='margin-top:0px;width:250px;height:180px;'><p style='height:50px;color:#f00;font:15px 微软雅黑;'>" + "aaa" + "</p><p style='height:50px;color:#f00;font:15px 微软雅黑;'>" + "bbb" + "</p><p style='height:50px;color:#f00;font: 15px 微软雅黑;'>" + "ccc" + "</p></div>";
  4875. var alarmDialogConfigObj = {
  4876. // titleBackground: 'rgb(249, 27, 38)',
  4877. titleBackground: tablestyle.paneTitleBackColor,
  4878. titleColor: tablestyle.paneTitleFontColor,
  4879. position: {
  4880. x: '',
  4881. y: ''
  4882. },
  4883. // closable: true,
  4884. draggable: false,
  4885. // contentPadding: 5,
  4886. content: content,
  4887. width: pwidth,
  4888. height: pheight,
  4889. buttons: [{
  4890. label: "确认",
  4891. className: "ensurebtn",
  4892. action: function () {
  4893. var _data = window.alarmData;
  4894. _data.removeArr(curAlarmIndex);
  4895. if (curAlarmIndex != 0) {
  4896. curAlarmIndex = curAlarmIndex - 1;
  4897. }
  4898. var EnsureUser = currentData.ensure_info;
  4899. var Ensuretag = currentData.tag_name;
  4900. tagobj = {
  4901. "tag_name": Ensuretag,
  4902. "ensure_info": EnsureUser
  4903. };
  4904. //console.log(currentData);
  4905. // console.log(curAlarmIndex);
  4906. ensureAlarm([tagobj], function (data) { });
  4907. // if (_data.length <= 0) {
  4908. // alarmInfoDialog.hide();
  4909. // getRealAlarmInfos(realdataModelReal, tablePaneReal, pageinputReal.value, rowssizeReal.getValue(), pageCountReal, dataAreaNameReal, alarmGroupValueReal, alarmLevelValueReal, alarmStateValueReal);
  4910. // return;
  4911. // } else {
  4912. // // curAlarmCount = data[0].alarm_no;
  4913. // if (curAlarmIndex >= curAlarmCount) {
  4914. // curAlarmIndex = curAlarmCount;
  4915. // }
  4916. // }
  4917. // AlarmInfoShow(_data, curAlarmIndex, tablestyle);
  4918. }
  4919. }
  4920. ],
  4921. buttonsAlign: "right",
  4922. }
  4923. var tabViewConfig = [];
  4924. // alarmSystem.forEach(function (item, index) {
  4925. // var d = {};
  4926. // d.name = item.system_name;
  4927. // d.selected = item.id === currentData.state3 ? true : false;
  4928. // d.view = item.id === currentData.state3 ? content : '';
  4929. // d.currentData = currentData;
  4930. // d.index = curAlarmIndex;
  4931. // tabViewConfig.push(d);
  4932. // });
  4933. // tabViewConfig.onTabChanged = function (oldTab, newTab) {
  4934. // currentData = newTab.a('currentData') || currentData;
  4935. // curAlarmIndex = newTab.a('curAlarmIndex') || curAlarmIndex;
  4936. // //console.log(currentData, curAlarmIndex);
  4937. // };
  4938. // if (typeof (alarmInfoDialog) == "undefined") {
  4939. // // alarmInfoDialog = new ht.widget.Dialog();
  4940. // alarmInfoDialog = createDialogWithTabView(alarmDialogConfigObj, tabViewConfig, true, tablestyle,alarmInfoDialog);
  4941. // var tab = alarmInfoDialog.tabModel.getDataByTag(alarmSystemObj[currentData.state3].system_name);
  4942. // tab.setView($(content)[0]);
  4943. // alarmInfoDialog.tabModel.getSelectionModel().setSelection(tab);
  4944. // // console.log(tabViewConfig);
  4945. // } else {
  4946. // // alarmInfoDialog.setTabConfig(alarmDialogConfigObj, tabViewConfig);
  4947. // try {
  4948. // var tab = alarmInfoDialog.tabModel.getDataByTag(alarmSystemObj[currentData.state3].system_name);
  4949. // tab.setView($(content)[0]);
  4950. // alarmInfoDialog.tabModel.getSelectionModel().setSelection(tab);
  4951. // } catch (error) {
  4952. // console.log(error);
  4953. // }
  4954. // }
  4955. var sysname = alarmSystemObj[currentData.state3].system_name;
  4956. alarmInfoDialog = createDialogAlarm(alarmInfoDialog, alarmDialogConfigObj, true, tablestyle, sysname);
  4957. // if(typeof (alarmInfoDialog) == "undefined"){
  4958. // alarmInfoDialog = createDialogAlarm(alarmInfoDialog,alarmDialogConfigObj, true, tablestyle,sysname);
  4959. // }else{
  4960. // alarmInfoDialog.setConfig(alarmDialogConfigObj);
  4961. // }
  4962. // var tab = alarmInfoDialog.tabModel.getDataByTag(alarmSystemObj[currentData.state3].system_name);
  4963. // tab.setView($(content)[0]);
  4964. // alarmInfoDialog.tabModel.getSelectionModel().setSelection(tab);
  4965. alarmInfoDialog.setModal(false);
  4966. alarmInfoDialog.$dialogTitle.text(_data.length);
  4967. if (alarmInfoDialog.isShowing()) {
  4968. //alarmInfoDialog.hide();
  4969. } else {
  4970. alarmInfoDialog.show();
  4971. }
  4972. document.getElementsByClassName("dialog-container-buttons")[0].style.background = tablestyle.paneContentBackColor;
  4973. //document.getElementsByClassName("dialog-button dialog-button-confirm")[0].style.background = tablestyle.btnBackgroundColor;
  4974. document.getElementsByClassName("dialog-content")[0].style.background = tablestyle.paneContentBackColor;
  4975. // (function (data, curAlarmIndex) {
  4976. // if (data.length > 1) {
  4977. // alarmTimer && clearTimeout(alarmTimer);
  4978. // alarmTimer = setTimeout(function () {
  4979. // nextIndex = curAlarmIndex - 1;
  4980. // nextIndex = nextIndex < 0 ? data.length - 1 : nextIndex;
  4981. // AlarmInfoShow(data, nextIndex, tablestyle);
  4982. // }, 10 * 1000);
  4983. // }
  4984. // })(_data, curAlarmIndex);
  4985. getAlarmSound(_data[curAlarmIndex]);
  4986. }
  4987. function getAllUnsureAlarmInfo(cb) {
  4988. cb = cb || function () { };
  4989. var reqData = {
  4990. "condition": [{
  4991. "field": "is_ensure",
  4992. "method": 0,
  4993. "value": "0"
  4994. }]
  4995. };
  4996. //var flagnum="get";
  4997. var eventName = "/alarm/GetSnapshots";
  4998. socket.alarmPost(eventName, reqData, function (data) {
  4999. if (data.success && data.data) {
  5000. return cb(data.data.data);
  5001. }
  5002. cb([]);
  5003. })
  5004. }
  5005. function AlarmErrorShow(message) {
  5006. var errorDialog = new ht.widget.Dialog();
  5007. errorDialog.setConfig({
  5008. title: "错误消息提示",
  5009. titleAlign: "left",
  5010. closable: true,
  5011. draggable: true,
  5012. contentPadding: 20,
  5013. content: "<p>" + message + "</p>",
  5014. buttons: [{
  5015. label: "关闭"
  5016. }],
  5017. buttonsAlign: "right",
  5018. action: function (item, e) {
  5019. errorDialog.hide();
  5020. }
  5021. });
  5022. errorDialog.setModal(false);
  5023. errorDialog.show();
  5024. }
  5025. Array.prototype.removeArr = function (index) {
  5026. if (isNaN(index) || index >= this.length) {
  5027. return false;
  5028. }
  5029. return this.splice(index, 1);
  5030. }
  5031. function getAreaIds(data) {
  5032. if (data._children) {
  5033. for (var i = 0; i < data._children._as.length; i++) {
  5034. alarmAreaIds.push(data._children._as[i]._id);
  5035. getAreaIds(data._children._as[i]);
  5036. }
  5037. }
  5038. }
  5039. function alarmInit() {
  5040. getAlarmGroups(function () {
  5041. getAlarmSystem(function (data) {
  5042. alarmSystem = data;
  5043. data.forEach(function (item, index) {
  5044. alarmSystemObj[item.id] = item;
  5045. });
  5046. getAlarmAreas(function () {
  5047. getAlarmCateByName();
  5048. getAlarmLevels();
  5049. alarmAreaFilter = (function () {
  5050. var extra = GD.getParams('extra') || {},//获取用户所属区域
  5051. userArea = extra.area || '',
  5052. id = alarmAreaDicName[userArea] && alarmAreaDicName[userArea].id || '',
  5053. userAreas = [];
  5054. userAreas.push(userArea);
  5055. alarmAreaIds.length=0;
  5056. function getUserArea(_ids) {
  5057. var areaData, pid, id, name, _id, tempArr = [], ids = [];
  5058. for (var i = 0, len = _ids.length; i < len; i++) {
  5059. _id = _ids[i];
  5060. if(_id!=""){
  5061. alarmAreaIds.push(_id);
  5062. }
  5063. for (var key in alarmAreaDicNameId) {
  5064. if (alarmAreaDicNameId.hasOwnProperty(key)) {
  5065. areaData = alarmAreaDicNameId[key] || {};
  5066. pid = areaData['parent_id'];
  5067. id = areaData['id'];
  5068. name = areaData['area_name'];
  5069. if (pid === _id) {
  5070. tempArr.push(name);
  5071. ids.push(id);
  5072. }
  5073. }
  5074. }
  5075. }
  5076. if (tempArr.length > 0) {
  5077. userAreas = userAreas.concat(tempArr);
  5078. getUserArea(ids);
  5079. }
  5080. }
  5081. getUserArea([id]);
  5082. function compare(uArea) {
  5083. if (!userArea) return true;
  5084. return userAreas.indexOf(uArea) !== -1;
  5085. }
  5086. return compare;
  5087. })();
  5088. });
  5089. })
  5090. });
  5091. }
  5092. function getAreaTreeData(treeView, DataType, id, map) {
  5093. var curid = id;
  5094. for (var i = 0; i < DataType.length; i++) {
  5095. var curdata = DataType[i];
  5096. if (curdata.parent_id == curid) {
  5097. data = new ht.Data();
  5098. data._id = curdata.id;
  5099. data._pid = curdata.parent_id;
  5100. data.setName(curdata.area_name);
  5101. data.setTag(curdata.area_name);
  5102. data.setParent(map[curdata.parent_id]);
  5103. treeView.dm().add(data);
  5104. map[curdata.id] = data;
  5105. if (i == DataType.length - 1) {
  5106. break;
  5107. } else {
  5108. getAreaTreeData(treeView, DataType, curdata.id, map);
  5109. }
  5110. }
  5111. }
  5112. }