deputyOrder.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /**
  2. * 引入toaster方法
  3. */
  4. document.write("<script language=javascript src='static/js/common/toastr.js'></script>");
  5. /**
  6. * 引入分页
  7. */
  8. document.write("<script language=javascript src='static/lib/jquery/jquery.pagination.js'></script>");
  9. /**
  10. * 引入base方法
  11. */
  12. document.write("<script language=javascript src='static/js/common/base.js'></script>");
  13. var deputyOrderList = [];
  14. /**
  15. * 获取企业列表
  16. */
  17. function getDeputyOrderList(count, page, keyword) {
  18. $('#loadingDiv').show();
  19. deputyOrderList = [];
  20. $("#deputyList-body").empty();
  21. $.get('deputyOrder/list', {
  22. count: count,
  23. page: page,
  24. keyword: keyword
  25. }, function (data) {
  26. $('#loadingDiv').hide();
  27. deputyOrderList = data.data;
  28. var pageNumber = data.page;
  29. var pageSize = data.size;
  30. var total = data.totalElements;
  31. var totalPage = data.totalPages;
  32. var tbody = document.getElementById("deputyList-body");
  33. var page = document.getElementById("page");
  34. //noinspection JSAnnotator
  35. $('#deputyList-total').val('共 ' + total + ' 条');
  36. if (deputyOrderList.length > 0) {
  37. for (var i = 0; i < deputyOrderList.length; i++) {
  38. var trow = getDataRow(deputyOrderList[i], i); //定义一个方法,返回tr数据
  39. tbody.appendChild(trow);
  40. // 查询详情
  41. (function(i) {
  42. $("#edit_one_" + deputyOrderList[i].id ).click(function () {
  43. editOne(deputyOrderList[i]);
  44. });
  45. })(i);
  46. }
  47. // 点击搜索
  48. $('#p_search').unbind('click').click(function () {// 每次先解除上次绑定的事件,防止重复发送请求
  49. $("#deputyList-body").load(location.href + " #deputyList-body");
  50. getDeputyOrderList(count, 1, $('#keyword').val());
  51. });
  52. // 键盘确认按钮搜索
  53. document.onkeydown = function(event) {
  54. var e = event || window.event;
  55. if (e && e.keyCode == 13) { // enter 键
  56. $("#deputyList-body").load(location.href + " #deputyList-body");
  57. getDeputyOrderList(count, 1, $('#keyword').val());
  58. }
  59. };
  60. }
  61. $('#m-page').pagination({
  62. pageCount: totalPage,
  63. totalData: total,
  64. current: pageNumber,
  65. showData: pageSize,
  66. coping: true,
  67. homePage: '首页',
  68. endPage: '末页',
  69. prevContent: '<<',
  70. nextContent: '>>',
  71. jump: true,
  72. jumpBtn: '跳转',
  73. callback: function (api) {
  74. $('.now').text(api.getCurrent());
  75. $("#deputyList-body").load(location.href + " #deputyList-body");
  76. getDeputyOrderList(count, api.getCurrent(), $('#keyword').val());
  77. }
  78. }, function (api) {
  79. $('.now').text(api.getCurrent());
  80. });
  81. })
  82. }
  83. /**
  84. * 编辑代采订单
  85. *
  86. * @param deputyOrder
  87. */
  88. var id = null;
  89. function editOne(order) {
  90. $('#para-title').empty();
  91. $("<p style='font-size: 16px; font-weight: bold'>").text(order.code).appendTo("#para-title");
  92. $('#deputyOrderInfo').modal('show');
  93. $("#order_code").append(order.code);
  94. $("#order_salecode").append(order.salecode);
  95. $("#order_enName").append(order.enName);
  96. $("#order_deputyname").append(order.deputyname);
  97. $("#order_tervendor").append(order.tervendor);
  98. id = order.id;
  99. }
  100. /**
  101. * 编辑代采订单
  102. */
  103. $('#okay').click(function () {
  104. $.ajax('deputyOrder/reDownOrder/' + id, {
  105. method: 'POST',
  106. async: false,
  107. success: function(data) {
  108. if (data.code == 0) {
  109. alert('修改成功');
  110. } else {
  111. alert('修改失败');
  112. }
  113. getDeputyOrderList(20, 1, null);
  114. },
  115. error: function (error) {
  116. alert(error.responseText);
  117. }
  118. });
  119. });
  120. /**
  121. * 建立表格数据
  122. *
  123. * @param en 企业信息
  124. * @param i 行号
  125. * @returns {Element}
  126. */
  127. function getDataRow(order, i) {
  128. var keyword = $('#keyword').val();
  129. var row = document.createElement('tr'); //创建行
  130. var indexCell = document.createElement('td'); //序号
  131. indexCell.setAttribute("class", "text-center");
  132. indexCell.innerHTML = i + 1; //填充数据
  133. row.appendChild(indexCell);
  134. // 订单信息
  135. var uuCell = document.createElement('td');
  136. uuCell.setAttribute("class", "text-left");
  137. uuCell.innerHTML = "流水号: " + highLightKeywords(order.code, keyword, null); //填充数据
  138. uuCell.innerHTML += "<br>订单编号: " + highLightKeywords(order.salecode || "-", keyword, null);
  139. row.appendChild(uuCell);
  140. // 采购企业
  141. var nameCell = document.createElement('td');
  142. nameCell.setAttribute("class", "text-left");
  143. nameCell.innerHTML = "企业名称: " + order.enName; //填充数据
  144. nameCell.innerHTML += "<br>企业UU: " + order.enuu;
  145. row.appendChild(nameCell);
  146. // 终端供应商
  147. var vendorCell = document.createElement('td');
  148. vendorCell.setAttribute("class", "text-left");
  149. vendorCell.innerHTML = "代采企业: " + order.deputyname;
  150. vendorCell.innerHTML += "<br>终端供应商: " + order.tervendor;
  151. row.appendChild(vendorCell);
  152. // 单据状态
  153. var orderStatusCell = document.createElement('td'); //营业执照
  154. orderStatusCell.setAttribute("class", "text-center");
  155. orderStatusCell.innerHTML = "录入状态: " + order.entrystatus;
  156. orderStatusCell.innerHTML += "<br>下载状态: " + order.downloadstatus;
  157. row.appendChild(orderStatusCell);
  158. // 日期
  159. var dateCell = document.createElement('td'); //日期
  160. dateCell.setAttribute("class", "text-center");
  161. dateCell.innerHTML = "录入时间: " + formatDateTime(order.entrydate) || "-"; //填充数据
  162. dateCell.innerHTML += "<br>提交时间: " + formatDateTime(order.date) || "-"; //填充数据
  163. row.appendChild(dateCell);
  164. // 操作
  165. var handleCell = document.createElement('td');
  166. handleCell.setAttribute('class', 'text-center redirect_b2b');
  167. handleCell.setAttribute('id', "edit_one_" + order.id);
  168. handleCell.setAttribute("title", "请注意:点击更新后会让单据重新下载");
  169. handleCell.innerHTML = '更新';
  170. row.appendChild(handleCell);
  171. return row;
  172. }
  173. $(function() {
  174. 'use strict';
  175. // 监听页面滚动
  176. $(window).scroll(function() {
  177. if($(window).scrollTop() >= 400) {
  178. $('#nav').addClass('on');
  179. } else {
  180. $('#nav').removeClass('on');
  181. }
  182. });
  183. // 设置分页大小
  184. var count = 20;
  185. getDeputyOrderList(count, 1, null);
  186. });