Newer
Older
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
<%--
since: 2019/7/9 17:11
author: shen.shaohua
description: 查看页面/重新发送页面
url: ${ctx}/mail-send/edit/{id}
--%>
<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="cui" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%
pageContext.setAttribute("idSuffix", String.valueOf(System.currentTimeMillis()).substring(6));
%>
<style>
.noneSealTips{
font-size: 14px;
color: red;
}
.deptName{
font-weight: bold;
}
</style>
<cui:layout id="layout${idSuffix}" fit="true">
<cui:layoutRegion region="center">
<cui:form id="form${idSuffix}" heightStyle="fill" style="padding: 0px;">
<!-- 原数据 -->
<div>
<table class="form-table" cellpadding="0" cellspacing="0">
<tr style="display: none">
<th>发文号</th>
<td colspan="3" id="mailNo${idSuffix}"></td>
</tr>
<tr>
<th>标题</th>
<td colspan="3" id="mailTitle${idSuffix}"></td>
</tr>
<tr>
<th>类型</th>
<td colspan="3">
<cui:radio id="radioAdd" name="type" value="1" label="本单位" onClick='mailSend_edit_sample.jsdwType()' />
<cui:radio id="radioAdd1" name="type" value="2" label="外部单位" onClick='mailSend_edit_sample.jsdwType()' />
</td>
</tr>
<tr>
<th>密级</th>
<td colspan="3">
<cui:radio id="radio33" name="safeLevel" value="无" label="无" readonly="true"/>
<cui:radio id="radio44" name="safeLevel" value="秘密" label="秘密" readonly="true"/>
<cui:radio id="radio55" name="safeLevel" value="机密" label="机密" readonly="true"/>
</td>
</tr>
<tr>
<th style="color: #ff0000">
<span class="validate-required">*</span>选择单位</th>
<td colspan="3">
<input type="hidden" name="yzDept" id="receiveDept${idSuffix}"/>
<cui:textarea id="deptNames${idSuffix}" componentCls="form-control" readonly="true"
required="true" cls="cm-readonly" height="60"/>
</td>
</tr>
<tr>
<th>选择印章</th>
<td colspan="3">
<div id="seal-box">
<ul id="seal-box-list"></ul>
</div>
</td>
</tr>
<tr>
<th>用章理由</th>
<td colspan="3">
<cui:textarea id="yzReason${idSuffix}" name="yzReason" componentCls="form-control" style="overflow: auto;height: 60px" />
</td>
</tr>
<tr>
<th>
电子文件
</th>
<td style="padding: 0px;"colspan="3">
<div id="fileList${idSuffix}"
style="height: 101px;overflow: auto;background-color: #ffffff;margin: 2px;border: 1px solid #4d4d4d;">
</div>
</td>
</tr>
</table>
</div>
</cui:form>
</cui:layoutRegion>
<cui:layoutRegion region="south" style="overflow: hidden;">
<div class="buttens-foot-tools">
<a onclick="mailSend_edit_sample.save()">提交</a>
</div>
</cui:layoutRegion>
</cui:layout>
<cui:dialog id="dialogB${idSuffix}" modal="true" autoOpen="false" resizable="true"
autoDestroy="true" reLoadOnOpen="true" maximized="false"></cui:dialog>
<cui:dialog id="dialogC${idSuffix}" modal="true" autoOpen="false" resizable="true"
autoDestroy="true" reLoadOnOpen="true" maximized="false"></cui:dialog>
<script type="text/javascript">
var mailSend_edit_fun = (function (win, $) {
var bussinessId = '${id}';
function sample() {
}
var $thisDialog = $('#layout${idSuffix}').closest('.ctrl-init-dialog');
var $form = $('#form${idSuffix}');
$(function () {
reloadAttachment();
initLoad();
});
//加载
function initLoad() {
loading('加载中...');
$.ajax({
type: 'GET',
url: '${ctx}/mail-send/' + bussinessId,
dataType: 'json',
success: function (data) {
console.log(data)
hide();
$('#mailTitle${idSuffix}').html(data.mailTitle);
$('#mailNo${idSuffix}').html(data.mailNo);
console.log(data.safeLevel)
if (data.safeLevel=="无"){
$('#radio33').radio("check")
}else if(data.safeLevel=="秘密"){
$('#radio44').radio("check")
}else if(data.safeLevel=="机密"){
$('#radio55').radio("check")
}
console.log($('#mailTitle${idSuffix}').text())
},
error: function (e) {
hide();
error(e);
}
});
}
//关闭
sample.prototype.colseD = function () {
closeThisDialog();
}
//提交
sample.prototype.save = function () {
if (!$form.form('valid')) {
warning('表单填写不正确!');
return;
}
if (!checkSealType()){
warning('每个单位至少选择一个印章!');
return;
}
loading('保存中...');
var formData = $form.form('formData');
formData.mailSendId=bussinessId;
formData.mailTitle=$('#mailTitle${idSuffix}').text()
formData.mailNo=$('#mailNo${idSuffix}').text()
$.ajax({
type: 'POST',
url: '${ctx}/stamp/saveStamp',
data: formData,
dataType: 'json',
success: function (data) {
hide();
if (data.status == 'success') {
message('申请成功!');
} else {
error('申请失败!');
}
mailSend_list_sample.reloadGrid();
closeThisDialog();
},
error: function (e) {
hide();
error(e);
}
});
}
function closeThisDialog() {
$thisDialog.dialog('close');
}
//选择部门
sample.prototype.jsdwPicker = function () {
var url = '${ctx}/auth/selectStampDept?initfun=mailSend_edit_sample.initfun&callback=mailSend_edit_sample.deptCallback';
$('#dialogB${idSuffix}').dialog('option', {
url: url,
title: '添加单位',
asyncType: 'get',
width: 735,
height: 565,
buttons: null
}).dialog('open');
}
sample.prototype.initfun = function () {
return deptArray;
}
//选择部门回调方法
sample.prototype.deptCallback = function (selectDeptArray) {
var str = JSON.stringify(selectDeptArray);
console.log(str)
$('#receiveDept${idSuffix}').val(str);
var dd = '';
$.each(selectDeptArray, function (i, item) {
if (i > 0) dd += ',';
dd += item.deptName;
});
$('#deptNames${idSuffix}').textbox('setValue', dd);
sample.prototype.loadDeptSeal();
}
//清除单位
sample.prototype.clearDept = function () {
$('#receiveDept${idSuffix}').val('');
$('#deptNames${idSuffix}').textbox('setValue','');
}
var deptArray = null;
//加载接受单位
function reloadDeptNames() {
$.ajax({
type: 'GET',
url: '${ctx}/mail-send/getDeptNames/' + bussinessId,
dataType: 'json',
success: function (data) {
//console.log(data);
//var arrayDeptNames = Array.prototype.slice.call(data);
//console.log(arrayDeptNames);
deptArray = data;
//localStorage.setItem("str",JSON.stringify(data));
var dd = '';
$.each(data, function (i, item) {
if (i > 0) dd += ',';
dd += item.deptName;
});
$('#deptNames${idSuffix}').textbox('setValue', dd);
},
error: function (e) {
error(e);
}
});
}
//判断字符是否为空的方法
function isEmpty(obj) {
if (typeof obj == "undefined" || obj == null || obj == "") {
return true;
} else {
return false;
}
}
//电子文件
function reloadAttachment() {
$.ajax({
type: 'GET',
url: '${ctx}/attachment/find/mail/' + bussinessId,
dataType: 'json',
success: function (data) {
//hide();
var hh = '';
$.each(data, function (i, item) {
var securityLevelFileText = "";
if(item.securityLevelFile!=null){
securityLevelFileText = '('+item.securityLevelFile+')';
}
var securityLevel = "(无)";
if(!isEmpty($("#safeLevel${idSuffix}").text())){
securityLevel = '('+ $("#safeLevel${idSuffix}").text()+')';
}
if(item.securityLevelFile!=null){
hh += '<div class="fileItem" id="upload-' + item.id + '">' +
'<a onclick="mailSend_edit_sample.printAttachment(\'' + item.id + '\',\'' + '${relevanceId}'+ '\')"" target="_blank">' + item.name.split(".")[0] + securityLevelFileText + '</a>' +
'</div>'
}else{
hh += '<div class="fileItem" id="upload-' + item.id + '">' +
'<a onclick="mailSend_edit_sample.printAttachment(\'' + item.id + '\',\'' + '${relevanceId}'+ '\')"" target="_blank">' + item.name.split(".")[0] + securityLevel + '</a>' +
'</div>'
}
});
$('#fileList${idSuffix}').html(hh);
},
error: function (e) {
//hide();
error(e);
}
});
}
//点击电子文件
sample.prototype.printAttachment = function (attachId, mailReceiveId) {
var url = '${ctx}/print-num/updatePrintNum3?attachId=' + attachId;
window.open(url);
}
//选择类型
sample.prototype.jsdwType = function () {
//alert($("#radioAdd" ).radio( "getValues" ))
if ($("#radioAdd" ).radio( "getValues" )=="1"){
//alert("本部门")
var str=[{"num":1,"deptId":"${deptId}","deptName":"${deptName}"}]
str = JSON.stringify(str);
$('#receiveDept${idSuffix}').val(str);
$('#deptNames${idSuffix}').textbox('setValue', "${deptName}");
$("#seal-box-list").empty();
sample.prototype.loadDeptSeal();
}else {
//alert("外部门")
$('#deptNames${idSuffix}').textbox('setValue', "");
sample.prototype.jsdwPicker();
}
}
sample.prototype.loadDeptSeal = function () {
$("#seal-box-list").html("");
var id = $("#id${idSuffix}").val();
var str = JSON.parse($('#receiveDept${idSuffix}').val());
var dd = '';
$.each(str, function (i, item) {
if (i > 0) dd += ',';
dd += item.deptId;
});
var orgIds = dd;
loading('加载中...');
var _that = this;
$.ajax({
type: 'POST',
url: '${ctx}/stamp/querySealByOrgId',
data: {id: id, orgIds: orgIds},
dataType: 'json',
success: function (res) {
if (res.data !== null){
_that.initSealCheckBox(res.data);
$('#seal-box-list li .coral-checkbox:nth-child(n-1)').after($("<br>"));
}
hide();
},
error: function (e) {
hide();
error(e);
}
});
}
sample.prototype.initSealCheckBox = function (data) {
var _that = this;
data.forEach((item) => {
_that.appendNode(item);
})
}
//选择部门后添加部门的印章node
sample.prototype.appendNode = function (params){
var orgId = params.orgId;
var orgName = params.orgName;
var seals = params.sealNodes;
var $ul = $("#seal-box-list");
var $li = $("<li style='margin-bottom: 15px'></li>");
var $span = $("<span></span>");
$span.html(orgName);
$span.addClass('deptName');
$li.append($span);
$li.append("<br>");
if (seals !== null && seals !== undefined && seals.length > 0){
seals.forEach((item) => {
var $input = $("<input>");
$input.attr("id", "seal"+item.value);
$input.attr("name", "sealType");
$input.attr('data-val', item.value);
$li.append($input);
})
$ul.append($li);
seals.forEach((item) => {
this.initCheckbox(item, orgId);
})
}
else {
$li.append('<span class="noneSealTips">未找到该部门下的印章</span>');
$ul.append($li);
}
}
//初始化印章checkbox
sample.prototype.initCheckbox = function (params, orgId) {
debugger;
var elemId = "#seal" + params.value;
$(elemId).checkbox({
value: params.value,
label: params.label,
checked: params.checked
});
if (params.checked){
$(elemId).checkbox('check');
$(elemId).val(params.value);
return false;
}
$(elemId).val('');
}
//印章点击事件
$("#seal-box-list").on('click', '.coral-checkbox', function () {
var sealCheckbox = isSealCheckbox($(this));
var inputId = $(this).find(".coral-checkbox-label").attr('for');
var $checkbox = $("#"+inputId);
var inputValue = $checkbox.val();
var checked = inputValue !== '' && inputValue.length > 0;
var enable = $("#seal-box-list").data('readonly');
if (sealCheckbox){
if (enable){
return false;
}
if (!checked){
$checkbox.checkbox('check');
$checkbox.val($checkbox.data('val'));
}else{
$checkbox.checkbox('uncheck');
$checkbox.val('');
}
}
//阻止冒泡事件
return false;
})
function isSealCheckbox(elem) {
return $(elem).parent().parent().is('#seal-box-list');
}
function checkSealType() {
var flag = true;
$("#seal-box-list li").each(function () {
var checkedDom = $(this).find(".cui-icon-checkbox-checked");
if (checkedDom.length < 1){
flag = false;
return false;
}
})
return flag;
}
return sample;
})(window, $);
var mailSend_edit_sample = new mailSend_edit_fun();
window['mailSend_edit_fun'] = null;
delete window['mailSend_edit_fun'];
</script>