jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
var layer;
var form;
var table;
var deviceList;//当前仓库的所有设备列表
var depotId;
var tableHeight= 550;
var deviceType = DeviceType.TYPE_01;//被选中的设备类型,默认是通风窗
var viewTargetStatus;
 
$(function() {
    layui.use([ 'layer', 'table', 'form' ], function() {
        table = layui.table;
        form = layui.form;
        layer = layui.layer;
 
        form.render();
 
        //监听仓库选择
        form.on('select(select_depotId)', function() {
            query();
            //调整已经勾选的设备为取消
            clearSelectDevice();
        });
 
        //监听层选择
        form.on('radio(check_deviceType)', function(obj) {
            var value = obj.value;
            if(1== value) value ="01";
            if(2== value) value ="02";
            if(3==value)  value ="03";
            deviceType = value;
            
            //调整已经勾选的设备为取消
            clearSelectDevice();
        });
    });
    
    //如果是管理员登陆支持更改设备位置
    if(loginUser.administrator){
        $("#btn-update-drag").removeClass("layui-btn-disabled");
        $("#btn-save-pos").removeClass("layui-btn-disabled");
    }
 
    // 根据页面自动计算余下款低-选择框的高度
    var bodyHeight = window.innerHeight;
    var headerHeight = $("#header-condition").outerHeight();
    var mainHeight = bodyHeight - headerHeight - 90;
 
    // 初始化ws
    initWS(deptId, bizType,null, userId);
});
 
 
//socket信息返回處理
function socketOnMessage(pocket) {
    if (pocket.orderResp == "MSG_SUCCESS") {
        query();
        //调整已经勾选的设备为取消
        clearSelectDevice();
        //调整动作为结束
        updateAnimate(deviceType,viewTargetStatus,true);
    }
    window.parent.sysNotify(pocket.data);
};
 
function showVideo(){
    layer.msg("该功能暂未配置……");
};
 
function closeAll(){
    layer.msg("该功能暂未配置……");
};
 
//状态查询
function queryStatus(){
    depotId = $("#depotId").val();
    if(!depotId){
        layer.msg("请先选择仓库!");
        return;
    }
    //把当前页面的设备传递到后台
    var data = {
        depotId : depotId,
        deviceList : []
    };
    var tips = $(".device");
    $.each(tips, function(index, item) {
        data.deviceList.push({
            id : item.id,
            depotId : item.getAttribute("depotid"),
            passCode : item.getAttribute("passcode"),
            name : item.getAttribute("name"),
            serId : item.getAttribute("serid"),
            link : item.getAttribute("link"),
            type : item.getAttribute("type"),
            companyId : companyId
        });
    });
 
    $.ajax({
        type : "POST",
        url : "../../basic/verb/query-status",
        dataType : "json",
        contentType : "application/json;charset=UTF-8",
        data : JSON.stringify(data),
        success : function(result) {
            layer.msg(result.msg);
        },
        error : function(result) {
            layer.msg("获取数据失败,请重新尝试!");
        }
    });
};
 
// 执行查询
function query() {
    depotId = $("#depotId").val();
    if(!depotId){
        layer.msg("请先选择仓库!");
        return;
    }
    $.ajax({
        type : "POST",
        url : "../../basic/verb/list-device-manual",
        dataType : "json",
        contentType : "application/json;charset=UTF-8",
        data : JSON.stringify({depotId:depotId}),
        success : function(result) {
            if (result.code != "0000") {
                layer.msg(result.msg);
                return;
            }
            deviceList = result.data;
 
            //根据设备渲染
            renderDevice(deviceList,depotId);
        },
        error : function(result) {
            layer.msg("获取数据失败,请重新尝试!");
        }
    });
};
 
//按钮事件切换正反面
function toCut(target){
    renderDevice2(deviceList,depotId,target);
};
 
renderDevice2 = function(deviceList,depotId,target){
    //首先清空div中的内容
    $("#device_view").empty();
    
    //获取当前仓库效果图
    viewAB = target;
    cutImg(depotId,viewAB);
    
      //根据设备列表添加原型信息
    addDevice(deviceList,viewAB);
};
 
//添加操作日志
function addLog(htmlStr) {
    var info = $("#areationInfo").html();
    $("#areationInfo").html(htmlStr + "</br>" + info);
};
 
//根据操作目标状态和选择的设备进行执行
function toExecute(targetStatus){
    //根据设备类型进行调整,针对风机类
    if(targetStatus == DeviceStatus.OPEN){
        if(deviceType == DeviceType.TYPE_02) targetStatus = DeviceStatus.W_OPEN;
        if(deviceType == DeviceType.TYPE_0C) targetStatus = DeviceStatus.W_OPEN;
    }
    
    if(targetStatus == DeviceStatus.CLOSE){
        if(deviceType == DeviceType.TYPE_02) targetStatus = DeviceStatus.W_CLOSE;
        if(deviceType == DeviceType.TYPE_0C) targetStatus = DeviceStatus.W_CLOSE;
    }
    
    viewTargetStatus = targetStatus;
    
    var data ={
        depotId: depotId,
        deviceList: []
    }
    //获取设备信息
    var tips = $(".device");
    var select;
    $.each(tips, function(index, item) {
        select = item.getAttribute("select");
        if("true" == select){
            data.deviceList.push({
                id: item.id,
                depotId: item.getAttribute("depotid"),
                passCode: item.getAttribute("passcode"),
                name: item.getAttribute("name"),
                serId: item.getAttribute("serid"),
                link: item.getAttribute("link"),
                type: item.getAttribute("type"),
                targetStatus: targetStatus
            });
        }
    });
    
    //开始调用后台执行
    layer.msg("开始执行……");
    $.ajax({
        type : 'POST',
        url : "../../basic/verb/control-device",
        dataType : 'JSON',
        contentType : "application/json;charset=UTF-8",
        data : JSON.stringify(data),
        success : function(result) {
            if(result.code != "ORDER_SUCCESS"){
                layer.msg(result.msg);
            }else{
                layer.msg("操作指令发送成功,待终端响应……");
                //开始调用动画 TODO 
                updateAnimate(deviceType,targetStatus,false);
            }
        },
        error : function(result) {
            layer.msg("操作发生异常,暂时无法解决!!");
        }
    });
    
};