| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- <!DOCTYPE HTML>
- <html xmlns:th="http://www.thymeleaf.org"
- xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
- layout:decorate="~{admin/common/common}">
- <head>
- <title>添加</title>
- <style>
- multiple:hover .dropdown-clear-all, .dropdown-single:hover .dropdown-clear-all {
- display: none;
- }
- .line {
- display: block;
- text-align: left;
- background-color: #fff;
- color: #333;
- border-bottom: 1px solid #0a6999;
- border-color: #fff;
- border-bottom: 1px solid #0a6999;
- margin-top: 10px;
- vertical-align: middle;
- padding: 4px 12px;
- height: 31px;
- line-height: 31px;
- font-size: 14px;
- font-weight: bold;
- }
- </style>
- </head>
- <body layout:fragment="content">
- <article class="page-container">
- <form class="form form-horizontal" id="form-add">
- <div class="line">基本信息</div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目标题:</label>
- <div class="formControls col-xs-8 col-sm-9">
- <input type="text" class="input-text" placeholder="请输入项目标题" id="title" name="title"/>
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目用地:</label>
- <div class="formControls col-xs-8 col-sm-9">
- <input type="text" class="input-text" placeholder="请输入项目用地" id="location" name="location"/>
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目介绍:</label>
- <div class="formControls col-xs-8 col-sm-9">
- <textarea id="content" name="content" required></textarea>
- </div>
- </div>
- <div class="row cl" th:id="upload_file">
- <label class="form-label col-xs-4 col-sm-2"><span>项目附件:</span></label>
- <div class="formControls col-xs-8 col-sm-9">
- <!-- <div class="uploader-thum-container">-->
- <!-- <div id="fileListPre" class="uploader-list"></div>-->
- <!-- <div id="filePicker">选择文件</div>-->
- <!-- </div>-->
- <div><i class="Hui-iconfont" style="cursor: pointer;"
- th:onclick="'javascript:addFileLine(\'upload_file\')'"> 添加</i></div>
- <table class="table table-border table-bordered table-bg table-hover ">
- <thead>
- <tr class="text-c">
- <th>文件</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody class="add_file_line" th:id="'tbody_upload_file'">
- <!-- <tr class="text-c">-->
- <!-- <td class="td_material">-->
- <!-- <div>-->
- <!-- <input class="uploadFileName btn btn-upload radius" name="uploadFileName"-->
- <!-- readonly="readonly"-->
- <!-- type="text" value="上传文件"-->
- <!-- th:onclick="'javascript:addFileByName(\'/land_supply/addApplyFile\',this);'"/>-->
- <!-- <input class="uploadFileId" type="hidden"-->
- <!-- th:name="'fileList[0].file_id'"/>-->
- <!-- </div>-->
- <!-- </td>-->
- <!-- <td class="icon_font"><i class='Hui-iconfont' onclick='removeLine(this)'> 删除</i>-->
- <!-- </td>-->
- <!-- </tr>-->
- </tbody>
- </table>
- </div>
- </div>
- <div th:if="*{canAsk}" th:each="item,itemStat: ${consulDepartmentList}">
- <div class="line">[[${item.name}]]</div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2"></label>
- <div class="formControls col-xs-8 col-sm-9">
- <input type="checkbox" th:name="'defaultList['+${itemStat.index}+']'" th:value="${item.id}">要求反馈意见
- </div>
- </div>
- <div class="row cl" th:id=" 'department'+${item.id}">
- <label class="form-label col-xs-4 col-sm-2"></label>
- <div class="formControls col-xs-8 col-sm-9">
- <div><i class="Hui-iconfont" style="cursor: pointer;"
- th:onclick="'javascript:addQuestionLine(\''+'department'+${item.id}+'\')'"> 添加</i>
- </div>
- <table class="table table-border table-bordered table-bg table-hover ">
- <thead>
- <tr class="text-c">
- <th>咨询问题</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody class="add_file_line" th:id="'tbody_department'+${item.id}">
- <tr class="text-c">
- <td class="td_material">
- <input type="text" class="input-text consultation" placeholder="请输入咨询的问题"
- th:name="'consultationList['+${itemStat.index}+'].consultation'"/>
- <input class="department_id" type="hidden"
- th:name="'consultationList['+${itemStat.index}+'].department_id'"
- th:value="${item.id}"/>
- </td>
- <td class="icon_font"><i class='Hui-iconfont' onclick='removeLine(this)'> 删除</i>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- <div class="row cl text-c" style="background-color: white">
- <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
- <a onclick="save()" class="btn btn-secondary radius"><i class="Hui-iconfont"></i>保存草稿</a>
- <a onclick="release()" class="btn btn-primary radius"><i class="Hui-iconfont"></i>提交 </a>
- <a onClick="removeIframe();" class="btn btn-default radius" type="button"> 取消 </a>
- </div>
- </div>
- </form>
- </article>
- <script type="text/javascript" th:src="@{/h-ui/lib/webuploader/0.1.5/webuploader.min.js}"></script>
- <script th:inline="javascript">
- //富文本kindeditor初始化
- var editor;
- KindEditor.ready(function (K) {
- editor = K.create('#content', {
- uploadJson: pagePath + '/upload/kindEditorUpload',
- cssData: 'body {font-family: "微软雅黑"; font-size: 14px}',
- allowFileManager: false,
- allowUpload: true,
- width: "100%",
- height: "350px",
- items: array,
- syncType: "auto",
- filterMode: false,
- afterBlur: function () {
- this.sync();
- }
- });
- });
- $(function () {
- // 初始化上传
- var options = {
- uploadBtnId: '#filePicker',
- picturePreId: 'fileListPre',
- hiddenPictureUrl: 'img',
- hiddenPictureName: 'imgName',
- width: 81,
- height: 81,
- fileSizeLimit: 100 * 1024 * 1024,
- fileSingleSizeLimit: 100 * 1024 * 1024
- };
- var webUploadDoc = new $WebUploadDoc(options);
- webUploadDoc.init();
- // var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
- // var isOpera = userAgent.indexOf("Opera") > -1;
- // //判断是否IE浏览器
- // if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
- // $("#apply_startdate").remove();
- // $("#apply_enddate").remove();
- // } else {
- // $("#apply_startdateIE").remove();
- // $("#apply_enddateIE").remove();
- // var startDate = laydate.render({
- // elem: '#apply_startdate',
- // type: 'datetime',
- // done: function (value, date) {
- // setTimeout(function () {
- // $("#form-add").validate().element($("#apply_startdate"));
- // }, 100)
- // if (value !== '') {
- // endDate.config.min.year = date.year;
- // endDate.config.min.month = date.month - 1;
- // endDate.config.min.date = date.date;
- // endDate.config.min.hours = date.hours;
- // endDate.config.min.minutes = date.minutes;
- // endDate.config.min.seconds = date.seconds;
- // } else {
- // endDate.config.min.year = '1900';
- // endDate.config.min.month = '0';
- // endDate.config.min.date = '1';
- // endDate.config.min.hours = '0';
- // endDate.config.min.minutes = '0';
- // endDate.config.min.seconds = '0';
- // }
- // }
- // });
- //
- // var endDate = laydate.render({
- // elem: '#apply_enddate',
- // type: 'datetime',
- // done: function (value, date) {
- // setTimeout(function () {
- // $("#form-add").validate().element($("#apply_enddate"));
- // }, 100)
- // if (value !== '') {
- // startDate.config.max.year = date.year;
- // startDate.config.max.month = date.month - 1;
- // startDate.config.max.date = date.date;
- // startDate.config.max.hours = date.hours;
- // startDate.config.max.minutes = date.minutes;
- // startDate.config.max.seconds = date.seconds;
- // } else {
- // startDate.config.max.year = '2100';
- // startDate.config.max.month = '0';
- // startDate.config.max.date = '1';
- // startDate.config.max.hours = '0';
- // startDate.config.max.minutes = '0';
- // startDate.config.max.seconds = '0';
- // }
- // }
- // });
- // }
- });
- //取消
- function removeIframe() {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- }
- //默认状态为草稿
- var state = '0';
- $("#form-add").validate({
- rules: {
- title: {
- required: true,
- },
- location: {
- required: true,
- },
- content: {
- required: true,
- }
- },
- onkeyup: false,
- focusCleanup: true,
- focusInvalid: false,
- success: "valid",
- submitHandler: function (form) {
- if (editor.isEmpty()) {
- errorMessage('请输入项目介绍');
- return false;
- } else if (editor.text().length > 2000) {
- //errorMessage('项目内容最多2000字');
- //return false;
- }
- // var ids = [];
- // $("input[name='defaultList']:checked").each(function(i){
- // ids.push($(this).val())
- // })
- $(form).ajaxSubmit({
- type: 'post',
- url: pagePath + "/land_supply/save",
- dataType: "json",
- data: {
- state: state,
- content_text: editor.text()/*,
- defaultList: ids*/
- },
- success: function (result) {
- if (result.success) {
- succeedMessage(result.message);
- setTimeClose();
- } else {
- // $(form).find(":submit").attr("disabled", false);
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- }
- });
- //发布
- function release() {
- state = "1";
- $("#form-add").submit();
- }
- //保存草稿
- function save() {
- state = "0";
- $("#form-add").ajaxSubmit({
- type: 'post',
- url: pagePath + "/land_supply/save",
- dataType: "json",
- data: {
- state: state,
- content_text: editor.text()
- },
- success: function (data) {
- if (data.success) {
- succeedMessage(data.message);
- setTimeClose();
- } else {
- // $(form).find(":submit").attr("disabled", false);
- errorMessage(data.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- }
- var departmentList = [[${consulDepartmentList}]];
- var index = departmentList.length;
- function addQuestionLine(divId) {
- var length = index;
- if ($("#" + divId).find('.add_file_line>tr').length > 0) {
- var html = "<i class='Hui-iconfont' onclick='removeLine(this)'> 删除</i>";
- $("#" + divId).find(".add_file_line tr:eq(0)").clone().insertAfter($("#" + divId).find('.add_file_line>tr').eq(-1))
- .find(".consultation").removeAttr("name").attr("name", "consultationList[" + length + "].consultation").val("").end()
- .find(".department_id").removeAttr("name").attr("name", "consultationList[" + length + "].department_id").end()
- .find(".icon_font").html(html).end();
- } else {
- var str = "";
- str += "<tr class='text-c'>"
- str += "<td class='td_material'>"
- str += "<input type='text' class='input-text consultation' placeholder='请输入咨询的问题' name='consultationList[" + length + "].consultation'/>"
- str += "<input class='department_id' type='hidden' value='" + divId.split("department")[1] + "' name='consultationList[" + length + "].department_id' />"
- str += "</td>"
- str += "<td class='icon_font'><i class='Hui-iconfont' onclick='removeLine(this)'> 删除</i>"
- str += "</td>"
- str += "</tr>"
- $("#tbody_" + divId).html(str);
- }
- $('#layui-layer2').height(48);
- index++;
- }
- var file_index = 0;
- function addFileLine(divId) {
- if (file_index == undefined) {
- file_index = 0
- }
- var length = file_index;
- if ($("#" + divId).find('.add_file_line>tr').length > 0) {
- var html = "<i class='Hui-iconfont' onclick='removeLine(this)'> 删除</i>";
- $("#" + divId).find(".add_file_line tr:eq(0)").clone().insertAfter($("#" + divId).find('.add_file_line>tr').eq(-1))
- .find(".uploadFileId").removeAttr("name").attr("name", "fileList[" + length + "].file_id").val("").end()
- .find(".uploadFileName").val("上传文件").end()
- .find(".icon_font").html(html).end();
- } else {
- var str = "";
- str += "<tr class='text-c'>"
- str += "<td class='td_material'>"
- str += "<div>"
- str += "<input class='uploadFileName btn btn-upload radius' name='uploadFileName' readonly='readonly' type='text' value='上传文件' onclick=\"addFileByName('/land_supply/addApplyFile',this);\"/>"
- str += "<input class='uploadFileId' hidden name='fileList[" + length + "].file_id'/>"
- str += "</div>"
- str += "</td>"
- str += "<td class='icon_font'><i class='Hui-iconfont' onclick='removeLine(this)'> 删除</i>"
- str += "</td>"
- str += "</tr>"
- $("#tbody_" + divId).html(str);
- }
- $('#layui-layer2').height(48);
- file_index++;
- }
- //添加相应name的文件
- function addFileByName(url, obj) {
- var name = $(obj).next().attr("name");
- url += "?fileIdName=" + name;
- layer_show('添加文件', pagePath + url, 800, 350);
- }
- function removeLine(obj) {
- $(obj).parent().parent().remove();
- }
- </script>
- </body>
- </html>
|