1
0

order.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. $(function () {
  2. let shippingStatus = getQueryString("shippingStatus");
  3. let payStatus = getQueryString("payStatus");
  4. let orderStatus = getQueryString("orderStatus");
  5. let merchOrderSn = getQueryString("merchOrderSn");
  6. let startTime = getQueryString("startTime");
  7. let endTime = getQueryString("endTime");
  8. let storeId = getQueryString("storeId");
  9. let url = '../order/list?1';
  10. if (shippingStatus) {
  11. url += '&shippingStatus=' + shippingStatus;
  12. }
  13. if (payStatus) {
  14. url += '&payStatus=' + payStatus;
  15. }
  16. if (orderStatus) {
  17. url += '&orderStatus=' + orderStatus;
  18. }
  19. if (merchOrderSn) {
  20. url += '&merchOrderSn=' + merchOrderSn;
  21. }
  22. if (startTime) {
  23. url += '&startTime=' + startTime;
  24. }
  25. if (endTime) {
  26. url += '&endTime=' + endTime;
  27. }
  28. if (storeId) {
  29. url += '&storeId=' + storeId;
  30. }
  31. $("#jqGrid").jqGrid({
  32. url: url,
  33. datatype: "json",
  34. colModel: [
  35. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  36. {label: '所属门店', name: 'storeName', index: 'storeName', width: 80},
  37. {label: '订单号', name: 'orderSn', index: 'order_sn', width: 100},
  38. {label: '会员', name: 'userName', index: 'user_name', width: 80},
  39. {label: '支付类型', name: 'isMergePay', index: 'is_merge_pay', width: 60,
  40. formatter: function (value) {
  41. if (value == '2') {
  42. return '合并支付';
  43. }else if (value == '1') {
  44. return '合并支付';
  45. } else if (value == '0') {
  46. return '单笔支付';
  47. }
  48. return '-';
  49. }
  50. },
  51. {label: '商户订单号', name: 'merchOrderSn', index: 'merchOrderSn', width: 140},
  52. {
  53. label: '订单业务类型', name: 'orderBizType', index: 'order_biz_type', width: 80,
  54. formatter: function (value) {
  55. if (value == '00') {
  56. return '保税备货';
  57. } else if (value == '02') {
  58. return '保税展示补货';
  59. } else if (value == '10') {
  60. return '保税展示跨境';
  61. } else if (value == '11') {
  62. return '普通货物';
  63. }
  64. return '-';
  65. }
  66. },
  67. {
  68. label: '订单状态', name: 'orderStatus', index: 'order_status', width: 80,
  69. formatter: function (value) {
  70. if (value == '0') {
  71. return '订单创建成功等待付款';
  72. } else if (value == '100') {
  73. return '订单付款中';
  74. } else if (value == '101') {
  75. return '订单已取消';
  76. } else if (value == '102') {
  77. return '订单已删除';
  78. } else if (value == '201') {
  79. return '订单已付款,等待发货';
  80. } else if (value == '300') {
  81. return '订单已发货';
  82. } else if (value == '301') {
  83. return '用户确认收货';
  84. } else if (value == '401') {
  85. return '没有发货,退款';
  86. } else if (value == '402') {
  87. return '已收货,退款退货';
  88. }
  89. return value;
  90. }
  91. },
  92. {
  93. label: '订付人核验', name: 'buyerPayCheck', index: 'buyer_pay_check', width: 80,
  94. formatter: function (value) {//订购人支付人校验,0:未知,1:一致,2:不一致,3:校验异常
  95. if (value == '0') {
  96. return '未知';
  97. } else if (value == '1') {
  98. return '一致';
  99. } else if (value == '2') {
  100. return '不一致';
  101. }
  102. return "-";
  103. }
  104. },
  105. {
  106. label: '付款状态', name: 'payStatus', index: 'pay_status', width: 80,
  107. formatter: function (value) {
  108. if (value == '0') {
  109. return '未付款';
  110. } else if (value == '1') {
  111. return '付款中';
  112. } else if (value == '2') {
  113. return '已付款';
  114. } else if (value == '3') {
  115. return '退款中';
  116. } else if (value == '4') {
  117. return '退款';
  118. }
  119. return value;
  120. }
  121. },
  122. // {label: '收货人', name: 'consignee', index: 'consignee', width: 80},
  123. // {label: '收货地址', name: 'address', index: 'address', width: 80},
  124. // {label: '联系电话', name: 'mobile', index: 'mobile', width: 80},
  125. {label: '实际支付', name: 'actualPrice', index: 'actual_price', width: 60},
  126. {label: '订单总价', name: 'orderPrice', index: 'order_price', width: 60},
  127. {
  128. label: '下单时间', name: 'addTime', index: 'add_time', width: 120,
  129. formatter: function (value) {
  130. console.log(value);
  131. return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  132. }
  133. },
  134. {label: '快递公司', name: 'shippingName', index: 'shipping_name', width: 80},
  135. {label: '配送单号', name: 'shippingNo', index: 'shipping_No', width: 80},
  136. {label: '快递费用', name: 'shippingFee', index: 'shipping_fee', width: 80},
  137. {
  138. label: '发货状态', name: 'shippingStatus', index: 'shipping_status', width: 60,
  139. formatter: function (value) {
  140. if (value == '0') {
  141. return '未发货';
  142. } else if (value == '1') {
  143. return '已发货';
  144. } else if (value == '2') {
  145. return '已收货';
  146. } else if (value == '4') {
  147. return '退货';
  148. }
  149. return value;
  150. }
  151. },
  152. {label: '修改人', name: 'moderSn', index: 'moderSn', width: 80},
  153. {
  154. label: '操作', width: 180, sortable: false,
  155. formatter: function (value, col, row) {
  156. let htmlStr = '<button class="btn btn-outline btn-info" onclick="vm.lookDetail(' + row.id + ')"><i class="fa fa-info-circle"></i>详情</button>&nbsp;';
  157. //订单状态: 0订单创建成功等待付款, 101订单已取消, 102订单已删除,201订单已付款,等待发货,300订单已发货, 301用户确认收货,401 没有发货,退款 402 已收货,退款退货
  158. if(hasPermission('order:printMsg')){
  159. if (row.orderStatus == 300 && (row.orderBizType == '10' || row.orderBizType == '02')) {
  160. htmlStr += '<button class="btn btn-outline btn-primary" onclick="vm.printDetail(' + row.id + ')"><i class="fa fa-print"></i>打印</button>&nbsp;';
  161. }
  162. }
  163. if (hasPermission('order:refund')) {
  164. if (row.orderStatus == 0) {
  165. htmlStr += '<button class="btn btn-outline btn-danger" onclick="vm.cancelUpdate(' + row.id + ')"><i class="fa fa-times-circle-o"></i>&nbsp;取消</button>&nbsp;';
  166. }
  167. if (row.orderStatus == 201) {
  168. if (row.isPaymentSend == 0 || row.isEleOrderSend == 0 || row.isCustomsSend == 0) {
  169. htmlStr += '<button class="btn btn-outline btn-danger" onclick="vm.refundUpdate(' + row.id + ')"><i class="fa fa-times-circle-o"></i>&nbsp;退款</button>&nbsp;';
  170. }
  171. }
  172. }
  173. return htmlStr;
  174. }
  175. }
  176. ],
  177. viewrecords: true,
  178. height: 550,
  179. rowNum: 10,
  180. rowList: [10, 30, 50],
  181. rownumbers: true,
  182. rownumWidth: 25,
  183. autowidth: true,
  184. multiselect: true,
  185. pager: "#jqGridPager",
  186. jsonReader: {
  187. root: "page.list",
  188. page: "page.currPage",
  189. total: "page.totalPage",
  190. records: "page.totalCount"
  191. },
  192. prmNames: {
  193. page: "page",
  194. rows: "limit",
  195. order: "order"
  196. },
  197. gridComplete: function () {
  198. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  199. }
  200. });
  201. });
  202. let vm = new Vue({
  203. el: '#rrapp',
  204. data: {
  205. showDiv: 1, // 1查询 2编辑 3发货 4选择骑手 5退款
  206. title: null,
  207. order: {},
  208. shippings: [],
  209. q: {
  210. orderSn: '',
  211. orderStatus: '',
  212. merchOrderSn: '',
  213. startTime: '',
  214. endTime: '',
  215. storeId: '',
  216. payStatus:''
  217. },
  218. refundMoney: 0,
  219. shipping: {},
  220. logisticsInfo: {
  221. tracesList: [],
  222. logisticCode: '',
  223. shipperCode: ''
  224. },
  225. macros: [],
  226. orderProcessRecordEntity: {},
  227. orderGoodsList: [],
  228. stores: [],
  229. orderStatusList:[],
  230. payStatusList:[],
  231. ruleValidate: {
  232. /*name: [
  233. {required: true, message: '名称不能为空', trigger: 'blur'}
  234. ]*/
  235. }
  236. },
  237. methods: {
  238. query: function () {
  239. vm.reload(1);
  240. },
  241. getMacro: function () {
  242. $.get("../sys/macro/queryMacrosByValue?value=goodsBizType", function (r) {
  243. vm.macros = r.list;
  244. });
  245. },
  246. getLogistics: function (event) {
  247. let id = getSelectedRow();
  248. if (id == null) {
  249. return;
  250. }
  251. $.get("../order/getLogistics/" + id, function (r) {
  252. if (r.code != 0) {
  253. alert(r.msg);
  254. return;
  255. }
  256. vm.logisticsInfo = r.result;
  257. vm.showDiv = 3;
  258. vm.title = "快递信息";
  259. });
  260. },
  261. getExpressInfo: function (event) {
  262. let id = getSelectedRow();
  263. if (id == null) {
  264. return;
  265. }
  266. $.get("../order/infos/" + id, function (r) {
  267. vm.order = r.order;
  268. vm.showDiv = 8;
  269. vm.title = "修改快递信息";
  270. });
  271. },
  272. updateExpressInfo: function (event) {
  273. $.ajax({
  274. type: "POST",
  275. url: '../order/updateExpressInfo',
  276. contentType: "application/json",
  277. data: JSON.stringify(vm.order),
  278. success: function (r) {
  279. if (r.code === 0) {
  280. alert('操作成功', function (index) {
  281. vm.reload();
  282. });
  283. } else {
  284. alert(r.msg);
  285. }
  286. }
  287. });
  288. },
  289. handleSubmit: function (name) {
  290. // handleSubmitValidate(this, name, function () {
  291. vm.updateExpressInfo()
  292. // });
  293. },
  294. getProcess: function (event) {
  295. let orderSn = getSelectedRowData().orderSn;
  296. if (orderSn == null) {
  297. return;
  298. }
  299. $.get("../order/getProcess/" + orderSn, function (r) {
  300. if (r.code != 0) {
  301. alert(r.msg);
  302. return;
  303. }
  304. if (r.orderProcessRecordEntity != null) {
  305. vm.orderProcessRecordEntity = r.orderProcessRecordEntity;
  306. vm.showDiv = 7;
  307. } else {
  308. alert(orderSn + "暂无清关信息");
  309. }
  310. });
  311. },
  312. confirm: function (event) {
  313. let id = getSelectedRow();
  314. if (id == null) {
  315. return;
  316. }
  317. confirm('确定收货?', function () {
  318. $.ajax({
  319. type: "POST",
  320. url: "../order/confirm",
  321. contentType: "application/json",
  322. data: JSON.stringify(id),
  323. dataType: "json",
  324. success: function (r) {
  325. if (r.code == 0) {
  326. alert('操作成功', function (index) {
  327. $("#jqGrid").trigger("reloadGrid");
  328. });
  329. } else {
  330. alert(r.msg);
  331. }
  332. }
  333. });
  334. });
  335. },
  336. openComment: function (event) {
  337. let id = getSelectedRow();
  338. if (id == null) {
  339. return;
  340. }
  341. openWindow({
  342. type: 2,
  343. title: '评价',
  344. content: '../shop/comment.html?orderId=' + id
  345. });
  346. },
  347. shippingChange: function (opt) {
  348. vm.order.shippingName = opt.label;
  349. vm.order.shippingCode = opt.value;
  350. },
  351. saveOrUpdate: function (event) {
  352. $.ajax({
  353. type: "POST",
  354. url: '../order/sendGoods',
  355. contentType: "application/json",
  356. data: JSON.stringify(vm.order),
  357. success: function (r) {
  358. if (r.code === 0) {
  359. alert('操作成功', function (index) {
  360. vm.reload();
  361. });
  362. } else {
  363. alert(r.msg);
  364. }
  365. }
  366. });
  367. },
  368. reload: function (event) {
  369. vm.showDiv = 1;
  370. let page = event;
  371. if (event != 1) {
  372. page = $("#jqGrid").jqGrid('getGridParam', 'page');
  373. }
  374. $("#jqGrid").jqGrid('setGridParam', {
  375. postData: {
  376. 'orderSn': vm.q.orderSn,
  377. 'orderStatus': vm.q.orderStatus,
  378. 'merchOrderSn': vm.q.merchOrderSn,
  379. 'startTime': vm.q.startTime,
  380. 'endTime': vm.q.endTime,
  381. 'storeId': vm.q.storeId,
  382. 'payStatus': vm.q.payStatus
  383. },
  384. page: page
  385. }).trigger("reloadGrid");
  386. },
  387. reloadSearch: function () {
  388. vm.q = {
  389. orderSn: '',
  390. orderStatus: '',
  391. merchOrderSn: '',
  392. startTime: '',
  393. endTime: '',
  394. storeId: '',
  395. payStatus: ''
  396. };
  397. },
  398. lookDetail: function (rowId) { //第三步:定义编辑操作
  399. vm.showDiv = 2;
  400. vm.title = "订单详情";
  401. $.get("../order/infos/" + rowId, function (r) {
  402. vm.order = r.order;
  403. vm.orderGoodsList = r.order.orderGoodsEntityList;
  404. });
  405. vm.getMacro();
  406. },
  407. printDetail: function (rowId) {
  408. confirm('确定连接打票机打印出票?', function () {
  409. $.ajax({
  410. type: "POST",
  411. url: "../order/printMsg",
  412. contentType: "application/json",
  413. data: JSON.stringify(rowId),
  414. success: function (r) {
  415. if (r.ticket != null) {
  416. // printArea(r.ticket);
  417. var content = getPrintContent(r.ticket);
  418. printArea(content);
  419. alert('打印小票完成');
  420. }else{
  421. alert("打印小票失败");
  422. }
  423. }
  424. });
  425. })
  426. },
  427. shippingBind: function (event) {
  428. let orderId = vm.order.id;
  429. $.ajax({
  430. type: "POST",
  431. url: '../order/shippingBind',
  432. data: {orderId: orderId, shippingCode: vm.shipping},
  433. success: function (r) {
  434. if (r.code === 0) {
  435. alert('操作成功', function (index) {
  436. vm.reload();
  437. });
  438. } else {
  439. alert(r.msg);
  440. }
  441. }
  442. });
  443. },
  444. refund: function (rowId) {
  445. vm.showDiv = 5;
  446. vm.refundMoney = 0;
  447. Ajax.request({
  448. url: "../order/info/" + rowId,
  449. async: true,
  450. successCallback: function (r) {
  451. vm.order = r.order;
  452. vm.refundMoney = r.order.actualPrice;
  453. }
  454. });
  455. },
  456. cancelUpdate: function (rowId) {
  457. let params = {};
  458. params.orderId = rowId;
  459. $.ajax({
  460. type: "POST",
  461. url: '../order/cancel',
  462. data: params,
  463. success: function (r) {
  464. if (r.code === 0) {
  465. alert('取消成功', function (index) {
  466. vm.reload();
  467. });
  468. } else {
  469. alert(r.msg);
  470. }
  471. }
  472. });
  473. },
  474. refundUpdate: function (rowId) {
  475. let params = {};
  476. params.orderId = rowId;
  477. $.ajax({
  478. type: "POST",
  479. url: '../order/refund',
  480. data: params,
  481. success: function (r) {
  482. if (r.code === 0) {
  483. alert('退款成功', function (index) {
  484. vm.reload();
  485. });
  486. } else {
  487. alert(r.msg);
  488. }
  489. }
  490. });
  491. },
  492. exportOrder: function() {
  493. var params = {};
  494. params.orderSn = vm.q.orderSn, params.orderStatus = vm.q.orderStatus, params.merchOrderSn = vm.q.merchOrderSn
  495. , params.startTime = vm.q.startTime, params.endTime = vm.q.endTime, params.storeId = vm.q.storeId,params.payStatus = vm.q.payStatus;
  496. exportFile('#rrapp', '../order/export', params);
  497. /*$.ajax({
  498. type: "get",
  499. url: '../order/export',
  500. data: params,
  501. success: function (r) {
  502. if (r.code === 0) {
  503. alert('导出成功', function (index) {
  504. vm.reload();
  505. });
  506. } else {
  507. alert(r.msg);
  508. }
  509. }
  510. });*/
  511. }
  512. },
  513. created: function () {
  514. $.get("../shipping/queryAll", function (r) {
  515. vm.shippings = r.list;
  516. });
  517. },
  518. mounted() {
  519. $.get("../store/queryAll", function (r) {
  520. vm.stores = r.list;
  521. });
  522. $.get("../sys/macro/queryMacrosByValue?value=orderStatus", function (r) {
  523. vm.orderStatusList = r.list;
  524. });
  525. $.get("../sys/macro/queryMacrosByValue?value=payStatus", function (r) {
  526. vm.payStatusList = r.list;
  527. });
  528. }
  529. });
  530. // var printAreaCount = 0;
  531. // function printArea(ticket) {
  532. // var idPrefix = "printArea_";
  533. // removePrintArea(idPrefix + printAreaCount);
  534. // printAreaCount++;
  535. // var iframeId = idPrefix + printAreaCount;
  536. // var iframeStyle = 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;';
  537. // iframe = document.createElement('IFRAME');
  538. // $(iframe).attr({
  539. // style: iframeStyle,
  540. // id: iframeId
  541. // });
  542. // document.body.appendChild(iframe);
  543. // var doc = iframe.contentWindow.document;
  544. // $(document).find("link").filter(function () {
  545. // return $(this).attr("rel").toLowerCase() == "stylesheet";
  546. // }).each(
  547. // function () {
  548. // doc.write('<link type="text/css" rel="stylesheet" href="'
  549. // + $(this).attr("href") + '" >');
  550. // });
  551. // doc.write('<div class="">' + content
  552. // + '</div>');
  553. // doc.close();
  554. // var frameWindow = iframe.contentWindow;
  555. // frameWindow.close();
  556. // frameWindow.focus();
  557. // frameWindow.print();
  558. // }
  559. // var removePrintArea = function (id) {
  560. // $("iframe#" + id).remove();
  561. // };
  562. function getPrintContent(ticket) {
  563. var content = "<div style=\"width: 250px;font-family: 微软雅黑;font-size: 8px;\">";
  564. //小票头
  565. content += "<div style=\"text-align: center;width: 100%;font-weight:bold;font-size: 13px;\">";
  566. content += ticket.ticketHead.title;
  567. content += "</div>";
  568. content += "<div style=\"width: 100%;\">";
  569. content += "会员:" + ticket.ticketHead.memberId;
  570. content += "</div>";
  571. content += "<div style=\"width: 100%;\">";
  572. content += "订单号:" + ticket.ticketHead.orderId;
  573. content += "</div>";
  574. content += "<div style=\"width: 100%;\">";
  575. content += "交易时间:" + ticket.ticketHead.tradeTime;
  576. content += "</div>";
  577. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  578. //商品信息
  579. content += "<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  580. content += "<tr>";
  581. content += "<td style=\"width: 50%;text-align: left;font-size: 10px;font-weight: bold;\">商品名称</td>";
  582. content += "<td style=\"width: 17%;text-align: right;font-size: 10px;font-weight: bold;\">单价</td>";
  583. content += "<td style=\"width: 15%;text-align: right;font-size: 10px;font-weight: bold;\">数量</td>";
  584. content += "<td style=\"width: 18%;text-align: right;font-size: 10px;font-weight: bold;\">小计</td>";
  585. content += "</tr>";
  586. content += "</table>";
  587. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  588. content += "<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  589. for (var i=0;i< ticket.goods.length;i++){
  590. content += "<tr>";
  591. content += "<td style=\"width: 50%;text-align: left;font-size: 8px;padding-top: 8px;\">";
  592. content += "<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  593. content += "<tr>";
  594. content += "<td style=\"text-align: left;font-size: 8px;vertical-align:top;\">#</td>";
  595. content += "<td style=\"text-align: left;font-size: 8px;\">" + ticket.goods[i].gname + "</td>";
  596. content += "</tr>";
  597. content += "</table>";
  598. content += "</td>";
  599. content += "<td style=\"width: 17%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].uprice + "</td>";
  600. content += "<td style=\"width: 15%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].num + "</td>";
  601. content += "<td style=\"width: 18%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].subtotal + "元</td>";
  602. content += "</tr>";
  603. }
  604. content += "</table>";
  605. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  606. //收银信息
  607. content += "<div style=\"width: 100%;\">";
  608. content += "<span style=\"float: left;width: 50%;text-align: left;\">商品合计:</span>";
  609. content += "<span style=\"float: left;width: 17%;text-align: left;\">" + ticket.cashInfo.goodsTotal + "件</span>";
  610. content += "<span style=\"float: right;width: 33%;text-align: right;\">" + ticket.cashInfo.total + "元</span>";
  611. content += "</div>";
  612. content += "<div style=\"width: 100%;\">";
  613. content += "<span style=\"float: left;width: 50%;text-align: left;\">实收:</span>";
  614. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.receipts + "元</span>";
  615. content += "</div>";
  616. content += "<div style=\"width: 100%;\">";
  617. content += "<span style=\"float: left;width: 50%;text-align: left;\">找零:</span>";
  618. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.oddChange + "元</span>";
  619. content += "</div>";
  620. content += "<div style=\"width: 100%;\">";
  621. content += "<span style=\"float: left;width: 50%;text-align: left;\">优惠券:</span>";
  622. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.coupon + "元</span>";
  623. content += "</div>";
  624. content += "<div style=\"width: 100%;\">";
  625. content += "<span style=\"float: left;width: 50%;text-align: left;\">运费:</span>";
  626. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.freight + "元</span>";
  627. content += "</div>";
  628. content += "<div style=\"width: 100%;\">";
  629. content += "<span style=\"float: left;width: 50%;text-align: left;\">支付渠道:</span>";
  630. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.paymentMode + "</span>";
  631. content += "</div>";
  632. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  633. //海关清单信息
  634. content += "<div style=\"width: 100%;\">";
  635. content += "订单号:" + ticket.cusListing.orderId;
  636. content += "</div>";
  637. content += "<div style=\"width: 100%;\">";
  638. content += "运单编号:" + ticket.cusListing.waybillId;
  639. content += "</div>";
  640. content += "<div style=\"width: 100%;\">";
  641. content += "海关清单号:" + ticket.cusListing.invtNo;
  642. content += "</div>";
  643. content += "<div style=\"width: 100%;\">";
  644. content += "收货人:" + ticket.cusListing.consignee;
  645. content += "</div>";
  646. content += "<div style=\"width: 100%;\">";
  647. content += "收货人电话:" + ticket.cusListing.consigneeTel;
  648. content += "</div>";
  649. content += "<div style=\"width: 100%;\">";
  650. content += "始发地:" + ticket.cusListing.originAddress;
  651. content += "</div>";
  652. content += "<div style=\"width: 100%;\">";
  653. content += "交货地:" + ticket.cusListing.deliveryAddress;
  654. content += "</div>";
  655. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  656. content += "<div style=\"width: 100%;\">";
  657. content += ticket.ticketFoot.summary;
  658. content += "</div>";
  659. content += "<div style=\"width: 100%;\">";
  660. content += "客服电话:" + ticket.ticketFoot.serviceTel;
  661. content += "</div>";
  662. content += "<div style=\"width: 100%;\">";
  663. content += "网址:" + ticket.ticketFoot.url1;
  664. content += "</div>";
  665. content += "<div style=\"width: 100%;\">";
  666. content += ticket.ticketFoot.welcome;
  667. content += "</div>";
  668. return content;
  669. }
  670. var printAreaCount = 0;
  671. function printArea(content) {
  672. var idPrefix = "printArea_";
  673. removePrintArea(idPrefix + printAreaCount);
  674. printAreaCount++;
  675. var iframeId = idPrefix + printAreaCount;
  676. var iframeStyle = 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;';
  677. iframe = document.createElement('IFRAME');
  678. $(iframe).attr({
  679. style: iframeStyle,
  680. id: iframeId
  681. });
  682. document.body.appendChild(iframe);
  683. var doc = iframe.contentWindow.document;
  684. doc.open();
  685. //$(document).find("link").filter(function () {
  686. //return $(this).attr("rel").toLowerCase() == "stylesheet";
  687. //}).each(
  688. //function () {
  689. //doc.write('<link type="text/css" rel="stylesheet" href="'
  690. //+ $(this).attr("href") + '" >');
  691. //});
  692. doc.write('<div class="">' + content
  693. + '</div>');
  694. doc.close();
  695. var frameWindow = iframe.contentWindow;
  696. frameWindow.close();
  697. frameWindow.focus();
  698. frameWindow.print();
  699. }
  700. var removePrintArea = function (id) {
  701. $("iframe#" + id).remove();
  702. };