hcInvoice.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <div class="invoice_container">
  3. <div class="title">
  4. <el-row>
  5. <el-col :span="24">
  6. <div class="top">
  7. <!-- <el-input placeholder="客户" class="input-demo" v-model="formCondition.customerName"></el-input> -->
  8. <el-input placeholder="购方名称" class="input-demo" v-model="formCondition.buyerName"></el-input>
  9. <el-date-picker v-model="formCondition.month" type="month" value-format="yyyy-MM" placeholder="选择月份"> </el-date-picker>
  10. <el-button type="success" style="margin-left: 1%;" @click="loadData">查询</el-button>
  11. <el-button type="success" style="margin-left: 1%;" @click="updateData">更新</el-button>
  12. <el-button type="primary" style="margin-left: 1%;" @click="exportExcel">导出报表</el-button>
  13. </div>
  14. </el-col>
  15. </el-row>
  16. </div>
  17. <!-- 表格部分 -->
  18. <template>
  19. <el-table
  20. class="table"
  21. v-loading="loading"
  22. ref="multipleTable"
  23. :data="invoiceTable"
  24. :height="heightt"
  25. border
  26. tooltip-effect="dark">
  27. <el-table-column
  28. prop="sellerName"
  29. label="销方名称"
  30. show-overflow-tooltip>
  31. </el-table-column>
  32. <el-table-column
  33. prop="sellerTaxpayerCode"
  34. label="销方税号"
  35. show-overflow-tooltip>
  36. </el-table-column>
  37. <el-table-column
  38. prop="buyerName"
  39. label="购方名称"
  40. show-overflow-tooltip>
  41. </el-table-column>
  42. <el-table-column
  43. prop="buyerTaxpayerCode"
  44. label="购方税号"
  45. show-overflow-tooltip>
  46. </el-table-column>
  47. <el-table-column
  48. prop="amount"
  49. label="金额"
  50. show-overflow-tooltip>
  51. <template slot-scope="scope">
  52. <span>{{scope.row.amount/100| rounding}}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column
  56. prop="rawInvoiceId"
  57. label="原票id"
  58. width="120"
  59. show-overflow-tooltip>
  60. </el-table-column>
  61. <el-table-column
  62. prop="rawInvoiceCode"
  63. label="原票发票代码"
  64. width="140"
  65. show-overflow-tooltip>
  66. </el-table-column>
  67. <el-table-column
  68. prop="rawInvoiceNum"
  69. width="140"
  70. label="原票发票号码"
  71. show-overflow-tooltip>
  72. </el-table-column>
  73. <el-table-column
  74. prop="invoiceCode"
  75. label="红票代码"
  76. show-overflow-tooltip>
  77. </el-table-column>
  78. <el-table-column
  79. prop="invoiceNum"
  80. label="红票号码"
  81. show-overflow-tooltip>
  82. </el-table-column>
  83. <el-table-column
  84. prop="invoiceUrl"
  85. width="140"
  86. label="红票下载url"
  87. show-overflow-tooltip>
  88. <template slot-scope="scope">
  89. <a :href="scope.row.invoiceUrl" target="_blank">{{scope.row.invoiceUrl}}</a>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. </template>
  94. </div>
  95. </template>
  96. <script type="text/javascript">
  97. import FileSaver from "file-saver";
  98. import XLSX from "xlsx";
  99. export default {
  100. data(){
  101. return{
  102. formCondition:{
  103. },
  104. invoiceTable:[],
  105. hightt:'0px',
  106. }
  107. },
  108. created() {
  109. this.heightt = tableHeight+100;
  110. },
  111. filters: {
  112. rounding (value) {
  113. return value.toFixed(2)
  114. }
  115. },
  116. methods:{
  117. // 列表展示
  118. async loadData() {
  119. if(this.formCondition.month == null || this.formCondition.month==''){
  120. this.$message({
  121. type: 'error',
  122. message:'请先选择需要查询的月份'
  123. });
  124. return
  125. }
  126. const loading = this.$loading({
  127. lock: true,
  128. text: '系统正在努力接收中...',
  129. spinner: 'el-icon-loading',
  130. background: 'rgba(0, 0, 0, 0.7)'
  131. });
  132. const response = await this.$http.post('noCarService/hCVoiceQuery', this.formCondition);
  133. loading.close();
  134. if (response.data.code === 0) {
  135. this.invoiceTable = response.data.data.result;
  136. }else{
  137. this.$message({
  138. type: 'error',
  139. message: ''+response.data.msg
  140. });
  141. }
  142. },
  143. // 列表展示
  144. async updateData() {
  145. if(this.formCondition.month == null || this.formCondition.month==''){
  146. this.$message({
  147. type: 'error',
  148. message:'请先选择需要查询的月份'
  149. });
  150. return
  151. }
  152. const loading = this.$loading({
  153. lock: true,
  154. text: '系统正在努力更新...',
  155. spinner: 'el-icon-loading',
  156. background: 'rgba(0, 0, 0, 0.7)'
  157. });
  158. const response = await this.$http.post('noCarService/hCVoiceUpdate', this.formCondition);
  159. loading.close();
  160. if (response.data.code === 0) {
  161. this.$message.success('更新成功');
  162. }else{
  163. this.$message({
  164. type: 'error',
  165. message: ''+response.data.msg
  166. });
  167. }
  168. },
  169. // 分页方法
  170. handleSizeChange(val) {
  171. this.pagesize = val;
  172. this.loadData();
  173. },
  174. handleCurrentChange(val) {
  175. this.current = val;
  176. this.loadData();
  177. },
  178. formartNum(wb){
  179. var sheet = wb['Sheets']['Sheet1'];
  180. var replaceTemp = [];
  181. for(var i in sheet){
  182. if(sheet[i]['v'] == '金额'){
  183. replaceTemp.push(i.replace(/[0-9]/g,''));
  184. continue;
  185. }
  186. if(replaceTemp.includes(i.replace(/[0-9]/g,''))){
  187. sheet[i]['t']='n';
  188. }
  189. }
  190. },
  191. async exportExcel() {
  192. const loading = this.$loading({
  193. lock: true,
  194. text: '系统正在努力接收中,过程大概需要几分钟的时间,请您耐心等待...',
  195. spinner: 'el-icon-loading',
  196. background: 'rgba(0, 0, 0, 0.7)'
  197. });
  198. let curr = this.current;
  199. let pagesize1 = this.pagesize;
  200. this.current = 1;
  201. this.pagesize = this.total;
  202. await this.loadData();
  203. // 设置当前日期
  204. let time = new Date();
  205. let year = time.getFullYear();
  206. let month = time.getMonth() + 1;
  207. let day = time.getDate();
  208. let name = "无车红冲发票查询列表_"+year + "" + month + "" + day;
  209. /* generate workbook object from table */
  210. // .table要导出的是哪一个表格
  211. var wb = XLSX.utils.table_to_book(document.querySelector(".table"),{ raw: true });
  212. this.formartNum(wb);
  213. /* get binary string as output */
  214. var wbout = XLSX.write(wb, {
  215. bookType: "xlsx",
  216. bookSST: true,
  217. type: "array"
  218. });
  219. try {
  220. // name+'.xlsx'表示导出的excel表格名字
  221. FileSaver.saveAs(
  222. new Blob([wbout], { type: "application/octet-stream" }),
  223. name + ".xlsx"
  224. );
  225. } catch (e) {
  226. if (typeof console !== "undefined") console.log(e, wbout);
  227. }
  228. this.current = curr;
  229. this.pagesize = pagesize1;
  230. this.loadData();
  231. loading.close();
  232. return wbout;
  233. },
  234. }
  235. };
  236. </script>
  237. <style>
  238. .invoice_container {
  239. border: 1px solid #d9d9d9;
  240. border-radius: 10px;
  241. }
  242. .invoice_container .title {
  243. font-size: 5px;
  244. margin-bottom: 20px;
  245. }
  246. .invoice_container .top {
  247. padding-top: 20px;
  248. padding-left: 20px;
  249. }
  250. .invoice_container .text {
  251. display: inline-block;
  252. color: #000;
  253. font-size: 16px ;
  254. margin-left: 1%;
  255. }
  256. .invoice_container .input-demo {
  257. display: inline-block;
  258. width: 20%;
  259. margin-left: 1%;
  260. }
  261. .invoice_container .block {
  262. font-size: 5px;
  263. text-align: center;
  264. margin-top: 25px;
  265. margin-bottom: 25px;
  266. }
  267. .invoice_container .el-dialog {
  268. width: 60%;
  269. }
  270. .invoice_container .el-dialog__header, .el-dialog__body {
  271. padding: 0 20px;
  272. }
  273. .invoice_container .tou {
  274. font-size: 20px;
  275. height: 30px;
  276. line-height: 30px;
  277. padding-top: 15px;
  278. }
  279. .invoice_container .line {
  280. margin-top: 15px;
  281. margin-bottom: 15px;
  282. width: 100%;
  283. height: 2px;
  284. background-color: #d9d9d9;
  285. }
  286. .invoice_container .xinxi {
  287. text-align: center;
  288. margin: 15px auto;
  289. font-size: 18px;
  290. }
  291. </style>