add.html
6.39 KB
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
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增通知公告')" />
<th:block th:include="include :: summernote-css" />
<th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-notice-add">
<!-- 暂存部门id-->
<input name="reportDept" type="hidden" id="treeId"/>
<div class="form-group">
<label class="col-sm-2 control-label is-required">公告标题:</label>
<div class="col-sm-10">
<input id="noticeTitle" name="noticeTitle" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">公告类型:</label>
<div class="col-sm-10">
<select name="noticeType" class="form-control m-b" th:with="type=${@dict.getType('sys_notice_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<!-- <div id="department" class="col-sm-6" style="display: none">-->
<div id="department" class="form-group" style="display: none">
<!-- <div class="form-group">-->
<label class="col-sm-2 control-label">归属部门:</label>
<div class="col-sm-8">
<div class="input-group">
<input name="deptName" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
<!-- </div>-->
</div>
<div class="form-group">
<label class="col-sm-2 control-label">公告内容:</label>
<div class="col-sm-10">
<input id="noticeContent" name="noticeContent" type="hidden">
<div class="summernote"></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">附件:</label>
<div class="col-sm-7">
<input type="hidden" name="fileIdList"/>
<div class="file-loading">
<input id="fileIdList" name="files" type="file" multiple>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">公告状态:</label>
<div class="col-sm-10">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_notice_status')}">
<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: summernote-js" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script type="text/javascript">
var prefix = ctx + "business/credit/notice";
/**
* 根据 选择的同时类型,show出归属本门的树
*/
$("select[name='noticeType']").change(function () {
let selectVal = $(this).val();
// console.log(selectVal);
//通知类型为 :核查(3) 时,增加所属部门
if (selectVal == 3){
$("#department").show();
}else {
$("#department").hide();
$("#treeId").val("");
}
})
/* 归属部门-选择部门树 */
function selectDeptTree() {
var treeId = $("#treeId").val();
var deptId = $.common.isEmpty(treeId) ? "130" : $("#treeId").val();
var url = ctx + "system/user/selectDeptTreeWithNoPermit/" + deptId;
var options = {
title: '选择部门',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = $.modal.getChildFrame(index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
$.modal.close(index);
}
$('.summernote').summernote({
placeholder: '请输入公告内容',
height : 192,
lang : 'zh-CN',
dialogsInBody: true,
followingToolbar: false,
dialogsInBody: true,
shortcuts: false,
disableDragAndDrop: true,
tabDisable: false,
toolbar:[
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['fontname', ['fontname']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'video']],
['view', ['fullscreen', 'codeview', 'help']]
],
callbacks: {
onImageUpload: function (files) {
///sendFile(files[0], this);
}
}
});
// 上传文件
function sendFile(file, obj) {
var data = new FormData();
data.append("file", file);
$.ajax({
type: "POST",
url: ctx + "common/upload",
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
$(obj).summernote('editor.insertImage', result.url, result.fileName);
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertWarning("图片上传失败。");
}
});
}
$("#form-notice-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
var sHTML = $('.summernote').summernote('code');
$("#noticeContent").val(sHTML);
$.operate.save(prefix + "/add", $('#form-notice-add').serialize());
}
}
$(function (){
// 多附件上传
$("#fileIdList").fileinput({
uploadUrl: ctx + 'business/common/cloud/uploads',
uploadAsync: false,
allowedFileExtensions:['xls', 'doc', 'docx', 'xlsx', 'png', 'jpg', 'pdf'],//允许上传的文件类型,错误会给出提示
maxFileCount: 10,
autoReplace: true,
uploadExtraData:{bType: "notice"}
}).on('filebatchuploadsuccess', function (event, data, previewId, index) {
var rsp = data.response;
$("input[name='" + event.currentTarget.id + "']").val(rsp.data.ids)
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
});
</script>
</body>
</html>