cmOrderArchiveForm.jsp 14 KB

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