add.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <!DOCTYPE HTML>
  2. <html xmlns:th="http://www.thymeleaf.org"
  3. xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  4. layout:decorate="~{admin/common/common}">
  5. <head>
  6. <title>添加</title>
  7. <style>
  8. .ke-container-default {
  9. width: 100% !important
  10. }
  11. .ke-swfupload-body {
  12. height: 265px
  13. }
  14. .ke-dialog-body {
  15. height: 340px !important;
  16. }
  17. .ke-dialog-default {
  18. height: 410px !important;
  19. }
  20. .error {
  21. color: red;
  22. }
  23. multiple:hover .dropdown-clear-all, .dropdown-single:hover .dropdown-clear-all {
  24. display: none;
  25. }
  26. </style>
  27. </head>
  28. <body layout:fragment="content">
  29. <article class="page-container">
  30. <form class="form form-horizontal" id="form-add">
  31. <div class="row cl">
  32. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>申报项:</label>
  33. <div class="formControls col-xs-8 col-sm-6">
  34. <div class="select-box autocomplete">
  35. <select style="display:none" class="select" th:name="project_service_type"
  36. th:id="project_service_type" th:placeholder="请选择">
  37. <option value=""></option>
  38. </select>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="row cl">
  43. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目来源:</label>
  44. <div class="formControls col-xs-8 col-sm-3">
  45. <span class="select-box">
  46. <select class="select" th:name="project_source" id="project_source">
  47. <option value="">-- 请选择项目来源 --</option>
  48. <option th:each="item : ${projectSourceList}" th:value="${item.value}" th:text="${item.name}">
  49. </select>
  50. </span>
  51. </div>
  52. </div>
  53. <div class="row cl">
  54. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否综合申报项目:</label>
  55. <div class="formControls col-xs-8 col-sm-9">
  56. <input type="radio" id="is_comprehensive1" name="is_comprehensive" th:value="1"
  57. onclick="changeDepartment()" checked>是
  58. <input type="radio" id="is_comprehensive2" name="is_comprehensive" th:value="0"
  59. onclick="changeDepartment()">否
  60. </div>
  61. </div>
  62. <div class="row cl" id="is_serial_btn" hidden>
  63. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否二级审核(串行):</label>
  64. <div class="formControls col-xs-8 col-sm-9">
  65. <input type="radio" id="is_serial1" name="is_serial" th:value="1"
  66. onclick="changeDepartment()" checked>是
  67. <input type="radio" id="is_serial2" name="is_serial" th:value="0"
  68. onclick="changeDepartment()">否
  69. </div>
  70. </div>
  71. <div class="row cl" id="department" hidden>
  72. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目责任单位:</label>
  73. <div class="formControls col-xs-8 col-sm-3">
  74. <span class="select-box">
  75. <select class="select" th:name="department_id" id="department_id" required>
  76. <option value="">-- 请选择项目责任单位 --</option>
  77. <option th:each="item : ${departmentList}" th:value="${item.id}"
  78. th:text="${item.name}">
  79. </option>
  80. </select>
  81. </span>
  82. </div>
  83. </div>
  84. <div class="row cl" id="department_two" hidden>
  85. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目责任单位:</label>
  86. <div class="formControls col-xs-8 col-sm-3">
  87. <span class="select-box">
  88. <select class="select" th:name="department_id_first" id="department_id_first" required>
  89. <option value="">-- 请选择先审核责任单位 --</option>
  90. <option th:each="item : ${departmentList}" th:value="${item.id}"
  91. th:text="${item.name}">
  92. </option>
  93. </select>
  94. </span>
  95. </div>
  96. <div class="formControls col-xs-8 col-sm-3">
  97. <span class="select-box">
  98. <select class="select" th:name="department_id_second" id="department_id_second" required>
  99. <option value="">-- 请选择后审核责任单位 --</option>
  100. <option th:each="item : ${departmentList}" th:value="${item.id}"
  101. th:text="${item.name}">
  102. </option>
  103. </select>
  104. </span>
  105. </div>
  106. </div>
  107. <div class="row cl" id="departmentAndType" hidden>
  108. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目类别及责任单位:</label>
  109. <div class="formControls col-xs-8 col-sm-3">
  110. <div><i class="Hui-iconfont" style="cursor: pointer;" onclick="addLine()">&#xe600;</i></div>
  111. <table class="table table-border table-bordered table-bg table-hover">
  112. <thead>
  113. <tr class="text-c">
  114. <th width="200">项目大类</th>
  115. <th width="200">项目小类</th>
  116. <th width="200">责任单位</th>
  117. <th width="100">操作</th>
  118. </tr>
  119. </thead>
  120. <tbody class="add_floor_line">
  121. <tr class="text-c ">
  122. <td><input type="text" class="name1" name="projectServiceCategory[0].project_type_name1"
  123. style="width: 100%;" required></td>
  124. <td><input type="text" class="name2" name="projectServiceCategory[0].project_type_name2"
  125. style="width: 100%;" required></td>
  126. <td>
  127. <div class="formControls col-sm-12 text-left">
  128. <span class="select-box">
  129. <select class="select department" name="projectServiceCategory[0].department_id"
  130. required>
  131. <option value="">-- 请选择项目责任单位 --</option>
  132. <option th:each="item : ${departmentList}" th:value="${item.id}"
  133. th:text="${item.name}" required></option>
  134. </select>
  135. </span>
  136. </div>
  137. </td>
  138. <td class="icon_font"></td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. </div>
  143. </div>
  144. <div class="row cl">
  145. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>属地审核:</label>
  146. <div class="formControls col-xs-8 col-sm-9">
  147. <input type="radio" id="is_street_audit1" name="is_street_audit" th:value="1" checked>是
  148. <input type="radio" id="is_street_audit2" name="is_street_audit" th:value="0">否
  149. </div>
  150. </div>
  151. <!--<div class="row cl">
  152. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>对应年份:</label>
  153. <div class="formControls col-xs-8 col-sm-3">
  154. <span class="select-box">
  155. <select class="select" th:name="year" id="year">
  156. <option value="">&#45;&#45; 请选年份 &#45;&#45;</option>
  157. <option th:value="2028" th:text="2028"></option>
  158. <option th:value="2027" th:text="2027"></option>
  159. <option th:value="2026" th:text="2026"></option>
  160. <option th:value="2025" th:text="2025"></option>
  161. <option th:value="2024" th:text="2024"></option>
  162. <option th:value="2023" th:text="2023"></option>
  163. <option th:value="2022" th:text="2022"></option>
  164. <option th:value="2021" th:text="2021"></option>
  165. <option th:value="2020" th:text="2020"></option>
  166. <option th:value="2019" th:text="2019"></option>
  167. <option th:value="2018" th:text="2018"></option>
  168. </select>
  169. </span>
  170. </div>
  171. </div>
  172. <div class="row cl">
  173. <label class="form-label col-xs-4 col-sm-2">对应季月:</label>
  174. <div class="formControls col-xs-8 col-sm-3">
  175. <span class="select-box">
  176. <select class="select" th:name="season_or_month" th:id="season_or_month">
  177. <option value="">&#45;&#45; 请选择季度或月度 &#45;&#45;</option>
  178. <option th:value="J" th:text="季度"></option>
  179. <option th:value="Y" th:text="月度"></option>
  180. </select>
  181. </span>
  182. </div>
  183. <div class="formControls col-xs-8 col-sm-3 season" hidden>
  184. <span class="select-box season" hidden>
  185. <select class="select" th:name="season" id="season" required>
  186. <option value="">&#45;&#45; 请选择季度 &#45;&#45;</option>
  187. <option th:value="1" th:text="第一季度"></option>
  188. <option th:value="2" th:text="第二季度"></option>
  189. <option th:value="3" th:text="第三季度"></option>
  190. <option th:value="4" th:text="第四季度"></option>
  191. </select>
  192. </span>
  193. </div>
  194. <div class="formControls col-xs-8 col-sm-3 month" hidden>
  195. <span class="select-box month" hidden>
  196. <select class="select" th:name="month" id="month" required>
  197. <option value="">&#45;&#45; 请选择月份 &#45;&#45;</option>
  198. <option th:value="1" th:text="一月"></option>
  199. <option th:value="2" th:text="二月"></option>
  200. <option th:value="3" th:text="三月"></option>
  201. <option th:value="4" th:text="四月"></option>
  202. <option th:value="5" th:text="五月"></option>
  203. <option th:value="6" th:text="六月"></option>
  204. <option th:value="7" th:text="七月"></option>
  205. <option th:value="8" th:text="八月"></option>
  206. <option th:value="9" th:text="九月"></option>
  207. <option th:value="10" th:text="十月"></option>
  208. <option th:value="11" th:text="十一月"></option>
  209. <option th:value="12" th:text="十二月"></option>
  210. </select>
  211. </span>
  212. </div>
  213. </div>-->
  214. <div class="row cl">
  215. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目标题:</label>
  216. <div class="formControls col-xs-8 col-sm-9">
  217. <input type="text" class="input-text" placeholder="请输入项目标题" id="project_name" name="project_name"/>
  218. </div>
  219. </div>
  220. <div class="row cl">
  221. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目内容:</label>
  222. <div class="formControls col-xs-8 col-sm-9">
  223. <textarea id="content" name="content" required></textarea>
  224. </div>
  225. </div>
  226. <div class="row cl">
  227. <label class="form-label col-xs-4 col-sm-2"><span>上传附件:</span></label>
  228. <div class="formControls col-xs-8 col-sm-9">
  229. <div class="uploader-thum-container">
  230. <div id="fileListPre" class="uploader-list"></div>
  231. <div id="filePicker">选择文件</div>
  232. </div>
  233. </div>
  234. </div>
  235. <div class="row cl">
  236. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>门户填报入口:</label>
  237. <div class="formControls col-xs-8 col-sm-9">
  238. <input type="radio" id="is_public1" name="is_public" th:value="1" checked>开放
  239. <input type="radio" id="is_public2" name="is_public" th:value="0">不开放
  240. </div>
  241. </div>
  242. <div class="row cl">
  243. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
  244. <a type="submit" onclick="save()" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe632;</i>保存草稿</a>
  245. <a th:onclick="'javascript:preview(\'项目申报预览\',\'/government/projectMatters/preview\',\'800\',\'600\');'"
  246. class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe632;</i>预览</a>
  247. <a class="btn btn-primary radius" onclick="release()"><i class="Hui-iconfont">&#xe632;</i>发布 </a>
  248. <a onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</a>
  249. </div>
  250. </div>
  251. </form>
  252. </article>
  253. <script type="text/javascript" th:src="@{/h-ui/lib/webuploader/0.1.5/webuploader.min.js}"></script>
  254. <script th:inline="javascript">
  255. //富文本kindeditor初始化
  256. var editor;
  257. KindEditor.ready(function (K) {
  258. editor = K.create('#content', {
  259. uploadJson: pagePath + '/upload/kindEditorUpload',
  260. allowFileManager: false,
  261. allowUpload: true,
  262. width: "100%",
  263. height: "350px",
  264. items: array,
  265. syncType: "auto",
  266. filterMode: false,
  267. afterBlur: function () {
  268. this.sync();
  269. }
  270. });
  271. });
  272. $(function () {
  273. // 初始化上传
  274. var options = {
  275. uploadBtnId: '#filePicker',
  276. picturePreId: 'fileListPre',
  277. hiddenPictureUrl: 'img',
  278. hiddenPictureName: 'imgName',
  279. width: 81,
  280. height: 81,
  281. fileSizeLimit: 100 * 1024 * 1024,
  282. fileSingleSizeLimit: 100 * 1024 * 1024
  283. };
  284. var webUploadDoc = new $WebUploadDoc(options);
  285. webUploadDoc.init();
  286. });
  287. //自动联想
  288. $('.autocomplete').dropdown({
  289. readOnly: true,
  290. //data: datas,
  291. input: '<input type="text" maxLength="20" placeholder="请输入关键字">',
  292. choice: function () {
  293. //$("span.placeholder").html($(".dropdown-chose")[0].innerText);
  294. $("#project_service_type").val($(".dropdown-chose").attr("data-value"));
  295. }
  296. });
  297. getServiceType()
  298. function getServiceType() {
  299. $.ajax({
  300. url: pagePath + "/government/projectMatters/getProjectServicetype/3",
  301. type: "get",
  302. dataType: "json",
  303. data: {
  304. timeStamp: new Date()
  305. },
  306. success: function (result) {
  307. if (result.success) {
  308. var obj = result.obj;
  309. var typeArr = new Array();
  310. if (obj) {
  311. for (var i = 0; i < obj.length; i++) {
  312. var type = {
  313. "name": obj[i].service_type_name,
  314. "id": obj[i].id,
  315. "disabled": false,
  316. //"groupName": '分组名',
  317. //"groupId": 1,
  318. "selected": false
  319. }
  320. typeArr.push(type);
  321. }
  322. }
  323. //autoComplete(typeArr);
  324. $('.autocomplete').data('dropdown').update(typeArr, true);
  325. } else {
  326. errorMessage(result.message);
  327. }
  328. },
  329. error: function () {
  330. errorMessage('系统错误!');
  331. }
  332. });
  333. }
  334. //取消
  335. function removeIframe() {
  336. var index = parent.layer.getFrameIndex(window.name);
  337. parent.layer.close(index);
  338. }
  339. //默认状态为草稿
  340. var state = '0';
  341. $("#form-add").validate({
  342. rules: {
  343. project_service_type: {
  344. required: true,
  345. },
  346. project_source: {
  347. required: true,
  348. },
  349. is_comprehensive: {
  350. required: true,
  351. },
  352. is_street_audit: {
  353. required: true,
  354. },
  355. project_name: {
  356. required: true,
  357. },
  358. year: {
  359. required: true,
  360. },
  361. content: {
  362. required: true,
  363. },
  364. start_time: {
  365. required: true,
  366. },
  367. end_time: {
  368. required: true,
  369. },
  370. next_step: {
  371. required: true,
  372. },
  373. is_public: {
  374. required: true,
  375. },
  376. },
  377. onkeyup: false,
  378. focusCleanup: true,
  379. focusInvalid: false,
  380. success: "valid",
  381. submitHandler: function (form) {
  382. if ($("#project_service_type").val() == null) {
  383. errorMessage('请选择申报项');
  384. return false;
  385. }
  386. if (editor.isEmpty()) {
  387. errorMessage('请输入项目内容');
  388. return false;
  389. } else if (editor.text().length > 2000) {
  390. //errorMessage('项目内容最多2000字');
  391. //return false;
  392. }
  393. /*if (state == '1') {
  394. if ($('input[name="is_public"]:checked').val() == 0) {
  395. if ($("#pushNames").text().length <= 0) {
  396. errorMessage('请选择推送对象');
  397. return false;
  398. }
  399. }
  400. }*/
  401. $(form).ajaxSubmit({
  402. type: 'post',
  403. url: pagePath + "/government/projectMatters/save",
  404. dataType: "json",
  405. data: {
  406. state: state
  407. },
  408. success: function (result) {
  409. if (result.success) {
  410. succeedMessage(result.message);
  411. setTimeClose();
  412. } else {
  413. // $(form).find(":submit").attr("disabled", false);
  414. errorMessage(result.message);
  415. }
  416. },
  417. error: function () {
  418. errorMessage('系统错误!');
  419. }
  420. });
  421. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  422. }
  423. });
  424. //发布
  425. function release() {
  426. state = "1";
  427. $("#form-add").submit();
  428. }
  429. //保存草稿
  430. function save() {
  431. state = "0";
  432. $("#form-add").ajaxSubmit({
  433. type: 'post',
  434. url: pagePath + "/government/projectMatters/save",
  435. dataType: "json",
  436. data: {
  437. state: state
  438. },
  439. success: function (data) {
  440. if (data.success) {
  441. succeedMessage(data.message);
  442. setTimeClose();
  443. } else {
  444. // $(form).find(":submit").attr("disabled", false);
  445. errorMessage(data.message);
  446. }
  447. },
  448. error: function () {
  449. errorMessage('系统错误!');
  450. }
  451. });
  452. }
  453. //预览
  454. function preview(title, url, w, h) {
  455. layer_show(title, pagePath + url, w, h);
  456. }
  457. //是否综合
  458. $('#departmentAndType').show()
  459. function changeDepartment() {
  460. if ($("input[name='is_comprehensive']:checked").val() == 1) {
  461. $('#is_serial_btn').hide();
  462. $('#department').hide();
  463. $('#department_two').hide();
  464. $('#departmentAndType').show()
  465. } else if ($("input[name='is_comprehensive']:checked").val() == 0) {
  466. $('#departmentAndType').hide()
  467. $('#is_serial_btn').show();
  468. if ($("input[name='is_serial']:checked").val() == 1) {
  469. $('#department').hide();
  470. $('#department_two').show();
  471. } else {
  472. $('#department_two').hide();
  473. $('#department').show();
  474. }
  475. }
  476. }
  477. //添加属地相关
  478. function addLine(projectService) {
  479. if (projectService) {
  480. if (projectService.length > 0) {
  481. for (var i = 0; i < projectService.length; i++) {
  482. var length = i;
  483. var html = "<i class='Hui-iconfont' onclick='removeLine(this)'>&#xe6a1;</i>";
  484. $(".add_floor_line tr:eq(0)").clone().insertAfter($('.add_floor_line>tr').eq(-1))
  485. .find(".name1").removeAttr("name").attr("name", "projectServiceCategory[" + i + "].project_type_name1").end()
  486. .find(".name1").val(projectService[i].project_type_name1).end()
  487. .find(".name2").removeAttr("name").attr("name", "projectServiceCategory[" + i + "].project_type_name2").end()
  488. .find(".name2").val(projectService[i].project_type_name2).end()
  489. .find(".department").removeAttr("name").attr("name", "projectServiceCategory[" + i + "].department_id").end()
  490. .find(".icon_font").html(html).end();
  491. $(".add_floor_line tr:eq(" + (i + 1) + ")").find("option[value='" + projectService[i].department_id + "']").attr("selected", true);
  492. }
  493. $(".add_floor_line tr:eq(0)").remove();
  494. }
  495. } else {
  496. var length = $(".add_floor_line tr").length;
  497. var html = "<i class='Hui-iconfont' onclick='removeLine(this)'>&#xe6a1;</i>";
  498. $(".add_floor_line tr:eq(0)").clone().insertAfter($('.add_floor_line>tr').eq(-1))
  499. .find(".name1").removeAttr("name").attr("name", "projectServiceCategory[" + length + "].project_type_name1").end()
  500. .find(".name1").val("").end()
  501. .find(".name2").removeAttr("name").attr("name", "projectServiceCategory[" + length + "].project_type_name2").end()
  502. .find(".name2").val("").end()
  503. .find(".department").removeAttr("name").attr("name", "projectServiceCategory[" + length + "].department_id").end()
  504. .find(".icon_font").html(html).end();
  505. $('#layui-layer2').height(48);
  506. }
  507. }
  508. function removeLine(obj) {
  509. if ($(".add_floor_line").find("tr").length == 1) {
  510. errorMessage("至少添加一个类目");
  511. } else {
  512. $(obj).parent().parent().remove();
  513. }
  514. }
  515. </script>
  516. </body>
  517. </html>