| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811 |
- {% load staticfiles %}
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <link href="{% static '/lib/bootstrap-3.3.7/css/bootstrap.css' %}" rel="stylesheet">
- <link rel="stylesheet" href="{% static '/lib/font-awesome/4.5.0/css/font-awesome.css' %}">
- <link rel="stylesheet" href="{% static '/lib/css/ace.min.css' %}" />
- <link rel="stylesheet" href="{% static '/lib/css/ace-skins.min.css' %}">
- <link rel="stylesheet" href="{% static '/lib/css/ace-rtl.min.css' %}">
- <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
- <link rel="stylesheet" href="{% static '/lib/css/jquery-ui.css' %}" />
- <style type="text/css">
- body {
- background: #fff;
- }
- .row {
- margin: 0;
- }
- /* 菜单 */
- .menu_body .nulldata {
- line-height: 80px;
- text-align: center;
- height: 80px;
- background: #eee;
- }
- .menu_list {
- margin-top: 10px;
- }
- .menu_head {
- height: 30px;
- line-height: 30px;
- padding-left: 10px;
- font-size: 12px;
- color: #313131;
- cursor: pointer;
- border: 1px solid #e1e1e1;
- border-top: 0px solid #e1e1e1;
- position: relative;
- background: #f1f1f1 url(../static/img/jia.png) center right 5px no-repeat;
- margin: 0;
- word-break: keep-all;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .menu_body {
- height: auto;
- overflow: hidden;
- line-height: 38px;
- border-left: 1px solid #e1e1e1;
- border-right: 1px solid #e1e1e1;
- }
- .menu_body a {
- display: block;
- height: 32px;
- line-height: 32px;
- padding-left: 10px;
- color: #525252;
- background: #fff;
- text-decoration: none;
- border-bottom: 1px solid #e1e1e1;
- }
- .menu_list .current {
- background: #f1f1f1 url(../static/img/jian.png) center right 5px no-repeat;
- font-weight: bold;
- color: #313131;
- }
- .menu_body .menu-active {
- color: #00bcd4;
- border-left: solid 3px #00bcd4;
- }
- .currAstive {
- background-color: #00bcd4;
- color: #fff;
- }
- /* 主题标题 */
- .widget-box {
- background: none repeat scroll 0 0 #F9F9F9;
- clear: both;
- margin-top: 16px;
- margin-bottom: 16px;
- position: relative;
- border: none;
- }
- .widget-title {
- height: 36px;
- border-bottom: solid 1px #e5e5e5;
- padding-bottom: 1px;
- text-align: center;
- }
- .widget-title h5 {
- color: #666;
- float: left;
- font-size: 12px;
- font-weight: bold;
- padding: 12px;
- line-height: 12px;
- margin: 0;
- margin-bottom: 3px;
- border-bottom: solid 2px #38b0ec;
- }
- /*状态 */
- .dev:HOVER {
- background: #2E363F;
- }
- .dev {
- width: 215px;
- height: 88px;
- float: left;
- margin: 0px;
- color: #f2f2f2;
- margin: 5px;
- cursor: pointer;
- position: relative;
- }
- .bg_lb {
- background: /* #27a9e3 */
- #4ab8e8;
- }
- .dev .left {
- width: 80px;
- padding-top: 10px;
- float: left;
- }
- .dev .left .img-dev {
- width: 45px;
- margin-left: 12px;
- margin-top: 8px;
- }
- .dev .right {
- width: 120px;
- padding-top: 3px;
- float: left;
- font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial, sans-serif;
- }
- .dev .right .name {
- font-size: 20px;
- text-align: left;
- padding-top: 10px;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .dev .right .data {
- font-size: 14px;
- text-align: left;
- padding-top: 15px;
- }
- /* 项目 */
- .todo li {
- border-bottom: 1px solid #EBEBEB;
- margin-bottom: 0;
- padding: 10px 0;
- }
- .equipPage {
- line-height: 34px;
- text-align: center;
- }
- table tr td.nullData {
- text-align: center;
- line-height: 250px;
- }
- /* 状态块颜色 */
- .bg_lb {
- background: /* #27a9e3 */
- #4ab8e8;
- }
- .bg_ly {
- background: /* #ffb848 */
- #f5b761;
- }
- .bg_lg {
- background: /* #28b779 */
- #3eb984;
- }
- .bg_ls {
- background: /* #2255a4 */
- #4978c1;
- }
- .bg_lo {
- background: /* #da542e */
- #dc6442;
- }
- .bg_lr {
- background: /* #f74d4d */
- #f77979;
- }
- .aisle {
- position: absolute;
- left: 6px;
- bottom: 1px;
- font-size: 12px;
- }
- #uploadPhoto {
- display: none;
- }
- #viewPhoto {
- cursor: pointer;
- }
- /* 设备控制 */
- #ctrlBox>div {
- margin-bottom: 20px;
- }
- .handCtrlBox {
- margin-bottom: 20px;
- }
- input[type="checkbox"].ace.ace-switch.ace-switch-4+.lbl::before,
- input[type="checkbox"].ace.ace-switch.ace-switch-5+.lbl::before {
- text-indent: -39px;
- }
- .equipCtrl {
- border: 1px solid #cecece;
- padding: 15px 10px;
- background: #f5f5f5;
- box-shadow: 1px 1px 4px 1px #cecece;
- border-radius: 3px;
- cursor: pointer;
- }
- .equipCtrl:hover {
- border-color: #468fcd;
- box-shadow: 1px 2px 4px 0px #468fcd;
- }
- .equipCtrlInp {
- margin-top: 20px;
- text-align: right;
- }
- .isonlineicon {
- display: inline-block;
- width: 8px;
- height: 8px;
- border-radius: 50%;
- margin-right: 7px;
- }
- .isonlineicon.active {
- background: green;
- animation: 1s ease 0s infinite normal none running myfirst01;
- }
- .isonlineicon {
- background: #909090;
- animation: 1s ease 0s infinite normal none running myfirst02;
- }
- @keyframes myfirst01 {
- 0% {
- -moz-box-shadow: 0px 0px 6px 1px green;
- box-shadow: 0px 0px 6px 1px green;
- }
- 100% {
- -moz-box-shadow: 0px 0px 6px 1px green;
- box-shadow: 0px 0px 6px 1px green;
- }
- }
- @keyframes myfirst02 {
- 0% {
- -moz-box-shadow: 0px 0px 6px 1px #909090;
- box-shadow: 0px 0px 6px 1px #909090;
- }
- 100% {
- -moz-box-shadow: 0px 0px 6px 1px #909090;
- box-shadow: 0px 0px 6px 1px #909090;
- }
- }
- .ctrlLoading {
- position: absolute;
- bottom: 6px;
- }
- .equipCtrl .fa-cog {
- position: absolute;
- right: 26px;
- font-size: 20px;
- color: #3eb983;
- top: 11px;
- }
- .qxzDownCtrl {
- display: none;
- float: right;
- width: 53px;
- background: white;
- border: 1px solid #8aafce;
- color: #6688a6!important;
- }
- .numName {
- display: inline-block;
- width: 70%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- vertical-align: middle;
- }
- /* 阈值控制 */
- #getthresholdDiv>div,
- #gettimingDiv>div {
- padding-bottom: 20px;
- }
- .thresholdCtrl {
- background: #4ab8e8;
- border-radius: 5px;
- color: #fff;
- box-shadow: 1px 1px 4px 1px #98dbf8;
- border: 1px solid #98dbf8;
- padding: 5px 10px;
- cursor: pointer;
- position: relative;
- }
- #gettimingDiv .thresholdCtrl {
- background: #65b83b;
- box-shadow: 1px 1px 4px 1px #d1ffba;
- border: 1px solid #65b83b;
- }
- .setthresholdBtn {
- position: absolute;
- right: 13px;
- top: 12px;
- font-size: 20px;
- }
- .setthresholdBtn:hover {
- color: #08ff46;
- }
- .thresholdCtrl::before {
- position: absolute;
- content: '';
- bottom: 0;
- left: 0;
- right: 0;
- height: 30%;
- background: rgba(255, 255, 255, 0.5);
- }
- .thresholdCtrlName {
- line-height: 30px;
- font-size: 16px;
- }
- .thresholdCtrlShowDiv {
- overflow: hidden;
- }
- .thresholdCtrlShowDiv>div {
- float: left;
- }
- .qxys img {
- width: 47px;
- }
- .maxminNum {
- font-size: 18px;
- line-height: 30px;
- margin-top: 11px;
- padding-left: 7%;
- }
- /* 色值阈值框 */
- .layui-form-item .layui-input-inline {
- width: 44%;
- }
- #Modal>div,
- #timingOnOffModal>div {
- margin-top: 20px;
- }
- .layui-form-mid.layui-word-aux span {
- color: red;
- }
- /* 定时设置 */
- #timingOnOffModal .layui-form-label {
- width: 100px;
- }
- </style>
- <body>
- <div class="content">
- <div class="row">
- <!-- 左菜单 -->
- <div class="col-xs-12 col-sm-3 col-md-2">
- <div class="input-group">
- <input type="text" class="form-control" id="searchImei" name="searchImei" placeholder="输入编号或名称查询">
- <div class="input-group-btn">
- <button type="button" id="searchBtn" class="btn btn-default no-border btn-sm">
- <i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
- </button>
- </div>
- </div>
- <div id="firstpane" class="menu_list">
- <p class="menu_head current" id="area_322">设备列表</p>
- <div class="menu_body">
- <!-- <a href="javascript:;" title="设备15112501" class="text-overflow" id="15112501" data-pid="322">设备15112501</a> -->
- </div>
- <div class="equipPage">
- <!-- <button class="btn btn-minier btn-yellow"><i class="fa fa-sort-up" aria-hidden="true"></i></button> -->
- <input type="button" class="btn btn-minier btn-yellow" onclick="gotofirstpage()" value="首页">
- <button class="btn btn-minier btn-yellow" id="jianPage" onclick="changePage('jian')">上一页</button>
- 第
- <span id="currentpage">1</span>页
- <button class="btn btn-minier btn-yellow" id="addPage" onclick="changePage('add')">下一页</button>
- 共
- <span id="totelpage">4</span>页
- </div>
- </div>
- <div class="">
- <div class="widget-box" style="margin-top: 20px;">
- <div class="widget-title">
- <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
- <h5>项目信息</h5>
- </div>
- </div>
- <div class="widget-content" style="padding: 0px;margin-top: 8px;">
- <div>
- <!-- <img src="www.yfzhwlw.com/qxz_photo/default.png" class="equip_photo" width="100%" height="100%" style=""> -->
- <form action="" method="post" id="userPhoto" class="form-horizontal" enctype="multipart/form-data">{% csrf_token %}
- <input type="hidden" value="" id="qxzPhotoId" name="id">
- <div class="personal-avatar">
- <div class="top-avatar" id="viewPhotoParent">
- <img id="viewPhoto" class="equip_photo" onclick="$('#uploadPhoto').click()" src="" width="100%" height="100%">
- </div>
- <a class="upload-avatar" href="javascript:;">
- <input class="upload-btn" name="upicture" onchange="previewImage(this,'viewPhotoParent','viewPhoto','uploadPhoto','100%',200)"
- type="file" id="uploadPhoto">
- </a>
- <!-- <input type="hidden" name="req" value="photo"> -->
- </div>
- </form>
- </div>
- <div class="todo" style="background: white;margin-top: 5px;">
- <ul>
- <li class="clearfix">
- <div class="txt equip_name"> 项目名称:设备15112501</div>
- </li>
- <li class="clearfix">
- <div class="txt equip_id"> 设备ID:15112501</div>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- <!-- 右 -->
- <div class="col-xs-12 col-sm-9 col-md-10">
- <!-- 实时状态 -->
- <div class="currTimeStatus">
- <div class="widget-box" style="margin-top: 0px;">
- <div class="widget-title">
- <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
- <h5>实时状态</h5>
- <span class="span5" style="min-height: 25px;text-align: right;margin-right: 20px;">
- <button class="btn btn-white btn-primary" id="updataTime" type="button"></button>
- <button class="btn btn-white btn-primary" id="newDataRefresh" onclick="newDataRefresh()" type="button">
- <i class="fa fa-refresh" aria-hidden="true"></i>
- </button>
- </span>
- <div style="position: absolute;right: 10px;top: 7px;" id="date_refresh"></div>
- </div>
- </div>
- </div>
- <div class="body-content clearfix" id="newStatusBox">
- <!-- <div class="dev bg_lb">
- <div class="left">
- <img class="img-dev" src="{% static '/img/switchBtnIcon.png' %}">
- </div>
- <div class="right">
- <div class="name">风速</div>
- <div class="data">
- <strong>
- <span style="font-size: 25px;">0.0</span>
- </strong>m/s</div>
- </div>
- </div> -->
- </div>
- <!-- 设备手动控制 -->
- <div id="ctrlBoxParentDiv">
- <div class="currTimeStatus">
- <div class="widget-box">
- <div class="widget-title">
- <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
- <h5>设备手动控制</h5>
- <button class="btn btn-white btn-primary qxzDownCtrl" onclick="qxzDownCtrlFun()">
- <i class="fa fa-refresh" aria-hidden="true"></i>
- </button>
- </div>
- </div>
- </div>
- <div class="row handCtrlBox" id="ctrlBox">
- <!-- <div class="col-xs-2">
- <div class="equipCtrl">
- <input type="hidden" value="1">
- <div>
- <span class="isonlineicon active"></span>
- 控制1
- </div>
- <div class="equipCtrlInp">
- <label>
- <input name="switch-field-1" checked class="ace ace-switch ace-switch-4 btn-rotate" type="checkbox">
- <span class="lbl"></span>
- </label>
- </div>
- </div>
- </div> -->
- </div>
- </div>
- <!-- 设备阈值控制 -->
- <div id="getthresholdDivParentDiv">
- <div class="currTimeStatus">
- <div class="widget-box" style="margin-top: 0px;">
- <div class="widget-title">
- <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
- <h5>设备阈值控制</h5>
- <button class="btn btn-white btn-primary qxzDownCtrl" id="" onclick="" type="button">
- <i class="fa fa-refresh" aria-hidden="true"></i>
- </button>
- </div>
- </div>
- </div>
- <div class="row" id="getthresholdDiv">
- <!-- <div class="col-xs-2 col-sm-3">
- <div class="thresholdCtrl">
- <div class="setthresholdBtn" onclick="setthresholdFun(this)">
- <i class="fa fa-cog setName" aria-hidden="true"></i>
- </div>
- <input type="hidden" class="currVal" value='{"JK":1,"eKey":1,"upper":700,"lower":300,"method":1}'>
- <div class="thresholdCtrlName">
- <p>开关1(e1)</p>
- </div>
- <div class="thresholdCtrlShowDiv">
- <div class="qxys">
- <div>
- <img src="{% static '/img/dev/icon_110.png' %}" alt="">
- </div>
- <div>雨量累计</div>
- </div>
- <div class="maxminNum">
- <p>最大值:
- <span>30</span>
- </p>
- <p>最小值:
- <span>10</span>
- </p>
- </div>
- </div>
- <div class="equipCtrlInp">
- <label>
- <input name="switch-field-1" class="ace ace-switch ace-switch-6" type="checkbox">
- <span class="lbl"></span>
- </label>
- </div>
- </div>
- </div> -->
- </div>
- </div>
- <!-- 设备定时控制 -->
- <div id="timingDivParentDiv">
- <div class="currTimeStatus">
- <div class="widget-box" style="margin-top: 0px;">
- <div class="widget-title">
- <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
- <h5>设备定时控制</h5>
- <button class="btn btn-white btn-primary qxzDownCtrl" id="" onclick="" type="button">
- <i class="fa fa-refresh" aria-hidden="true"></i>
- </button>
- </div>
- </div>
- </div>
- <div class="row" id="gettimingDiv">
- <!-- <div class="col-xs-2 col-sm-3">
- <div class="thresholdCtrl">
- <div class="setthresholdBtn" onclick="timingOnOff(this)">
- <i class="fa fa-cog setName" aria-hidden="true"></i>
- </div>
- <input type="hidden" class="currVal" value='{"JK":1,"StartTime":12,"Duration":10}'>
- <div class="thresholdCtrlName">
- <p>开关1(e1)</p>
- </div>
- <div class="thresholdCtrlShowDiv">
- <div class="maxminNum">
- <p>起始时间:
- <span>12</span>
- 点
- </p>
- <p>工作时长:
- <span>10</span>
- 小时
- </p>
- </div>
- </div>
- <div class="equipCtrlInp">
- <label>
- <input name="switch-field-1" class="ace ace-switch ace-switch-6" type="checkbox">
- <span class="lbl"></span>
- </label>
- </div>
- </div>
- </div> -->
- </div>
- </div>
- <!-- 24小时数据 -->
- <div id="data24Div">
- <div class="currTimeStatus">
- <div class="widget-box">
- <div class="widget-title">
- <!-- <span class="icon"> <i class="icon-th"></i> </span> -->
- <h5>24小时数据</h5>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-xs-12 col-md-12 col-lg-9">
- <table id="newtable" class="table table-striped table-hover">
- <thead>
- <tr>
- <th>传感器通道</th>
- <th>通道名称</th>
- <th>最小值</th>
- <th>最小值时间</th>
- <th>最大值</th>
- <th>最大值时间</th>
- </tr>
- </thead>
- <tbody>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- Modal -->
- <div id="Modal" class="model" style="display:none">
- <div>
- <form class="layui-form" action="" id="modelForm" lay-filter="formModel">
- <input type="hidden" value="" name="JK">
- <input type="hidden" value="" name="eKey">
- <div class="layui-form-item">
- <label class="layui-form-label">最大值</label>
- <div class="layui-input-inline">
- <input type="text" name="upper" id="upper" required lay-verify="required" placeholder="请输入最大值" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">最小值</label>
- <div class="layui-input-inline">
- <input type="text" name="lower" required lay-verify="required" placeholder="请输入最小值" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">规 则</label>
- <div class="layui-input-inline">
- <input type="radio" name="method" lay-filter="radioSwitch" value="1" title="程序一" checked="">
- <input type="radio" name="method" lay-filter="radioSwitch" value="0" title="程序二">
- </div>
- <div class="layui-form-mid layui-word-aux" id="hintDiv">低于下限
- <span>开启</span>,高于上限
- <span>关闭</span>
- </div>
- </div>
- </form>
- </div>
- </div>
- <!-- Modal2 -->
- <div id="timingOnOffModal" class="model" style="display:none">
- <div>
- <form class="layui-form" action="" id="modelForm" lay-filter="formModel">
- <input type="hidden" value="" name="JK">
- <div class="layui-form-item">
- <label class="layui-form-label">起始时间:</label>
- <div class="layui-input-inline">
- <input type="number" name="StartTime" id="starttime" required lay-verify="required|starttimeRegex" placeholder="请输入起始时间"
- autocomplete="off" class="layui-input">
- <!-- <select name="city" lay-verify="">
- <option value="">请选择一个城市</option>
- <option value="010">北京</option>
- <option value="021">上海</option>
- <option value="0571">杭州</option>
- </select>
- <select name="city" lay-verify="required">
- <option value=""></option>
- <option value="0">北京</option>
- <option value="1">上海</option>
- <option value="2">广州</option>
- <option value="3">深圳</option>
- <option value="4">杭州</option>
- </select> -->
- </div>
- <div class="layui-form-mid layui-word-aux">时间范围(0-23)</div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">工作时长:</label>
- <div class="layui-input-inline">
- <input type="number" name="Duration" id="Duration" required lay-verify="required|durationRegex" placeholder="请输入工作时长" autocomplete="off"
- class="layui-input">
- </div>
- <div class="layui-form-mid layui-word-aux">工作时长(1-24)</div>
- </div>
- </form>
- </div>
- </div>
- <script src="{% static '/lib/js/jquery-2.1.4.min.js' %}"></script>
- <script src="{% static '/lib/bootstrap-3.3.7/js/bootstrap.js' %}"></script>
- <script src="{% static '/lib/layui/layui.all.js' %}"></script>
- <script src="{% static '/js/common.js' %}?versions=0.5.0"></script>
- <script type="text/javascript">
- $.ajaxSetup({
- data: { csrfmiddlewaretoken: '{{ csrf_token }}' },
- });
- </script>
- <script>
- //默认加载设备列表
- getEquipList(1, '');
- // 搜索
- $('#searchBtn').on('click', function () {
- getEquipList(1, $('#searchImei').val())
- });
- $('#searchImei').on('keyup', function (event) {
- if (event.keyCode == 13) {
- getEquipList(1, $('#searchImei').val())
- }
- })
- function getEquipList(page, filter) {
- $.ajax({
- url: 'qxz_page',
- type: 'get',
- dataType: 'json',
- data: {
- page: page,
- f_id: filter
- },
- beforeSend: function (XMLHttpRequest) {
- loadingFlag = layer.load();
- },
- success: function (data) {
- layer.close(loadingFlag);
- if (data.nums) {
- var html = '';
- var msg = data.ids
- var pagecount = Math.ceil(data.nums / 10);
- for (var i = 0; i < msg.length; i++) {
- if (msg[i].equip_name) {
- var equip_name = '设备:' + msg[i].equip_name;
- } else {
- var equip_name = '设备:' + msg[i].equip_id;
- }
- // var equip_name = msg[i].equip_name?'---设备名:'+msg[i].equip_name:'';
- html += '<a href="javascript:;" title="设备' + msg[i].equip_id + '" class="text-overflow" id="' + msg[i].equip_id + '" data-pid="322">' + equip_name + '</a>'
- }
- $('#firstpane .menu_body').html(html);
- $('.equipPage').show();
- $('#totelpage').html(pagecount)
- // 菜单栏
- $("#firstpane .menu_body:eq(0) a:eq(0)").addClass('menu-active');
- $(".menu_body a").click(function () {
- $(".menu_head").removeClass("currAstive");
- $(".menu_body a").removeClass("menu-active");
- $(this).addClass("menu-active");
- $(this).parent().prev().addClass('currAstive');
- var facId = $(this).attr("id");
- if (facId && facId != null && facId != "") {
- loadProject(facId);
- $('#qxzPhotoId').val(facId);
- }
- });
- loadProject(msg[0].equip_id);
- $('#qxzPhotoId').val(msg[0].equip_id)
- } else {
- $('.equipPage').hide();
- var html = '<a href="javascript:;" class="text-overflow nulldata" data-pid="322">暂未设备</a>'
- $('#firstpane .menu_body').html(html);
- }
- },
- error: function (type) {
- layer.close(loadingFlag);
- }
- })
- }
- //设备状态
- function loadProject(facId) {
- $.ajax({
- url: 'qxz_detail',
- type: 'get',
- dataType: 'json',
- data: {
- id: facId,
- },
- beforeSend: function (XMLHttpRequest) {
- loadingFlag = layer.load();
- },
- success: function (data) {
- layer.close(loadingFlag);
- var myDate = new Date();//获取系统当前时间
- $('#date_refresh').html(myDate.getHours() + ':' + myDate.getMinutes() + ':' + myDate.getSeconds())
- // 实时状态
- var newData = data.new_data;
- newStatus('newStatusBox', newData, facId)
- // var runStatus = eval('('+data.qxz_switch+')');
- addCtrlBtn(data.qxz_switch, data.switch_name)
- var dayData = data.all_data;
- if (data.qxz_switch && (data.qxz_switch.length != 2)) {
- $('#ctrlBoxParentDiv').show();
- $('#getthresholdDivParentDiv').show();
- $('#timingDivParentDiv').show();
- $('#data24Div').hide();
- gettimimgFun(data);
- getthresholdFun(data);
- scrollBar()
- } else { // 无开关显示24小时数据
- $('#ctrlBoxParentDiv').hide();
- $('#getthresholdDivParentDiv').hide();
- $('#timingDivParentDiv').hide();
- $('#data24Div').show();
- $("#newtable tr:not(:first)").remove();
- if (dayData.length) {
- Fill_Table('newtable', dayData, facId)
- } else {
- Fill_null_Table('newtable', dayData, facId)
- }
- }
- },
- error: function (type) {
- layer.close(loadingFlag);
- }
- })
- }
- // 阈值请求
- function getthresholdFun(data) {
- var switch_name = data.switch_name;
- var qxz_switch = data.qxz_switch;
- if (data.auto_list.length) {
- var switchData = eval('(' + data.auto_list + ')');
- var qxz_switch = eval('(' + data.qxz_switch + ')');
- var qxz_list = data.new_data;
- if (switch_name.length > 2) {
- var switch_name = eval('(' + switch_name + ')');
- } else {
- var switch_name = [];
- }
- } else {
- var switchData = [];
- var qxz_list = [];
- var switch_name = [];
- }
- if (switchData.length) {
- var html = '';
- for (var i = 0; i < switchData.length; i++) {
- if (switchData[i].JK != 255) {
- if (switchData[i].upper == 32767 || switchData[i].lower == 32767) {
- var check = false;
- } else {
- var check = true;
- }
- // 判断通道号
- if (!isNaN(switchData[i].eKey)) {
- var eknum = switchData[i].eKey + 1;
- var ek = 'e' + eknum;
- } else {
- var ek = switchData[i].eKey;
- }
- // 开关名
- if (switchData[i].JK == qxz_switch[i].JK) {
- if(switch_name.length){
- var name = switch_name[i].name;
- }else{
- var name = '开关'+qxz_switch[i].JK;
- }
- } else {
- var name = timingData[i].JK;
- }
- for (var j = 0; j < qxz_list.length; j++) {
- if (qxz_list[j].eKey == ek) {
- var eNum = qxz_list[j].unit[0];
- var txt = qxz_list[j].unit[1];
- html += '<div class="col-xs-2 col-sm-3"><div class="thresholdCtrl">' +
- '<div class="setthresholdBtn" onclick="setthresholdFun(this)">' +
- '<i class="fa fa-cog setName" aria-hidden="true"></i></div>' +
- '<input type="hidden" class="currVal" value=\'' + JSON.stringify(switchData[i]) + '\'>' +
- '<div class="thresholdCtrlName"><p>' + name + '(通道' + switchData[i].eKey + ')</p></div>' +
- '<div class="thresholdCtrlShowDiv"><div class="qxys"><div>' +
- '<img src="http://www.yfzhwlw.com/static/img/dev/icon_' + eNum + '.png" alt=""></div>' +
- '<div>' + txt + qxz_list[j].unit[2] + '</div></div><div class="maxminNum"><p>最大值:<span>' + switchData[i].upper + '</span></p>' +
- '<p>最小值:<span>' + switchData[i].lower + '</span></p></div></div><div class="equipCtrlInp">';
- if (check) {
- html += '<label><input name="switch-field-1" class="ace ace-switch ace-switch-6" checked="checked" type="checkbox">' +
- '<span class="lbl"></span></label></div></div></div>';
- } else {
- html += '<label><input name="switch-field-1" class="ace ace-switch ace-switch-6" type="checkbox">' +
- '<span class="lbl"></span></label></div></div></div>';
- }
- break;
- }
- }
- }
- if (i == switchData.length - 1) {
- if (html) {
- $('#getthresholdDiv').html(html)
- } else {
- $('#getthresholdDiv').html('<div style="text-align:center">空</div>')
- }
- }
- }
- } else {
- $('#getthresholdDiv').html('<div style="text-align:center">空</div>')
- }
- }
- // 定时请求
- function gettimimgFun(data) {
- var switch_name = data.switch_name;
- var qxz_switch = data.qxz_switch;
- if (data.timing_list.length) {
- var timingData = eval('(' + data.timing_list + ')');
- var qxz_switch = eval('(' + data.qxz_switch + ')');
- var qxz_list = data.qxz_list;
- if(switch_name.length > 2){
- var switch_name = eval('(' + switch_name + ')');
- }else{
- var switch_name = [];
- }
- } else {
- var timingData = [];
- var qxz_list = [];
- var switch_name = [];
- }
- if (timingData.length) {
- var html = '';
- for (var i = 0; i < timingData.length; i++) {
- if (timingData[i].JK != 255) {
- if (timingData[i].Duration == 32767 || timingData[i].StartTime == 32767) {
- var check = false;
- var curCheckedVal = {
- JK: timingData[i].JK,
- StartTime: '--',
- Duration: '--'
- }
- var startTime = '--';
- var duration = '--';
- } else {
- var check = true;
- var curCheckedVal = {
- JK: timingData[i].JK,
- StartTime: timingData[i].StartTime,
- Duration: timingData[i].Duration
- }
- var startTime = timingData[i].StartTime;
- var duration = timingData[i].Duration;
- }
- if (timingData[i].JK == qxz_switch[i].JK) {
- if(switch_name.length){
- var name = switch_name[i].name;
- }else{
- var name = '开关'+qxz_switch[i].JK;
- }
- } else {
- var name = timingData[i].JK;
- }
- html += '<div class="col-xs-2 col-sm-3"><div class="thresholdCtrl">' +
- '<div class="setthresholdBtn" onclick="timingOnOff(this)">' +
- '<i class="fa fa-cog setName" aria-hidden="true"></i></div>' +
- '<input type="hidden" class="currVal" value=\'' + JSON.stringify(curCheckedVal) + '\'>' +
- '<div class="thresholdCtrlName"><p>' + name + '</p></div>' +
- '<div class="thresholdCtrlShowDiv"><div class="maxminNum">' +
- '<p>起始时间:<span>' + startTime + '</span>点</p><p>工作时长:<span>' + duration + '</span>小时</p>' +
- '</div></div><div class="equipCtrlInp"><label>';
- if (check) {
- html += '<input name="switch-field-1" checked class="ace ace-switch ace-switch-6" type="checkbox">' +
- '<span class="lbl"></span></label></div></div></div>';
- } else {
- html += '<input name="switch-field-1" class="ace ace-switch ace-switch-6" type="checkbox">' +
- '<span class="lbl"></span></label></div></div></div>';
- }
- }
- if (i == timingData.length - 1) {
- if (html) {
- $('#gettimingDiv').html(html)
- } else {
- $('#gettimingDiv').html('<div style="text-align:center">空</div>')
- }
- }
- }
- } else {
- $('#gettimingDiv').html('<div style="text-align:center">空</div>')
- }
- }
- // 控制按钮
- function addCtrlBtn(data, switch_name) {
- if (data && switch_name.length > 2) {
- var data = eval('(' + data + ')');
- var ctrl_name = eval('(' + switch_name + ')');
- $('.qxzDownCtrl').show();
- } else if (data) {
- var data = eval('(' + data + ')');
- var ctrl_name = [];
- } else {
- var data = []
- $('.qxzDownCtrl').hide();
- }
- if (data.length) {
- var html = '';
- for (var i = 0; i < data.length; i++) {
- if (data[i].status == 0) {
- var curClass = '';
- } else {
- var curClass = 'active';
- }
- if (data[i].status == 0) {
- var curChecked = ''; //关
- } else {
- var curChecked = 'checked';
- }
- if (ctrl_name.length) {
- if (ctrl_name[i].name != '') {
- var switch_name = ctrl_name[i].name;
- } else {
- var switch_name = '开关' + ctrl_name[i].JK;
- }
- } else {
- var switch_name = '开关' + data[i].JK;
- }
- html += '<div class="col-xs-2"><div class="equipCtrl"><input type="hidden" class="currStutas" value="' + data[i].JK + '">' +
- '<i class="fa fa-cog setName" aria-hidden="true"></i><div><span class="isonlineicon ' + curClass + '"></span><span class="numName">' + switch_name + '</span></div><div class="equipCtrlInp">' +
- '<label><input name="switch-field-1" ' + curChecked + ' class="ace ace-switch ace-switch-4 btn-rotate" type="checkbox">' +
- '<span class="lbl"></span></label></div></div></div>';
- if (i == data.length - 1) {
- $('#ctrlBox').html(html);
- }
- }
- } else {
- $('#ctrlBox').html('<div style="text-align:center">空</div>');
- }
- }
- $('#ctrlBox').on('click', '.btn-rotate', function () {
- var _this = this;
- $(this).parents('.equipCtrl').find('.ctrlLoading').remove()
- $(this).attr('disabled', true);
- $(this).parents('.equipCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
- var currWay = $(this).parents('.equipCtrl').find('.currStutas').val();
- var imei = $('#qxzPhotoId').val();
- if ($(this).is(":checked")) {
- var oldStatus = 0;
- var currStutas = 1;
- } else {
- var oldStatus = 1;
- var currStutas = 0;
- }
- $.ajax({
- url: 'qxz_switch',
- type: 'post',
- data: {
- 'req': 'set',
- 'imei': imei,
- 'way': currWay,
- 'switch': currStutas
- },
- success: function (data) {
- setTimeout(function () {
- var id = $('#firstpane .menu-active').attr('id')
- loadProject(id);
- }, 5000)
- // $(_this).attr('disabled', false);
- // $(_this).parents('.equipCtrl').find('.ctrlLoading').html('');
- // if (currStutas) {
- // $(_this).parents('.equipCtrl').find('.isonlineicon').addClass('active')
- // } else {
- // $(_this).parents('.equipCtrl').find('.isonlineicon').removeClass('active')
- // }
- },
- error: function (type) {
- layer.close(loadingFlag);
- $(_this).parents('.equipCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
- $(_this).attr('disabled', false);
- if (oldStatus) {
- $(_this).prop('checked', true);
- $(_this).parents('.equipCtrl').find('.isonlineicon').addClass('active')
- } else {
- $(_this).prop('checked', '');
- $(_this).parents('.equipCtrl').find('.isonlineicon').removeClass('active')
- }
- }
- })
- })
- // 下发控制名称
- $('#ctrlBox').on('click', '.setName', function () {
- var _this = this;
- var ele = $(this).parents('.equipCtrl').find('.numName');
- var currWay = $(this).parents('.equipCtrl').find('.currStutas').val();
- layui.use('layer', function () {
- var layer = layui.layer;
- layer.prompt({ title: '自定义名称', offset: '300px', formType: 0, value: ele.html(), maxlength: 10 }, function (text, index) {
- if (text == ele.html()) {
- return false;
- layer.close(index);
- layer.msg('演示完毕!您的口令:' + text);
- ele.html(text)
- }
- $.ajax({
- url: 'qxz_switch_name',
- type: 'post',
- data: {
- 'imei': $('#qxzPhotoId').val(),
- 'way': currWay,
- 'sw_name': text
- },
- success: function (data) {
- if (data == 0) {
- ele.html(text)
- }
- layer.close(index);
- },
- error: function (type) {
- $(_this).parents('.equipCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
- $(_this).attr('disabled', false);
- if (oldStatus) {
- $(_this).prop('checked', true);
- $(_this).parents('.equipCtrl').find('.isonlineicon').addClass('active')
- } else {
- $(_this).prop('checked', '');
- $(_this).parents('.equipCtrl').find('.isonlineicon').removeClass('active')
- }
- }
- })
- });
- });
- })
- // 获取最新控制按钮状态
- function qxzDownCtrlFun() {
- $.ajax({
- url: 'qxz_switch',
- type: 'post',
- data: {
- 'req': 'conf', //
- 'imei': $('#qxzPhotoId').val(),
- },
- beforeSend: function () {
- loadFlage = layer.load();
- },
- complete: function () {
- setTimeout(function () {
- layer.close(loadFlage);
- }, 5000)
- },
- success: function (data) {
- setTimeout(function () {
- loadProject($('#qxzPhotoId').val())
- }, 5000)
- }
- })
- }
- // 获取最新数据
- function newDataRefresh() {
- $.ajax({
- url: 'qxz_switch',
- type: 'post',
- data: {
- 'req': 'read',
- 'imei': $('#qxzPhotoId').val(),
- },
- beforeSend: function () {
- loadFlage = layer.load();
- },
- complete: function () {
- setTimeout(function () {
- layer.close(loadFlage);
- }, 5000)
- },
- success: function (data) {
- setTimeout(function () {
- loadProject($('#qxzPhotoId').val())
- }, 5000)
- }
- })
- }
- // 设备列表
- var currpage = 1;
- function changePage(symbol) {
- var totelpage = Number($('#totelpage').html());
- if (symbol == 'add') {
- if (currpage < totelpage) {
- currpage++;
- $('#currentpage').html(currpage);
- $('addPage').attr('disable', 'false')
- } else {
- $('addPage').attr('disable', 'true')
- return false;
- }
- } else {
- if (currpage > 1) {
- currpage--;
- $('#currentpage').html(currpage);
- $('jianPage').attr('disable', 'false')
- } else {
- $('jianPage').attr('disable', 'true')
- return false;
- }
- }
- getEquipList(currpage, $('#searchImei').val())
- }
- // 首页
- function gotofirstpage() {
- currpage = 1;
- $('#currentpage').html(1);
- getEquipList(1, $('#searchImei').val())
- }
- // 定时刷新
- // msgInterval = setInterval(function () {
- // var currid = $('#firstpane .menu-active').attr('id');
- // loadProject(currid);
- // }, 60000);
- var waterTempId = [16062009, 16062010, 16062011, 16062012, 16062013, 16062014, 16062015, 16062016, 16062017, 16062018, 16062019, 16062020, 16062021, 16062022, 16062023, 16062024, 16062025];
- // 实时状态
- function newStatus(statusBox, dat, facId) {
- var html = '';
- $(document.getElementById(statusBox)).html('');
- if (dat.length) {
- for (var i = 0; i < dat.length; i++) {
- var random = ['bg_lb', 'bg_ly', 'bg_ls', 'bg_lg', 'bg_lo', 'bg_lr']; //颜色随机
- var unit = dat[i].unit;
- if (unit[0] == '106' && (waterTempId.indexOf(parseInt(facId)) != -1)) {
- var elementName = '水温';
- var curUnit = unit[2];
- var curVal = dat[i].eValue;
- var icon = unit[0];
- } else if (dat[i].eKey.substr(1) == '16' && (facId == '16062388')) { // 徐丹 16062388气象站
- var elementName = '氮';
- var curUnit = unit[2];
- var curVal = dat[i].eValue;
- var icon = 'n';
- } else if (dat[i].eKey.substr(1) == '15' && (facId == '16062388')) { // 徐丹 16062388气象站
- var elementName = '磷';
- var curUnit = unit[2];
- var curVal = dat[i].eValue;
- var icon = 'p';
- } else if (dat[i].eKey.substr(1) == '5' && (facId == '16062388')) { // 徐丹 16062388气象站
- var elementName = '钾';
- var curUnit = unit[2];
- var curVal = dat[i].eValue;
- var icon = 'k';
- } else {
- var elementName = unit[1];
- var curUnit = unit[2];
- var curVal = dat[i].eValue;
- var icon = unit[0];
- }
- var colorClass = unit[0] % 4;
- html += '<div class="dev ' + random[colorClass] + '"><div class="left">' +
- '<img class="img-dev" src="/static/img/dev/icon_' + icon + '.png">' +
- '</div><div class="right"><div class="name">' + elementName + '</div>' +
- '<div class="data"><strong><span style="font-size: 25px;">' + curVal + '</span>' +
- '</strong>' + curUnit + '</div></div><div class="aisle">通道' + dat[i].eKey.substr(1) + '</div></div>';
- }
- $(document.getElementById(statusBox)).append(html);
- $('#updataTime').html('数据更新时间:' + dat[0].upl_time)
- if (dat[0].equip_name) {
- $('.widget-content .equip_name').html(dat[0].equip_name);
- } else {
- $('.widget-content .equip_name').html('项目名称:设备' + dat[0].equip_id);
- }
- $('.widget-content .equip_id').html('设备ID:' + dat[0].equip_id);
- $('#viewPhoto').attr('src', dat[0].qxz_picture);
- scrollBar()
- } else {
- html = '空';
- $(document.getElementById(statusBox)).append(html);
- $('#updataTime').html('暂无上传数据')
- $('.widget-content .equip_name').html('');
- var id = $('#firstpane .menu-active').attr('id')
- $('.widget-content .equip_id').html('设备ID:' + id);
- $('#viewPhoto').attr('src', 'qxz_photo/default.jpg');
- scrollBar()
- }
- scrollBar()
- }
- // 24小时数据
- function Fill_Table(table_id, dat, facId) {
- //js循环读取json数据
- var table = document.getElementById(table_id).children[1];
- for (var i = 0; i < dat.length; i++) {
- var row = table.insertRow(table.rows.length);
- var c1 = row.insertCell(0);
- c1.innerHTML = dat[i].ekey;
- var c2 = row.insertCell(1);
- var unit = dat[i].unit
- if (unit[0] == '106' && (waterTempId.indexOf(parseInt(facId)) != -1)) {
- var elementName = '水温';
- } else {
- var elementName = unit[1];
- }
- c2.innerHTML = elementName + '(' + unit[2] + ')';
- var c3 = row.insertCell(2);
- c3.innerHTML = dat[i].min;
- var c4 = row.insertCell(3);
- var min_time = dat[i].min_time;
- var minlength = min_time.length - 1;
- c4.innerHTML = min_time.substring(1, minlength);
- var c5 = row.insertCell(4);
- c5.innerHTML = dat[i].max;
- var c6 = row.insertCell(5);
- var max_time = dat[i].max_time;
- var maxlength = max_time.length - 1;
- c6.innerHTML = max_time.substring(1, maxlength);
- if (i == dat.length - 1) {
- scrollBar()
- }
- }
- }
- function Fill_null_Table(table_id) {
- var table = document.getElementById(table_id).children[1];
- var row = table.insertRow(table.rows.length);
- var c1 = row.insertCell(0);
- c1.setAttribute('colspan', '16');
- c1.setAttribute('class', 'nullData');
- c1.innerHTML = "暂无数据";
- scrollBar()
- }
- window.onresize = function () {
- scrollBar()
- }
- // file 文件
- // divId div id
- // imgId 图片id
- // fileId 文件id
- // width 图片宽
- // height 图片高
- function previewImage(file, divId, imgId, fileId, width, height) {
- width = $('#viewPhotoParent').width();
- var div = document.getElementById(divId);
- if (file.files && file.files[0]) {
- if (file.files[0].size / 1024 / 1024 < 4) {
- sendUserPhoto();
- div.innerHTML = '<img id=' + imgId + ' onclick=$("#' + fileId + '").click()>';
- var img = document.getElementById(imgId);
- img.onload = function () {
- // var rect = clacImgZoomParam(width, height, img.offsetWidth, img.offsetHeight);
- img.width = width;
- img.height = height;
- // img.style.marginTop = rect.top+'px';
- }
- var reader = new FileReader();
- reader.onload = function (evt) {
- img.src = evt.target.result;
- // $(window.parent.document).find('.nav-user-photo').attr('src',evt.target.result);
- }
- reader.readAsDataURL(file.files[0]);
- // $('#userPhoto').submit();
- } else {
- $(file).val('');
- layer.alert("图片过大!");
- }
- } else {//兼容IE
- var sFilter = 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
- file.select();
- if (document.selection != undefined) {
- var src = document.selection.createRange().text;
- div.innerHTML = '<img id=' + imgId + '>';
- var img = document.getElementById(imgId);
- img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
- var rect = clacImgZoomParam(width, height, img.offsetWidth, img.offsetHeight);
- status = ('rect:' + rect.top + ',' + rect.left + ',' + rect.width + ',' + rect.height);
- div.innerHTML = "<div id=divhead style='width:" + rect.width + "px;height:" + rect.height + "px;" + sFilter + src + "\"'></div>";
- }
- }
- }
- function clacImgZoomParam(maxWidth, maxHeight, width, height) {
- var param = { top: 0, left: 0, width: width, height: height };
- if (width > maxWidth || height > maxHeight) {
- var rateWidth = width / maxWidth;
- var rateHeight = height / maxHeight;
- if (rateWidth > rateHeight) {
- param.width = maxWidth;
- param.height = Math.round(height / rateWidth);
- } else {
- param.width = Math.round(width / rateHeight);
- param.height = maxHeight;
- }
- }
- param.left = Math.round((maxWidth - param.width) / 2);
- param.top = Math.round((maxHeight - param.height) / 2);
- return param;
- }
- // 上传图片
- function sendUserPhoto() {
- var formData = new FormData($("#userPhoto")[0]);
- $.ajax({
- url: 'qxz_photo',
- type: 'POST',
- data: formData,
- contentType: false,
- processData: false,
- success: function (data) {
- if (data == 0) {
- $(window.parent.document).find('.nav-user-photo').attr('src', $('#viewPhoto').prop('src'));
- $('#uploadPhoto').val('');
- }
- else { layer.msg("上传失败!"); return false; }
- }
- });
- }
- // 设置阈值
- function setthresholdFun(ele) {
- var obj = $(ele);
- var currValstr = obj.next().val();
- var currVal = eval('(' + currValstr + ')');
- layui.use(['layer', 'form'], function () {
- var rule0 = "低于下限<span>开启</span>,高于上限<span>关闭</span>";
- var rule1 = "低于下限<span>关闭</span>,高于上限<span>开启</span>";
- var layer = layui.layer;
- var form = layui.form;
- //给表单赋值
- form.val("formModel", {
- "JK": currVal.JK
- , "eKey": currVal.eKey
- , "upper": currVal.upper
- , "lower": currVal.lower
- , "method": currVal.method
- });
- if (currVal.method == 1) {
- $('#hintDiv').html(rule1)
- } else {
- $('#hintDiv').html(rule0)
- }
- form.on('radio(radioSwitch)', function (data) {
- // console.log(data.value); //被点击的radio的value值
- if (data.value == 1) {
- $('#hintDiv').html(rule1)
- } else {
- $('#hintDiv').html(rule0)
- }
- });
- layer.open({
- type: 1,
- title: '阈值设置',
- offset: '380px',
- btn: ['确定', '取消'],
- area: ['600px', '300px'], //宽高
- content: $('#Modal'),
- success: function (layero, index) { // 成功弹出后回调
- // 添加form标识
- layero.addClass('layui-form');
- // 将保存按钮改变成提交按钮
- layero.find('.layui-layer-btn0').attr({
- 'lay-filter': 'setYuzhi',
- 'lay-submit': ''
- });
- },
- yes: function (index, layero) {
- form.on('submit(setYuzhi)', function (data) {
- var dat = data.field;
- if (parseInt(data.field.upper) < parseInt(data.field.lower)) {
- layer.tips('最大值不能小于最小值!', $('#upper'));
- return false;
- }
- var hideVal = JSON.stringify(data.field)
- var id = $('#firstpane .menu-active').attr('id')
- data.field.equip_id = id;
- var curinputBtn = obj.parent().find('.ace-switch');
- if (curinputBtn.is(":checked")) {
- var oldStatus = 0;
- var currStutas = 1;
- } else {
- var oldStatus = 1;
- var currStutas = 0;
- }
- obj.parents('.thresholdCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
- $.ajax({
- url: 'qxz_value_mqtt',
- type: 'post',
- data: data.field,
- success: function (data) {
- setTimeout(function () {
- curinputBtn.attr('disabled', false);
- curinputBtn.parents('.thresholdCtrl').find('.ctrlLoading').html('');
- obj.parent().find('.maxminNum').find('p').eq(0).find('span').html(dat.upper)//最大值
- obj.parent().find('.maxminNum').find('p').eq(1).find('span').html(dat.lower)//最小值
- obj.parents('.thresholdCtrl').find('.ace-switch').prop('checked', 'checked');//开启阈值
- var id = $('#firstpane .menu-active').attr('id')
- loadProject(id);
- }, 5000)
- },
- error: function (type) {
- curinputBtn.parents('.thresholdCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
- curinputBtn.attr('disabled', false);
- }
- })
- // $('.maxminNum')
- layer.closeAll(); //疯狂模式,关闭所有层
- return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
- });
- }
- , btn2: function (index, layero) {
- $('#Modal').hide()
- //return false 开启该代码可禁止点击该按钮关闭
- }
- });
- });
- }
- // 下发阈值控制
- $('#getthresholdDiv').on('click', '.ace-switch', function () {
- var _this = this;
- $(this).parents('.thresholdCtrl').find('.ctrlLoading').remove()
- $(this).attr('disabled', true);
- $(this).parents('.thresholdCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
- var currVal = $(this).parents('.thresholdCtrl').find('.currVal').val();
- var currWayjson = JSON.parse(currVal);
- var id = $('#firstpane .menu-active').attr('id')
- currWayjson.equip_id = id;
- if ($(this).is(":checked")) { //开启
- var oldStatus = 0;
- var currStutas = 1;
- } else { //关闭
- var oldStatus = 1;
- var currStutas = 0;
- currWayjson.upper = '32767';
- currWayjson.lower = '32767';
- }
- $.ajax({
- url: 'qxz_value_mqtt',
- type: 'post',
- data: currWayjson,
- success: function (data) {
- setTimeout(function () {
- $(_this).attr('disabled', false);
- $(_this).parents('.thresholdCtrl').find('.ctrlLoading').html('');
- var id = $('#firstpane .menu-active').attr('id')
- loadProject(id);
- }, 5000)
-
- },
- error: function (type) {
- $(_this).parents('.thresholdCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
- $(_this).attr('disabled', false);
- if (oldStatus) {
- $(_this).prop('checked', true);
- } else {
- $(_this).prop('checked', '');
- }
- }
- })
- })
- // 定时开关
- function timingOnOff(ele) {
- var obj = $(ele);
- var currValstr = obj.next().val();
- var currVal = eval('(' + currValstr + ')');
- layui.use(['layer', 'form'], function () {
- var layer = layui.layer;
- var form = layui.form;
- form.verify({
- starttimeRegex: function (value, item) { //value:表单的值、item:表单的DOM对象
- if (value < 0 || value > 23) {
- return '请输入范围内数值';
- }
- },
- durationRegex: function (value, item) { //value:表单的值、item:表单的DOM对象
- if (value < 1 || value > 24) {
- return '请输入范围内数值';
- }
- }
- });
- //给表单赋值
- form.val("formModel", {
- "JK": currVal.JK
- , "StartTime": currVal.StartTime
- , "Duration": currVal.Duration
- });
- layer.open({
- type: 1,
- title: '阈值设置',
- offset: '380px',
- btn: ['确定', '取消'],
- area: ['600px', '300px'], //宽高
- content: $('#timingOnOffModal'),
- success: function (layero, index) { // 成功弹出后回调
- // 添加form标识
- layero.addClass('layui-form');
- // 将保存按钮改变成提交按钮
- layero.find('.layui-layer-btn0').attr({
- 'lay-filter': 'setdingshi',
- 'lay-submit': ''
- });
- },
- yes: function (index, layero) {
- form.on('submit(setdingshi)', function (data) {
- var hideVal = JSON.stringify(data.field)
- var dat = data.field;
- var curinputBtn = obj.parent().find('.ace-switch');
- if (curinputBtn.is(":checked")) {
- var oldStatus = 0;
- var currStutas = 1;
- } else {
- var oldStatus = 1;
- var currStutas = 0;
- }
- var id = $('#firstpane .menu-active').attr('id')
- dat.equip_id = id;
- obj.parents('.thresholdCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
- $.ajax({
- url: 'qxz_timing_mqtt',
- type: 'post',
- data: dat,
- success: function (data) {
- setTimeout(function () {
- obj.next().val(hideVal)
- curinputBtn.attr('disabled', false);
- curinputBtn.parents('.thresholdCtrl').find('.ctrlLoading').html('');
- obj.parent().find('.maxminNum').find('p').eq(0).find('span').html(dat.StartTime)//最大值
- obj.parent().find('.maxminNum').find('p').eq(1).find('span').html(dat.Duration)//最小值
- obj.parents('.thresholdCtrl').find('.ace-switch').prop('checked', 'checked');//开启阈值
- var id = $('#firstpane .menu-active').attr('id')
- loadProject(id);
- }, 5000)
-
- },
- error: function (type) {
- curinputBtn.parents('.thresholdCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
- curinputBtn.attr('disabled', false);
- }
- })
- // $('.maxminNum')
- layer.closeAll(); //疯狂模式,关闭所有层
- return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
- });
- }
- , btn2: function (index, layero) {
- $('#Modal').hide()
- //return false 开启该代码可禁止点击该按钮关闭
- }
- });
- });
- }
- $('#starttime').on('blur', function () {
- $(this).val(parseInt($(this).val()))
- })
- $('#Duration').on('blur', function () {
- $(this).val(parseInt($(this).val()))
- })
- // 下发定时开关
- $('#gettimingDiv').on('click', '.ace-switch', function () {
- var _this = this;
- var currVal = $(this).parents('.thresholdCtrl').find('.currVal').val();
- var currWayjson = JSON.parse(currVal);
- var id = $('#firstpane .menu-active').attr('id')
- currWayjson.equip_id = id;
- if (currWayjson.StartTime == '--' || currWayjson.Duration == '--') {
- $(this).parents('.thresholdCtrl').find('.setthresholdBtn').click();
- layer.msg('请先设置定时时间', { icon: 2 })
- return false;
- }
- $(this).parents('.thresholdCtrl').find('.ctrlLoading').remove()
- $(this).attr('disabled', true);
- $(this).parents('.thresholdCtrl').append('<div class="ctrlLoading"><img src="http://www.nyzhwlw.com/images/loading.gif" width="24">操作中...</div>');
- if ($(this).is(":checked")) { //开启
- var oldStatus = 0;
- var currStutas = 1;
- } else { //关闭
- var oldStatus = 1;
- var currStutas = 0;
- currWayjson.StartTime = '255';
- currWayjson.Duration = '32767';
- }
- $.ajax({
- url: 'qxz_timing_mqtt',
- type: 'post',
- data: currWayjson,
- success: function (data) {
- setTimeout(function () {
- $(_this).attr('disabled', false);
- $(_this).parents('.thresholdCtrl').find('.ctrlLoading').html('');
- var id = $('#firstpane .menu-active').attr('id')
- loadProject(id);
- }, 5000)
-
- },
- error: function (type) {
- $(_this).parents('.thresholdCtrl').find('.ctrlLoading').html('<span style="color:red">操作失败</span>');
- $(_this).attr('disabled', false);
- if (oldStatus) {
- $(_this).prop('checked', true);
- } else {
- $(_this).prop('checked', '');
- }
- }
- })
- })
- </script>
- </body>
- </html>
|