yusijie
2023-02-02 04ee1e66aa1e13d786bc6b89e866b659f235d8f1
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
 
 
<!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 id="layout1" 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">
                        <form id="form1" class="layui-form" action="">
                            <div class="layui-form-item" style="margin-bottom: 20px;">
                                <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="HBarcodeSaverPZ">生成品种码</button>
                                <!--<button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="HBarcodeSaverWY">生成唯一码</button>
                                <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="HBarcodeSaverPC">生成批次码</button>-->
                            </div>
                            <div class="layui-form-item" style="margin-bottom: 10px;">
                                单 据 号:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HBillNo" lay-verify="HBillNo" id="HBillNo" hbillno="test-table-demoReload" autocomplete="off" disabled>
                                </div>
                                单据日期:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HDate" id="HDate" hdate="test-table-demoReload" autocomplete="off" disabled>
                                </div>
                                主    管:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HManagerName" id="HManagerName" hmanagername="test-table-demoReload" autocomplete="off" disabled>
                                    <input id="HManagerID" name="HManagerID" type="hidden" />
                                </div>
                                供 应 商:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HSupName" lay-verify="HSupName" value="DDD" id="HSupName" hsupname="test-table-demoReload" autocomplete="off" style="width: 180px;" disabled>
                                    <input id="HSupID" name="HSupID" type="hidden" />
                                </div>
                                <!--<button class="layui-btn" data-type="reload">选择</button>-->
                            </div>
                            <div class="layui-form-item" style="margin-bottom: 10px;">
                                备    注:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HRemark" id="HRemark" hremark="test-table-demoReload" autocomplete="off" style="width: 660px;">
                                </div>
                                业 务 员:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HEmpName" id="HEmpName" hempname="test-table-demoReload" autocomplete="off" style="width: 180px;">
                                    <input id="HEmpID" name="HEmpID" type="hidden" />
                                </div>
                            </div>
                            <div class="layui-form-item" style="margin-bottom: 10px;">
                                制单日期:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HMakerDate" id="HMakerDate" hmakedate="test-table-demoReload" autocomplete="off" disabled>
                                </div>
                                制 单 人:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HMaker" id="HMaker" hmaker="test-table-demoReload" autocomplete="off" disabled>
                                </div>
                                审核日期:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HCheckDate" id="HCheckDate" hcheckdate="test-table-demoReload" autocomplete="off" disabled>
                                </div>
                                审 核 人:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HChecker" id="HChecker" hchecker="test-table-demoReload" autocomplete="off" disabled>
                                </div>
                            </div>
                            <div class="layui-form-item" style="margin-bottom: 10px;">
                                主键:
                                <div class="layui-inline">
                                    <input class="layui-input" name="HInterID" id="HInterID" hinterid="test-table-demoReload" autocomplete="off" style="width: 100px;" disabled>
                                </div>
                            </div>
                        </form>
                    </div>
                    <!--<script type="text/html" id="toolbarDemo">
                        <div class="test-table-reload-btn" style="margin-bottom: 10px;">
                            <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">删行</button>
 
                        </div>
                    </script>-->
                    <table class="layui-hide" id="test-table-reload" lay-filter="test-table-reload"></table>
                    <table class="layui-hide" id="barcode-table-reload" lay-filter="barcode-table-reload"></table>
                    <blockquote class="layui-elem-quote">条码单据</blockquote>
                </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" type="text/javascript"></script>
    <script src="../../layuiadmin/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <!--<script src="../../../../Scripts/jquery-1.8.2.js"></script>-->
    <script>
        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;
        }
        var params = getUrlVars();
        var linterid = params[params[0]];
        var lentryid = params[params[1]];
      // debugger;
        $.ajax({
            url: "http://localhost:8083/Web/GetHBarCodeShowBillMain",
            type: "GET",
            data: { "sMsg": linterid },
            success: function (d) {
                console.log(d.data);
                //$("#HDate").val(d.)
                $("#HInterID").val(d.data[0].HInterID);
                $("#HBillNo").val(d.data[0].HBillNo);
                $("#HRemark").val(d.data[0].HRemark);
                $("#HDate").val(d.data[0].HDateForWeb);
                $("#HMaker").val(d.data[0].HMaker);
                $("#HMakerDate").val(d.data[0].HMakerDate)
                $("#HChecker").val(d.data[0].HChecker);
                $("#HCheckDate").val(d.data[0].HCheckDate);
                $("#HSupID").val(d.data[0].HSupID);
                $("#HSupName").val(d.data[0].HSupName);
                $("#HEmpID").val(d.data[0].HEmpID);
                $("#HEmpName").val(d.data[0].HEmpName);
                $("#HManagerID").val(d.data[0].HManagerID);
                $("#HManagerName").val(d.data[0].HManagerName);
            }
        });
 
 
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table','form'], function () {
            var table = layui.table
            ,$ = layui.$
            ,form = layui.form;
 
            form.on('submit(HBarcodeSaverPZ)', function (data) {//保存
                //debugger;
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['test-table-reload']);
                console.log(sMainStr)
                console.log(sSubStr)
                var sMainSub = sMainStr + ';' + sSubStr;
                layer.load(3)
                $.ajax(
                {
                    type: "POST",
                    url: "http://localhost:8083/web/GetBarcodeSaveBill", //方法所在页面和方法名
                    async: true,
                    data: { "msg": sMainSub },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) { // 说明验证成功了,
                            layer.msg(data.Message, { icon: 1 });
                             table.render({
                                elem: '#barcode-table-reload'
                              , url: 'http://localhost:8083/Web/GetHBarCodeShowBillSub2'
                              , toolbar: '#toolbarDemo'
                              , where: { sMsg: linterid }
                              , cols: [[
                               // , { field: 'HMTONO', title: '计划跟踪单号', width: 100,, sort: true, fixed: true edit: 'text', hide: true }
                                , { field: 'HMaterID', title: '物料ID', width: 100, hide: true }
                                , { field: 'HMaterNumber', title: '物料代码', width: 100 }
                                , { field: 'HMaterName', title: '物料名称', width: 200 }
                                , { field: 'HMaterModel', title: '规格型号', width: 200 }
                                , { field: 'HUnitName', title: '计量单位', width: 100 }
                                , { field: 'HUnitNumber', title: '计量单位代码', width: 100, edit: 'text', hide: true }
                                , { field: 'HUnitID', title: '计量单位ID', width: 100, edit: 'text', hide: true }
                                , { field: 'HQty', title: '数量', width: 100 }  
                                , { field: 'HBarCode', title: '条码编号', width: 100 }
                              ]]
                                // , data: [linterid]
                            //  , page: true
                              , height: 500
                              , done: function () {
                                  layer.closeAll("loading");
                              }
                            });
                        }
                        else {
                            // $("#verifycode").click();
                            layer.msg(data.Message, { icon: 5 });
                        }
                        layer.closeAll("loading");
                    },
                    error: function (err) {
                        f_alert("错误:" + err);
                    }
                });
                return false;
            });
 
 
            //监听提交
            form.verify({
                numberOrEmpty: function (value, item) {
                    // if (value != '') {
                    if (!/^\d+$/.test(value)) {
                        return '不能为空或数字或者0';
                    }
                    //}
                }
            });
            layer.load(3)
            table.render({
                elem: '#test-table-reload'
              , url: 'http://localhost:8083/Web/GetHBarCodeShowBillSub'
              , toolbar: '#toolbarDemo'
              , where: { sMsg: linterid, sMsg2: lentryid }
              ,cols: [[
               // , { field: 'HMTONO', title: '计划跟踪单号', width: 100,, sort: true, fixed: true edit: 'text', hide: true }
                , { field: 'HMaterID', title: '物料ID', width: 100, hide: true }
                , { field: 'HMaterNumber', title: '物料代码', width: 100}
                , { field: 'HMaterName', title: '物料名称', width: 200 }
                , { field: 'HMaterModel', title: '规格型号', width: 200}
                , { field: 'HUnitName', title: '计量单位', width: 100 }
                , { field: 'HUnitNumber', title: '计量单位代码', width: 100, edit: 'text', hide: true }
                , { field: 'HUnitID', title: '计量单位ID', width: 100, edit: 'text', hide: true }
                , { field: 'HQty', title: '数量', width: 100 }
                , { field: 'HMinQty', title: '最小包装数', width: 100, edit: 'text' }
                , { field: 'HBQty', title: '条码张数', width: 100, edit: 'text' }
                , { field: 'HPrice', title: '单价', width: 100, edit: 'text', hide: true }
                , { field: 'HMoney', title: '金额', width: 100, edit: 'text', hide: true }
                //, { field: 'HDate', title: '要求交货日期', width: 150, edit: 'text' }
                //, { field: 'HDate2', title: '确认交货日期', width: 150, edit: 'text' }
                , { field: 'HPOOrderInterID', title: '采购单主内码', width: 150, edit: 'text', hide: true }
                , { field: 'HPOOrderEntryID', title: '采购单子内码', width: 150, edit: 'text', hide: true }
                , { field: 'HSourceBillType', title: '源单类型', width: 100, edit: 'text', hide: true }
                , { field: 'HPOOrderBillNo', title: '采购单号', width: 200 }
                , { field: 'HBillType', title: '单据类型', width: 100 }
                , { field: 'HSourceBillNo', title: '源单单号', width: 200 }
                , { field: 'HSourceEntryID', title: '源单子内码', width: 150, edit: 'text', hide: true }
                , { field: 'HSourceInterID', title: '源单主内码', width: 150, edit: 'text', hide: true }
               // , { field: 'HCheckDate', title: '审核日期', width: 150, edit: 'text' }
                , { field: 'HChecker', title: '审核人', width: 100, edit: 'text', hide: true }
                , { field: 'HSupID', title: '供应商ID', width: 150, edit: 'text', hide: true }
                , { field: 'HManagerID', title: '主管ID', width: 100, edit: 'text', hide: true }
                , { field: 'HEmpID', title: '职员ID', width: 100, edit: 'text', hide: true }
                , { field: 'HMaker', title: '制单人', width: 100, edit: 'text', hide: true }
              ]]
              // , data: [linterid]
             // , page: true
              , height: 500
              , done: function () {
                     layer.closeAll("loading");
                 }
            });
            table.on('edit(test-table-reload)', function (obj) { //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值"
               var value = obj.value //得到修改后的值
                  ,data = obj.data //得到所在行所有键值
                  , field = obj.field; //得到字段
               obj.update({
                   HBQty:   parseFloat(obj.data.HQty)/parseFloat(obj.value)
               });
               //obj.data.HBQty = parseFloat(data.HQty) / parseFloat(value);
               //layer.msg('条码张数:' + parseFloat(data.HQty) / parseFloat(value));
            });
            var $ = layui.$, active = {
                reload: function () {
                    var demoReload = $('#test-table-demoReload');
                    //执行重载
                    table.reload('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>