add.html 6.39 KB
<!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>