yangle
2022-07-28 e73dfda065667fcef6d60efe4128ae6c8b65d938
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
<!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 style="padding: 10px; ">
                            <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">导入数据</button>
                            <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="Cancel" id="Cancel">退出</button>
                            <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="UpLoad" id="UpLoad">文件上传</button>
                        </div>
                        <div class="layui-collapse">
                            <div class="layui-colla-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 85px;">会计年</label>
                                    <div class="layui-input-block" style="margin-left: 120px; width: 85px;">
                                        <select name="HYear" id="HYear" lay-verify="HYear">
                                            <!--动态渲染组织-->
                                        </select>
                                    </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: 85px;">
                                        <select name="HPeriod" id="HPeriod" lay-verify="HPeriod">
                                            <!--动态渲染组织-->
                                        </select>
                                    </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="WorkBookName" id="WorkBookName" value="Sheet1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-block" style="margin-left: 10px;min-height:0px">
                                        <input type="checkbox" name="DataAppend" id="DataAppend" lay-skin="primary" lay-filter="DataAppend" title="追加">
                                        <input type="hidden" name="HOrgID" id="HOrgID" lay-verify="HOrgID">
                                    </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: 85px;">
                                        <select name=" HTProcessFlag" id="HTProcessFlag">
                                            <option value="1">是</option>
                                            <option value="0">否</option>
                                        </select>
                                    </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_DeleteBill"><i class="layui-icon layui-icon-delete"></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','upload'], 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
            , upload = layui.upload
        //#endregion
 
        //#region 进入页面即加载
 
        //初始化界面
        set_ClearBill();
 
        //#endregion
 
        //#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
 
        //文件上传
        upload.render({
            elem: '#UpLoad',
            url: GetWEBURL() + '/Gy_RoutingBill/Gy_RoutingBillimport',
            contentType: 'application/json',
            exts: 'xls|xlsx', //允许上传的类型
            data: {
                "WorkBookName": function () {
                    return $("#WorkBookName").val();
                },
                "HOrgID": function () {
                    return sessionStorage["OrganizationID"];
                }
            },
            before: function (data) {
                loadIndex = layer.load(2);
                this.data = {
                    "WorkBookName": $("#WorkBookName").val(),
                    "HOrgID": sessionStorage["OrganizationID"]
 
                }
            },
            done: function (data1) {
                if (data1.count == 1) {
                    option.data = data1.data;
                    table.render(option);
                    layer.close(loadIndex);
                } else {
                    layer.close(loadIndex);
                    layer.alert(data1.code + data1.Message, { icon: 5 });
                }
            },
            error: function (err) {
                debugger
                layer.alert('导入出现异常', { icon: 2 });
            }
        });
 
        //退出
        form.on('submit(Cancel)', function () {
            Pub_Close(2);
        })
 
        //导入  保存数据
        form.on('submit(btnSave)', function (data) {
          
            if (table.cache["mainTable"] != null) {
                set_AddNew(data);
            }
            else {
                layer.msg("无数据,请先导入数据!");
            }
        })
        //#endregion
 
        //#region 本页面被调用的所有方法
 
        //会计年
        function Year() {
            var yyyy = new Date().getFullYear();
            var YearOption = "";
            for (var i = 0; i <= 10; i++) {
                YearOption += '<option  style="color:blue;" value="' + (yyyy - 5 + i) + '">' + (yyyy - 5 + i) + '</option>';
            }
            $("#HYear").append(YearOption);
            $("#HYear").val(yyyy)
            form.render('select');
        }
 
        //会计月
        function Month() {
            var MM = new Date().getMonth() + 1;
            var MonthOption = "";
            for (var i = 1; i <= 12; i++) {
                MonthOption += '<option  style="color:blue;" value="' + i + '">' + i + '</option>';
            }
            $("#HPeriod").append(MonthOption);
            $("#HPeriod").val(MM)
            form.render('select');
        }
 
        //#region 初始化界面
        function set_ClearBill() {
            Year();
            Month();
            //初始化表格
            set_InitGrid();
        }
        //#endregion
 
        //初始化表格
        function set_InitGrid() {
            option = {
                elem: '#mainTable'
                , toolbar: '#toolbarDemo'
                , height: 'full-120'
                , page: true
                , cellMinWidth: 90
                , limit: 50
                , limits: [50, 500, 5000, 20000]
                , loading: false
                , cols: [[
                    { type: 'checkbox', fixed: 'left' }
                    , { field: '产品代码', title: '产品代码', width: 120 }
                    , { field: '产品名称', title: '产品名称', width: 120 }
                    , { field: '规格型号', title: '规格型号', width: 120 }
                    , { field: '单位', title: '单位', width: 120 }
                    , { field: '工艺路线名称', title: '工艺路线名称', width: 120 }
                    , { field: '物料分类', title: '物料分类', width: 120 }
                    , { field: '工序序号', title: '工序序号', width: 120 }
                    , { field: '工序代码', title: '工序代码', width: 120 }
                    , { field: '工序', title: '工序', width: 120 }
                    , { field: '工作中心代码', title: '工作中心代码', width: 120 }
                    , { field: '工作中心', title: '工作中心', width: 120 }
                    , { field: '时间单位', title: '时间单位', width: 120 }
                    , { field: '加工数量', title: '加工数量', width: 120 }
                    , { field: '班产定额', title: '班产定额', width: 120 }
                    , { field: '工序工价', title: '工序工价', width: 120 }
                    , { field: '不合格单价', title: '不合格单价', width: 120 }
                    , { field: '报废单价', title: '报废单价', width: 120 }
                    , { field: '本道固定开工天数', title: '本道固定开工天数', width: 120 }
                    , { field: '本道开工余量', title: '本道开工余量', width: 120 }
                    , { field: '上道等待天数', title: '上道等待天数', width: 120 }
                    , { field: '上道循环周期', title: '上道循环周期', width: 120 }
                    , { field: '自动转移', title: '自动转移', width: 120 }
                    , { field: '外协标记', title: '外协标记', width: 120 }
                    , { field: '供应商代码', title: '供应商代码', width: 120 }
                    , { field: '供应商', title: '供应商', width: 120 }
                    , { field: '工艺参数', title: '工艺参数', width: 120 }
                    , { field: '图纸编号', title: '图纸编号', width: 120 }
                    , { field: '本工序确认记录', title: '本工序确认记录', width: 120 }
                    , { field: '良率', title: '良率', width: 120 }
                    , { field: '备注', title: '备注', width: 120 }
                    , { field: '图号版本', title: '图号版本', width: 120 }
                    , { field: '总装图号', title: '总装图号', width: 120 }
                    , { field: '材质', title: '材质', width: 120 }
                    , { field: '成品编号', title: '成品编号', width: 120 }
                    , { field: '版本', title: '版本', width: 120 }
                    , { field: '模具编号', title: '模具编号', width: 120 }
                    , { field: '程序号', title: '程序号', width: 120 }
                ]]
            };
 
            //渲染页面
            table.render(option);
        }
 
        //导入(保存)
        function set_AddNew(data) {
 
            //var num = [];
            //for (var i = 0; i < table.cache["mainTable"].length; i++) {
            //    if (table.cache["mainTable"][i] != "") {
            //        table.cache["mainTable"][i].LAY_TABLE_INDEX = i;
            //        num.push(table.cache["mainTable"][i])
            //    }
            //}
            data.field.HOrgID = sessionStorage["OrganizationID"];//组织
            var sMainStr = JSON.stringify(data.field);
            var sSubStr = '1';//JSON.stringify(num)
            var sMainSub = sMainStr + ';' + sSubStr + ';' + sessionStorage["HUserName"];
            var index = layer.load();
 
            $.ajax({
                type: "POST",
                url: GetWEBURL() + "/Gy_RoutingBill/Gy_RoutingBill_btnSave",
                async: true,
                data: { "sMainSub": sMainSub },
                dataType: "json",
                success: function (data) {
                    if (data.count == 1) {
                        layer.close(index);
                        layer.msg(data.Message);
                        option.data = null;
                        table.render(option);
                    }
                    else {
                        layer.close(index);
                        layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                },
                error: function (err) {
                    layer.close(index);
                    layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                }
            });
        }
 
        //#endregion
        //以上是layui模块
    });
</script>