yangle
2022-03-31 be865f78f107484ba689b09aab3adb1f78bd024b
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
<!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/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>
</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">开始日期</label>
                                    <div class="layui-input-block">
                                        <input type="date" class="layui-input" id="HBeginDate" style="width:190px;">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">结束日期</label>
                                    <div class="layui-input-block">
                                        <input type="date" class="layui-input" id="HEndDate" style="width:190px;">
                                    </div>
                                </div>
                                <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" style="width:190px;">
                                    </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 class="layui-colla-content" style="margin-left: 4%;">
                                    <div class="layui-row" style="margin-top:10px;">
                                        <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="text" class="layui-input" lay-verify="MaterialNumber" name="MaterialNumber" id="MaterialNumber" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnMaterial" id="btnMaterial" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </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="MaterialName" lay-verify="MaterialName" id="MaterialName" style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="MaterialID" id="MaterialID" lay-verify="MaterialID" value="0">
                                            </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="MaterialModel" id="MaterialModel" onmouseover="this.title=this.value" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row" style="margin-top:10px;">
                                        <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="text" class="layui-input" name="HDeptName" lay-verify="HDeptName" id="HDeptName" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHDept" id="btnHDept" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </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="btn-audit"><i class="layui-icon layui-icon-repeat"></i>审核</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Faudit"><i class="layui-icon layui-icon-refresh"></i>反审核</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Refresh"><i class="layui-icon layui-icon-refresh-3"></i>刷新</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Exit"><i class="layui-icon layui-icon-logout"></i>退出</button>-->
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_DeleteBill"><i class="layui-icon layui-icon-delete"></i>删除</button>
 
                            </div>
                        </script>
                    </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 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 'get_Refresh': get_Refresh();
                    //    break;
                    ////退出按钮
                    //case 'get_Exit': Pub_Close(2);
                    //    break;
                };
            });
 
            //#endregion
 
            //#region 查询按钮
            form.on('submit(btnSearch)', function (data) {//选择仓位
                get_FastQuery();
            });
            //#endregion
 
            //重置按钮
            form.on('submit(btnReSearch)', function (data) {
                set_ClearQuery();
            });
 
            //选择物料
            form.on('submit(btnMaterial)', function (data) {
                btnMaterial();
            })
 
            //选择生产车间
            form.on('submit(btnHDept)', function (data) {
                btnHDept();
            })
            //#endregion
 
            //#region 此页面所有的方法
 
            //#region 初始化界面
            function set_ClearBill() {
                //初始化表格
                set_InitGrid();
                //查询
                get_Display(sWhere);
                //日期初始化
                $("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));
                $("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));
            }
            //#endregion
 
            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', width: 110 }*/
                        , { field: '单据号', title: '单据号', sort: true, width: 165 }
                        , { field: '日期', title: '日期', width: 200, templet: "<div>{{d.日期 ==null ?'':layui.util.toDateString(d.日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '源单单号', title: '源单单号', width: 170 }
                        , { field: '部门代码', title: '部门代码', width: 170 }
                        , { field: '部门名称', title: '部门名称', width: 170 }
                        , { field: '物料代码', title: '物料代码', width: 170 }
                        , { field: '物料名称', title: '物料名称', width: 170 }
                        , { field: '规格型号', title: '规格型号', width: 215 }
                        , { field: '数量', title: '数量', width: 170 }
                        , { field: '工序代码', title: '工序代码', width: 170 }
                        , { field: '工序名称', title: '工序名称', width: 170 }
                        , { field: '仓库代码', title: '仓库代码', width: 170 }
                        , { field: '单据类型', title: '单据类型' }
                        , { field: '表头备注', title: '表头备注', width: 170 }
                        , { field: '退回人', title: '退回人', width: 170 }
                        , { field: '退回日期', title: '退回日期', width: 200, templet: "<div>{{d.退回日期 ==null ?'':layui.util.toDateString(d.退回日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '退回原因', title: '退回原因', width: 170 }
                        , { field: '审核人', title: '审核人' }
                        , { field: '审核日期', title: '审核日期', width: 200, templet: "<div>{{d.审核日期 ==null ?'':layui.util.toDateString(d.审核日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '制单人', title: '制单人' }
                        , { field: '制单日期', title: '制单日期', width: 200, templet: "<div>{{d.制单日期 ==null ?'':layui.util.toDateString(d.制单日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '修改人', title: '修改人' }
                        , { field: '修改日期', title: '修改日期', width: 200, templet: "<div>{{d.修改日期 ==null ?'':layui.util.toDateString(d.修改日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '关闭人', title: '关闭人', width: 170 }
                        , { field: '关闭日期', title: '关闭日期', width: 200, templet: "<div>{{d.关闭日期 ==null ?'':layui.util.toDateString(d.关闭日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '关闭类型', title: '关闭类型', width: 170 }
                        , { field: '作废人', title: '作废人' }
                        , { field: '作废日期', title: '作废日期', width: 200, templet: "<div>{{d.作废日期 ==null ?'':layui.util.toDateString(d.作废日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '源单类型', title: '源单类型', width: 170 }
                        , { field: '源单子内码', title: '源单子内码', width: 170 }
                        , { field: '源单号', title: '源单号', width: 170 }
                        , { field: '打印次数', title: '打印次数', width: 170 }
                        , { field: '叫料人代码', title: '叫料人代码', width: 170 }
                        , { field: '叫料人', title: '叫料人', width: 170 }
                        , { field: '配送人代码', title: '配送人代码', width: 170 }
                        , { field: '配送人', title: '配送人', width: 170 }
                        , { field: '保管人代码', title: '保管人代码', width: 170 }
                        , { field: '保管人', title: '保管人', width: 170 }
                        , { field: '叫料模式', title: '叫料模式', width: 170 }
                        , { field: '表体备注', title: '表体备注', width: 170 }
                        , { field: '仓库名称', title: '仓库名称', width: 170 }
                        , { field: '仓位名称', title: '仓位名称', width: 170 }
                    ]]
                };
            }
 
            //#region 重置过滤条件方法
            function set_ClearQuery() {
                $("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));//开始日期
                $("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));//结束日期
                $("#HBillNo").val("");//销售订单号
                $("#MaterialNumber").val("");//物料代码
                $("#MaterialName").val("");//物料名称
                $("#MaterialID").val("");//物料id
                $("#MaterialModel").val("");//规格型号
                $("#HDeptName").val("");//生产车间
 
                $("#btnSearch").click();//刷新
                sWhere = "";
            }
            //#endregion
 
            //#region 查询
            function get_Display(sWhere) {
                var ajaxLoad = layer.load();
                $.ajax({
                    url: GetWEBURL() + '/Cj_CallGoodsBillMain/CallGoodsBillMainList',
                    type: "GET",
                    data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
                    success: function (data1) {
                        if (data1.count == 1) {
                            option.data = data1.data;
                            table.render(option);
                            layer.close(ajaxLoad);
                            //layer.alert("查询成功", { icon: 1 });
                        } else {
                            layer.close(ajaxLoad);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(ajaxLoad);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
 
            //#region 快速过滤
            function get_FastQuery() {
                var HBeginDate =   $("#HBeginDate").val();//开始时间
                var HEndDate = $("#HEndDate").val();//结束时间
                var HBillNo = $("#HBillNo").val();//单据号
                var HDeptName = $("#HDeptName").val();//生产车间
                var MaterialCode = $("#MaterialCode").val();//物料代码
                var MaterialName =$("#MaterialName").val();//物料名称
                var MaterialModel = $("#MaterialModel").val();//规格型号
                var HOrgID = sessionStorage["OrganizationID"];//当前组织id
 
                if (HBeginDate) {
                    sWhere += " and CONVERT(varchar(100),日期, 23) >= '" + HBeginDate + "'";
                }
                if (HEndDate) {
                    sWhere += " and CONVERT(varchar(100),日期, 23) <= '" + HEndDate + "'";
                }
                if (HBillNo) {
                    sWhere += " and 单据号 like '%" + HBillNo + "%'";
                }
                if (HDeptName) {
                    sWhere += " and 部门名称 like '%" + HDeptName + "%'";
                }
                if (MaterialCode) {
                    sWhere += " and 物料代码 like '%" + MaterialCode + "%'";
                }
                if (MaterialName) {
                    sWhere += " and 物料名称 like '%" + MaterialName + "%'";
                }
                if (MaterialModel) {
                    sWhere += " and 规格型号 like '%" + MaterialModel + "%'";
                }
                if (HOrgID) {
                    sWhere += " and 组织 =" + HOrgID + " ";
                }
               
                get_Display(sWhere);
                sWhere = "";//调用接口后清空sWhere缓存
            }
            //#endregion
 
            //删除
            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() + '/Cj_CallGoodsBillMain/DelCallGoodsBill'
                                , 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 btnMaterial() {
                layer.open({
                    type: 2 //类型
                    , skin: 'layui-layer-rim'//加上边框
                    , area: ['90%', '90%']//大小
                    , title: '物料列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_MaterialList.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('请选择数据');
                        }
                        //获取数据
                        $("#MaterialName").val(checkStatus.data[0].HName);//物料名称
                        $("#MaterialModel").val(checkStatus.data[0].HModel);//物料规格型号
                        $("#MaterialNumber").val(checkStatus.data[0].HNumber);//物料代码
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
 
            //选择生产车间
            function btnHDept() {
                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('请选择数据');
                        }
                        //获取数据
                        $("#HDeptName").val(checkStatus.data[0].HName);//部门名称
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
 
            //#endregion
 
            //以上是layui模块
        });
    </script>
</body>
</html>