goodsexportpdf.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. $(function () {
  2. });
  3. let vm = new Vue({
  4. el: '#rrapp',
  5. data: {
  6. selectButtonDisabled:true,
  7. q: {
  8. storeId: '',
  9. barCode: '',
  10. sku: '',
  11. isHead: '0',
  12. pdfType: '36',
  13. headUrl: '',
  14. isPrintRate:'1'
  15. },
  16. stores: [],
  17. labels:[],
  18. isHeads: [{
  19. id: '0',
  20. name: '无标签头'
  21. }, {
  22. id: '1',
  23. name: '有标签头'
  24. }],
  25. isPrintRates: [{
  26. id: '0',
  27. name: '不打印税率'
  28. }, {
  29. id: '1',
  30. name: '打印税率'
  31. }],
  32. pdfTypes: [ {id: '36',
  33. name: '36规格'}
  34. ]
  35. },
  36. methods: {
  37. changeHead:function(){
  38. // console.log(vm.q)
  39. // console.log(vm.selectButtonDisabled)
  40. if (vm.q.isHead=='0'){
  41. vm.pdfTypes=[ {id: '36',
  42. name: '36规格'}
  43. ];
  44. vm.q.pdfType='36';
  45. vm.selectButtonDisabled=!vm.selectButtonDisabled;
  46. }else {
  47. vm.pdfTypes=[{
  48. id: '1',
  49. name: '1规格'
  50. }, {
  51. id: '2',
  52. name: '2规格'
  53. }, {
  54. id: '4',
  55. name: '4规格'
  56. }, {
  57. id: '9',
  58. name: '9规格'
  59. }, {
  60. id: '12',
  61. name: '12规格'
  62. }, {
  63. id: '18',
  64. name: '18规格'
  65. }, {id: '36',
  66. name: '36规格'}
  67. ]
  68. vm.selectButtonDisabled=!vm.selectButtonDisabled;
  69. }
  70. },
  71. // selectLabelHead: function () {
  72. //
  73. //
  74. //
  75. //
  76. // alert("selectLabelHead")
  77. // },
  78. exportPdf: function () {
  79. if (vm.q.storeId==''){
  80. alert("请先选择门店")
  81. return;
  82. }
  83. if (vm.q.sku=='' && vm.q.barCode==''){
  84. alert("请先输入sku或者条形码")
  85. return;
  86. }
  87. if (vm.q.isHead=='1' && vm.q.headUrl==''){
  88. alert("请先标签头")
  89. return;
  90. }
  91. window.open("../pdf/printPdf?type="+vm.q.pdfType+"&sku="+vm.q.sku+"&prodBarcode="
  92. +vm.q.barCode+"&head="+vm.q.isHead+"&headUrl="+vm.q.headUrl+"&storeId="+vm.q.storeId+"&isPrintRate="+vm.q.isPrintRate);
  93. $.get("../pdf/printPdf?type="+vm.q.pdfType+"&sku="+vm.q.sku+"&prodBarcode="
  94. +vm.q.barCode+"&head="+vm.q.isHead+"&headUrl="+vm.q.headUrl+"&storeId="+vm.q.storeId+"&isPrintRate="+vm.q.isPrintRate, function (r) {
  95. console.log(r)
  96. alert(r)
  97. });
  98. },
  99. barCodeEnter:function () {
  100. this.exportPdf();
  101. },
  102. uploadExcelSuccess: function (data) {
  103. if(data.code==0){
  104. console.log(data)
  105. var PDFGoodsDtoList = data.PDFGoodsDtoList;
  106. for(var i=0;i<PDFGoodsDtoList.length;i++){
  107. var pdfGoodsDto = PDFGoodsDtoList[i];
  108. window.open("../pdf/printPdf?type="+pdfGoodsDto.type+"&sku="+pdfGoodsDto.sku+"&prodBarcode="
  109. +pdfGoodsDto.prodBarcode+"&head="+pdfGoodsDto.head+"&headUrl="+pdfGoodsDto.headUrl+"&storeId="+pdfGoodsDto.storeId+"&isPrintRate="+pdfGoodsDto.isPrintRate);
  110. }
  111. }else{
  112. console.log(data)
  113. }
  114. },
  115. uploadExcelError: function (data) {
  116. console.log(data);
  117. alert('上传出现异常,请重试!');
  118. },
  119. uploadExcelFormatError: function (file) {
  120. this.$Notice.warning({
  121. title: '文件格式不正确',
  122. desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
  123. });
  124. }
  125. },
  126. mounted() {
  127. $.get("../store/queryAll", function (r) {
  128. vm.stores = r.list;
  129. });
  130. $.ajax({
  131. type: "POST",
  132. url: "../goodslabelhead/list",
  133. contentType: "application/json",
  134. success: function (r) {
  135. if (r.code === 0) {
  136. console.log(r);
  137. vm.labels = r.page.list
  138. } else {
  139. alert(r.msg);
  140. }
  141. }
  142. });
  143. }
  144. });