zzr99
2022-06-27 a37381dbdf421b8e7333e03bee9dfb6a9e6483a8
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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>日计划工单列表</title>
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.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 src="../../../layuiadmin/PubCustom.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;">单据号</label>
                                    <div class="layui-input-block" style="margin-left: 120px;">
                                        <input type="text" class="layui-input" name="HBillNo" id="HBillNo">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 85px;">生产组织</label>
                                    <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
                                        <select name="Organization" id="Organization" lay-verify="Organization">
                                            <!--动态渲染组织-->
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 85px;padding: 9px 18px;">生产车间</label>
                                    <div class="layui-input-block" style="margin-left: 77px;">
                                        <input type="hidden" class="layui-input" lay-verify="HWorkShopID" name="HWorkShopID" id="HWorkShopID" value="0" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                        <input type="text" class="layui-input" lay-verify="HWorkShopIDName" name="HWorkShopIDName" id="HWorkShopIDName" value="" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                        <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHWorkShopID" id="btnHWorkShopID" style="padding: 0 10px;float: right;margin-right: 3px;">
                                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                        </button>
                                    </div>
                                </div>
                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearch" id="btnSearch">查询</button>
                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnReSearch" id="btnReSearch">重置</button>
                                <div class="layui-colla-content" style="padding: 0px; margin-left: 6%;">
                                    <div class="layui-row" style="margin-top:10px;">
                                        <!--其他条件-->
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="date" class="layui-input" lay-verify="HBTimes" name="HBTimes" id="HBTimes" style="padding-left: 78px;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">至:</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="date" class="layui-input" lay-verify="HETimes" name="HETimes" id="HETimes" style="padding-left: 78px;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">物料名称</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMaterName" id="HMaterName">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row" style="margin: 10px 0 10px;">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">物料编码</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMaterNumber" id="HMaterNumber">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">销售订单号</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HSeOrderBillNo" id="HSeOrderBillNo">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
 
                        <table class="" 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="set_AddNew"><i class="layui-icon layui-icon-file-b"></i>新增</button>-->
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_ShowBill"><i class="layui-icon layui-icon-form"></i>编辑</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_DeleteBill"><i class="layui-icon layui-icon-delete"></i>删除</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_CloseBill"><i class="layui-icon layui-icon-logout"></i>关闭</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_TuiBill"><i class="layui-icon layui-icon-form"></i>下推</button>
                            </div>
                        </script>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script>
    var treeCkData = { id: 0 };
    var TagId = "";
    var TagParentId = "";
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['tree', 'index', 'form', 'table', 'element', 'laypage', 'laydate', 'util'], 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
            , util = layui.util
            , tree = layui.tree
            , util = layui.util
        var sWhere = "";
        var option = [];
        //#endregion
 
        //#region 进入页面即加载
 
        //初始化界面
        set_ClearBill();
 
        //#endregion
 
        //#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
 
        //#region 头工具栏事件
        table.on('toolbar(mainTable)', function (obj) {
            switch (obj.event) {
                //新增
                case 'set_AddNew': set_AddNew();
                    break;
                //编辑
                case 'set_ShowBill': set_ShowBill();
                    break;
                //删除
                case 'set_DeleteBill': set_DeleteBill();
                    break;
                //关闭
                case 'set_CloseBill': set_CloseBill();
                    break;
                //下推
                case 'set_TuiBill': set_TuiBill();
                    break;
            };
        });
        //#endregion
 
        //#region 生产车间
        form.on('submit(btnHWorkShopID)', function (data) {
            btnHWorkShopID();
        });
        //#endregion
 
        //#region 重置按钮
        form.on('submit(btnReSearch)', function (data) {
            set_ClearQuery();
        });
        //#endregion
 
        //#region 查询按钮
        form.on('submit(btnSearch)', function (data) {
            get_FastQuery();
        });
        //#endregion
 
        //#endregion
 
        //#region 本页面被调用的所有方法
 
        //#region 初始化界面
        function set_ClearBill() {
            //初始化日期
            $("#HBTimes").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));//日期
            $("#HETimes").val(Format(new Date(), "yyyy-MM-dd"));//至
            //生产组织加载
            Organ();
            //初始化表格
            set_InitGrid();
            //查询
            get_Display(sWhere);
        }
        //#endregion
 
        //#region 初始化表格方法
        function set_InitGrid() {
            option = {
                elem: '#mainTable'
                , toolbar: '#toolbarDemo'
                , height: 'full-50'
                , page: true
                , cellMinWidth: 90
                , limit: 50
                , limits: [50, 500, 5000, 20000]
                , cols: [[
                    { type: 'checkbox', fixed: 'left' }
                    , { field: 'hmainid', title: 'hmainid', hide: true }
                    , { field: '单据号', title: '单据号', width: 200  }
                    , { field: '单据类型', title: '单据类型', width: 120 }
                    , { field: '单据状态', title: '单据状态' }
                    , { field: '日期', title: '日期' }
                    , { field: '生产订单号', title: '生产订单号' }
                    , { field: '物料代码', title: '物料代码' }
                    , { field: '物料名称', title: '物料名称' }
                    , { field: '规格型号', title: '规格型号' }
                    , { field: '计量单位', title: '计量单位' }
                    , { field: '订单需求数量', title: '订单需求数量' }
                    , { field: '销售订单号', title: '销售订单号' }
                    , { field: '班组', title: '班组' }
                    , { field: '操作工', title: '操作工' }
                    , { field: '订单交货期', title: '订单交货期' }
                    , { field: '生产资源', title: '生产资源' }
                    , { field: '订单等级', title: '订单等级' }
                    , { field: '生产组织', title: '生产组织' }
                    , { field: '销售订单数量', title: '销售订单数量' }
                    , { field: '日计划生产日期', title: '日计划生产日期' }
                    , { field: '子日计划数量', title: '日计划数量' }
                    , { field: '汇报完成数量', title: '汇报完成数量' }
                    , { field: '编制日期', title: '编制日期' }
                    , { field: '未排数量', title: '未排数量' }
                    , { field: '关闭数量', title: '关闭数量' }
                    , { field: '日计划数量总量', title: '日计划数量总量' }
                    , { field: '生产订单明细行号', title: '生产订单明细行号' }
                    , { field: '日计划用料清单单号', title: '日计划用料清单单号' }
                    , { field: '审核人', title: '审核人' }
                    , { field: '审核日期', title: '审核日期' }
                    , { field: '制单人', title: '制单人' }
                    , { field: '制单日期', title: '制单日期' }
                    , { field: '修改人', title: '修改人' }
                    , { field: '修改日期', title: '修改日期' }
                    , { field: '关闭人', title: '关闭人' }
                    , { field: '关闭日期', title: '关闭日期' }
                    , { field: '关闭类型', title: '关闭类型' }
                    , { field: '作废人', title: '作废人' }
                    , { field: '作废日期', title: '作废日期' }
                ]]
            };
        }
        //#endregion
 
        //获取组织
        function Organ() {
            //获取登录页组织列
            var Organization = '<option  style="color:blue;" value="">组织</option>';
            $.ajax({
                type: "get",
                url: GetWEBURL() + "/Web/GetOrganizations",
                success: function (result) {
                    if (result.count == 1) { // 说明验证成功了,
                        var data = result.data;
                        for (var i = 0; i < data.length; i++) {
                            Organization += '<option  style="color:blue;" value="' + data[i].ID + '">' + data[i].Name + '</option>';
                        }
                        $("#Organization").append(Organization);
                        form.render('select');
                    }
                    layer.closeAll("loading");
                }
            })
        }
 
        //#region 查询
        function get_Display(sWhere) {
            var ajaxLoad = layer.load();
            $.ajax({
                url: GetWEBURL() + '/Sc_WorkBillSortBill/Sc_WorkBillSortBillList',
                type: "GET",
                data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
                success: function (result) {
                    if (result.count == 1) {
                        option.data = result.data;
                        table.render(option);
                        layer.close(ajaxLoad);
                        //layer.alert("查询成功", { icon: 1 });
                    } else {
                        layer.close(ajaxLoad);
                        layer.alert(result.code + result.Message, { icon: 5 });
                    }
                }, error: function () {
                    layer.close(ajaxLoad);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            });
        }
 
        //#endregion
 
        //#region 快速过滤
        function get_FastQuery() {
            var HBillNo = $("#HBillNo").val();
            var Organization = $("#Organization").val();//采购组织
            var HWorkShopIDName = $("#HWorkShopIDName").val();//生产车间
            var HBTimes = $("#HBTimes").val();//日期
            var HETimes = $("#HETimes").val();//至
            var HMaterName = $("#HMaterName").val();//物料名称
            var HMaterNumber = $("#HMaterNumber").val();//物料编码
            var HSeOrderBillNo = $("#HSeOrderBillNo").val();//销售订单号
 
            if (HBillNo) {
                sWhere += " and 单据号 like '%" + HBillNo + "%'";
            }
            if (Organization) {
                sWhere += " and 生产组织 = '" + Organization + "'";
            }
            if (HWorkShopIDName) {
                sWhere += " and 生产车间 = '" + HWorkShopIDName + "'";
            }
            if (HBTimes != "" && HETimes!="") {
                sWhere += " and 日期 between '" + HBTimes + "' and '" + HETimes+"'  ";
            }
            if (HMaterName) {
                sWhere += " and 物料名称 like'%" + HMaterName + "%'";
            }
            if (HMaterNumber) {
                sWhere += " and 物料代码 like'%" + HMaterNumber + "%'";
            }
            if (HSeOrderBillNo) {
                sWhere += " and 销售订单号 like'%" + HSeOrderBillNo + "%'";
            }
            get_Display(sWhere);
            sWhere = "";//调用接口后清空sWhere缓存
        }
        //#endregion
 
        //#region 重置过滤条件方法
        function set_ClearQuery() {
            $("#HBillNo").val("");
            $("#Organization").val("");//采购组织
            $("#HWorkShopIDName").val("");//生产车间
            $("#HWorkShopID").val("");//生产车间
            $("#HBTimes").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));//日期
            $("#HETimes").val(Format(new Date(), "yyyy-MM-dd"));//至
            $("#HMaterName").val("");//物料名称
            $("#HMaterNumber").val("");//物料编码
            $("#HSeOrderBillNo").val("");//销售订单号
            sWhere = "";
        }
        //#endregion
 
        //生产车间列表
        function btnHWorkShopID() {
            layer.open({
                type: 2 //类型
                , skin: 'layui-layer-rim'//加上边框
                , area: ['90%', '90%']//大小
                , title: '生产车间列表'//标题
                , shift: 2//弹出动画
                , content: ['../../Baseset/基础资料/Gy_DepartmentList.html', 'yes']
                , btn: ['确定', '取消']
                , btn1: function (index, layero) {//按钮【按钮一】的回调
                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                    if (checkStatus.data.length === 0) {
                        return layer.msg('请选择数据');
                    }
                    //获取数据
                    $("#HWorkShopID").val(checkStatus.data[0].HItemID);//车间id
                    $("#HWorkShopIDName").val(checkStatus.data[0].HName);//车间名称
                    layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                }
                , btn2: function (index, layero) { }
            })
 
        }
 
        //删除
        function set_DeleteBill() {
            var CheckStatus = table.checkStatus("mainTable");
 
            if (CheckStatus.data.length != 1) {
                return layer.msg("请选择一条数据!")
            } else {
                layer.confirm('您确定要删除吗?', {
                    btn: ['确定', '取消'] //按钮
                    , btn1: function () {
                        var HInterID = CheckStatus.data[0].hmainid; //获取编号
                        var HEntryID = CheckStatus.data[0].hsubid; //获取第几条子数据
 
                        $.ajax({
                            url: GetWEBURL() + '/Sc_WorkBillSortBill/DelWorkBillSortBillList'
                            , type: "GET"
                            , data: { "HInterID": HInterID, "HEntryID": HEntryID, "User": sessionStorage["HUserName"] }
                            , success: function (result) {
                                if (result.count == 1) {
                                    layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                        // 得到frame索引
                                        var index = layer.getFrameIndex(window.name);
                                        //关闭当前frame
                                        layer.close(index);
                                        //修改为功后刷新界面
                                        window.location.reload();
                                        ////重载tree
                                        //tree.reload('treeDepartment', {});
                                    });
                                } else {
                                    layer.alert(result.code + result.Message, { icon: 5 });
                                }
                            }
                        })
                    }
                })
            }
        }
 
        //关闭
        function set_CloseBill() {
            var CheckStatus = table.checkStatus("mainTable");
 
            if (CheckStatus.data.length != 1) {
                return layer.msg("请选择一条数据!")
            } else {
                layer.confirm('您确定要关闭吗?', {
                    btn: ['确定', '取消'] //按钮
                    , btn1: function () {
                        var HInterID = CheckStatus.data[0].hmainid; //获取编号
 
                        $.ajax({
                            url: GetWEBURL() + '/Sc_WorkBillSortBill/CloseWorkBillSortBillList'
                            , type: "GET"
                            , data: { "HInterID": HInterID, "User": sessionStorage["HUserName"] }
                            , success: function (result) {
                                if (result.count == 1) {
                                    layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                        // 得到frame索引
                                        var index = layer.getFrameIndex(window.name);
                                        //关闭当前frame
                                        layer.close(index);
                                        //修改为功后刷新界面
                                        window.location.reload();
                                        ////重载tree
                                        //tree.reload('treeDepartment', {});
                                    });
                                } else {
                                    layer.alert(result.code + result.Message, { icon: 5 });
                                }
                            }
                        })
                    }
                })
            }
        }
 
        //#region 新增
        function set_AddNew() {
            layer.open({
                type: 2
                , skin: 'layui-layer-rim' //加上边框
                , area: ['100%', '100%']
                , title: '日计划工单列表-新增'
                , shift: 0//弹出动画
                , content: '../生产日计划工单/JIT_DayPlanBillEdit.html?OperationType=1&linterid=-1&HSouceBillType='
                , end: function () {
                    //刷新页面,
                    location.reload();
                }
            })
        }
            //#endregion
 
        //#region 编辑
        function set_ShowBill() {
            var checkStatus = table.checkStatus('mainTable')
                , data = checkStatus.data;
            if (checkStatus.data.length === 1) {
                var linterid = data[0].hmainid;
 
                layer.open({
                    type: 2
                    , skin: 'layui-layer-rim' //加上边框
                    , area: ['100%', '100%']
                    , title: '日计划工单列表-编辑'
                    , shift: 0//弹出动画
                    , content: '../生产日计划工单/JIT_DayPlanBillEdit.html?OperationType=3&linterid=' + linterid + '&HSouceBillType='
                    , end: function () {
                        //刷新页面,
                        location.reload();
                    }
                })
            } else {
                layer.msg('请选择一行数据编辑!');
            }
        }
            //#endregion
 
        //编辑单据 下推
        function set_TuiBill() {
            var checkStatus = table.checkStatus('mainTable')
                , data = checkStatus.data;
            if (data.length === 1) {
                var linterid = data[0].源单主内码.toString();
                var HEntryID = data[0].源单子内码.toString();
                layer.open({
                    type: 2
                    , area: ['100%', '100%']
                    , title: '工序流转卡-编辑'
                    , shift: 0//弹出动画
                    , content: '../../车间管理/工序流转卡/Sc_ProcessExchangeBill.html?OperationType=2&linterid=' + linterid + '&HEntryID=' + HEntryID + '&HSouceBillType=3772'
                })
            } else {
                layer.msg('请选择一行数据下推!');
            }
        }
 
        //#endregion
        //以上是layui模块
    });
</script>