project-exit.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <!--#include file="common/_header.html"-->
  5. <title>项目详情页</title>
  6. </head>
  7. <body>
  8. <article class="page-container">
  9. <form class="form form-horizontal" id="form1">
  10. <input type="hidden" class="input-text" id="projectId" name="projectId">
  11. <div class="row cl">
  12. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>停止时间:</label>
  13. <div class="formControls col-xs-8 col-sm-9">
  14. <input id="exitTime" name="exitTime" class="input-text" style="width:180px;"
  15. onfocus="WdatePicker({dateFmt:'yyyy-MM',readOnly:true})" />
  16. <input type="hidden" class="input-text" id="status" name="status" value="8">
  17. </div>
  18. </div>
  19. <div class="row cl">
  20. <label class="form-label col-xs-4 col-sm-3">备注:</label>
  21. <div class="formControls col-xs-8 col-sm-9">
  22. <input type="text" class="input-text" id="exitRemark" name="exitRemark">
  23. </div>
  24. </div>
  25. </form>
  26. <div class="form form-horizontal">
  27. <div class="row cl">
  28. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
  29. <input class="btn btn-primary radius" type="button" id="subForm" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
  30. </div>
  31. </div>
  32. </article>
  33. <!--_footer 作为公共模版分离出去-->
  34. <!--#include file="common/_footer.html"-->
  35. <!--/_footer 作为公共模版分离出去-->
  36. <!--请在下方写此页面业务相关的脚本-->
  37. <script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
  38. <script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
  39. <script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
  40. <script type="text/javascript" src="scripts/global.js"></script>
  41. <!--引入webuploader-->
  42. <link rel="stylesheet" type="text/css" href="lib/webuploader/0.1.5/webuploader.css">
  43. <script type="text/javascript" src="lib/webuploader/0.1.5/webuploader.js"></script>
  44. <!-- select2 start-->
  45. <link rel="stylesheet" type="text/css" href="lib/select2/select2.min.css" />
  46. <script src="lib/select2/select2.full.js" type="text/javascript"></script>
  47. <script src="lib/select2/select2.zh-CN.js" type="text/javascript"></script>
  48. <!-- select2 end -->
  49. <script type="text/javascript">
  50. var path = global_backend_url;
  51. $(document).ready(function () {
  52. //获取url中传参
  53. var id = getQueryString("id");
  54. var needLoad = false;
  55. var remoteUrl = path + "/project/add";
  56. if (id != null && id.length > 0) {
  57. remoteUrl = path + "/project/update";
  58. needLoad = true;
  59. }
  60. $("#form1").validate({
  61. rules: {
  62. exitTime: {
  63. required: true
  64. }
  65. },
  66. onkeyup: false,
  67. focusCleanup: true,
  68. success: "valid",
  69. submitHandler: function (form) {
  70. var loadingIndex = layer.load(1, { shade: [0.1, '#fff'] });
  71. $(form).ajaxSubmit({
  72. type: 'post',
  73. url: remoteUrl,
  74. success: function (data) {
  75. layer.close(loadingIndex);
  76. if (data.result) {
  77. layer.msg('添加成功!', { icon: 1, time: 1000 });
  78. var index = parent.layer.getFrameIndex(window.name);
  79. if (index >= 0) {
  80. parent.reloadList();
  81. parent.layer.close(index);
  82. }
  83. }
  84. else {
  85. layer.msg(data.message, { icon: 1, time: 1000 });
  86. }
  87. },
  88. error: function (XmlHttpRequest, textStatus, errorThrown) {
  89. layer.msg('error!', { icon: 1, time: 1000 });
  90. }
  91. });
  92. }
  93. });
  94. if (needLoad) {
  95. var loadingIndex = layer.load(1, { shade: [0.1, '#fff'] });
  96. $.get(path + "/project/detail/" + id, null, function (json) {
  97. layer.close(loadingIndex);
  98. if (json.result) {
  99. json2Form(json.data, "form1");
  100. // if(json.data.procInstId != null ){
  101. // $("#projectAdminId").attr("disabled", true);
  102. // }
  103. getSelectMany("townshipAdminId", json.data.townshipAdminId, json.data.townshipAdminName);
  104. getSelect("secretaryAdminId", json.data.secretaryAdmin);
  105. getSelect("leaderAdminId", json.data.leaderAdmin);
  106. getSelect("projectAdminId", json.data.projectAdmin);
  107. getParkList(json.data.parkId);
  108. loadFile(json.data.pfList);
  109. }
  110. else {
  111. layer.msg(json.message);
  112. }
  113. }, "json");
  114. } else {
  115. getParkList("");
  116. getSelectMany("townshipAdminId", null, null);
  117. getSelect("secretaryAdminId", null);
  118. getSelect("leaderAdminId", null);
  119. getSelect("projectAdminId", null);
  120. }
  121. $("#subForm").click(function () {
  122. $("#status").val("8");
  123. $("#form1").submit();
  124. });
  125. //swf: 'lib/webuploader/0.1.5/Uploader.swf',
  126. var $list = $("#thelist");
  127. var uploader = WebUploader.create({
  128. // swf文件路径
  129. swf: 'lib/webuploader/0.1.5/Uploader.swf',
  130. // 文件接收服务端。
  131. server: path + "/projectFile/fileUpload",
  132. // 选择文件的按钮。可选。
  133. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  134. pick: '#picker',
  135. // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
  136. resize: false
  137. });
  138. // 当有文件被添加进队列的时候
  139. uploader.on('uploadBeforeSend', function (obj, data, headers) {
  140. $.extend(headers, {
  141. "Authorization": sessionStorage.getItem("token")
  142. });
  143. });
  144. // 当有文件被添加进队列的时候
  145. uploader.on('fileQueued', function (file) {
  146. $list.append('<div id="' + file.id + '" class="item">' +
  147. '<h6 class="info">' + file.name + '</h6>' +
  148. '<p class="state">等待上传...</p>' +
  149. '</div>');
  150. });
  151. // 文件上传过程中创建进度条实时显示。
  152. uploader.on('uploadProgress', function (file, percentage) {
  153. var $li = $('#' + file.id),
  154. $percent = $li.find('.progress .progress-bar');
  155. // 避免重复创建
  156. if (!$percent.length) {
  157. $percent = $('<div class="progress progress-striped active">' +
  158. '<div class="progress-bar" role="progressbar" style="width: 0%">' +
  159. '</div>' +
  160. '</div>').appendTo($li).find('.progress-bar');
  161. }
  162. $li.find('p.state').text('上传中');
  163. $percent.css('width', percentage * 100 + '%');
  164. });
  165. uploader.on('uploadSuccess', function (file, response) {
  166. $('#' + file.id).find('p.state').text('已上传');
  167. var fileUrls = $("#fileUrls").val();
  168. $("#fileUrls").val(response.data.fileUrls + "*" + fileUrls);
  169. });
  170. uploader.on('uploadError', function (file) {
  171. $('#' + file.id).find('p.state').text('上传出错');
  172. });
  173. uploader.on('uploadComplete', function (file) {
  174. $('#' + file.id).find('.progress').fadeOut();
  175. });
  176. $("#uploadbtn").click(function () {
  177. uploader.upload();
  178. });
  179. });
  180. function getSelect(id, value) {
  181. if (value != null) {
  182. var Html = "<option value='" + value.id + "' selected>" + value.realName + "</option>";
  183. $('#' + id).append(Html);
  184. //$('#' + id).select2();
  185. }
  186. $("#" + id).select2({
  187. language: "zh-CN",
  188. placeholder: "请输入用户姓名",//文本框的提示信息
  189. minimumInputLength: 0, //至少输入n个字符,才去加载数据
  190. allowClear: true, //是否允许用户清除文本信息
  191. ajax: {
  192. url: path + "/jpAdmin/selectUser", //地址
  193. type: "POST",
  194. dataType: 'json', //接收的数据类型
  195. delay: 250,
  196. cache: true,
  197. processResults: function (data) {
  198. var results = data.map(function (item) {
  199. return {
  200. id: item.userId,
  201. text: item.realName,
  202. userName: item.userName,
  203. orgName: item.orgName
  204. }
  205. });
  206. return {
  207. results: results
  208. }
  209. }
  210. },
  211. language: "zh-CN",
  212. templateResult: function (state) {
  213. var html = "<div>";
  214. html += "<strong>姓名:" + state.text + "</strong>(" + state.userName + ")<br/>";
  215. html += "单位:" + state.orgName;
  216. html += "</div>";
  217. return $(html);
  218. }
  219. });
  220. }
  221. function getSelectMany(id, userId, userName) {
  222. $("#" + id).select2({
  223. language: "zh-CN",
  224. placeholder: "请输入用户姓名",//文本框的提示信息
  225. minimumInputLength: 0, //至少输入n个字符,才去加载数据
  226. allowClear: false, //是否允许用户清除文本信息
  227. multiple: true,
  228. ajax: {
  229. url: path + "/jpAdmin/selectUser", //地址
  230. type: "POST",
  231. dataType: 'json', //接收的数据类型
  232. delay: 250,
  233. cache: true,
  234. processResults: function (data) {
  235. var results = data.map(function (item) {
  236. return {
  237. id: item.userId,
  238. text: item.realName,
  239. userName: item.userName,
  240. orgName: item.orgName
  241. }
  242. });
  243. return {
  244. results: results
  245. }
  246. }
  247. },
  248. language: "zh-CN",
  249. templateResult: function (state) {
  250. var html = "<div>";
  251. html += "<strong>姓名:" + state.text + "</strong>(" + state.userName + ")<br/>";
  252. html += "单位:" + state.orgName;
  253. html += "</div>";
  254. return $(html);
  255. }
  256. });
  257. $("#" + id).on("select2-clearing", function (e) {
  258. //alert(true);
  259. });
  260. if (userId != null && userId.length > 0) {
  261. var ids = userId.split(",");
  262. var names = userName.split(",");
  263. $('option', $("#" + id)).remove();
  264. for (var i = 0; i < ids.length; i++) {
  265. if (ids[i] != "") {
  266. $("#" + id).append(new Option(names[i], ids[i], false, false));//第一个参数时id,第二个参数是text
  267. }
  268. }
  269. $($("#" + id)).val(ids).trigger('change');
  270. }
  271. else {
  272. $('option', $("#" + id)).remove();
  273. $($("#" + id)).val(null).trigger('change');
  274. }
  275. }
  276. function getParkList(parkId) {
  277. $.post(path + "/park/allList", function (json) {
  278. if (json.result) {
  279. $.each(json.data, function (index, obj) {
  280. if (parkId != "") {
  281. if (obj.parkId == parkId) {
  282. $("#parkId").append("<option value='" + obj.parkId + "' selected>" + obj.title + "</option>")
  283. } else {
  284. $("#parkId").append("<option value='" + obj.parkId + "'>" + obj.title + "</option>")
  285. }
  286. }
  287. else {
  288. $("#parkId").append("<option value='" + obj.parkId + "'>" + obj.title + "</option>")
  289. }
  290. })
  291. }
  292. else {
  293. layer.msg(json.message);
  294. }
  295. }, "json")
  296. }
  297. function loadFile(fileList) {
  298. if (fileList.length > 0) {
  299. $("#thelist").append('<h4 class="info">已上传附件</h4>');
  300. for (var i = 0; i < fileList.length; i++) {
  301. $("#thelist").append('<div id="' + fileList[i].fileId + '" class="item">' +
  302. '<h6 class="info"><a href="' + fileList[i].realAddress + '" download = "' + fileList[i].fileName + "." + fileList[i].fileType.toLowerCase() + '" target="_blank">' + fileList[i].fileName + "." + fileList[i].fileType.toLowerCase() + '</a>' +
  303. '<a href="javacript:void(0);" onclick=delFile("' + fileList[i].fileId + '")>删除</a>' +
  304. '</h6>' +
  305. '</div>');
  306. }
  307. }
  308. }
  309. function delFile(fileId) {
  310. layer.confirm("是否删除?", {
  311. btns: ["是", "否"]
  312. }, function () {
  313. $.post(path + "/projectFile/deleteReturnFile/" + fileId, null, function (json) {
  314. if (json.result) {
  315. layer.msg("删除成功!", { icon: 1, time: 2000 });
  316. var fileList = json.data.fileList;
  317. $("#thelist").empty();
  318. if (fileList.length > 0) {
  319. $("#thelist").append('<h4 class="info">已上传附件</h4>');
  320. for (var i = 0; i < fileList.length; i++) {
  321. $("#thelist").append('<div id="' + fileList[i].fileId + '" class="item">' +
  322. '<h6 class="info"><a href="' + fileList[i].realAddress + '" download = "' + fileList[i].fileName + "." + fileList[i].fileType.toLowerCase() + '" target="_blank">' + fileList[i].fileName + "." + fileList[i].fileType.toLowerCase() + '</a>' +
  323. '<a href="javacript:void(0);" onclick=delFile("' + fileList[i].fileId + '")>删除</a>' +
  324. '</h6>' +
  325. '</div>');
  326. }
  327. }
  328. }
  329. else {
  330. layer.msg("删除失败!" + json.message);
  331. }
  332. });
  333. });
  334. }
  335. </script>
  336. <!--/请在上方写此页面业务相关的脚本-->
  337. </body>
  338. </html>