add.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. .childTit{
  9. font-size:14px;
  10. color:#333;
  11. padding:8px 5px;
  12. /*margin: 15px 0;*/
  13. border-left: 3px solid #409EFF;
  14. background: rgba(240,240,240,0.9);
  15. text-align: left;
  16. }
  17. .line {
  18. display: block;
  19. text-align: left;
  20. background-color: #fff;
  21. color: #333;
  22. border-bottom: 1px solid #0a6999;
  23. border-color: #fff;
  24. border-bottom: 1px solid #0a6999;
  25. margin-top: 10px;
  26. vertical-align: middle;
  27. padding: 4px 12px;
  28. height: 31px;
  29. line-height: 31px;
  30. font-size: 14px;
  31. font-weight: bold;
  32. }
  33. </style>
  34. </head>
  35. <body layout:fragment="content">
  36. <article class="page-container">
  37. <form class="form form-horizontal" id="form-add">
  38. <!--<div class="row cl">-->
  39. <!--<h2 class="childTit" style="margin-bottom: 15px">基本信息</h2>-->
  40. <!--</div>-->
  41. <div class="line">基本信息</div>
  42. <div class="row cl">
  43. <div class="col-xs-6 col-sm-6">
  44. <label class="form-label col-xs-2 col-sm-2">板块:</label>
  45. <div class="formControls col-xs-8 col-sm-8">
  46. <input type="test" class="input-text" name = "plateName" th:value="${plateName}" readonly/>
  47. </div>
  48. </div>
  49. <div class="col-xs-6 col-sm-6">
  50. <label class="form-label col-xs-3 col-sm-3">上传用户:</label>
  51. <div class="formControls col-xs-9 col-sm-9">
  52. <input type="test" class="input-text" name = "userNsme" th:value="${userName}" readonly/>
  53. </div>
  54. </div>
  55. </div>
  56. <!--<div class="row cl">-->
  57. <!--<h2 class="childTit">文件资料</h2>-->
  58. <!--</div>-->
  59. <div class="line">文件资料</div>
  60. <div class="row cl">
  61. <div class="col-xs-6 col-sm-6">
  62. <label class="form-label col-xs-2 col-sm-2">类型:</label>
  63. <select class=" col-xs-8 col-sm-8" th:name="type" id="type" onChange="changeType()" style="height: 30px;">
  64. <option value="">-- 请选择类型 --</option>
  65. <option th:value="1" th:text="每年度初上报材料"></option>
  66. <option th:value="2" th:text="季度进展情况"></option>
  67. <option th:value="3" th:text="项目完成上报材料"></option>
  68. <option th:value="4" th:text="需提交会办材料"></option>
  69. </select>
  70. </div>
  71. </div>
  72. <div class="row cl" id="template">
  73. <table class="table table-border table-bordered table-bg table-hover" style="margin-top: 15px">
  74. <thead>
  75. <tr class="text-c">
  76. <th>编号</th>
  77. <th>模版</th>
  78. <th>上传材料</th>
  79. </tr>
  80. </thead>
  81. <tbody>
  82. <tr class="text-c" >
  83. </tr>
  84. </tbody>
  85. </table>
  86. </div>
  87. <div class="row cl">
  88. <div class="col-xs-12 col-sm-9 col-xs-offset-5 col-sm-offset-5">
  89. <a class="btn btn-primary radius" onclick="save()">&nbsp;&nbsp;提交&nbsp;&nbsp;</a>
  90. <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
  91. </div>
  92. </div>
  93. </form>
  94. </article>
  95. <script type="text/javascript" th:src="@{/js/common/page.js}"></script>
  96. <script th:inline="javascript">
  97. var fileUrl = [[${fileUrl}]];
  98. function changeType(){
  99. $.ajax({
  100. url :pagePath+"/retreatOpt/getTemplateFile",
  101. type : "get",
  102. data : {
  103. 'type': $("#type").val()
  104. },
  105. dataType : "json",
  106. success: function (result) {
  107. if (result.success) {
  108. var templates = result.obj;
  109. if(templates.length>0){
  110. $("#template").find("tbody tr").remove();
  111. for(var i=0;i< templates.length;i++){
  112. var file = templates[i].fileDown;
  113. var tr = '<tr class="text-c" >';
  114. //编号
  115. tr +='<td class="index" > '+(i+1)+' </td>';
  116. //模板
  117. tr += '<td class ="templateFile">'
  118. if(file && file.file_url){
  119. url = fileUrl + file.file_url;
  120. tr += '<a href="'+url+'" target="_blank">'+file.file_name+'</a>';
  121. }else{
  122. tr += '<span>'+templates[i].item_name+'</span>';
  123. }
  124. tr += '</td>';
  125. //上传文件
  126. tr += '<td id="materials">';
  127. tr += '<input class="uploadFileTemplateId" type="hidden" name="materials['+i+'].id" value="'+templates[i].id+'"/>';
  128. tr += '<input class="uploadFileName input-text" name="uploadFileName" readonly="readonly" type="text" onclick="javascript:addFile(\'添加文件\',\'/retreatOpt/addFile/1/'+templates[i].id+'\',\'800\',\'350\');"/>';
  129. tr += '<input class="uploadFileId" type="hidden" name="materials['+i+'].fileDown.file_id" />';
  130. tr += '</td>';
  131. $("#template").find("tbody").append(tr);
  132. }
  133. }else{
  134. $("#template").find("tbody tr").remove();
  135. }
  136. } else {
  137. errorMessage(result.message);
  138. }
  139. },
  140. error: function () {
  141. errorMessage('系统错误!');
  142. }
  143. });
  144. }
  145. //添加文件
  146. function addFile(title, url, w, h) {
  147. layer_show(title, pagePath + url, w, h);
  148. }
  149. function save(){
  150. var validateFile = true;
  151. $("#materials").find(".uploadFileName").each(function(){
  152. if($(this).val()===""){
  153. console.log("type ="+ $(this).val());
  154. errorMessage('请上传所有材料!');
  155. validateFile = false;
  156. }
  157. });
  158. if($("#type").val() === ""){
  159. errorMessage('请选择类型!');
  160. validateFile = false;
  161. }
  162. if (validateFile){
  163. $("#form-add").ajaxSubmit({
  164. type: 'post',
  165. url: pagePath + "/retreatOpt/save",
  166. dataType: "json",
  167. success: function (data) {
  168. if (data.success) {
  169. succeedMessage(data.message);
  170. console.log(data.message)
  171. setTimeClose();
  172. // window.location.href =pagePath + "/retreatOpt/index";
  173. } else {
  174. errorMessage(data.message);
  175. }
  176. },
  177. error: function () {
  178. errorMessage('系统错误!');
  179. }
  180. });
  181. }
  182. }
  183. /**
  184. * 取消
  185. */
  186. function removeIframe(){
  187. var index = parent.layer.getFrameIndex(window.name);
  188. parent.layer.close(index);
  189. }
  190. </script>
  191. </body>
  192. </html>