多单位版国产化地质资料管理系统
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
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
 
<!DOCTYPE HTML>
<html>
<head>
    <base href="<%=basePath%>">
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>扫描枪录入</title>
    <link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
    <link href="static/plugins/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="static/styles/initialize.css" type="text/css">
    <link rel="stylesheet" href="static/styles/common.css" type="text/css">
    <link rel="stylesheet" href="static/plugins/layer/skin/default/layer.css" type="text/css">
    <script type="text/javascript" src="static/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="static/plugins/jquery-easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="static/plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <script type="text/javascript" src="static/plugins/layer/layer.js"></script>
 
    <script type="text/javascript" src="static/scripts/customResize.js"></script>
 
    <script type="text/javascript" src="static/plugins/spinjs/spin.js"></script>
    <script type="text/javascript" src="static/plugins/spinjs/jquery.spin.js"></script>
    <script type="text/javascript" src="static/plugins/jquery.blockUI.js"></script>
 
    <script type="text/javascript" src="static/wcp/scripts/wcp.js"></script>
    <script type="text/javascript" src="static/wcp/scripts/libs/wcp.layer.js"></script>
    <script type="text/javascript" src="static/wcp/scripts/libs/wcp.blockUI.js"></script>
    <script type="text/javascript" src="static/wcp/scripts/libs/wcp.spin.js"></script>
    <script type="text/javascript" src="static/wcp/scripts/libs/wcp.jquery.js"></script>
 
    <!--[if lt IE 9]>
    <script type="text/javascript" src="static/plugins/json2.js"></script>
    <![endif]-->
    <style>
        html, body {
            height: 100%;
            width: 100%;
            overflow: hidden;
        }
    </style>
</head>
<body>
<div class="pt-wrap margin-lr" style="height:100%;">
    <div class="pt-main-top clear">
        <div class="pt-nav">
            <span class="pt-title-icon"><i class="fa fa-pencil"></i></span>
            <div class="pt-title">
                <div>
                    <h4>扫描列表</h4>
                </div>
            </div>
        </div>
        <div class="pt-search clear">
 
            <button id="delAllBtn" style="float:right; margin:0px 4px 0 0;" onclick="delAll();"
                    class="pt-btn pt-btn-danger pull-right"><i class="fa fa-trash-o"></i>全部删除
            </button>
            <p class="pt-retrieval" style="float:right; margin:0px 4px 0 0;">
                <input id="txtKeySearch" type="text" placeholder="请输入案卷档号">
                <button id="btnKeySearch">
                    <i class="fa fa-search"></i>
                </button>
            </p>
        </div>
    </div>
    <div id="div_table">
        <table id="dg_publicColumn" style="width:100%;height:100%;">
        </table>
    </div>
    <div class="pt-form-btn" style="bottom:0px;">
        <div class="form-group">
            <button id="btnSave" class="pt-btn pt-btn-primary">确定</button>
            <button id="btnClose" class="pt-btn pt-btn-default">关闭</button>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="static/scripts/ResizeScroll.js"></script>
<script>
    //定义页面全局变量
    var NowSelectedNodeId = 0;
    var params = {
        callBack: null
    };
    $(function () {
        //右边已选框
        $("#dg_publicColumn").datagrid({
            fitColumns: true,
            nowrap: true,
            rownumbers: true,
            height: 480,
            idField: 'archival_code',
            columns: [[
                {
                    field: 'archival_code',
                    title: '档号',
                    width: 150,
                    align: 'center'
                },
                {
                    field: 'edit',
                    title: '操作',
                    width: 100,
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<a onclick="delTableRow(\'' + row.type + '\',\'' + value + '\',' + index + ');" class="pt-color-danger"><i class="fa fa-trash-o" title="删除"></i></a>';
                    }
                }
            ]],
            onLoadSuccess: function () {
                new ResizeScroll({
                    "id": ".datagrid-body",
                    "height": "500",
                    "index": 3
                });
 
            }
        });
        //保存按钮事件
        $("#btnSave").click(function () {
            var checkRows = $("#dg_publicColumn").datagrid("getRows");
            if (checkRows.length == 0) {
                layer.alert("档号列表不能为空!");
            } else {
                saveScanPrintData(checkRows)
            }
        });
 
        //关闭按钮事件
        $("#btnClose").click(function () {
            closeWindow();
        });
 
        //绑定检索输入框回车事件
        $("#btnKeySearch").click(function () {
            addArchivalCode();
        });
 
        //检索按钮事件
        $('#txtKeySearch').bind('keypress', function (event) {
            if (event.keyCode == "13") {
                addArchivalCode();
            }
        });
 
        new CustomResize({
            "id": "div_table",
            "fun": computeHeight
        });
 
    })
 
    //添加一行
    function addArchivalCode() {
        // var archivalType = $("#archive_type").combobox("getValue");
        // if (archivalType == null || archivalType == "") {
        //     layer.alert("请先选择档案门类");
        //     return;
        // }
        var val = $('#txtKeySearch').val();
        //去重
        var bool = true;
        var rows = $('#dg_publicColumn').datagrid("getRows");
        if (rows && rows != null) {
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].archival_code == val) {
                    bool = false;
                }
            }
        }
        if (bool) {
            var rowData = {
                archival_code: val
            }
            $("#dg_publicColumn").datagrid("appendRow", rowData);
        }
        $('#txtKeySearch').val("");
    }
 
    //计算弹出框大小
    function computeHeight() {
        var wh = $(window).height();
        $("#div_table").height(wh - 80);
        $("#dg_publicColumn").datagrid("resize");
    }
 
    function closeWindow() {
        var index = top.layer.getFrameIndex(window.name); //获取窗口索引
        top.layer.close(index);
    }
 
    //删除已选中的行
    function delTableRow(type, id, index) {
        $("#dg_publicColumn").datagrid('deleteRow', index);
        //刷新已选区,重新生成行号,不然会出错
        var hasRows = $('#dg_publicColumn').datagrid("getRows");
        for (var i = 0; i < hasRows.length; i++) {
            $("#dg_publicColumn").datagrid('refreshRow', i);
        }
    }
 
    //已选取的全部删除
    function delAll() {
        $('#dg_publicColumn').datagrid("loadData", []);
    }
 
    //获取档案类型
    // function findAllArchivesList() {
    //     var optionArray = [];
    //     $("#archive_type").combobox('clear');
    //     $.ajax({
    //         type: "post",
    //         async: false,
    //         url: "archivesStructure/getAllArchivesList?showAll=" + true,
    //         dataType: "json",
    //         success: function (result) {
    //             if (result) {
    //                 for (var i = 0; i < result.length; i++) {
    //                     var nodeIdentify = "";
    //                     var text = result[i].text;
    //                     if (result[i].attributes.archivesNodeType == 3) {
    //                         nodeIdentify = result[i].attributes.nodeIdentify;
    //                     }
    //                     optionArray.push({
    //                         "text": text,
    //                         "id": nodeIdentify,
    //                         "value": nodeIdentify
    //                     })
    //                 }
    //             }
    //         },
    //         error: function (errorMsg) {
    //             //请求失败时执行该函数
    //             alert("请求数据失败!");
    //         }
    //     });
    //     $("#archive_type").combobox("loadData", optionArray);
    //     $("#archive_type").combobox({
    //         data: optionArray,
    //         valueField: 'value',
    //         textField: 'text',
    //         onChange: function () {
    //             changeArchivalType();
    //         }
    //     });
    // }
 
    //修改档案门类
    // function changeArchivalType() {
    //     var rows = $("#dg_publicColumn").datagrid("getRows");
    //     if (rows.length > 0) {
    //         layer.confirm("列表已存在数据,修改档案门类会清空列表,是否继续?", {
    //             icon: 3,
    //             title: '提示'
    //         }, function (index) {
    //             delAll();
    //             layer.close(index);
    //         })
    //     }
    // }
 
 
    //保存数据
    <%--function saveScanPrintData(rows) {--%>
    <%--    layer.confirm("已扫描" + rows.length + "条数据,确认入库?", {--%>
    <%--        icon: 3,--%>
    <%--        title: '提示'--%>
    <%--    }, function (index) {--%>
    <%--        wcp.ui.setBusy("body", wcp.ajax({--%>
    <%--            url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}',--%>
    <%--            data: JSON.stringify(rows),--%>
    <%--        }).done(function (result) {--%>
    <%--            params.callBack();--%>
    <%--            //关闭窗口--%>
    <%--            closeWindow();--%>
    <%--        }));--%>
    <%--    })--%>
    <%--}--%>
 
    <%--//保存数据--%>
    <%--function saveScanPrintData(rows) {--%>
    <%--    // getBoxNum(rows);--%>
    <%--    layer.prompt({--%>
    <%--        formType: 2,--%>
    <%--        value: '',--%>
    <%--        title: '请添加盒号'--%>
    <%--    }, function (value, index, elem) {--%>
    <%--        wcp.ui.setBusy("body", wcp.ajax({--%>
    <%--            url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}' + '&boxNum=' + value,--%>
    <%--            data: JSON.stringify(rows),--%>
    <%--        }).done(function (result) {--%>
    <%--            params.callBack();--%>
    <%--            //关闭窗口--%>
    <%--            closeWindow();--%>
    <%--        }));--%>
    <%--    });--%>
    <%--}--%>
 
    //保存数据
    function saveScanPrintData(rows) {
        // 首先获取已存在的盒号
        wcp.ui.setBusy("body", wcp.ajax({
            url: 'scanPrintController/getBoxNum',
            data: JSON.stringify(rows),
        }).done(function (result) {
            debugger;
            var boxNumList = result || []; // 假设AjaxResponse的data字段包含实际数据
            var existingBoxNum = boxNumList.length > 0 ? boxNumList[0] : ''; // 取第一个盒号或空字符串
 
 
            layer.prompt({
                formType: 2,
                title: '请添加盒号'
            }, function (inputBoxNum, index, elem) {
                // 如果已存在盒号且与输入的盒号不同,则提示用户确认
                if (existingBoxNum && existingBoxNum !== inputBoxNum) {
                    layer.confirm('当前档案已存在盒号 "' + existingBoxNum + '",您输入的是 "' + inputBoxNum + '",是否要更改盒号?', {
                        icon: 3,
                        title: '确认更改盒号'
                    }, function (confirmIndex) {
                        // 确认更改,执行保存
                        performSave(inputBoxNum, rows);
                        layer.close(confirmIndex);
                    }, function () {
                        // 取消更改,重新打开输入框
                        layer.close(index);
                    });
                } else {
                    // 盒号相同或不存在已存在的盒号,直接保存
                    performSave(inputBoxNum, rows);
                }
            });
        })).fail(function () {
            // 获取盒号失败时,直接让用户输入
            layer.prompt({
                formType: 2,
                value: '',
                title: '请添加盒号'
            }, function (value, index, elem) {
                wcp.ui.setBusy("body", wcp.ajax({
                    url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}' + '&boxNum=' + value,
                    data: JSON.stringify(rows),
                }).done(function (result) {
                    params.callBack();
                    //关闭窗口
                    closeWindow();
                }));
            });
        });
    }
 
 
    // 执行保存操作的辅助函数
    function performSave(boxNum, rows) {
        wcp.ui.setBusy("body", wcp.ajax({
            url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}' + '&boxNum=' + boxNum,
            data: JSON.stringify(rows),
        }).done(function (result) {
            params.callBack();
            //关闭窗口
            closeWindow();
        }));
    }
 
    function getBoxNum(rows) {
        wcp.ui.setBusy("body", wcp.ajax({
            url: 'scanPrintController/getBoxNum',
            data: JSON.stringify(rows),
        }).done(function (result) {
            console.log(result);
        }));
    }
</script>
</html>