freightPrinting.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>打印运费结算单</title>
  6. <script src="../../js/min-loader-next.js"></script>
  7. <script src="../../js/jquery.jqprint-0.3.js"></script>
  8. <script src="http://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script>
  9. <style>
  10. .layui-table-cell {
  11. height: 28px;
  12. line-height: 28px;
  13. padding: 0 0px;
  14. position: relative;
  15. box-sizing: border-box;
  16. overflow: visible !important;
  17. text-overflow: !important;
  18. white-space: nowrap !important;
  19. }
  20. .printChuku{
  21. display: none;
  22. }
  23. </style>
  24. </head>
  25. <body class="body-content">
  26. <div class="order-body">
  27. <div class="order-tiaojian back-gray">
  28. <div class="tiaojian-part1" id="conditions">
  29. <div class="fl f12-gray4-op mt4">所选条件:</div>
  30. </div>
  31. <div class="tiaojian-part2 fr demoTableOne">
  32. <button class="order-bnt1" onclick="reload();">查询</button>
  33. <button class="order-bnt2" onclick="cancle();">重置</button>
  34. <a href="#" id="toggle" class="top">收起<i class="iconfont up iconSelect_drop-down"></i></a>
  35. </div>
  36. </div>
  37. <form class="layui-form" action="javascript:void(0)" id = "formName" >
  38. <div class="order-select back-border" id="content" style="display: block;">
  39. <div class="layui-inline">
  40. <label class="f12-gray4">到货日期:</label>
  41. <input type="text" class="search-select" id="datesTwo" autocomplete="off" placeholder=" - ">
  42. </div>
  43. <div class="layui-inline">
  44. <label class="f12-gray4">运输方:</label>
  45. <div class="layui-input-inline" id ="name" >
  46. </div>
  47. </div>
  48. </div>
  49. </form>
  50. </div>
  51. <div class="shadow-content" >
  52. <div class="gray-title demoTable" id = "buttonForm">
  53. <button class="layui-btn left-bnt1 in-b" id="printBtn" >
  54. 打印
  55. </button>
  56. <button class="layui-btn left-bnt1 in-b" id="saveBtn">
  57. 保存
  58. </button>
  59. <button class="layui-btn left-bnt1 in-b" id="detailBtn">
  60. 查看明细数据
  61. </button>
  62. <button class="layui-btn left-bnt1 in-b" id="addDetailBtn">
  63. 新增明细数据
  64. </button>
  65. </div>
  66. <div id="big" style = "display : none">
  67. <div style="margin-bottom: 24px;border-bottom: 1px black solid;width: 100%;height: 127px; display: none;" id = "headImg">
  68. <img src="../../images/wlHead.jpg" style="
  69. width: 80%;
  70. margin-left: 10%;
  71. height: 125px;
  72. ">
  73. </div>
  74. <div id="DivHead" style="margin-bottom: 24px;">
  75. <div style="margin: 0;width: 100%;">
  76. <div style="font-size: 18px;font-weight: 600;text-align: center;margin: 0;">
  77. <span id="title">运费结算单</span>
  78. </div>
  79. <div style="font-size:18px;font-weight: 600;text-align: center;margin: 0;">
  80. <span style="float:left" contenteditable="true"><span id="sell1"></span>:</span>
  81. </div><br/><br/>
  82. <div style="float:left;font-size: 12px;font-weight: 400;text-align: center;margin: 0;">
  83. <span contenteditable="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  84. 现将我司<span id="strh"></span>月运费结算明细与贵司确认:</span>
  85. </div>
  86. <br>
  87. <div style = "width:980px;margin-top: 20px;">
  88. <table id="tableTest" lay-filter="tableFilter" ></table>
  89. <table id="tableTestPrint" style="display: none;width: 100%;" class="printChuku">
  90. <thead style = "padding-left:24px;padding-right:24px;">
  91. <tr>
  92. <th>运费结算月</th>
  93. <th>发出库</th>
  94. <th>到站地</th>
  95. <th>到货重量</th>
  96. <th>运费单价(元)</th>
  97. <th>运费(元)</th>
  98. </tr>
  99. </thead>
  100. <tbody id ="small" style = "padding-left:24px;padding-right:24px;">
  101. </tbody>
  102. </table>
  103. </div>
  104. </div>
  105. </div>
  106. <div id="DivFoot" style="margin: 0;padding-bottom: 24px;">
  107. <div style="margin: 0;width: 100%;">
  108. <div class="display5" style="font-size: 18px;font-weight: 600;float:left">
  109. <div>卖方:</div>
  110. <div id="sell" style="padding-right:300px;font-size: 18px;font-weight: 600;" contenteditable="true"></div>
  111. <div>买方:</div>
  112. <div id="buy" contenteditable="true"></div>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <script>
  119. var tabPageId = getQueryString("tabPageId");
  120. var datesTwo = getTempVal('datesTwo');
  121. var transporter = getTempVal('transporter');
  122. var chooseDate = getQueryString("chooseDate");
  123. var id = getQueryString("id");
  124. var companyName = decodeURI(decodeURI(getQueryString("companyName")));
  125. if(!isEmpty(chooseDate)){
  126. $("#datesTwo").val(chooseDate);
  127. }
  128. if(!isEmpty(companyName)){
  129. layui.use('form', function(){
  130. var form = layui.form;
  131. $.request({
  132. action : 'giveOutManageAction/qureyTransporter',
  133. data : {},
  134. success : function(data) {
  135. var name ="name";
  136. var html = '<select name="';
  137. html = html + name;
  138. html = html + '"';
  139. html = html + 'lay-search="" lay-filter="'+name+'"';
  140. html = html + '><option value="">请选择物流方</option>';
  141. $.each(data.data, function(i, j) {
  142. if( j.name == companyName){
  143. html = html + '<option ';
  144. html = html + 'selected value="';
  145. html = html + j.name + '">';
  146. html = html + j.name+ '</option>';
  147. }else{
  148. html = html + '<option ';
  149. html = html + 'value="';
  150. html = html + j.name + '">';
  151. html = html + j.name+ '</option>';
  152. }
  153. })
  154. html = html + '</select>';
  155. $("#name").html(html);
  156. form.render();
  157. }
  158. })
  159. })
  160. }else{
  161. layui.use('form', function(){
  162. var form = layui.form;
  163. $.request({
  164. action : 'giveOutManageAction/qureyTransporter',
  165. data : {},
  166. success : function(data) {
  167. var name ="name";
  168. var html = '<select name="';
  169. html = html + name;
  170. html = html + '"';
  171. html = html + 'lay-search="" lay-filter="'+name+'"';
  172. html = html + '><option value="">请选择物流方</option>';
  173. $.each(data.data, function(i, j) {
  174. html = html + '<option ';
  175. html = html + 'value="';
  176. html = html + j.name + '">';
  177. html = html + j.name+ '</option>';
  178. })
  179. html = html + '</select>';
  180. $("#name").html(html);
  181. form.render();
  182. }
  183. })
  184. })
  185. }
  186. if(!isEmpty(id)){
  187. reload();
  188. }
  189. layui.use('laydate', function(){
  190. var laydate = layui.laydate;
  191. laydate.render({
  192. elem: '#datesTwo'
  193. ,range: true
  194. ,format:'yyyyMMdd'
  195. ,trigger: 'click'
  196. });
  197. })
  198. var table;
  199. function reload(func){
  200. var datesTwo = $("#datesTwo").val();
  201. var transporter = $("[name='name']").val();
  202. if (isEmpty(transporter)) {
  203. transporter = companyName;
  204. }
  205. if (isEmpty(id)) {
  206. if (isEmpty(datesTwo)) {
  207. $.ErrorAlert("请选择到货日期!");
  208. return;
  209. }
  210. if (isEmpty(transporter)) {
  211. $.ErrorAlert("请选择运输方!");
  212. return;
  213. }
  214. }
  215. $.request({
  216. action : 'giveOutManageAction/freightPrinting',
  217. loading : false,
  218. data : {MINView:"JSON", datesTwo : datesTwo,transporter : transporter, id : id},
  219. success : function(res) {
  220. $('#sell1').html(res.sell);
  221. $('#strh').html(res.strh);
  222. $('#buy').html(res.buy+"(盖章)");
  223. $('#sell').html(res.sell+"(盖章)");
  224. var mesList = res.data;
  225. tableData = heji(mesList);
  226. //新增
  227. layui.use('table', function(){
  228. //创建一行参数
  229. table = layui.table;
  230. table.render({
  231. id : 'tableTest'
  232. ,elem: '#tableTest'
  233. ,data : tableData
  234. ,limit:1000
  235. ,size: 'sm' //小尺寸的表格
  236. ,cols : [[ //表头
  237. {field : 'strh', title: '运费结算月',edit: 'text'}
  238. ,{field : 'deliver', title: '发出库',edit: 'text'}
  239. ,{field : 'arrive', title: '到站地', edit: 'text'}
  240. ,{field : 'weight', title: '到货重量', edit: 'text'}
  241. ,{field : 'price', title: '运费单价(元)', edit: 'text'}
  242. ,{field : 'totalPriceII', title: '运费(元)', edit: 'text'}
  243. ]]
  244. ,page: false
  245. ,done: function(res, curr, count){
  246. //如果是异步请求数据方式,res即为你接口返回的信息。
  247. $("#big").show();
  248. // 处理合计行
  249. var trs = $("tbody").find("tr");
  250. // 最后一个tr的div
  251. var divs = $(trs[trs.length - 1]).find("div");
  252. $(divs[0]).html("合计");
  253. if (!isEmpty(func)) {
  254. func();
  255. }
  256. }
  257. });
  258. table.on('edit(tableFilter)', function(obj){ //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值"
  259. console.log(obj); //所在行的所有相关数据
  260. var editData = obj.data;
  261. var index = editData.LAY_TABLE_INDEX;
  262. var field = obj.field;
  263. var tableData = table.cache["tableTest"];
  264. //修改单价或重量,且不是合计
  265. if ((field == 'weight' || field == 'price') && index != (tableData.length - 1)) {
  266. var editTr = $("tbody").find("tr")[index];
  267. $(editTr).find('td[data-field="totalPriceII"]').click();
  268. $($($(editTr).find('td[data-field="totalPriceII"]')).find("input")).val(accMul(editData.weight, editData.price, 2));
  269. tableData[index].totalPriceII = accMul(editData.weight, editData.price, 2);
  270. var totalWeight = "0";
  271. var totalPrice = "0";
  272. for (var i = 0; i < (tableData.length - 1); i ++) {
  273. var trData = tableData[i];
  274. totalWeight = accAdd(totalWeight, trData.weight, 4);
  275. totalPrice = accAdd(totalPrice, trData.totalPriceII, 2);
  276. }
  277. var hejiTr = $("tbody").find("tr")[tableData.length - 1];
  278. $(hejiTr).find('td[data-field="weight"]').click();
  279. $($($(hejiTr).find('td[data-field="weight"]')).find("input")).val(totalWeight);
  280. $(hejiTr).find('td[data-field="totalPriceII"]').click();
  281. $($($(hejiTr).find('td[data-field="totalPriceII"]')).find("input")).val(totalPrice);
  282. }
  283. });
  284. })
  285. },
  286. error : function(data) {
  287. layer.alert(data.MINErrorMessage, {
  288. icon: 5,
  289. title: "提示"
  290. });
  291. }
  292. });
  293. }
  294. function heji(tableData) {
  295. // 总重量
  296. var weight = 0;
  297. // 总结算金额
  298. var totalPriceII = 0;
  299. for (var i = 0; i < tableData.length; i ++) {
  300. var d = tableData[i];
  301. // 总重量
  302. weight = accAdd(d.weight, weight);
  303. // 总结算金额
  304. totalPriceII = accAdd(d.totalPriceII, totalPriceII);
  305. }
  306. var hejiMap = {};
  307. hejiMap.weight = fomatFloat(weight,4);
  308. hejiMap.totalPriceII = fomatFloat(totalPriceII,2);
  309. tableData.push(hejiMap);
  310. return tableData;
  311. }
  312. //打印
  313. $(document).on('click','#printBtn',function(){
  314. var tableData = table.cache['tableTest'];
  315. var printTableHtml = "";
  316. for (var i = 0; i < tableData.length; i ++) {
  317. var inf = tableData[i];
  318. printTableHtml += '<tr><td>' + (isEmpty(inf.strh)?'合计':inf.strh) + '</td><td>' + (isEmpty(inf.deliver)?'':inf.deliver)
  319. + '</td><td>' + (isEmpty(inf.arrive)?'':inf.arrive) + '</td><td>' + (isEmpty(inf.weight)?'':inf.weight) + '</td><td>'
  320. + (isEmpty(inf.price)?'':inf.price) + '</td><td>' + (isEmpty(inf.totalPriceII)?'':inf.totalPriceII) + '</td></tr>';
  321. }
  322. $("#small").html(printTableHtml);
  323. $(".layui-table-view").hide();
  324. $("#headImg").show();
  325. $("#tableTestPrint").show();
  326.     $("#big").jqprint();
  327. $("#headImg").hide();
  328. $("#tableTestPrint").hide();
  329. $(".layui-table-view").show();
  330. });
  331. //保存
  332. $(document).on('click','#saveBtn',function(){
  333. isConfirm = true;
  334. saveFunc();
  335. });
  336. function saveFunc() {
  337. var datesTwo = $("#datesTwo").val();
  338. var transporter = $("[name='name']").val();
  339. if (isEmpty(datesTwo)) {
  340. $.ErrorAlert("请选择到货日期!");
  341. return;
  342. }
  343. if (isEmpty(transporter)) {
  344. $.ErrorAlert("请选择运输方!");
  345. return;
  346. }
  347. var isShow = $("#big").css("display");
  348. if (isShow == 'none') {
  349. $.ErrorAlert("请先查询!");
  350. return;
  351. }
  352. var saveHtml = window.btoa(encodeURI($("#big").html()));
  353.     $.request({
  354. action : 'giveOutManageAction/freightPrintingSave',
  355. data : {MINView:"JSON", datesTwo : datesTwo,transporter : transporter, saveHtml : saveHtml, id : id},
  356. success : function(data) {
  357. var resId = data.id;
  358. id = resId;
  359. if (isConfirm) {
  360. $.SuccAlert("保存成功!");
  361. }
  362. }
  363. })
  364. }
  365. $(document).on('click','#detailBtn',function(){
  366. if (isEmpty(id)) {
  367. $.ErrorAlert("保存后查看明细数据.");
  368. return;
  369. }
  370. openMainTabPageParent(tabPageId+'-01', '发运数据明细', 'logisticsManage/logisticsInformation.html?tabPageId='+tabPageId+'-01&oprate=del&delTransId='+id,'',tabPageId,back);
  371. });
  372. $(document).on('click','#addDetailBtn',function(){
  373. if (isEmpty(id)) {
  374. $.ErrorAlert("请保存后再增加明细数据!");
  375. return;
  376. }
  377. var transporter = $("[name='name']").val();
  378. openMainTabPageParent(tabPageId+'-02', '选择发运数据明细', 'logisticsManage/logisticsInformation.html?tabPageId='+tabPageId+'-02&transState=01&oprate=add&addTransId='+id+'&transporter='+encodeURI(encodeURI(transporter)),'',tabPageId,back);
  379. });
  380. var isConfirm;
  381. function back() {
  382. var logisticsDel = getTempVal("logisticsDel");
  383. if (!isEmpty(logisticsDel)) {
  384. isConfirm = false;
  385. setTempVal("logisticsDel", null);
  386. reload(saveFunc);
  387. } else {
  388. console.log("未经行删除操作!");
  389. }
  390. }
  391. </script>
  392. </body>
  393. </html>