edit.html 29 KB

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