沈泽
2021-09-02 af5ddf873da1981fed8fb0f8dfcdaafb97f47d17
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
<!DOCTYPE html>
<html>
<head>
    <meta 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.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <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>
</head>
<body>
 
    <div class="layui-card layadmin-header">
        <div class="layui-breadcrumb" lay-filter="breadcrumb">
            <a lay-href="">主页</a>
            <!--<a><cite>采购订单</cite></a>
            <a><cite>采购订单表格</cite></a>
            <a><cite>采购订单表格的重载</cite></a>-->
        </div>
    </div>
 
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
 
                    <div class="layui-card-body">
                        <!--<div class="test-table-reload-btn" style="margin-bottom: 10px;">-->
                        <form class="layui-form" action="">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">单据号</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="HBillNo" id="HBillNo">
                                    </div>
                                </div>
 
                                <div class="layui-inline">
                                    <label class="layui-form-label">开始日期</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="HDate1" id="HDate1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">结束日期</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="HDate2" id="HDate2">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="f_Query">
                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                    </button>
                                </div>
                            </div>
 
                        </form>
                        <!--</div>-->
                    </div>
 
 
                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                    <script type="text/html" id="toolbarDemo">
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Edit"><i class="layui-icon layui-icon-form"></i>编辑</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Delete"><i class="layui-icon layui-icon-form"></i>删除</button>
                        </div>
                    </script>
                </div>
            </div>
        </div>
    </div>
 
    <!--<script src="../../layuiadmin/layui/lay/modules/mobile/jquery-3.3.1.min.js"></script>-->
    <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>
        var _cur_page = 1;
        var sql = " ";
        //var options = document.getElementById('HStatus').children;
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }
 
        function f_alert(sMsg) {
            layer.alert(sMsg, { icon: 5 });
            //layer.open({
            //    type: 1
            //  , offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
            //  , id: 'layerDemo' //防止重复弹出
            //  , content: '<div style="padding: 20px 100px;">' + sMsg + '</div>'
            //  , shade: 0 //不显示遮罩
            //  , yes: function () {
            //      layer.closeAll();
            //  }
            //});
        }
        var params = getUrlVars();
        var type = params[params[0]];
        //switch (type) {
        //    case "UnConfirm":
        //        options[1].selected = true;
        //        sql += " and 状态 like ^^%未确认%^^";
        //        //$("#HStatus").attr("disabled", true)
        //        break;
        //    case "ReConfirm":
        //        options[2].selected = true;
        //        sql += " and 状态 like ^^%已确认%^^";
        //        sql += " and 未关联数量 > 0";
        //        break;
        //    case "ReBack":
        //        options[3].selected = true;
        //        sql += " and 状态 like ^^%已驳回%^^";
        //        break;
        //}
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'code', 'table', 'element', 'layer'], function () {
            var $ = layui.$
            , admin = layui.admin
            , layer = layui.layer
            , laydate = layui.laydate
            , table = layui.table
            , form = layui.form
            , element = layui.element;
            //常规用法
            laydate.render({
                elem: '#HDate1'
            });
            laydate.render({
                elem: '#HDate2'
            });
            //layui.code();
            RoadHBillNo(sql);
            layer.load(3)
            //方法级渲染
            table.render({
                elem: '#mainTable'
                , dateType: 'json'
                , colFilterRecord: true//是否开启字段筛选的记忆功能
                , data: []
                //  , url:  GetWEBURL()+'GetPOOrderBill'
                , toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板
                , defaultToolbar: ['filter', 'exports', 'print']
                // , where: { msg: "", NowPage: 1, OnePage: 10 }
              , cellMinWidth: 100
              , cols: [[
                  { type: 'checkbox', fixed: 'left' }
                  , { field: 'hmainid', title: 'hmainid', sort: true, fixed: true, hide: true }
                  , { field: 'hsubid', title: 'hsubid' ,hide: true }
                  , { field: '日期', title: '日期', sort: true, width: 120 }
                  , { field: '单据号', title: '单据号', sort: true, width: 170 }
                  , { field: '表头备注 ', title: '表头备注', width: 105 }
                  , { field: '生产资源名称', title: '生产资源名称' }
                  , { field: '生产资源代码', title: '生产资源代码' }
                  , { field: '产品内码', title: '产品内码' }
                  , { field: '产品名称', title: '产品名称' }
                  , { field: '产品型号', title: '产品型号', width: 115 }
                  , { field: '检验员代码', title: '检验员代码', width: 115 }
                  , { field: '检验员名称', title: '检验员名称' }
                  , { field: '制单人', title: '制单人', width: 160 }
                  , { field: '制单日期', title: '制单日期', width: 160 }
                  , { field: '审核人', title: '审核人', width: 160 }
                  , { field: '审核日期', title: '审核日期', width: 160 }
                  , { field: '修改人', title: '修改人', width: 160 }
                  , { field: '修改日期', title: '修改日期', width: 160 }
                  , { field: '关闭人', title: '关闭人', width: 160 }
                  , { field: '关闭日期', title: '关闭日期', width: 160 }
                  , { field: '作废人', title: '作废人', hide: true, width: 160 }
                  , { field: '作废日期 ', title: '作废日期', width: 215 }
                  , { field: '单据类型 ', title: '单据类型 ', width: 115 }
              ]]
                //, skin: 'row' //表格风格
                // , even: true
            , page: true //是否显示分页
            , limits: [10, 20, 50, 100]
            , limit: 50 //每页默认显示的数量
                //, height: 500
            , done: function (res, curr, count) {
                _cur_page = curr;
                layer.closeAll("loading");
            }
            });
 
            //头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'btn-getCheckData':
                        var data = checkStatus.data;
                        layer.alert(JSON.stringify(data));
                        break;
                    case 'btn-Edit':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
                            var hID = data[0].hmainid.toString();
                            //if (AllowLoadData(sSubStr) != false) {//非空验证
                            layer.open({
                                type: 2
                                , area: ['100%', '100%']
                                , title: '编辑巡检单'
                                , shade: 0.6 //遮罩透明度
                                , maxmin: true //允许全屏最小化
                                , anim: 0 //0-6的动画形式,-1不开启
                                , content: '../巡检记录单/QC_Add_Edit_PatrolProcCheckBill.html?hID=' + hID
                                , resize: false
                                , cancel: function () {
                                    //$(".layui-btn").removeClass("layui-btn-disabled");
                                }
                            })
 
                        } else {
                            layer.msg('请选择一行数据编辑!');
                        }
 
                        break;
                    case 'btn-Delete':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
                            var InterID = data[0].hmainid.toString();
                            //逻辑删除方法
                            $.ajax({
                                url: GetWEBURL() + 'DeltetQC_PatrolProcCheck',
                                type: "GET",
                                data: { "HInterID": InterID },
                                success: function (result) {
                                    console.log('gouba' + result);
                                    if (result.count == 1) {
                                        layer.msg(result.Message, { icon: 1 }, function () {
                                            // 得到frame索引
                                            var index = layer.getFrameIndex(window.name);
                                            //关闭当前frame
                                            layer.close(index);
                                            //修改为功后刷新界面
                                            window.location.reload();
                                        });
 
                                    } else {
                                        layer.alert(result.code + result.Message, { icon: 5 });
                                    }
                                }, error: function () {
                                    layer.alert("接口请求失败!", { icon: 5 });
                                }
                            });
                        }
                        else {
                            layer.msg('请选择一行数据删除!');
                        }
                        break;
                };
            });
 
 
 
            ///加载显示数据
            function RoadHBillNo(sqlWhere) {
                where = sqlWhere;
                $.ajax({
                    type: "get",
                    url: GetWEBURL() +"/QC_Management/MES_QC_PatrolProcCheckBillList_Json",
                    async: true,
                    data: { "sqlWhere": sqlWhere },//"HSupNo": sessionStorage["HUserName"],
                    success: function (result) {
                        if (result.count == 1) {
                        ajaxReturnData = JSON.parse(JSON.stringify(result)).data;
                        table.reload('mainTable', {
                            data: ajaxReturnData
                            , height: 'full-10'
                            , page: {
                                curr: _cur_page //必须从第 1 页开始
                            }
                            , loading: false
                            , done: function (index, res) {
 
                            }
                        });
                        layer.close(index0);
                    } else {
                            layer.close(index0);
                            layer.alert(result.code + result.Message, { icon: 5 });
                    }
 
                    },
                    error: function (result) {
                        layer.close(index0);
                    layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            };
            form.on('submit(f_Query)', function (data) {//查询
                var sqlWhere = " and 1=1 ";
                //if ($("#HStatus").val() != "")
                //    sqlWhere += " and 状态 like ^^%" + $("#HStatus").val() + "%^^";
                var HBillNo = $("#HBillNo").val();//单据号
                var HNumber = $("#HNumber").val();//物料代码
                var HName = $("#HName").val();//物料名称
                var HModel = $("#HModel").val();//规格型号
                var HDate1 = $("#HDate1").val();//开始日期
                var HDate2 = $("#HDate2").val();//结束日期
 
                if (HBillNo)
                    sqlWhere += " and 单据号 like '%" + HBillNo+ "%'";
                if (HNumber)
                    sqlWhere += " and 物料代码 like '%" + HNumber + "%'";
                if (HName)
                    sqlWhere += " and 物料名称 like '%" + HName + "%'";
                if (HModel)
                    sqlWhere += " and 规格型号 like '%" + HModel + "%'";
                //if ($("#HClStatus").val() != "")
                //    sqlWhere += " and 关闭状态 like ^^%" + $("#HClStatus").val() + "%^^";
                //if ($("#HPURCHASEORGID").val() != "")
                //    sqlWhere += " and 采购组织 like ^^%" + $("#HPURCHASEORGID").val() + "%^^";
                if (HDate1) {
                    sqlWhere += " and 日期 >= '" + HDate1 + "'";
                }
                if (HDate2) {
                    sqlWhere += " and 日期 <= '" + HDate2 + "'";
                }
                //if ($("#HISGenerate").val() != "") {
                //    if ($("#HISGenerate").val() == "是")
                //    {
                //        sqlWhere += " and 未关联数量 <= 0";
                //    }
                //    else if ($("#HISGenerate").val() == "否") {
                //        sqlWhere += " and 未关联数量 > 0";
                //    }
                //}
 
 
                var Time = $("#Time").val();
                var dd = new Date();
                var dt;
                switch (Time) {
                    case 1: dd = new Date(dd.setDate(dd.getDate() + 7));
                    case 2: dd = new Date(dd.setDate(dd.getDate() + 14));
                    case 3: dd = new Date(dd.setMonth(dd.getMonth() + 1));
                    case 4: dd = new Date(dd.setMonth(dd.getMonth() + 2));
                    case 5: dd = new Date(dd.setMonth(dd.getMonth() + 3));
                    case 6: dd = new Date(dd.setMonth(dd.getMonth() + 6));
                    case 7: dd = new Date(dd.setMonth(dd.getMonth() + 12));
                    default: dd = new Date(dd.setDate(dd.getDate()));
                }
                dt = dd.getFullYear().toString();
                if (dd.getMonth() + 1 < 10) {
                    dt = dt + "-0" + (dd.getMonth() + 1).toString();
                }
                else {
                    dt = dt + "-0" + (dd.getMonth() + 1).toString();
                }
                if (dd.getDate() < 10) {
                    dt = dt + "-0" + dd.getDate().toString();
                }
                else {
                    dt = dt + "-" + dd.getDate().toString();
                }
                //if (Time != 8) {
                //    sqlWhere += " and 交货日期 <= ^^" + dt + "^^";
                //}
                sql = sqlWhere;
                //从第一页开始
                _cur_page = 1;
                RoadHBillNo(sqlWhere);
            });
            var $ = layui.$, active = {
                f_Query: function () { //查询
 
                },
                f_Qrjq: function () { //接受
 
                },
                f_Bhjq: function () { //拒绝
 
                },
                //JSreload: function () {
                //    var demoReload = $('#test-table-demoReload');
                //    //执行重载
                //    table.JSreload('test-table-reload', {
                //        page: {
                //            curr: 1 //重新从第 1 页开始
                //        }
                //      , where: {
                //          key: {
                //              id: demoReload.val()
                //          }
                //      }
                //    });
                //}
            };
            $('.test-table-reload-btn .layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</body>
 
</html>