123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <!DOCTYPE html>
- <html>
- <head>
- <filter><script src="../js/common.js"></script><script src="../js/jquery.min.js"></script></filter>
- <script class="include" system="" path="inc/" file="head">include()</script>
- </head>
- <body class="gray">
- <header>
- 智能设置 <a href="#" class="ico-back"></a>
- </header>
- <section class="wrapper">
- <section class="card w100">
- <h4>设备条件:</h4>
- <label for=""> </label>
- <p class="form-group">
- <select name="product" id="product" onchange="set()">
- <option value="">请选择设备</option>
- <option value="">222</option>
- <option value="">444</option>
- </select>
- <select name="type" id="type" onchange="set()">
- <option value="">请选择设备类型</option>
- <option value="">222</option>
- <option value="">444</option>
- </select>
- </p>
- <p class="form-group">
- <select name="element" id="element">
- <option value="">请选择传感器</option>
- <option value="">222</option>
- <option value="">444</option>
- </select>
- </p>
- </section>
- <section class="card w100 sensor" style="display:none;">
- <h4>条件判断:</h4>
- <label for=""> </label>
- <p class="form-group" style="display:none;">
- 表达式:<input type="text" value="{b}" name="exp" id="exp"/>({b}为当前值)
- </p>
- <p class="form-group">
- <select name="than" id="than">
- <option value="">大于</option>
- <option value="">小于</option>
- </select>
- <input type="text" value="0" name="value" id="value" />
- </p>
- </section>
- <section class="card w100 sensor" style="display:none;">
- <h4>执行结果:<input type="hidden" value="" name="result" id="result" /></h4>
- <label for=""> </label>
- <p class="form-group">
- <select class="result" id="result_1">
- <option value="1">报警</option>
- <option value="2">不报警</option>
- </select>
- </p>
- <div id="result_add">
- </div>
- <p class="form-group">
- <a href="javascript:;" onclick="add()" class="input">+</a>
- </p>
- </section>
- <section class="card w100 control" style="display:none;">
- <h4>操作类型:</h4>
- <label for=""> </label>
- <p class="form-group">
- <select name="oper" id="oper">
- <option value="">大于</option>
- <option value="">小于</option>
- </select>
- <input type="text" value="600" name="time" id="time" />
- </p>
- </section>
- <input type="hidden" id="set_id" name="set_id" value="-1">
- <input type="hidden" id="result_num" name="result_num" value="">
- <input type="hidden" id="result_value" name="result_value" value="">
- <input type="button" value="确定" class="button" id="set" />
- <div style="display:none;">
- <select id="result_2">
- <option value="">请选择传感器</option>
- </select>
- <select id="result_3">
- <option value="3">不操作</option>
- <option value="1">打开</option>
- <option value="2">关闭</option>
- </select>
- </div>
- </section>
- </body>
- </html>
- <script>
- var addindex = 0;
- $("select option").each(function()
- {
- if($(this).attr('select') && $(this).attr('select') == 'true')
- {
- $(this).attr('selected', 'true');
- }
- else
- {
- $(this).removeAttr('selected');
- }
- });
- function set()
- {
- var type = $("#type").val();
- var product_id = $("#product").val();
- var url = $("#set").attr('url');
- $.getJSON(url, {type:type,id:product_id}, function(t)
- {
- t = t.data;
- if(t)
- {
- $("#element").html(t);
- $("#element").parent().show();
- }
- else
- {
- $("#element").parent().hide();
- }
- if(type == 1)
- {
- $(".control").hide();
- $(".sensor").show();
- }
- else
- {
- $(".sensor").hide();
- $(".control").show();
- }
- });
- $.getJSON(url, {type:2,id:product_id}, function(t)
- {
- t = t.data;
- if(t)
- {
- $("#result_2").html(t);
- if(addindex <= 0)
- {
- var num = $("#result_num").val();
- var value = $("#result_value").val();
- if(num > 0)
- {
- num = num*2;
- var v = value.split(',');
- for(var i=0; i<num; i++)
- {
- add(v[i], v[i+1]);
- i++;
- }
- }
- }
- }
- else
- {
- $("#result_2").hide();
- }
- });
-
- }
- function add(v1,v2)
- {
- var e = $('#result_add');
- var r = $("#result_2");
- var a = $("#result_3");
- var html = '<p class="form-group"><select class="result" id="result_i_'+addindex+'">' + r.html() + '</select>' + '<select class="result" id="result_j_'+addindex+'">' + a.html() + '</select></p>';
- e.append(html);
- if(v1)
- {
- $("#result_i_" + addindex).val(v1);
- }
- if(v2)
- {
- $("#result_j_" + addindex).val(v2);
- }
- addindex++;
- }
- function result()
- {
- var result = [];
- $(".result").each(function()
- {
- result.push($(this).val());
- });
- $("#result").val(result.join(','));
- }
- set();
- </script>
|