|
|
|
@ -8,8 +8,8 @@
|
|
|
|
|
<!-- 引入 layui.css -->
|
|
|
|
|
<link href="../static/layui-v2.8.11/css/layui.css" rel="stylesheet">
|
|
|
|
|
<!-- 引入 layui.js -->
|
|
|
|
|
<script src="../static/layui-v2.8.11/layui.js"></script>
|
|
|
|
|
<script src="../static/jquery/jquery-3.2.1.min.js"></script>
|
|
|
|
|
<script src="../static/layui-v2.8.11/layui.js"></script>
|
|
|
|
|
<!-- 加载 Select2 -->
|
|
|
|
|
<link href="../static/select2/4.0.8/css/select2.min.css" rel="stylesheet" />
|
|
|
|
|
<script src="../static/select2/4.0.8/js/select2.min.js"></script>
|
|
|
|
@ -145,7 +145,8 @@
|
|
|
|
|
<td>
|
|
|
|
|
<div class="layui-col-md7">
|
|
|
|
|
<div class="layui-form">
|
|
|
|
|
<input type="text" name="name" id="celueName" placeholder="请填写策略名称···" class="layui-input" th:value="${detail.name}" th:readonly="${type=='detail'}">
|
|
|
|
|
<input type="hidden" th:value="${detail.celueid}" id="celueid"/>
|
|
|
|
|
<input type="text" name="name" id="celueName" placeholder="请填写策略名称···" class="layui-input" th:value="${detail.name}">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
@ -173,18 +174,13 @@
|
|
|
|
|
<td>
|
|
|
|
|
<div class="layui-form layui-row layui-col-space16">
|
|
|
|
|
<div class="layui-col-md3">
|
|
|
|
|
<select id="type" th:value="${detail.type}" th:readonly="${type=='detail'}" th:if="${type!='detail'}">
|
|
|
|
|
<input type="hidden" th:value="${detail.type}" id="typeValue"/>
|
|
|
|
|
<select id="type" th:readonly="${type=='detail'}">
|
|
|
|
|
<option value="">请选择</option>
|
|
|
|
|
<option value="1">开灯/放电</option>
|
|
|
|
|
<option value="0">关灯/断电</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<div th:else th:switch="${detail.type}">
|
|
|
|
|
<div class="layui-field-box">
|
|
|
|
|
<span th:case="1">开灯/放电</span>
|
|
|
|
|
<span th:case="0">关灯/断电</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
@ -192,7 +188,8 @@
|
|
|
|
|
<td>执行周期:</td>
|
|
|
|
|
<td>
|
|
|
|
|
<div class="layui-form">
|
|
|
|
|
<input type="radio" name="timeType" value="everyDay" lay-filter="demo-radio-filter" title="每天" th:checked="${detail.timeType=='everyDay'}">
|
|
|
|
|
<input type="hidden" id="timeTypeValue" th:value="${detail.timeType}"/>
|
|
|
|
|
<input type="radio" name="timeType" value="everyDay" lay-filter="demo-radio-filter" title="每天" th:checked="${detail.timeType=='everyDay' || type == 'add'}">
|
|
|
|
|
<input type="radio" name="timeType" value="weekly" lay-filter="demo-radio-filter" title="每周" th:checked="${detail.timeType=='weekly'}">
|
|
|
|
|
<input type="radio" name="timeType" value="day" lay-filter="demo-radio-filter" title="单日" th:checked="${detail.timeType=='day'}">
|
|
|
|
|
<input type="radio" name="timeType" value="date" lay-filter="demo-radio-filter" title="日期段" th:checked="${detail.timeType=='date'}">
|
|
|
|
@ -200,7 +197,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr id="weeklyTr" th:hidden="${type=='add' && detail.timeType!='weekly'}">
|
|
|
|
|
<tr id="weeklyTr" th:hidden="${type=='add' || detail.timeType!='weekly'}">
|
|
|
|
|
<!--周-->
|
|
|
|
|
<td>选择日期:</td>
|
|
|
|
|
<td>
|
|
|
|
@ -221,13 +218,13 @@
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr id="dayTr" th:hidden="${type=='add' && detail.timeType!='day'}">
|
|
|
|
|
<tr id="dayTr" th:hidden="${type=='add' || detail.timeType!='day'}">
|
|
|
|
|
<!--单日-->
|
|
|
|
|
<td>选择日期:</td>
|
|
|
|
|
<td>
|
|
|
|
|
<div class="layui-col-md3" id="dayDiv">
|
|
|
|
|
<div class="layui-input-wrap">
|
|
|
|
|
<input type="text" class="layui-input" id="ID-laydate-demo" placeholder="选择策略执行时间">
|
|
|
|
|
<input type="text" class="layui-input" id="ID-laydate-demo" placeholder="选择策略执行时间" th:value="${detail.startTime}">
|
|
|
|
|
<div class="layui-input-split layui-input-suffix" style="background-color: #f5f5f5">
|
|
|
|
|
<i class="layui-icon layui-icon-time"></i>
|
|
|
|
|
</div>
|
|
|
|
@ -235,14 +232,14 @@
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr id="dateTr" th:hidden="${type=='add' && detail.timeType!='date'}">
|
|
|
|
|
<tr id="dateTr" th:hidden="${type=='add' || detail.timeType!='date'}">
|
|
|
|
|
<!--范围-->
|
|
|
|
|
<td>选择日期:</td>
|
|
|
|
|
<td>
|
|
|
|
|
<div id="ID-laydate-rangeLinked">
|
|
|
|
|
<div class="layui-col-md3" style="margin-right: 0.5%">
|
|
|
|
|
<div class="layui-input-wrap">
|
|
|
|
|
<input type="text" autocomplete="off" id="ID-laydate-start-date-1" class="layui-input" placeholder="选择策略执行开始日期">
|
|
|
|
|
<input type="text" autocomplete="off" id="ID-laydate-start-date-1" class="layui-input" placeholder="选择策略执行开始日期" th:value="${detail.startTime}">
|
|
|
|
|
<div class="layui-input-split layui-input-suffix" style="background-color: #f5f5f5">
|
|
|
|
|
<i class="layui-icon layui-icon-date"></i>
|
|
|
|
|
</div>
|
|
|
|
@ -250,7 +247,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-col-md3">
|
|
|
|
|
<div class="layui-input-wrap">
|
|
|
|
|
<input type="text" autocomplete="off" id="ID-laydate-end-date-1" class="layui-input" placeholder="选择策略执行结束日期">
|
|
|
|
|
<input type="text" autocomplete="off" id="ID-laydate-end-date-1" class="layui-input" placeholder="选择策略执行结束日期" th:value="${detail.endTime}">
|
|
|
|
|
<div class="layui-input-split layui-input-suffix" style="background-color: #f5f5f5">
|
|
|
|
|
<i class="layui-icon layui-icon-date"></i>
|
|
|
|
|
</div>
|
|
|
|
@ -264,7 +261,7 @@
|
|
|
|
|
<td>
|
|
|
|
|
<div class="layui-col-md3">
|
|
|
|
|
<div class="layui-input-wrap">
|
|
|
|
|
<input type="text" class="layui-input" id="ID-laydate-type-time" placeholder="选择策略开始时间">
|
|
|
|
|
<input type="text" class="layui-input" id="ID-laydate-type-time" placeholder="选择策略开始时间" th:value="${detail.exeTime}">
|
|
|
|
|
<div class="layui-input-split layui-input-suffix" style="background-color: #f5f5f5">
|
|
|
|
|
<i class="layui-icon layui-icon-time"></i>
|
|
|
|
|
</div>
|
|
|
|
@ -277,7 +274,7 @@
|
|
|
|
|
<td>
|
|
|
|
|
<div class="layui-col-md7">
|
|
|
|
|
<div class="layui-form">
|
|
|
|
|
<textarea name="detail" id="detail" placeholder="请填写备注文字···" class="layui-textarea"></textarea>
|
|
|
|
|
<textarea name="detail" id="detail" placeholder="请填写备注文字···" class="layui-textarea" th:text="${detail.description}"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
@ -285,11 +282,12 @@
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
<div class="layui-input-inline" th:if="${type == 'add'}">
|
|
|
|
|
<button type="button" onclick="sub()" class="layui-btn layui-btn-normal">提交</button>
|
|
|
|
|
<button type="button" onclick="sub('add')" class="layui-btn layui-btn-normal">提交</button>
|
|
|
|
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-input-inline" th:if="${type == 'detail'}">
|
|
|
|
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
|
|
|
|
<button type="button" onclick="sub('edit')" class="layui-btn layui-btn-normal">提交</button>
|
|
|
|
|
<button type="button" class="layui-btn layui-btn-primary" onclick="back()">返回</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
@ -303,16 +301,43 @@
|
|
|
|
|
var name='';
|
|
|
|
|
var status='';
|
|
|
|
|
getDeviceList()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getDeviceList(){
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: "/device/listAll",
|
|
|
|
|
success: function(res){
|
|
|
|
|
console.log(res)
|
|
|
|
|
if(res.success){
|
|
|
|
|
var selectorx = $('#id_select2_demo1').select2();
|
|
|
|
|
//var data=[{"id":"1","text":"1F左侧走廊照明灯组"},{"id":2,"text":"1F右侧走廊照明灯组"},{"id":3,"text":"2F左侧走廊照明灯组"},{"id":4,"text":"2F右侧走廊照明灯组"}];
|
|
|
|
|
$("#id_select2_demo1").select2({
|
|
|
|
|
data:res.result
|
|
|
|
|
});
|
|
|
|
|
changeSelect()
|
|
|
|
|
}else{}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function changeSelect(){
|
|
|
|
|
/*select2 回显*/
|
|
|
|
|
var str=$("#devids").val();
|
|
|
|
|
var arr=str.split(',');
|
|
|
|
|
console.log(arr)
|
|
|
|
|
$('#id_select2_demo1').val(arr).trigger('change')
|
|
|
|
|
|
|
|
|
|
var select2d = $("#id_select2_demo1").select2();
|
|
|
|
|
select2d.val(arr).trigger('change')
|
|
|
|
|
}
|
|
|
|
|
loadTable();
|
|
|
|
|
var form;
|
|
|
|
|
|
|
|
|
|
/*详情页,加载列表颜色*/
|
|
|
|
|
var timeTypeValue = $("#timeTypeValue").val();
|
|
|
|
|
if(timeTypeValue!=null &&timeTypeValue!=undefined &&timeTypeValue!=''){
|
|
|
|
|
rowColor(timeTypeValue)
|
|
|
|
|
}else{
|
|
|
|
|
/*新增页,默认每天*/
|
|
|
|
|
rowColor('everyDay')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadTable(){
|
|
|
|
|
layui.use('table', function () {
|
|
|
|
|
var table = layui.table;
|
|
|
|
@ -341,6 +366,7 @@
|
|
|
|
|
/*$('#dayTr').hide();
|
|
|
|
|
$('#dayTr2').show();*/
|
|
|
|
|
|
|
|
|
|
//周 回显
|
|
|
|
|
let weeklyd = $("#weeklyd").val();
|
|
|
|
|
if (weeklyd != null && weeklyd != '') {
|
|
|
|
|
let split = weeklyd.split(',');
|
|
|
|
@ -352,11 +378,21 @@
|
|
|
|
|
}
|
|
|
|
|
form.render();
|
|
|
|
|
});
|
|
|
|
|
/*for (let i = 0; i < split.length; i++) {
|
|
|
|
|
console.log(split[i])
|
|
|
|
|
$("#weeklyDay"+split[i]).attr("checked","checked");
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
//操作类型 回显
|
|
|
|
|
$("#type").each(function (){
|
|
|
|
|
var typeValue=$("#typeValue").val();
|
|
|
|
|
// this代表的是<option></option>,对option再进行遍历
|
|
|
|
|
$(this).children("option").each(function() {
|
|
|
|
|
// 判断需要对那个选项进行回显
|
|
|
|
|
if (this.value == typeValue) {
|
|
|
|
|
console.log($(this).text());
|
|
|
|
|
// 进行回显
|
|
|
|
|
$(this).attr("selected","selected");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
form.render();
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 事件
|
|
|
|
|
// radio 事件
|
|
|
|
@ -366,7 +402,6 @@
|
|
|
|
|
var value = elem.value; // 获得 radio 值
|
|
|
|
|
var othis = data.othis; // 获得 radio 元素被替换后的 jQuery 对象
|
|
|
|
|
|
|
|
|
|
var i=0;
|
|
|
|
|
console.log(value)
|
|
|
|
|
if(value=='weekly'){
|
|
|
|
|
$("#weeklyTr").show();
|
|
|
|
@ -385,38 +420,56 @@
|
|
|
|
|
$("#dayTr").hide();
|
|
|
|
|
$("#dateTr").hide();
|
|
|
|
|
}
|
|
|
|
|
rowColor(value)
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*if (value == 'day') {
|
|
|
|
|
$('#dayTr').show();
|
|
|
|
|
$("#dayTr2").hide();
|
|
|
|
|
function rowColor(value){
|
|
|
|
|
var i=0;
|
|
|
|
|
$('tr').each(function(i) {
|
|
|
|
|
$(this).css("background", '');
|
|
|
|
|
});
|
|
|
|
|
//选择每天
|
|
|
|
|
if (value == 'day') {
|
|
|
|
|
$('tr').each(function(i) {
|
|
|
|
|
if ($(this).attr('id') != 'dayTr') {
|
|
|
|
|
i++;
|
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
|
$(this).css("background", "#f5f5f5");
|
|
|
|
|
}else{
|
|
|
|
|
$(this).css("background",'');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
$('#dayTr').hide();
|
|
|
|
|
$('#dayTr2').show();
|
|
|
|
|
}else if(value =='weekly'){
|
|
|
|
|
$('tr').each(function(i) {
|
|
|
|
|
i++;
|
|
|
|
|
if(i % 2 ==0){
|
|
|
|
|
$(this).css("background","#f5f5f5");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}else if(value == 'everyDay'){
|
|
|
|
|
$('tr').each(function() {
|
|
|
|
|
if ($(this).attr('id') != 'dayTr') {
|
|
|
|
|
i++;
|
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
|
$(this).css("background", "#f5f5f5");
|
|
|
|
|
} else {
|
|
|
|
|
$(this).css("background", '');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}*/
|
|
|
|
|
} else{
|
|
|
|
|
$('tr').each(function() {
|
|
|
|
|
i++;
|
|
|
|
|
if ($(this).attr('id') != 'dateTr') {
|
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
|
$(this).css("background", "#f5f5f5");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function sub(){
|
|
|
|
|
function sub(subType){
|
|
|
|
|
//策略名称
|
|
|
|
|
let celueName = $("#celueName").val();
|
|
|
|
|
//选择设备
|
|
|
|
@ -495,8 +548,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var index = layer.load(0, {shade: false});
|
|
|
|
|
//请求保存
|
|
|
|
|
var obj = JSON.stringify({
|
|
|
|
|
var obj = {
|
|
|
|
|
'name':celueName,
|
|
|
|
|
'devidList':devidList,
|
|
|
|
|
'type':type,
|
|
|
|
@ -507,23 +559,45 @@
|
|
|
|
|
'starDate':startDate,
|
|
|
|
|
'endDate':endDate,
|
|
|
|
|
'description':description
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
let ajaxType='POST'//请求类型
|
|
|
|
|
if (subType == 'edit') {
|
|
|
|
|
obj.celueid = $("#celueid").val()
|
|
|
|
|
ajaxType = 'PUT'
|
|
|
|
|
}
|
|
|
|
|
//请求保存
|
|
|
|
|
var jsonObj = JSON.stringify(obj);
|
|
|
|
|
console.log(jsonObj)
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
type: ajaxType,
|
|
|
|
|
url: "/celue",
|
|
|
|
|
data: obj,
|
|
|
|
|
data: jsonObj,
|
|
|
|
|
contentType: 'application/json;charset=utf-8',
|
|
|
|
|
success: function(res){
|
|
|
|
|
console.log(res)
|
|
|
|
|
layer.close(index);
|
|
|
|
|
if (res.success) {
|
|
|
|
|
layer.msg(res.message, {icon: 0});
|
|
|
|
|
layer.alert(res.message, {
|
|
|
|
|
time: 2*1000,
|
|
|
|
|
success: function(layero, index){
|
|
|
|
|
var timeNum = this.time/1000, setText = function(start){
|
|
|
|
|
layer.title('<span class="layui-font-red">'+ (start ? timeNum : --timeNum) + '</span> 秒后自动关闭', index);
|
|
|
|
|
};
|
|
|
|
|
setText(!0);
|
|
|
|
|
this.timer = setInterval(setText, 1000);
|
|
|
|
|
if(timeNum <= 0) clearInterval(this.timer);
|
|
|
|
|
},
|
|
|
|
|
end: function(){
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
window.location.href='/';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
layer.msg(res.message, {icon: 0});
|
|
|
|
|
layer.msg(res.message, {icon: 0,title:'提示'});
|
|
|
|
|
}
|
|
|
|
|
},error:function (res){
|
|
|
|
|
layer.close(index);
|
|
|
|
|
layer.msg(res.message, {icon: 0});
|
|
|
|
|
layer.msg(res.message, {icon: 0,title:'提示'});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
setTimeout(function(){
|
|
|
|
@ -544,25 +618,8 @@
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
function getDeviceList(){
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: "/device/listAll",
|
|
|
|
|
/*data: obj,
|
|
|
|
|
contentType: 'application/json;charset=utf-8',*/
|
|
|
|
|
success: function(res){
|
|
|
|
|
console.log(res)
|
|
|
|
|
if(res.success){
|
|
|
|
|
var selectorx = $('#id_select2_demo1').select2();
|
|
|
|
|
$("#id_select2_demo1").select2({
|
|
|
|
|
data:res.result
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
}
|
|
|
|
|
},error:function (res){
|
|
|
|
|
/*layer.msg('删除失败,'+res.message, {icon: 1});*/
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
function back(){
|
|
|
|
|
window.location.href='/';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|