王 垚
2021-11-15 a24c56ed180615d62277799f22fefd977521feef
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
 
 
<!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">
</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-header">送货单列表</div>
                    <div class="layui-card-body">
                        <div class="test-table-reload-btn" style="margin-bottom: 10px;">
                            单据号:
                            <div class="layui-inline">
                                <input class="layui-input" name="HBillNo" id="HBillNo" autocomplete="off">
                            </div>
                            <button class="layui-btn" data-type="f_Query">查询</button>
                            <button class="layui-btn" data-type="f_Qrjq">确认交期</button>
                            <button class="layui-btn" data-type="f_Bhjq">驳回交期</button>
                            <button class="layui-btn" data-type="f_Jumppage">生成送货单</button>
                        </div>
                        <table class="layui-hide" id="test-table-reload" lay-filter="user"></table>
                        <blockquote class="layui-elem-quote">要货通知单列表</blockquote>
                    </div>
                </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/layui/JavaScript1.js"></script>-->
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table'], function () {
            var table = layui.table;
            var $ = layui.$;
            var layer = layui.layer;
            RoadHBillNo("and 1=1");
            layer.load(3)
            //方法级渲染
            table.render({
                elem: '#test-table-reload'
                , dateType: 'json'
                , colFilterRecord: true//是否开启字段筛选的记忆功能
                , data: []
             // , url: 'http://localhost:8083/Web/GetSup_PODemandPlanBilList'
              , toolbar: '#toolbarDemo'
              //, where: { msg: "", NowPage: 1, OnePage: 10 }
                // , where: { sqlWhere: "178070" }
              , cols: [[
                { checkbox: true, fixed: true }
                , { field: 'HState', title: '单据状态', width: 100, edit: 'text', sort: true, fixed: true }
                , { field: 'HBillno', title: '单据号', width: 200, sort: true, edit: 'text', sort: true, fixed: true }
                , { field: 'HMTONO', title: '计划跟踪单号', width: 100, edit: 'text', hide: true }
                , { field: 'HSupName', title: '供应商', width: 150, edit: 'text' }
                , { field: 'HMaterNumber', title: '物料代码', width: 200, edit: 'text' }
                , { field: 'HMaterName', title: '物料名称', width: 200, edit: 'text' }
                , { field: 'HMaterModel', title: '规格型号', width: 200, edit: 'text' }
                , { field: 'HUnitName', title: '计量单位', width: 100, edit: 'text' }
                , { field: 'HQty', title: '数量', width: 100, edit: 'text' }
               // , { field: '日期', title: '单据日期', width: 150, edit: 'text' }
                , { field: 'HDate', title: '单据日期', width: 130, edit: 'text' }
                , { field: 'HJHDate', title: '交货日期', width: 150, edit: 'text' }
                , { field: 'HUnitID', title: '单位ID', width: 150, edit: 'text', hide: true }
                , { field: 'HSupID', title: '供应商ID', width: 150, edit: 'text', hide: true }
                , { field: 'hmainid', title: '主键', width: 150, edit: 'text', hide: true }
                , { field: 'hsubid', title: '子表主键', width: 150, edit: 'text', hide: true }
                , { field: 'HManagerID', title: '主管ID', width: 100, edit: 'text', hide: true }
                , { field: 'hmanagerName', title: '主管', width: 100, edit: 'text', hide: true }
                , { field: 'HEmpID', title: '职员ID', width: 100, edit: 'text', hide: true }
                , { field: 'HRemark', title: '表头备注', width: 150, edit: 'text', hide: true }
                , { field: 'HMaker', title: '制单人', width: 100, edit: 'text', hide: true }
                , { field: 'HMakedate', title: '制单日期', width: 100, edit: 'text', hide: true }
                , { field: 'HChecker', title: '审核人', width: 100, edit: 'text', hide: true }
                , { field: 'HCheckdate', title: '审核日期', width: 100, edit: 'text', hide: true }
                //, { field: 'hmanagerName', title: '主管', width: 100, edit: 'text', hide: true }
                //, { field: 'HRemark', title: '备注', width: 100, edit: 'text', hide: true }
                //, { field: 'HChecker', title: '审核人', width: 100, edit: 'text', hide: true }
                //, { field: 'HCheckdate', title: '审核日期', width: 100, edit: 'text', hide: true }
                //, { field: 'HMaker', title: '制单人', width: 100, edit: 'text', hide: true }
                //, { field: 'HMakedate', title: '制单日期', width: 100, edit: 'text', hide: true }
                //, { field: 'hmainid', title: '主键', width: 100, edit: 'text' }
                //, { field: 'hsubid', title: '子表主键', width: 100, edit: 'text' }
              ]]
              , page: true
              , height: 500
             , done: function () {
                     layer.closeAll("loading");
                 }
            });
            ///加载显示数据
              function RoadHBillNo (sqlWhere) {
                where = sqlWhere;
                $.ajax({
                    type: "get",
                    url: "http://localhost:8083/Web/GetSup_PODemandPlanBilList",
                    async: true,
                    data: { "HSupNo": sessionStorage["HUserName"], "sqlWhere": sqlWhere },
                    success: function (result) {
                        ajaxReturnData = JSON.parse(JSON.stringify(result)).data;
                        table.reload('test-table-reload', {
                            data: ajaxReturnData
                            , height: 'full-10'
                            , loading: false
                            , done: function (index, res) {
 
                            }
                        });
                    },
                    error: function (result) {
                        console.log(result);
                        //layer.msg('获取采购订单出现异常', { icon: 2, time: 2000 });
                    }
                });
            };
            //定义事件集合
            var $ = layui.$, active = {
                reload: function () {
                    var demoReload = $('#HBillNo');
                    //执行重载
                    table.reload('test-table-reload', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                      , where: {
                          key: {
                              id: demoReload.val()
                          }
                      }
                    });
                },
                //快速查询
                f_Query:function(){ //查询
                    var sqlWhere = " and 1=1 ";
                    if ($("#HBillNo").val() != "")
                        sqlWhere += " and 单据号 like ''%" + $("#HBillNo").val() + "%''";
                    RoadHBillNo(sqlWhere);
                },
                f_Qrjq: function () { //确认交期
                    var checkStatus = table.checkStatus('test-table-reload')
                        , data = checkStatus.data;
                    for (var i = 0; i < data.length; i++) {
                        // rows += data[i].hmainid.toString() + ',' + data[i].hsubid.toString() + ';';
                        if (data[i].HState == "未确认")
                        {
                            $.ajax({
                                type: "get",
                                url: "http://localhost:8083/Web/UpdateBill",
                                data: { "HInterID": data[i].hmainid.toString(), "HEntryID": data[i].hsubid.toString(), "HState": "2" },
                                success: function (result) {
                                    if (result.count == 1) { // 说明验证成功了,
                                        layer.msg(result.Message, { icon: 1 });
                                        RoadHBillNo("and 1=1");
                                    }
                                    else {
                                        // $("#verifycode").click();
                                        layer.msg(result.Message, { icon: 5 });
                                    }
                                    layer.closeAll("loading");
                                }
                            })
                        }
                        else
                        {
                            layer.msg("必须是未确认单据才能进行确认操作!", { icon: 5 });
                        }
                    }
                },
                f_Bhjq: function () { //驳回交期
                    var checkStatus = table.checkStatus('test-table-reload')
                       , data = checkStatus.data;
                    for (var i = 0; i < data.length; i++) {
                        // rows += data[i].hmainid.toString() + ',' + data[i].hsubid.toString() + ';';
                        if (data[i].HState == "未确认")
                        {
                            $.ajax({
                                type: "get",
                                url: "http://localhost:8083/Web/UpdateBill",
                                data: { "HInterID": data[i].hmainid.toString(), "HEntryID": data[i].hsubid.toString(), "HState": "1" },
                                success: function (result) {
                                    if (result.count == 1) { // 说明验证成功了,
                                        layer.msg("驳回成功!", { icon: 1 });
                                        RoadHBillNo("and 1=1");
                                    }
                                    else {
                                        // $("#verifycode").click();
                                        layer.msg(result.Message, { icon: 5 });
                                    }
                                    layer.closeAll("loading");
                                }
                            })
                        }
                        else
                        {
                            layer.msg("必须是未确认单据才能进行驳回操作!", { icon: 5 });
                        }
                       
                    }
                },
                f_Jumppage: function () {//送货单
                    var checkStatus = table.checkStatus('test-table-reload')
                        , data = checkStatus.data;
                    ajaxLabelData = data;
                    var rows = '';
                    var HEntry = '';
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].HState == "已确认")
                        {
                            rows += data[i].hmainid.toString() + ',' + data[i].hsubid.toString() + ';';
                        }
                        else
                        {
                            HEntry += i + ',';
                        }
                    }
                    if (HEntry != '')
                    {
                        layer.msg("第" + HEntry + "行未确认!", { icon: 5 });
                    }
                    //layer.alert(rows);
                    layer.open({
                        type: 2
                        , area: ['100%', '100%']
                        , title: '送货单'
                        , shade: 0.6 //遮罩透明度
                        , maxmin: false //允许全屏最小化
                        , anim: 0 //0-6的动画形式,-1不开启
                        , content: ['../../views/WarM/KF_POInStockBill.html?linterid=' + data[0].hmainid + '&lentryid=' + rows.toString(), 'yes']
                        // , content: ['../../views/WarM/KF_POInStockBill.html?linterid=' + JSON.stringify(data), 'yes']
                       // , content: ['../../views/WarM/KF_POInStockBill.html?linterid=' + rows, 'yes']
                        , resize: false
                        , cancel: function () {
                            $(".layui-btn").removeClass("layui-btn-disabled");
                        }
                    })
                },
                f_Jumppages: function () {//送货单
                    var checkStatus = table.checkStatus('test-table-reload')
                        , data = checkStatus.data;
                    ajaxSHDData = data;
                    window.open('../../views/WarM/KF_POInStockBill.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no');
                }
            };
            $('.test-table-reload-btn .layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</body>
</html>