customerRechargeMoney.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="customerRecharge_container">
  3. <div class="title">
  4. <el-row>
  5. <el-col :span="24">
  6. <div class="top">
  7. <el-button type="primary" style="margin-left: 1%;" @click="exportExcel">导出报表</el-button>
  8. </div>
  9. </el-col>
  10. </el-row>
  11. </div>
  12. <!-- 表格部分 -->
  13. <template>
  14. <el-table
  15. class="table"
  16. v-loading="loading"
  17. ref="multipleTable"
  18. :data="customerRechargeList"
  19. :height="heightt"
  20. border
  21. tooltip-effect="dark">
  22. <!-- <el-table-column
  23. prop="aMony"
  24. label="充值前账户余额"
  25. show-overflow-tooltip>
  26. <template slot-scope="scope">
  27. <span>{{scope.row.beforeMony-scope.row.rechargeMony| rounding}}</span>
  28. </template>
  29. </el-table-column> -->
  30. <!-- <el-table-column
  31. prop="beforeMony"
  32. label="当前余额"
  33. show-overflow-tooltip>
  34. <template slot-scope="scope">
  35. <span>{{scope.row.beforeMony| rounding}}</span>
  36. </template>
  37. </el-table-column> -->
  38. <el-table-column
  39. prop="rechargeMony"
  40. label="充值金额"
  41. show-overflow-tooltip>
  42. <template slot-scope="scope">
  43. <span>{{scope.row.rechargeMony| rounding}}</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column
  47. prop="rechargeTime"
  48. label="充值日期"
  49. show-overflow-tooltip>
  50. </el-table-column>
  51. </el-table>
  52. </template>
  53. <!-- 分页 -->
  54. <div class="block">
  55. <el-pagination
  56. @size-change="handleSizeChange"
  57. @current-change="handleCurrentChange"
  58. :current-page="current"
  59. :page-sizes="[6, 8, 10, 20, 50, 100]"
  60. :page-size="pagesize"
  61. layout="total, sizes, prev, pager, next, jumper"
  62. :total="total">
  63. </el-pagination>
  64. </div>
  65. </div>
  66. </template>
  67. <script type="text/javascript">
  68. import FileSaver from 'file-saver'
  69. import XLSX from 'xlsx'
  70. export default {
  71. data() {
  72. return {
  73. formCondition: {
  74. rechargeStartTime: ``,
  75. rechargeEndTime: ``
  76. },
  77. hightt: `0px`,
  78. customerRechargeList: [],
  79. current: 1,
  80. pagesize: 8,
  81. total: ``
  82. }
  83. },
  84. created() {
  85. this.heightt = tableHeight // eslint-disable-line
  86. this.loadData()
  87. },
  88. filters: {
  89. rounding(value) {
  90. return value.toFixed(2)
  91. }
  92. },
  93. methods: {
  94. // 列表展示
  95. async loadData() {
  96. this.customerName = sessionStorage.getItem(`userName`)
  97. const formData = new FormData()
  98. formData.append(`current`, this.current)
  99. formData.append(`size`, this.pagesize)
  100. formData.append(`customerName`, this.customerName)
  101. formData.append(`rechargeStartTime`, this.rechargeStartTime)
  102. formData.append(`rechargeEndTime`, this.rechargeEndTime)
  103. const response = await this.$http.post(`customer/findCustomerRechargeMoney`, formData)
  104. if (response.data.code === 0) {
  105. this.customerRechargeList = response.data.data.records
  106. this.total = response.data.data.total
  107. }
  108. },
  109. firstLoadData() {
  110. this.current = 1
  111. this.pagesize = 8
  112. this.loadData()
  113. },
  114. // 分页方法
  115. handleSizeChange(val) {
  116. this.pagesize = val
  117. this.loadData()
  118. },
  119. handleCurrentChange(val) {
  120. this.current = val
  121. this.loadData()
  122. },
  123. async exportExcel() {
  124. const loading = this.$loading({
  125. lock: true,
  126. text: `系统正在努力接收中,过程大概需要几分钟的时间,请您耐心等待...`,
  127. spinner: `el-icon-loading`,
  128. background: `rgba(0, 0, 0, 0.7)`
  129. })
  130. let curr = this.current
  131. let pagesize1 = this.pagesize
  132. this.current = 1
  133. this.pagesize = this.total
  134. await this.loadData()
  135. // 设置当前日期
  136. let time = new Date()
  137. let year = time.getFullYear()
  138. let month = time.getMonth() + 1
  139. let day = time.getDate()
  140. let name = `充值记录查询列表_` + year + `` + month + `` + day
  141. /* generate workbook object from table */
  142. // .table要导出的是哪一个表格
  143. var wb = XLSX.utils.table_to_book(document.querySelector(`.table`), { raw: true })
  144. /* get binary string as output */
  145. var wbout = XLSX.write(wb, {
  146. bookType: `xlsx`,
  147. bookSST: true,
  148. type: `array`
  149. })
  150. try {
  151. // name+'.xlsx'表示导出的excel表格名字
  152. FileSaver.saveAs(
  153. new Blob([wbout], { type: `application/octet-stream` }),
  154. name + `.xlsx`
  155. )
  156. } catch (e) {
  157. }
  158. this.current = curr
  159. this.pagesize = pagesize1
  160. this.loadData()
  161. loading.close()
  162. return wbout
  163. }
  164. }
  165. }
  166. </script>
  167. <style>
  168. .customerRecharge_container {
  169. border: 1px solid #d9d9d9;
  170. border-radius: 10px;
  171. }
  172. .customerRecharge_container .title {
  173. font-size: 5px;
  174. margin-bottom: 20px;
  175. }
  176. .customerRecharge_container .top {
  177. padding-top: 20px;
  178. padding-left: 20px;
  179. }
  180. .customerRecharge_container .text {
  181. display: inline-block;
  182. color: #000;
  183. font-size: 16px ;
  184. margin-left: 1%;
  185. }
  186. .customerRecharge_container .input-demo {
  187. display: inline-block;
  188. width: 20%;
  189. margin-left: 1%;
  190. }
  191. .customerRecharge_container .block {
  192. font-size: 5px;
  193. text-align: center;
  194. margin-top: 25px;
  195. margin-bottom: 25px;
  196. }
  197. .customerRecharge_container .el-dialog {
  198. width: 60%;
  199. }
  200. .customerRecharge_container .el-dialog__header, .el-dialog__body {
  201. padding: 0 20px;
  202. }
  203. .customerRecharge_container .tou {
  204. font-size: 20px;
  205. height: 30px;
  206. line-height: 30px;
  207. padding-top: 15px;
  208. }
  209. .customerRecharge_container .line {
  210. margin-top: 15px;
  211. margin-bottom: 15px;
  212. width: 100%;
  213. height: 2px;
  214. background-color: #d9d9d9;
  215. }
  216. .customerRecharge_container .xinxi {
  217. text-align: center;
  218. margin: 15px auto;
  219. font-size: 18px;
  220. }
  221. </style>