cmOrderArchiveForm.jsp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
  3. <html>
  4. <head>
  5. <title>订单资料管理</title>
  6. <meta name="decorator" content="default"/>
  7. <script type="text/javascript">
  8. $(document).ready(function() {
  9. //$("#name").focus();
  10. $("#inputForm").validate({
  11. submitHandler: function(form){
  12. var orderArchiveId = $("#id").val();
  13. var shopOrderId = $("#shopOrderId").val();
  14. $.post("${ctx}/archive/cmOrderArchive/checkShopOrderId",{"id":orderArchiveId,"shopOrderId":shopOrderId},function (result) {
  15. if (result.code != 0) {
  16. var errorMsg = result.msg;
  17. jBox.tip(errorMsg, "error");
  18. } else {
  19. loading('正在提交,请稍等...');
  20. form.submit();
  21. }
  22. })
  23. },
  24. errorContainer: "#messageBox",
  25. errorPlacement: function(error, element) {
  26. $("#messageBox").text("输入有误,请先更正。");
  27. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  28. error.appendTo(element.parent().parent());
  29. } else {
  30. error.insertAfter(element);
  31. }
  32. }
  33. });
  34. });
  35. /**
  36. * @param obj
  37. * jquery控制input只能输入数字
  38. */
  39. function onlynum(obj) {
  40. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  41. }
  42. </script>
  43. <style>
  44. .controls .new-tag {
  45. display: inline-block;
  46. width: 78px;
  47. height: 30px;
  48. border: 1px solid #e5e5e5;
  49. border-radius: 5px;
  50. margin: 7px;
  51. text-align: center;
  52. line-height: 30px;
  53. font-size: 14px;
  54. overflow: hidden;
  55. text-overflow: ellipsis;
  56. white-space: nowrap;
  57. cursor: pointer;
  58. }
  59. .controls .new-tag.active {
  60. border-color: #e15616;
  61. color: #e15616;
  62. }
  63. #tagInput {
  64. width: 263px;
  65. margin: 7px;
  66. display: inline-block;
  67. height: 30px;
  68. }
  69. .controls .tags-operate .tag-add {
  70. height: 40px;
  71. line-height: 40px;
  72. vertical-align: middle;
  73. }
  74. .upload {
  75. position: relative;
  76. display: inline-block;
  77. background: #D0EEFF;
  78. border: 1px solid #99D3F5;
  79. border-radius: 4px;
  80. padding: 4px 12px;
  81. color: #1E88C7;
  82. text-decoration: none;
  83. text-indent: 0;
  84. line-height: 20px;
  85. margin-left: 20px;
  86. cursor: pointer;
  87. width: 52px;
  88. height: 20px;
  89. }
  90. .upload input {
  91. position: absolute;
  92. width: 170px;
  93. font-size: 20px;
  94. right: 0;
  95. top: 0;
  96. opacity: 0;
  97. cursor: pointer;
  98. }
  99. .upload:hover {
  100. background: #AADFFD;
  101. border-color: #78C3F3;
  102. color: #004974;
  103. text-decoration: none;
  104. }
  105. .add-submit {
  106. position: relative;
  107. display: inline;
  108. background: #D0EEFF;
  109. border: 1px solid #99D3F5;
  110. border-radius: 4px;
  111. padding: 4px 12px;
  112. color: #1E88C7;
  113. text-decoration: none;
  114. text-indent: 0;
  115. line-height: 20px;
  116. margin-left: 20px;
  117. cursor: pointer;
  118. width: 52px;
  119. height: 30px;
  120. }
  121. .add-submit input {
  122. position: absolute;
  123. width: 50px;
  124. font-size: 20px;
  125. right: 0;
  126. top: 0;
  127. opacity: 0;
  128. cursor: pointer;
  129. }
  130. .add-submit:hover {
  131. background: #AADFFD;
  132. border-color: #78C3F3;
  133. color: #004974;
  134. text-decoration: none;
  135. }
  136. .upload-loading{
  137. display: none;
  138. width: 32px;
  139. height: 32px;
  140. margin-left: 10px;
  141. }
  142. .upload-loading img{
  143. width: 16px;
  144. height: 16px;
  145. margin: 0 auto 0;
  146. }
  147. #file-list-display {
  148. width: 600px;
  149. height: auto;
  150. float: left;
  151. margin-left: 20px;
  152. }
  153. #file-list-display p {
  154. line-height: 30px;
  155. font-size: 14px;
  156. color: #333333;
  157. margin: 0;
  158. }
  159. #file-list-display p .del {
  160. color: #2fa4e7;
  161. font-size: 12px;
  162. cursor: pointer;
  163. margin-left: 20px;
  164. }
  165. .Main-content{
  166. height: 100px;
  167. }
  168. </style>
  169. </head>
  170. <body>
  171. <ul class="nav nav-tabs">
  172. <li><a href="${ctx}/archive/cmOrderArchive/">订单资料列表</a></li>
  173. <li class="active"><a href="${ctx}/archive/cmOrderArchive/form?id=${cmOrderArchive.id}">订单资料${not empty cmOrderArchive.id?'编辑':'添加'}</a></li>
  174. </ul><br/>
  175. <form:form id="inputForm" modelAttribute="cmOrderArchive" action="${ctx}/archive/cmOrderArchive/save" method="post" class="form-horizontal">
  176. <form:hidden path="id"/>
  177. <form:hidden path="fileIds" id="fileIds"/>
  178. <sys:message content="${message}"/>
  179. <div class="control-group">
  180. <label class="control-label">订单资料标题:</label>
  181. <div class="controls">
  182. <form:input path="title" htmlEscape="false" maxlength="30" class="input-xlarge "/>
  183. </div>
  184. </div>
  185. <div class="control-group">
  186. <label class="control-label"><font color="red">*</font>子订单ID:</label>
  187. <div class="controls">
  188. <form:input path="shopOrderId" htmlEscape="false" maxlength="8" class="input-xlarge required" onkeyup="onlynum(this)"/>
  189. </div>
  190. </div>
  191. <div class="control-group">
  192. <label class="control-label"><font color="red">*</font>供应商名称:</label>
  193. <div class="controls">
  194. <form:input path="shopName" htmlEscape="false" maxlength="50" class="input-xlarge required"/>
  195. </div>
  196. </div>
  197. <div class="control-group">
  198. <label class="control-label"><font color="red">*</font>机构名称:</label>
  199. <div class="controls">
  200. <form:input path="clubName" htmlEscape="false" maxlength="50" class="input-xlarge required"/>
  201. </div>
  202. </div>
  203. <div class="control-group">
  204. <label class="control-label" style="margin-top: 14px">商品标签:</label>
  205. <div class="controls Main-content">
  206. <div class="tags-operate">
  207. <input type="text" class="reg-input tag-input" id="tagInput" placeholder="输入商品标签,支持添加多个"
  208. maxlength="15">
  209. <span class="new-tag tag-add" id="tagAdd">添加</span>
  210. </div>
  211. <div class="tags-area" id="tagArea"></div>
  212. <span class="err-tip" style="display: inline-block;margin-left:-55px;"></span>
  213. <input type="hidden" name="tag" value="${cmOrderArchive.tag}" id="tag">
  214. </div>
  215. </div>
  216. <div class="control-group">
  217. <label class="control-label"><font color="red">*</font>返佣订单:</label>
  218. <div class="controls">
  219. <form:select path="rebateFlag" class="input-small ">
  220. <form:option value="0" label="否"/>
  221. <form:option value="1" label="是"/>
  222. </form:select>
  223. </div>
  224. </div>
  225. <div class="control-group">
  226. <label class="control-label">备注:</label>
  227. <div class="controls">
  228. <form:textarea path="remark" htmlEscape="false" rows="3" maxlength="200" class="input-xlarge"/>
  229. </div>
  230. </div>
  231. <div class="control-group">
  232. <label class="control-label">资料上传:</label>
  233. <input id="uploadFileName" type="text" style="display: inline;margin-left:20px" placeholder="支持pdf、word、png、jpg" disabled="true" class="input-xlarge required" />
  234. <div class="upload">
  235. <input type="file" name="file" id="archiveFile" accept=".pdf,.doc,.docx,.png,.jpg">选择文件
  236. </div>
  237. <div class="add-submit">
  238. <input id="addSubmit" type="button" value="上传"/>上传&nbsp;
  239. </div>
  240. <div class="upload-loading">
  241. <img alt="gif" src="/static/images/upload.gif" width="32px" border="none">
  242. </div>
  243. </div>
  244. <div class="control-group">
  245. <label class="control-label">资料列表:</label>
  246. <div id='file-list-display'>
  247. <c:if test="${not empty archiveFileList}">
  248. <c:forEach items="${archiveFileList}" var="archiveFile" varStatus="statusIndex">
  249. <p>${archiveFile.fileName}
  250. <span class="del"><a href="${archiveFile.ossUrl}" target="_blank">预览</a></span>
  251. <span class="del" onclick="dataDelete(this,'${archiveFile.id}')">删除</span>
  252. </p>
  253. </c:forEach>
  254. </c:if>
  255. </div>
  256. </div>
  257. <div class="form-actions">
  258. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  259. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  260. </div>
  261. </form:form>
  262. <script>
  263. // 初始化主营内容数据
  264. $(function () {
  265. var html = '';
  266. $('#tagArea').html(html);
  267. $('.Main-content').show();
  268. //主营项目
  269. var cMainProVal = $('#tag').val();
  270. if (cMainProVal != null && cMainProVal != "") {
  271. var _mainPros = cMainProVal.split('|');
  272. var proList = $('#tagArea').find('.new-tag');
  273. for (var j = 0; j < _mainPros.length; j++) {
  274. var _flag = false;
  275. for (var i = 0; i < proList.length; i++) {
  276. if ($(proList[i]).attr('data-typeName') == _mainPros[j]) {
  277. _flag = true;
  278. }
  279. }
  280. if (_flag) {
  281. for (var i = 0; i < proList.length; i++) {
  282. if ($(proList[i]).attr('data-typeName') == _mainPros[j]) {
  283. $(proList[i]).addClass('active');
  284. }
  285. }
  286. } else {
  287. $('#tagArea').append('<span class="new-tag up-club-tag active" data-typeName="' + _mainPros[j] + '">' + _mainPros[j] + '</span> ');
  288. $('.Main-content').show();
  289. }
  290. }
  291. $('#cMainPro').val(cMainProVal);
  292. }
  293. //机构品项选择
  294. var optsClub = {
  295. $tag: $('.up-club-tag'),
  296. $tagArea: $('#tagArea'),
  297. $mainPro: $('#tag'),
  298. $other: $('#tagOther'),
  299. $input: $('#tagInput'),
  300. $add: $('#tagAdd'),
  301. $type: 'club'
  302. };
  303. getTags(optsClub);
  304. //点击上传按钮后上传文件
  305. $('#addSubmit').click(function () {
  306. var filesById = document.getElementById('archiveFile');
  307. var files = $('#archiveFile');
  308. var fileList = files.prop('files');
  309. var fileName = $('#uploadFileName').val();
  310. if (files === '' || files.length == 0 || fileName == '') {
  311. alertx('请选择上传文件');
  312. return;
  313. }
  314. $("#uploadFileName").val("");
  315. var data = new FormData();
  316. var orderArchiveId = $("#id").val();
  317. var fileIds = $("#fileIds").val();
  318. data.append('file', fileList[0]);
  319. data.append('fileName', fileName);
  320. data.append('orderArchiveId', orderArchiveId);
  321. data.append('fileIds', fileIds);
  322. $('.upload-loading').css("display", "inline");
  323. $.ajax({
  324. url: "${ctx}/archive/cmOrderArchive/upload",
  325. data: data,
  326. type: "POST",
  327. processData: false,
  328. contentType: false,
  329. dataType: "json",
  330. success: function (res) {
  331. if (res.success) {
  332. filesById.value = '';
  333. renderFileList(res.archiveFile);
  334. $('.upload-loading').hide();
  335. } else {
  336. $.jBox.tip(res.msg, 'error');
  337. $("#uploadFileName").val(fileName);
  338. $('.upload-loading').hide();
  339. }
  340. },
  341. error: function (json) {
  342. }
  343. });
  344. })
  345. var fileList = [];
  346. var fileIds = '';
  347. var files = document.getElementById("archiveFile"), renderFileList;
  348. //选择上传文件后显示文件名称
  349. files.addEventListener("change", function (event) {
  350. var name = event.target.files[0].name;
  351. console.log(name)
  352. $('#uploadFileName').val(name);
  353. });
  354. var fileListDisplay = document.getElementById('file-list-display');
  355. renderFileList = function (data) {
  356. fileIds += data.id + ',';
  357. console.log(fileIds);
  358. $('#fileIds').val(fileIds);
  359. fileList.push({fileName: data.fileName, id: data.id, ossUrl: data.ossUrl});
  360. fileList.forEach(function (file, index) {
  361. var fileDisplayEl = document.createElement("p");
  362. var deleteFile = document.createElement("span");
  363. var viewFile = document.createElement("span");
  364. var viewFileUrl = document.createElement("a");
  365. //预览链接
  366. viewFileUrl.innerHTML = '预览';
  367. viewFileUrl.setAttribute("href", file.ossUrl);
  368. viewFileUrl.setAttribute("target", "_blank");
  369. //预览按钮
  370. viewFile.className = 'viewFile';
  371. console.log(viewFile);
  372. viewFile.setAttribute("class","del");
  373. viewFile.appendChild(viewFileUrl);
  374. //删除按钮
  375. deleteFile.innerHTML = '删除';
  376. deleteFile.className = 'deleteFile';
  377. console.log(deleteFile);
  378. deleteFile.setAttribute("class","del");
  379. deleteFile.setAttribute("onclick", "dataDelete(this, " + file.id + ")");
  380. fileDisplayEl.setAttribute("id", file.id);
  381. fileDisplayEl.innerHTML = file.fileName;
  382. fileDisplayEl.appendChild(viewFile);
  383. fileDisplayEl.appendChild(deleteFile);
  384. fileListDisplay.appendChild(fileDisplayEl);
  385. });
  386. fileList.splice(0, fileList.length);
  387. };
  388. });
  389. //选择tags(主营和服务类型通用)
  390. function getTags(opts) {
  391. opts.$tagArea.on('click', '.new-tag', function () {
  392. var $this = $(this);
  393. $this.toggleClass('active');
  394. setTags(opts);
  395. });
  396. opts.$other.on('click', function () {
  397. opts.$input.css('display', 'inline-block');
  398. opts.$add.css('display', 'inline-block');
  399. });
  400. opts.$add.on('click', function () {
  401. var _tag = $.trim(opts.$input.val());
  402. if (_tag) {
  403. var flag = false;
  404. opts.$tagArea.find('.new-tag').each(function (i, v) {
  405. var _name = $(v).attr('data-typeName');
  406. if (_tag == _name) {
  407. flag = true;
  408. return false;
  409. } else {
  410. if (i == opts.$tagArea.find('.new-tag').length) {
  411. flag = false;
  412. }
  413. }
  414. })
  415. if (flag) {
  416. opts.$tagArea.find('.new-tag').each(function (i, v) {
  417. var _name = $(v).attr('data-typeName');
  418. if (_tag == _name) {
  419. $(v).addClass('active');
  420. alertx('该类型已存在', opts.$add);
  421. flag = true;
  422. return false;
  423. }
  424. })
  425. } else {
  426. opts.$tagArea.append('<span class="new-tag up-' + opts.$type + '-tag active" data-typeName="' + _tag + '">' + _tag + '</span> ');
  427. setTags(opts);
  428. opts.$input.val('');
  429. return;
  430. }
  431. }
  432. })
  433. }
  434. //设置tags(主营和服务类型通用)
  435. function setTags(opts) {
  436. var tagArr = [];
  437. opts.$mainPro.val('')
  438. opts.$tagArea.find('.new-tag.active').each(function (i, v) {
  439. var _typeName = $(v).attr('data-typeName');
  440. tagArr.push(_typeName);
  441. opts.$mainPro.val(tagArr.join(' | '));
  442. })
  443. }
  444. //删除文件
  445. function dataDelete(that, id) {
  446. console.log($(that).text());
  447. $(that).parent().remove();
  448. /*var fileIds = $("#fileIds").val();
  449. if (fileIds.indexOf(id)) {
  450. fileIds.replace(id + ",", "");
  451. }*/
  452. $.ajax({
  453. url: "${ctx}/archive/cmOrderArchive/deleteFile",
  454. data: {"fileId": id},
  455. async: false,
  456. type: "POST"
  457. });
  458. }
  459. </script>
  460. </body>
  461. </html>