双重预防项目-国泰新华二开定制版
SZH
2022-08-20 f9f0687195e0fe349185437d22c495d74c8d4a20
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
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改事件上报')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: layui-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-incidentReport-edit" th:object="${incidentReport}">
            <input name="incidentReportId" th:field="*{incidentReportId}" type="hidden">
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">创建人id:</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="createUserId" th:field="*{createUserId}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">更新者id:</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="updateUserId" th:field="*{updateUserId}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">事件名称:</label>
                <div class="col-sm-8">
                    <input name="eventName" th:field="*{eventName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">事件简介:</label>
                <div class="col-sm-8">
                    <textarea name="introduction" class="form-control" required>[[*{introduction}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">事件地点:</label>
                <div class="col-sm-8">
                    <input name="eventLocation" th:field="*{eventLocation}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">事件时间:</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="eventTime" th:value="${#dates.format(incidentReport.eventTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否上报:</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('dc_whether_to_report')}">
                        <input type="radio" th:id="${'whetherToReport_' + dict.dictCode}" name="whetherToReport" th:value="${dict.dictValue}" th:field="*{whetherToReport}">
                        <label th:for="${'whetherToReport_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">处理状态:</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('dc_processing_status')}">
                        <input type="radio" th:id="${'processingStatus_' + dict.dictCode}" name="processingStatus" th:value="${dict.dictValue}" th:field="*{processingStatus}">
                        <label th:for="${'processingStatus_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">事件所属图片:</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="ownedPicture" th:field="*{ownedPicture}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
 
            <div class="form-group">
                <label class="col-sm-3 control-label">事件所属图片:</label>
                <div class="col-sm-8">
                    <input name="ownedPicture" th:value="*{ownedPicture}"  type="hidden" id="ownedPicture">
                    <div class="file-loading">
                        <input name="file" id="ownedPictureUpload" type="file">
                    </div>
                </div>
            </div>
 
 
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">事件所属文件:</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="ownedFile" th:field="*{ownedFile}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
 
            <div class="form-group">
                <label class="col-sm-3 control-label">事件所属图片:
                </label>
 
                <div class="col-sm-8" >
                    <button type="button" class="layui-btn layui-btn-normal" id="testList">选择多文件</button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                </label>
 
                <div class="col-sm-8" >
                    <div class="layui-upload-list">
                        <table class="layui-table">
                            <thead>
                            <tr><th>文件名</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr></thead>
                            <tbody id="demoList" >
                            <tr th:each="file :${fileList}" th:id="${file.attachmentId}">
                                <td>[[${file.originalFileName}]]</td>
                                <td>已上传</td>
                                <td>
                                    <a target="_blank" th:if="${#strings.contains(file.filePath,'.pdf')}" th:href="${serviceDomainName}+${file.filePath}"><button type="button" class="layui-btn layui-btn-xs layui-btn-primary">阅览</button></a>
                                    <a target="_blank" th:if="${!#strings.contains(file.filePath,'.pdf')}" th:href="'https://view.officeapps.live.com/op/view.aspx?src='+${serviceDomainName}+${file.filePath}"><button type="button" class="layui-btn layui-btn-xs layui-btn-primary">阅览</button></a>
                                    <a th:href="${file.filePath}" th:download="${file.originalFileName}"><button type="button" class="layui-btn layui-btn-xs layui-btn-normal" >下载</button></a>
                                    <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" th:onclick="'deleteFile('+${file.attachmentId}+')'">删除</button>
                                </td>
 
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <button type="button" class="layui-btn" id="testListAction">开始上传</button>
                </div>
            </div>
 
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <th:block th:include="include :: layui-js"/>
    <!-- 封装layui上传方法 -->
    <script src="/js/common/fileUpload.js"></script>
    <script type="text/javascript">
        //存放已上传的附件的数组
        var attachmentListArray = new Array();
 
        var prefix = ctx + "dc/incidentReport";
        $("#form-incidentReport-edit").validate({
            focusCleanup: true
        });
 
        function submitHandler() {
            if ($.validate.form()) {
                var data = $('#form-incidentReport-edit').serializeArray();
                data.push({"name": "ownedFile", "value": JSON.stringify(attachmentListArray)});
 
                $.operate.save(prefix + "/edit", data);
            }
        }
 
        $("input[name='eventTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
 
 
    <script>
 
        $(function() {
            fileUpload("#testList","#testListAction","#demoList",attachmentListArray);
            imageUploadEdit($("#ownedPictureUpload"),$("#ownedPicture"));
        });
 
        //图片上传
        function imageUploadEdit(thatFile, thatUrl) {
            //处理预览数据
            var urlObj = $(thatUrl).val();
            var previewUrl = [];
            var config = [];
            var previewKeys = [];
            if (urlObj) {
                urlObj = JSON.parse(urlObj);
                for (var key in urlObj) {
                    previewUrl.push(urlObj[key]);
                    var tem = {};
                    tem['key'] = key;
                    config.push(tem);
                    previewKeys.push(key);
                }
            }
            ;
 
            //图片上传
            var params = {
                'theme': 'explorer-fas',
                'uploadUrl': ctx + 'common/defUpload',
                'deleteUrl': '#',
                showUpload: false,
                overwriteInitial: false,
                initialPreviewAsData: true,
                language: 'zh',
                uploadAsync: true,
                dropZoneEnabled: false,
                maxFileCount: 10,
                resizeImage: false,
                showCaption: false,
                showPreview: true,
                browseClass: "btn btn-primary btn-lg",
                allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg', 'bmp'],
                previewFileIcon: "",
                initialPreviewConfig: config,
                initialPreview: previewUrl
            };
            var lastThatFile =
                $(thatFile).fileinput(params)
                    .on("filebatchselected", function (event, data) {
                        //选择即上传
                        $(thatFile).fileinput("upload");
                    })
                    .on('fileuploaded', function (event, data, previewId, index) {
                        //处理上传后数据,上传后插件会将现有上传文件previewId重排,,此时需对现有地址数据做重排处理,此时有预览数据,预览数据不做处理
                        let count = 0;
                        let imgUrl = {};
                        if ($(thatUrl).val()) {
                            let temp = JSON.parse($(thatUrl).val());
                            for(let key in temp){
                                if (previewKeys.indexOf(key) == -1){
                                    imgUrl[previewId.substr(0, previewId.length - 1) + count] = temp[key];
                                    count++;
                                }else {
                                    imgUrl[key] = temp[key];
                                }
                            }
                        };
                        previewId = previewId.substr(0, previewId.length - 1) + count;
                        imgUrl[previewId] = data.response.url;
                        $(thatUrl).val(JSON.stringify(imgUrl));
                    })
                    .on('filesuccessremove', function (event, previewId) {
                        //点击缩略图中删除按钮触发此事件(此事件是新上传图片缩略图触发)
                        var imgUrl = JSON.parse($(thatUrl).val());
                        delete imgUrl[previewId];
                        $(thatUrl).val(JSON.stringify(imgUrl));
                    })
                    .on('filedeleted', function (event, key) {
                        //点击缩略图中删除按钮触发此事件(此事件是初始化预览图片缩略图触发)
                        var tem = JSON.parse($(thatUrl).val());
                        delete tem[key];
                        let index = previewKeys.indexOf(key);
                        if (index != -1)
                            delete previewKeys[index];
                        $(thatUrl).val(JSON.stringify(tem));
                    })
                    .on('filecleared', function (event) {
                        //点击左下角移除或者右上角×号按钮触发此事件,此时需把初始化预览图片置空
                        $(thatUrl).val("");
                        $(thatFile).fileinput('refresh', {initialPreview: []});
                    });
        }
 
    </script>
</body>
</html>