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
<!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">
    </head>
    <body>
 
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">关键字</label>
                            <div class="layui-input-inline">
                                <input type="text" id="Msg" name="Msg" placeholder="编码/名称/规格" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">单据类型</label>
                            <div class="layui-input-inline">
                                <select name="Type" id="Type" lay-filter="Type" disabled="disabled"
                                    lay-search>
                                    <option value="0">成品入库</option>
                                    <option value="1">采购入库</option>                    
                                    <option value="2">中间品入库</option>
                                    <option value="3">退货入库</option>
                                    <option value="4">车间余料退回入库</option>
                                    <option value="5">其它入库</option>
                                    <option value="6">代储入库</option>
                                    <option value="7">寄存入库</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                            </button>
                            <button class="layui-btn layui-btn-sm layuiadmin-btn-list" data-type="setParent">确定</button>
                        </div>
                    </div>
                </div>
                <div class="layui-card-body">
                    <table id="goods-list" lay-filter="goods-list"></table>
                </div>
            </div>
        </div>
 
        <script src="../../layuiadmin/layui/layui.js"></script>
        <script src="../../js/jquery-3.5.1.min.js"></script>
        <script src="../../js/jquery.cookie.js"></script>
        <script src="../../js/public.js"></script>
        
        <script>
            layui.config({
                base: '../../layuiadmin/' //静态资源所在路径
            }).extend({
                index: 'lib/index' //主入口模块
            }).use(['index', 'table', 'laypage', 'layer'], function() {
                var table = layui.table,
                    form = layui.form,
                    laypage = layui.laypage,
                    index1 = parent.layer.getFrameIndex(window.name),
                    layer = layui.layer;
 
 
                // 获取上游页面的传值
                getQueryString('type');
                
 
                function getQueryString(name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                    var r = window.location.search.substr(1).match(reg);
 
                    if (r != null)
                    {
                        // $("#Type").empty();
                        // if (unescape(r[2]) == 0)
                        // {
                        //     $("#Type").append('<option value ="0" Selected >标准物料</option>');
                        //     $("#Type").append('<option value ="1">非标物料</option>');
                        // }
                        // if (unescape(r[2]) == 1)
                        // {
                        //     $("#Type").append('<option value ="0">标准物料</option>');
                        //     $("#Type").append('<option value ="1" Selected >非标物料</option>');
                        // }
 
                        
                        $("#Type").val(unescape(r[2])); // "optionValue"为需要被选中的选项的value属性值
                        form.render('select');
                    } 
 
                    //return null;
                }
 
 
                refreshTable();
 
                var active = {
                  setParent: function(){
                    var checkStatus = table.checkStatus('goods-list');   
                    var id = '#LAY-app-content-list',goods = $('#goods-list');
                    if(checkStatus.data.length == 0)
                    {
                      parent.layer.msg('请选择待入库的物料!');
                      return true;
                    }
                    window.parent.success(checkStatus.data);
                    parent.layer.close(index1);
                  }
                };
                $('.layui-inline .layui-btn').on('click', function(){
                  var othis = $(this)
                  ,type = othis.data('type');
                  active[type] && active[type].call(this);
                });
                
                
                var tableIns;
                function refreshTable() {
                    var param = {
                        SkuNo:  $("#Msg").val(),
                        Type: $("#Type").val()
                    };
 
                    sendData(IP + "/BllAsn/GetMaterialsList", param, 'post', function(res) {
                        if (res.code == 0) { //成功
                            var list = res.data;
                                $.extend(infoOptions, {
                                    data: list
                                });
                                infoOptions.page = {
                                    curr: 1
                            }
                            tableIns = table.render(infoOptions);
                        } else { //不成功
                            layer.msg('获取物料信息失败!', {
                                icon: 2,
                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                            }, function() {});
                        }
                    });
        
                }
                // 表单需要的变量
                var infoOptions = {
                    elem: '#goods-list',
                    height: 'full-100',
                    id: 'goods-list',
                    page: true,
                    limit: pageCnt,
                    limits: pageLimits,
                    cellMinWidth: 80, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
                    cols: [
                        [{
                            field: 'SkuId',
                            title: 'Id',
                            type: 'checkbox',
                            width: 100,
                            sort: true,
                            fixed: 'left'
                        }, {
                            field: 'SkuNo',
                            title: '物料编码',
                            width: 100,
                            fixed: 'left'
                        }, {
                            field: 'SkuName',
                            title: '物料名称',
                            width: 180,
                        },{
                            field: 'Standard',
                            title: '规格',
                            align: 'center',
                            width: 180
                        }, {
                            field: 'Type',
                            title: '类型',
                            width: 100,
                            templet: function (d) {
                                    switch (d.Type) {
                                        case "0" : return "原料"; 
                                        case "1" : return "包材"; 
                                        case "2" : return "成品";
                                        case "3" : return "耗材";
                                        case "4" : return "半成品";
                                        default : return ""; 
                                    }
                                }
                        }, {
                            field: 'IsControlled',
                            title: '是否标准',                    
                            // JC08 title: '是否受控',                    
                            width: 100,
                            // JC09
                            templet: function (d) {
                                    switch (d.IsControlled) {
                                        case "0" : return "标准"; 
                                        case "1" : return "非标"; 
                                        default : return ""; 
                                    }
                                },
                            // JC08
                            // templet: function (d) {
                            //         switch (d.IsBale) {
                            //             case "0" : return "受控"; 
                            //             case "1" : return "非受控"; 
                            //             default : return ""; 
                            //         }
                            //     }
                        },{
                            field: 'IsInspect',
                            title: '是否免检',                                
                            width: 100,
                            templet: function (d) {
                                    switch (d.IsInspect) {
                                        case "0" : return "否"; 
                                        case "1" : return "是"; 
                                        default : return ""; 
                                    }
                                },
                        },{
                            field: 'Origin',
                            title: '来源',                                
                            width: 120
                        },{
                            field: 'UnitName',
                            title: '计量单位',
                            width: 100,
                        }, {
                            field: 'PackagName',
                            title: '包装名称',
                            width: 120
                        }, {
                            field: 'Environment',
                            title: '存储环境',
                            width: 120,
                            templet: function (d) {
                                    switch (d.Environment) {
                                        case "0" : return "常温"; 
                                        case "1" : return "低温"; 
                                        case "3" : return "干燥通风"; 
                                        default : return ""; 
                                    }
                                },
                        }, {
                            field: 'Weight',
                            title: '理论重量',
                            width: 100
                        },{
                            field: 'Price',
                            title: '理论单价',
                            width: 100
                        }, {
                            field: 'Warranty',
                            title: '保质期(天)',
                            width: 100
                        },{
                            field: 'GoodsRemark',
                            title: '备注',
                            width: 160
                        }
                        ]
                    ],
        
                };
 
                //监听搜索
                form.on('submit(LAY-app-contlist-search)', function(data) {
                    refreshTable();
                });
            });
        </script>
    </body>
</html>