yusijie
2025-08-07 12c9063005c7371018bdade0be8f810f5548538d
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>直方图</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../layuiadmin/HideButton.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-col-md12">
            <div class="layui-card" style="padding: 1px">
                <div class="layui-card-body" style="padding: 1px;">
                    <form class="layui-form" action="" lay-filter="component-form-group">
                        <div class="layui-collapse">
                            <div class="layui-colla-item">
                                <div class="layui-colla-title layui-inline">
                                    <div class="layui-inline">
                                        <span>更多</span>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 85px;">PNL条码编号</label>
                                    <div class="layui-input-block" style="margin-left: 120px;">
                                        <input type="text" class="layui-input" name="HBarCode_PNL" id="HBarCode_PNL">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 85px;">set条码编号</label>
                                    <div class="layui-input-block" style="margin-left: 120px;">
                                        <input type="text" class="layui-input" name="HBarCode_Set" id="HBarCode_Set">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-block" style="margin-left: 0px;">
                                        <input type="checkbox" name="checkbox_isAVI" id="checkbox_isAVI" lay-skin="primary" lay-filter="checkbox_isAVI" checked title="AVI">
                                        <input type="hidden" value="true" name="isAVI" id="isAVI" lay-verify="isAVI">
                                    </div>
                                </div>
                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearch" id="btnSearch">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnReSearch" id="btnReSearch" style="padding:0 5px">重置</button>
                            </div>
                        </div>
                        <div id="HistogramReport" style = "background-color: black; height: 2000px; width: 100%; display: flex; flex-direction: column; align-items:center;">
 
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index', //主入口模块
        }).use(['index', 'form', 'table', 'element', 'laypage', 'laydate'], function () {
            //#region 公用变量
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , table = layui.table
                , form = layui.form
                , element = layui.element
                , laypage = layui.laypage
                , laydate = layui.laydate
            var HModName = "HY_HistogramReport";
 
            var HBarCode_PNL_Note = "";                             //记录查询后的PNL条码编号
            var HLayOut_PNL = [];                                   //PNL布局信息数据
            var HPCSNoList = [];                                    //记录布局上已经加入的PCS号
            //#endregion
 
            //#region 进入页面即加载
            //#region 初始化界面
            set_ClearBill();
            //#endregion
            //#endregion
 
            //#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
            //#region 重置按钮
            form.on('submit(btnReSearch)', function (data) {
                set_ClearQuery();
            });
            //#endregion
 
            //#region 查询按钮
            form.on('submit(btnSearch)', function (data) {
                get_FastQuery(2);
            });
            //#endregion
 
            //#region AVI复选框
            form.on('checkbox(checkbox_isAVI)', function (data) {
                $("#isAVI").val(data.elem.checked);
            });
            //#endregion
            //#region 本页面所有被调用的方法
 
            //#region 初始化界面
            function set_ClearBill() {
                //查询
                get_FastQuery(1);
                //Organ();
            }
            //#endregion
            //#endregion
 
            //#region 查询
            function get_Display(sql) {
                var ModRightNameCheck = "";
                $.ajax({
                    url: GetWEBURL() + '/CommonModel/searchMethod',
                    async: false,
                    type: "GET",
                    data: { "sql": sql, "user": sessionStorage["HUserName"], "ModRightNameCheck": ModRightNameCheck},
                    success: function (data1) {
                        if (data1.count == 1) {
                            for (var i = 0; i < data1.data.length; i++) {
                                HLayOut_PNL.push(data1.data[i]);
                            }
                        } else {
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function (e) {
                        layer.alert("接口请求失败!" + e, { icon: 5 });
                    }
                });
 
            }
            //#endregion
 
            //#region 快速过滤
            function get_FastQuery(number) {
                var HBarCode_PNL = $("#HBarCode_PNL").val();        //PNL条码编号
                var HBarCode_Set = $("#HBarCode_Set").val();        //set条码编号
 
                if (HBarCode_PNL != "" && HBarCode_Set != "") {
                    layer.alert("PNL条码编号与Set条码编号只可选择一个进行查询!!", { icon: 5 });
                    //加载PNL布局直方图
                    draw_Histogram([]);
                    return;
                }
 
                //打开加载遮罩
                var ajaxLoad = layer.load();
 
                //获取PNL布局的左侧备料数据
                var sql = "exec h_p_HY_HistogramReport '" + HBarCode_PNL + "','" + HBarCode_Set + "','left'";
                get_Display(sql);
                //获取PNL布局的中间数据
                var sql = "exec h_p_HY_HistogramReport '" + HBarCode_PNL + "','" + HBarCode_Set + "','center'";
                get_Display(sql);
                //获取PNL布局的右侧备料数据
                var sql = "exec h_p_HY_HistogramReport '" + HBarCode_PNL + "','" + HBarCode_Set + "','right'";
                get_Display(sql);
 
                //更新 全局PNL条码编号
                if (HLayOut_PNL.length > 0) {
                    HBarCode_PNL_Note = HLayOut_PNL[0]["HBarCode_PNL"];
                } else {
                    HBarCode_PNL_Note = "";
                }
 
                //加载PNL布局直方图
                draw_Histogram(HLayOut_PNL);
 
                //加载PNL布局中PCS的监听事件
                set_buttonClickListener(HLayOut_PNL);
 
                //清空PNL布局数据
                HLayOut_PNL = [];
 
                //关闭加载遮罩
                layer.close(ajaxLoad);
                
            }
            //#endregion
 
            //#region 重置过滤条件方法
            function set_ClearQuery() {
                $("#HBarCode_PNL").val("");
                $("#HBarCode_Set").val("");
                sWhere = "";
            }
            //#endregion
 
            //#region 刷新
            function get_Refresh() {
                $("#btnSearch").trigger('click');
            }
            //#endregion
 
            //#region 权限判定
            function set_ModCheck(ModRightNameCheck) {
                var Permission = false;
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/LMES/getReportByModRightNameCheck", //方法所在页面和方法名
                    async: false,
                    data: { "ModRightNameCheck": ModRightNameCheck, "user": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                            Permission = true;
                        } else {
                            layer.alert("当前模块没有查询权限!", { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
                return Permission;
            }
            //#endregion
 
            //#region 根据数据绘制直方图
            function draw_Histogram(data) {
                //清空 布局上已经加入的PCS号
                HPCSNoList = []
 
                var HSetNo = "";                                                //记录上一个PCS所属的set号
                var HPosition_x = 0;                                            //记录上一个PCS的行索引
                var HIconUrl = "";                                              //记录PCS图标资源的位置
 
                var HContainerElementID = "HistogramReport";                    //直方图容器id
                var HCurrentElementID_Set = "";                                 //当前set容器id
 
                if (data.length > 0) {
                    HIconUrl = data[0]["HIcon"];
                }
 
                //获取直方图容器对象
                var HContainerElement_0 = document.getElementById(HContainerElementID);
 
                // 遍历直方图容器对象中的所有子元素并从DOM中移除
                while (HContainerElement_0.firstChild) {
                    HContainerElement_0.removeChild(HContainerElement_0.firstChild);
                }
 
                //遍历生成直方图
                for (var i = 0; i < data.length; i++) {
                    if ($.inArray(data[i]["HPCSNo"], HPCSNoList) > -1) {
                        continue;
                    } else {
                        HPCSNoList.push(data[i]["HPCSNo"]);
 
                        //如果当前PCS所属的set号 与记录的 上一个PCS所属的set号 不一致,则需要创建新的set容器
                        if (data[i]["HSetNo"] != HSetNo) {
                            //获取直方图容器对象
                            var HContainerElement = document.getElementById(HContainerElementID);
 
                            //set容器
                            var HContainerElement_Set = document.createElement('div');                              //set容器
                            HContainerElement_Set.id = data[i]["HSetNo"];                                           //set容器的id为set号
                            HContainerElement_Set.className = "layui-inline";
                            HContainerElement_Set.style = "margin-left:20px;margin-top:20px;";
 
                            //在每一个set上的各个列最上方增加列索引
                            var HColIndexList = [];
                            var HSetNo_ForRowIndex = data[0]["HSetNo"];
                            for (var j = 0; j < data.length; j++) {
                                if (data[j]["HSetNo"] == HSetNo_ForRowIndex && data[j]["HPosition_x"] == "1") {
                                    if ($.inArray(data[j]["HPosition_y"], HColIndexList) == -1) {
                                        HColIndexList.push(data[j]["HPosition_y"], HColIndexList);
 
                                        //列索引容器
                                        var HContainerElement_RowIndex = document.createElement('div');                                 //列索引容器
                                        HContainerElement_RowIndex.style = "border: 2px solid black;color:white;";
                                        HContainerElement_RowIndex.className = "layui-inline";
 
                                        //列索引按钮
                                        var HButtonElement_RowIndex = document.createElement('div');                                 //列索引容器中的按钮
                                        HButtonElement_RowIndex.className = "layui-btn layuiadmin-btn-order";
                                        HButtonElement_RowIndex.style = "background-color:black;color:white;width:18px;";
                                        HButtonElement_RowIndex.innerHTML = data[j]["HPosition_y"];
 
 
                                        //将列索引按钮添加到列索引容器对象中
                                        HContainerElement_RowIndex.appendChild(HButtonElement_RowIndex);
 
                                        //将列索引容器添加到set容器对象中
                                        HContainerElement_Set.appendChild(HContainerElement_RowIndex);
                                    }
                                } else {
                                    var HBrElement_PCS = document.createElement('br');
                                    HContainerElement_Set.appendChild(HBrElement_PCS);
                                    break;
                                }
                            }
 
 
 
                            //将set容器添加到直方图容器对象中
                            HContainerElement.appendChild(HContainerElement_Set);
 
                            //记录 当前set容器id
                            HCurrentElementID_Set = data[i]["HSetNo"];
 
                            
                        }
 
                        //根据 当前set容器id 获取 当前set容器对象
                        var HCurrentElement_Set = document.getElementById(HCurrentElementID_Set);
 
                        //在每一个set上的各个行前增加行索引
                        if ((data[i]["HSetNo"] == HCurrentElementID_Set && data[i]["HPosition_x"] != HPosition_x) || (data[i]["HSetNo"] == HCurrentElementID_Set && data[i]["HPosition_x"] == "1" && data[i]["HPosition_y"] == "1")) {             //相同set容器中,当前PCS的行索引与上一个PCS的行索引不一致,则换行,并设置列坐标
                            //列索引容器
                            var HContainerElement_ColIndex = document.createElement('div');                                 //行索引容器
                            HContainerElement_ColIndex.style = "border: 2px solid black;color:white;";                      
                            HContainerElement_ColIndex.className = "layui-inline";
                            HContainerElement_ColIndex.innerHTML = data[i]["HPosition_x"];
                            if (data[i]["HSetNo"] == HSetNo && data[i]["HPosition_x"] != HPosition_x) {                     //相同set容器中,当前PCS的行索引与上一个PCS的行索引不一致,则换行
                                var HBrElement_PCS = document.createElement('br');
                                HCurrentElement_Set.appendChild(HBrElement_PCS);
                            }
 
                            //将行索引容器容器添加到set容器对象中
                            HCurrentElement_Set.appendChild(HContainerElement_ColIndex);
                        }
 
 
                        //PCS容器
                        var HContainerElement_PCS = document.createElement('div');                              //PCS容器
                        HContainerElement_PCS.id = data[i]["HPCSNo"];                                           //PCS容器的id为PCS号
                        HContainerElement_PCS.style = "border: 2px solid black;";      //设置PCS的图标
                        HContainerElement_PCS.className = "layui-inline";
                        //if (data[i]["HSetNo"] == HSetNo && data[i]["HPosition_x"] != HPosition_x) {             //相同set容器中,当前PCS的行索引与上一个PCS的行索引不一致,则换行
                        //    var HBrElement_PCS = document.createElement('br');
                        //    HCurrentElement_Set.appendChild(HBrElement_PCS);
                        //}
 
                        //PCS数据维护按钮
                        var HButtonElement_PCS = document.createElement('button');                              //PCS容器中的按钮
                        HButtonElement_PCS.id = data[i]["HPCSNo"] + "_Button";
                        HButtonElement_PCS.setAttribute('lay-filter', data[i]["HPCSNo"] + "_Button");
                        HButtonElement_PCS.type = "button";
                        HButtonElement_PCS.className = "layui-btn layuiadmin-btn-order";
                        if (data[i]["HIsBadFlag"] == "1" && data[i]["HCheckProc"] == "炬森VRS内层") {
                            HButtonElement_PCS.style = "background-image: url('" + HIconUrl + "'); background-size: cover; background-position: center; background-repeat: no-repeat;background-color:" + data[i]["HColorStr"] + ";";
                        }
                        else if (data[i]["HIsBadFlag"] == "1" && data[i]["HCheckProc"] == "炬森VRS外层") {
                            HButtonElement_PCS.style = "background-image: url('" + HIconUrl + "'); background-size: cover; background-position: center; background-repeat: no-repeat;background-color:orange;";
                        }
                        else if (data[i]["HIsBadFlag"] == "1" && data[i]["HCheckProc"] == "AVI") {
                            HButtonElement_PCS.style = "background-image: url('" + HIconUrl + "'); background-size: cover; background-position: center; background-repeat: no-repeat;background-color:yellow;";
                        }
                        else if (data[i]["HIsBadFlag"] == "1" && data[i]["HCheckProc"] == "电测") {
                            HButtonElement_PCS.style = "background-image: url('" + HIconUrl + "'); background-size: cover; background-position: center; background-repeat: no-repeat;background-color:green;";
                        }
                        else {
                            HButtonElement_PCS.style = "background-image: url('" + HIconUrl + "'); background-size: cover; background-position: center; background-repeat: no-repeat;background-color:black;";
                        }
 
                        ////将PCS数据维护按钮添加到PCS容器对象中
                        HContainerElement_PCS.appendChild(HButtonElement_PCS);
 
                        //将PCS容器添加到set容器对象中
                        HCurrentElement_Set.appendChild(HContainerElement_PCS);
 
                        HSetNo = data[i]["HSetNo"];
                        HPosition_x = data[i]["HPosition_x"];
                    }
                };
            }
            //#endregion
 
            //#region 设置PCS的监听事件
            function set_buttonClickListener(data) {
                //清空 布局上已经加入的PCS号
                HPCSNoList = []
 
                for (var i = 0; i < data.length; i++) {
                    if ($.inArray(data[i]["HPCSNo"], HPCSNoList) > -1) {
                        continue;
                    } else {
                        HPCSNoList.push(data[i]["HPCSNo"]);
 
                        var elementID = data[i]["HPCSNo"] + "_Button";
                        var element = document.getElementById(elementID);
 
                        if (element == null) {
                            continue;
                        } else {
                            element.addEventListener('click', function (event) {
                                var PCSNo_Button = event.currentTarget.id;                                                  //获取触发事件的元素的ID
                                var PCSElement_Button = document.getElementById(PCSNo_Button);                              //获取PCS按钮元素
                                var PCSElement_Div = PCSElement_Button.parentElement;                                       //获取PCS按钮元素所在的PCS容器元素
                                var SetElement_Div = PCSElement_Div.parentElement;                                          //获取PCS容器元素所在的set容器元素
                                var PCSNo = PCSElement_Div.id;                                                              //PCS号
                                var SetNo = SetElement_Div.id;                                                              //set号
 
                                var title = "PNL条码编号:" + HBarCode_PNL_Note + ";set号:" + SetNo + ";PCS号:" + PCSNo;
 
                                var isAVI = $("#isAVI").val();
 
                                if (isAVI=="true") {
                                    layer.open({
                                        type: 2,
                                        skin: 'layui-layer-rim', //加上边框
                                        title: 'AVI新增(' + title + ')',
                                        closeBtn: 1,
                                        shift: 2,
                                        area: ['100%', '100%'],
                                        maxmin: true,
                                        content: '../../质量管理/PNL检验信息/QC_CheckNote_PNL_TempEdit.html?OperationType=6&linterid=&HSouceBillType=10004&HBarCode_PNL=' + HBarCode_PNL_Note + "&HSetNo=" + SetNo + "&HPCSNo=" + PCSNo,
                                        end: function () {
                                            //刷新页面,
                                            get_FastQuery();
                                        }
                                    });
                                } else {
                                    layer.open({
                                        type: 2
                                        , skin: "layui-layer-rim" //加上边框
                                        , title: "PCS检验信息维护(" + title + ")"  //标题
                                        , closeBtn: 1  //窗体右上角关闭 的 样式
                                        , shift: 2 //弹出动画
                                        , area: ["50%", "80%"] //窗体大小
                                        , maxmin: true //设置最大最小按钮是否显示
                                        , content: ['./HY_HistogramReport_ForPCSCheckNote.html?HBarCode_PNL=' + HBarCode_PNL_Note + "&HSetNo=" + SetNo + "&PCSNo=" + PCSNo, "yes"]
                                        , end: function () {
                                            $("#btnSearch").trigger('click');
                                        }
                                    })
                                }
                            });
                        }
                    }
 
                    
                }
            }
//#endregion
        });
 
            //#endregion
    </script>
 
</body>
</html>