calculateInfo.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div class="calculateInfo_container">
  3. <div class="title">
  4. <el-row>
  5. <el-col :span="24">
  6. <div class="top">
  7. <div class="demo-input-suffix">
  8. <el-input placeholder="主体名称" class="input-demo" v-model="formCondition.companyLongName"></el-input>
  9. <el-input placeholder="公司名称" class="input-demo" v-model="formCondition.companyName"></el-input>
  10. <el-input placeholder="税号" class="input-demo" v-model="formCondition.companyReferencenum"></el-input>
  11. <el-input placeholder="etc卡号" class="input-demo" v-model="formCondition.etcNum"></el-input>
  12. </div>
  13. <div class="demo-input-suffix" style="margin-top: 5px;margin-left: 10px;">
  14. <el-date-picker v-model="formCondition.calTime" type="monthrange" value-format="yyyy-MM" range-separator="至" start-placeholder="计费开始" end-placeholder="计费结束"></el-date-picker>
  15. <el-button type="success" style="margin-left: 1%;" @click="firstLoadData">查询</el-button>
  16. <el-button type="primary" style="margin-left: 1%;" @click="exportExcel">导出报表</el-button>
  17. </div>
  18. </div>
  19. </el-col>
  20. </el-row>
  21. </div>
  22. <!-- 表格部分 -->
  23. <template>
  24. <el-table
  25. class="table"
  26. v-loading="loading"
  27. ref="multipleTable"
  28. :data="calculateInfo"
  29. :height="heightt"
  30. border
  31. tooltip-effect="dark">
  32. <el-table-column
  33. prop="companyLongName"
  34. label="主体名称"
  35. show-overflow-tooltip>
  36. </el-table-column>
  37. <el-table-column
  38. label="公司名称"
  39. prop="companyName"
  40. show-overflow-tooltip>
  41. </el-table-column>
  42. <el-table-column
  43. label="购方税号"
  44. prop="companyReferencenum"
  45. show-overflow-tooltip>
  46. </el-table-column>
  47. <el-table-column
  48. prop="etcNum"
  49. label="ETC卡号"
  50. show-overflow-tooltip>
  51. </el-table-column>
  52. <el-table-column
  53. prop="fee"
  54. label="费用"
  55. show-overflow-tooltip>
  56. </el-table-column>
  57. <el-table-column
  58. prop="calTime"
  59. label="计费时间"
  60. show-overflow-tooltip>
  61. </el-table-column>
  62. </el-table>
  63. </template>
  64. <!-- 分页 -->
  65. <div class="block">
  66. <el-pagination
  67. @size-change="handleSizeChange"
  68. @current-change="handleCurrentChange"
  69. :current-page="current"
  70. :page-sizes="[6, 8, 10, 20, 50, 100]"
  71. :page-size="pagesize"
  72. layout="total, sizes, prev, pager, next, jumper"
  73. :total="total">
  74. </el-pagination>
  75. </div>
  76. </div>
  77. </template>
  78. <script type="text/javascript">
  79. import FileSaver from 'file-saver'
  80. import XLSX from 'xlsx'
  81. export default {
  82. data() {
  83. return {
  84. formCondition: {
  85. companyName: ``,
  86. companyReferencenum: ``,
  87. etcNum: ``,
  88. calTime: ``,
  89. companyLongName: ``
  90. },
  91. calculateInfo: [],
  92. hightt: `0px`,
  93. current: 1,
  94. pagesize: 8,
  95. total: ``
  96. }
  97. },
  98. created() {
  99. this.heightt = tableHeight // eslint-disable-line
  100. this.loadData()
  101. },
  102. filters: {
  103. rounding(value) {
  104. return value.toFixed(2)
  105. }
  106. },
  107. methods: {
  108. firstLoadData() {
  109. this.current = 1
  110. this.pagesize = 8
  111. this.loadData()
  112. },
  113. // 列表展示
  114. async loadData() {
  115. const formData = new FormData()
  116. formData.append(`current`, this.current)
  117. formData.append(`size`, this.pagesize)
  118. formData.append(`companyName`, this.formCondition.companyName)
  119. formData.append(`companyReferencenum`, this.formCondition.companyReferencenum)
  120. formData.append(`etcNum`, this.formCondition.etcNum)
  121. formData.append(`calTime`, this.formCondition.calTime)
  122. formData.append(`companyLongName`, this.formCondition.companyLongName)
  123. const response = await this.$http.post(`selfCar/findSelfcarCalculateInfo`, formData)
  124. if (response.data.code == 0) {
  125. this.calculateInfo = response.data.data.records
  126. this.total = response.data.data.total
  127. }
  128. },
  129. // 分页方法
  130. handleSizeChange(val) {
  131. this.pagesize = val
  132. this.loadData()
  133. },
  134. handleCurrentChange(val) {
  135. this.current = val
  136. this.loadData()
  137. },
  138. formartNum(wb) {
  139. var sheet = wb[`Sheets`][`Sheet1`]
  140. var replaceTemp = []
  141. for (var i in sheet) {
  142. if (sheet[i][`v`] == `费用`) {
  143. replaceTemp.push(i.replace(/[0-9]/g, ``))
  144. continue
  145. }
  146. if (replaceTemp.includes(i.replace(/[0-9]/g, ``))) {
  147. sheet[i][`t`] = `n`
  148. }
  149. }
  150. },
  151. async exportExcel() {
  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. let curr = this.current
  159. let pagesize1 = this.pagesize
  160. this.current = 1
  161. this.pagesize = this.total
  162. await this.loadData()
  163. // 设置当前日期
  164. let time = new Date()
  165. let year = time.getFullYear()
  166. let month = time.getMonth() + 1
  167. let day = time.getDate()
  168. let name = `自有车计费查询列表_` + year + `` + month + `` + day
  169. /* generate workbook object from table */
  170. // .table要导出的是哪一个表格
  171. var wb = XLSX.utils.table_to_book(document.querySelector(`.table`), { raw: true })
  172. this.formartNum(wb)
  173. /* get binary string as output */
  174. var wbout = XLSX.write(wb, {
  175. bookType: `xlsx`,
  176. bookSST: true,
  177. type: `array`
  178. })
  179. try {
  180. // name+'.xlsx'表示导出的excel表格名字
  181. FileSaver.saveAs(
  182. new Blob([wbout], { type: `application/octet-stream` }),
  183. name + `.xlsx`
  184. )
  185. } catch (e) {
  186. }
  187. this.current = curr
  188. this.pagesize = pagesize1
  189. this.loadData()
  190. loading.close()
  191. return wbout
  192. }
  193. }
  194. }
  195. </script>
  196. <style>
  197. .calculateInfo_container {
  198. border: 1px solid #d9d9d9;
  199. border-radius: 10px;
  200. }
  201. .calculateInfo_container .title {
  202. font-size: 5px;
  203. margin-bottom: 20px;
  204. }
  205. .calculateInfo_container .top {
  206. padding-top: 20px;
  207. padding-left: 20px;
  208. }
  209. .calculateInfo_container .text {
  210. display: inline-block;
  211. color: #000;
  212. font-size: 16px ;
  213. margin-left: 1%;
  214. }
  215. .calculateInfo_container .input-demo {
  216. display: inline-block;
  217. width: 20%;
  218. margin-left: 1%;
  219. }
  220. .calculateInfo_container .block {
  221. font-size: 5px;
  222. text-align: center;
  223. margin-top: 25px;
  224. margin-bottom: 25px;
  225. }
  226. .calculateInfo_container .el-dialog {
  227. width: 60%;
  228. }
  229. .calculateInfo_container .el-dialog__header, .el-dialog__body {
  230. padding: 0 20px;
  231. }
  232. .calculateInfo_container .tou {
  233. font-size: 20px;
  234. height: 30px;
  235. line-height: 30px;
  236. padding-top: 15px;
  237. }
  238. .calculateInfo_container .line {
  239. margin-top: 15px;
  240. margin-bottom: 15px;
  241. width: 100%;
  242. height: 2px;
  243. background-color: #d9d9d9;
  244. }
  245. .calculateInfo_container .xinxi {
  246. text-align: center;
  247. margin: 15px auto;
  248. font-size: 18px;
  249. }
  250. </style>