add.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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-9">
  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-9">
  45. <span class="select-box">
  46. <select class="select" th:name="project_source" id="project_source">
  47. <option value="">-- 请选择项目来源 --</option>
  48. <option th:value="1" th:text="国家"></option>
  49. <option th:value="2" th:text="江苏省"></option>
  50. <option th:value="3" th:text="苏州市"></option>
  51. <option th:value="4" th:text="高新区"></option>
  52. </select>
  53. </span>
  54. </div>
  55. </div>
  56. <div class="row cl">
  57. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>对应年份:</label>
  58. <div class="formControls col-xs-8 col-sm-3">
  59. <span class="select-box">
  60. <select class="select" th:name="year" id="year">
  61. <option value="">-- 请选年份 --</option>
  62. <option th:value="2028" th:text="2028"></option>
  63. <option th:value="2027" th:text="2027"></option>
  64. <option th:value="2026" th:text="2026"></option>
  65. <option th:value="2025" th:text="2025"></option>
  66. <option th:value="2024" th:text="2024"></option>
  67. <option th:value="2023" th:text="2023"></option>
  68. <option th:value="2022" th:text="2022"></option>
  69. <option th:value="2021" th:text="2021"></option>
  70. <option th:value="2020" th:text="2020"></option>
  71. <option th:value="2019" th:text="2019"></option>
  72. <option th:value="2018" th:text="2018"></option>
  73. </select>
  74. </span>
  75. </div>
  76. </div>
  77. <div class="row cl">
  78. <label class="form-label col-xs-4 col-sm-2">对应季月:</label>
  79. <div class="formControls col-xs-8 col-sm-3">
  80. <span class="select-box">
  81. <select class="select" th:name="season_or_month" th:id="season_or_month">
  82. <option value="">-- 请选择季度或月度 --</option>
  83. <option th:value="J" th:text="季度"></option>
  84. <option th:value="Y" th:text="月度"></option>
  85. </select>
  86. </span>
  87. </div>
  88. <div class="formControls col-xs-8 col-sm-3 season" hidden>
  89. <span class="select-box season" hidden>
  90. <select class="select" th:name="season" id="season">
  91. <option value="">-- 请选择季度 --</option>
  92. <option th:value="1" th:text="第一季度"></option>
  93. <option th:value="2" th:text="第二季度"></option>
  94. <option th:value="3" th:text="第三季度"></option>
  95. <option th:value="4" th:text="第四季度"></option>
  96. </select>
  97. </span>
  98. </div>
  99. <div class="formControls col-xs-8 col-sm-3 month" hidden>
  100. <span class="select-box month" hidden>
  101. <select class="select" th:name="month" id="month">
  102. <option value="">-- 请选择月份 --</option>
  103. <option th:value="1" th:text="一月"></option>
  104. <option th:value="2" th:text="二月"></option>
  105. <option th:value="3" th:text="三月"></option>
  106. <option th:value="4" th:text="四月"></option>
  107. <option th:value="5" th:text="五月"></option>
  108. <option th:value="6" th:text="六月"></option>
  109. <option th:value="7" th:text="七月"></option>
  110. <option th:value="8" th:text="八月"></option>
  111. <option th:value="9" th:text="九月"></option>
  112. <option th:value="10" th:text="十月"></option>
  113. <option th:value="11" th:text="十一月"></option>
  114. <option th:value="12" th:text="十二月"></option>
  115. </select>
  116. </span>
  117. </div>
  118. </div>
  119. <div class="row cl">
  120. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>报表标题:</label>
  121. <div class="formControls col-xs-8 col-sm-9">
  122. <input type="text" class="input-text" placeholder="请输入报表标题" id="project_name" name="project_name"/>
  123. </div>
  124. </div>
  125. <div class="row cl">
  126. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目内容:</label>
  127. <div class="formControls col-xs-8 col-sm-9">
  128. <textarea id="project_content" name="project_content"></textarea>
  129. </div>
  130. </div>
  131. <div class="row cl">
  132. <label class="form-label col-xs-4 col-sm-2"><span>上传附件:</span></label>
  133. <div class="formControls col-xs-8 col-sm-9">
  134. <div class="uploader-thum-container">
  135. <div id="fileListPre" class="uploader-list"></div>
  136. <div id="filePicker">选择文件</div>
  137. </div>
  138. </div>
  139. </div>
  140. <div class="row cl">
  141. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>填报开始时间:</label>
  142. <div class="formControls col-xs-4 col-sm-1">
  143. <input class="Wdate input-text" type="text" th:id="apply_startdateIE" th:name="apply_startdate"
  144. style="float:left; width: 150px;"
  145. onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'apply_enddateIE\')}',isShowClear:true,readOnly:true})"/>
  146. <input type="text" class="input-text" th:id="apply_startdate" th:name="apply_startdate"
  147. style="float:left; width: 150px;"/>
  148. </div>
  149. </div>
  150. <div class="row cl">
  151. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>填报结束时间:</label>
  152. <div class="formControls col-xs-4 col-sm-1">
  153. <input class="Wdate input-text" type="text" th:id="apply_enddateIE" th:name="apply_enddate"
  154. style="float:left; width: 150px;"
  155. onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'apply_startdateIE\')}',isShowClear:true,readOnly:true})"/>
  156. <input type="text" class="input-text pull-left" th:id="apply_enddate" th:name="apply_enddate"
  157. style="float:left; width: 150px;"/>
  158. </div>
  159. </div>
  160. <div class="row cl">
  161. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>显示在门户:</label>
  162. <div class="formControls col-xs-8 col-sm-9">
  163. <input type="radio" id="is_public1" name="is_public" th:value="1" checked>是
  164. <input type="radio" id="is_public2" name="is_public" th:value="0">否
  165. </div>
  166. </div>
  167. <div class="row cl push">
  168. <label class="form-label col-xs-4 col-sm-2"><span>推送对象:</span></label>
  169. <div class="formControls col-xs-8 col-sm-9">
  170. <a class="btn btn-primary radius"
  171. th:onclick="'javascript:notify_addPush(\'推送\',\'/projectFilling/addPush\',\'800\',\'500\');'"><i
  172. class="Hui-iconfont">&#xe6df;</i>选择</a>
  173. <input id="pushCompanyIds" name="push_company_ids" type="hidden" value=""/>
  174. </div>
  175. <label class="form-label col-xs-4 col-sm-2"><span>已添加单位:</span></label>
  176. <div class="formControls col-xs-8 col-sm-9">
  177. <span id="pushNames"></span>
  178. </div>
  179. </div>
  180. <div class="row cl">
  181. <label class="form-label col-xs-4 col-sm-2"><span>摘要:</span></label>
  182. <div class="formControls col-xs-8 col-sm-9">
  183. <textarea id="summary" class="input-text" name="summary"></textarea>
  184. </div>
  185. </div>
  186. <div class="row cl">
  187. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
  188. <a type="submit" onclick="save()" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe632;</i>保存草稿</a>
  189. <a th:onclick="'javascript:preview(\'报表填报预览\',\'/projectFilling/preview\',\'800\',\'600\');'"
  190. class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe632;</i>预览</a>
  191. <a class="btn btn-primary radius" onclick="release()"><i class="Hui-iconfont">&#xe632;</i>发布</a>
  192. <a onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</a>
  193. </div>
  194. </div>
  195. </form>
  196. </article>
  197. <script type="text/javascript" th:src="@{/h-ui/lib/webuploader/0.1.5/webuploader.min.js}"></script>
  198. <script th:inline="javascript">
  199. //富文本kindeditor初始化
  200. var editor;
  201. KindEditor.ready(function (K) {
  202. editor = K.create('#project_content', {
  203. uploadJson: pagePath + '/upload/kindEditorUpload',
  204. allowFileManager: false,
  205. allowUpload: true,
  206. width: "100%",
  207. height: "350px",
  208. items: array,
  209. syncType: "auto",
  210. filterMode: false,
  211. afterBlur: function () {
  212. this.sync();
  213. }
  214. });
  215. });
  216. $(function () {
  217. // 初始化上传
  218. var options = {
  219. uploadBtnId: '#filePicker',
  220. picturePreId: 'fileListPre',
  221. hiddenPictureUrl: 'img',
  222. hiddenPictureName: 'imgName',
  223. width: 81,
  224. height: 81,
  225. fileSizeLimit: 100 * 1024 * 1024,
  226. fileSingleSizeLimit: 100 * 1024 * 1024
  227. };
  228. var webUploadDoc = new $WebUploadDoc(options);
  229. webUploadDoc.init();
  230. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  231. var isOpera = userAgent.indexOf("Opera") > -1;
  232. console.log(3);
  233. //判断是否IE浏览器
  234. if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
  235. console.log(1);
  236. $("#apply_startdate").remove();
  237. $("#apply_enddate").remove();
  238. } else {
  239. console.log(2);
  240. $("#apply_startdateIE").remove();
  241. $("#apply_enddateIE").remove();
  242. var startDate = laydate.render({
  243. elem: '#apply_startdate',
  244. type: 'datetime',
  245. done: function (value, date) {
  246. setTimeout(function () {
  247. $("#form-add").validate().element($("#apply_startdate"));
  248. }, 100)
  249. if (value !== '') {
  250. endDate.config.min.year = date.year;
  251. endDate.config.min.month = date.month - 1;
  252. endDate.config.min.date = date.date;
  253. endDate.config.min.hours = date.hours;
  254. endDate.config.min.minutes = date.minutes;
  255. endDate.config.min.seconds = date.seconds;
  256. } else {
  257. endDate.config.min.year = '1900';
  258. endDate.config.min.month = '0';
  259. endDate.config.min.date = '1';
  260. endDate.config.min.hours = '0';
  261. endDate.config.min.minutes = '0';
  262. endDate.config.min.seconds = '0';
  263. }
  264. }
  265. });
  266. var endDate = laydate.render({
  267. elem: '#apply_enddate',
  268. type: 'datetime',
  269. done: function (value, date) {
  270. setTimeout(function () {
  271. $("#form-add").validate().element($("#apply_enddate"));
  272. }, 100)
  273. if (value !== '') {
  274. startDate.config.max.year = date.year;
  275. startDate.config.max.month = date.month - 1;
  276. startDate.config.max.date = date.date;
  277. startDate.config.max.hours = date.hours;
  278. startDate.config.max.minutes = date.minutes;
  279. startDate.config.max.seconds = date.seconds;
  280. } else {
  281. startDate.config.max.year = '2100';
  282. startDate.config.max.month = '0';
  283. startDate.config.max.date = '1';
  284. startDate.config.max.hours = '0';
  285. startDate.config.max.minutes = '0';
  286. startDate.config.max.seconds = '0';
  287. }
  288. }
  289. });
  290. }
  291. });
  292. //自动联想
  293. $('.autocomplete').dropdown({
  294. readOnly: true,
  295. //data: datas,
  296. input: '<input type="text" maxLength="20" placeholder="请输入关键字">',
  297. choice: function () {
  298. //$("span.placeholder").html($(".dropdown-chose")[0].innerText);
  299. $("#project_service_type").val($(".dropdown-chose").attr("data-value"));
  300. }
  301. });
  302. getServiceType();
  303. function getServiceType() {
  304. $.ajax({
  305. url: pagePath + "/projectFilling/getProjectServicetype/2",
  306. type: "get",
  307. dataType: "json",
  308. data: {
  309. timeStamp: new Date()
  310. },
  311. success: function (result) {
  312. if (result.success) {
  313. var obj = result.obj;
  314. console.log(obj)
  315. var typeArr = new Array();
  316. if (obj) {
  317. for (var i = 0; i < obj.length; i++) {
  318. var type = {
  319. "name": obj[i].service_type_name,
  320. "id": obj[i].id,
  321. "disabled": false,
  322. //"groupName": '分组名',
  323. //"groupId": 1,
  324. "selected": false
  325. }
  326. typeArr.push(type);
  327. }
  328. }
  329. console.log(typeArr)
  330. //autoComplete(typeArr);
  331. $('.autocomplete').data('dropdown').update(typeArr, true);
  332. } else {
  333. errorMessage(result.message);
  334. }
  335. },
  336. error: function () {
  337. errorMessage('系统错误!');
  338. }
  339. });
  340. }
  341. /**
  342. * 取消
  343. */
  344. function removeIframe() {
  345. var index = parent.layer.getFrameIndex(window.name);
  346. parent.layer.close(index);
  347. }
  348. var state = '0';
  349. $("#form-add").validate({
  350. rules: {
  351. project_type: {
  352. required: true
  353. },
  354. project_service_type: {
  355. required: true
  356. },
  357. project_source: {
  358. required: true
  359. },
  360. department_id: {
  361. required: true
  362. },
  363. year: {
  364. required: true
  365. },
  366. project_content: {
  367. required: true
  368. //maxlength: 2000
  369. },
  370. apply_startdate: {
  371. required: true
  372. },
  373. apply_enddate: {
  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_open"]: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 + "/projectFilling/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. function release() {
  425. state = "1";
  426. $("#form-add").submit();
  427. }
  428. function save() {
  429. state = "0";
  430. $("#form-add").ajaxSubmit({
  431. type: 'post',
  432. url: pagePath + "/projectFilling/save",
  433. dataType: "json",
  434. data: {
  435. state: state
  436. },
  437. success: function (data) {
  438. if (data.success) {
  439. succeedMessage(data.message);release
  440. setTimeClose();
  441. } else {
  442. // $(form).find(":submit").attr("disabled", false);
  443. errorMessage(data.message);
  444. }
  445. },
  446. error: function () {
  447. errorMessage('系统错误!');
  448. }
  449. });
  450. }
  451. $(function () {
  452. $("#allBuilds").click(function () {
  453. if (this.checked) {
  454. $("#pushBuildsList :checkbox").prop("checked", true);
  455. } else {
  456. $("#pushBuildsList :checkbox").prop("checked", false);
  457. }
  458. });
  459. });
  460. function sendNotify() {
  461. $("#isPush").val(true);
  462. if ($("#pushStreetIds").val() == "" && $("#pushBuildIds").val() == "" && $("#pushCompanyIds").val() == "") {
  463. sadMessage("请选择推送单位!");
  464. return false;
  465. }
  466. }
  467. function clearPush() {
  468. $("#isPush").val(false);
  469. }
  470. function getPushBuildsIds() {
  471. var chlength = $('#pushBuildsList').find('input[type="checkbox"]:checked').length;
  472. var build_ids = '';
  473. $('#pushBuildsList').find('input[type="checkbox"]:checked').each(function (i, item) {
  474. build_ids = build_ids + $(this).attr("value") + ",";
  475. });
  476. build_ids = build_ids.substring(0, build_ids.length - 1);
  477. return build_ids;
  478. }
  479. /*
  480. 参数解释:
  481. title 标题
  482. url 请求的url
  483. id 需要操作的数据id
  484. w 弹出层宽度(缺省调默认值)
  485. h 弹出层高度(缺省调默认值)
  486. */
  487. /*管理员-*/
  488. function notify_addPush(title, url, w, h) {
  489. var targetUrl = pagePath + url+"?pushCompanyIds="+$("#pushCompanyIds").val();
  490. var index = layer_show(title, targetUrl, w, h);
  491. layer.full(index);
  492. }
  493. function preview(title, url, w, h) {
  494. layer_show(title, pagePath + url, w, h);
  495. }
  496. $("#season_or_month").change(function () {
  497. if ($('#season_or_month option:selected').val() == "J") {
  498. $(".season").show();
  499. $(".month").hide();
  500. } else if ($('#season_or_month option:selected').val() == "Y") {
  501. $(".month").show()
  502. $(".season").hide();
  503. } else {
  504. $(".month").hide()
  505. $(".season").hide();
  506. }
  507. });
  508. $("#project_type").change(function () {
  509. if ($('#project_type option:selected').val() == "1") {
  510. $(".push").hide();
  511. } else if ($('#project_type option:selected').val() == "2") {
  512. $(".push").show()
  513. }
  514. });
  515. </script>
  516. </body>
  517. </html>