index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <div class="app-container">
  3. <el-row>
  4. <el-col :span="24">
  5. <div class="cell">
  6. <div class="cell-title">
  7. <div class="title-left">
  8. <div class="title">充值记录</div>
  9. <div class="title-detail">总余额:{{total_balance}}元</div>
  10. <div class="title-detail">总充值:{{total_recharge}}元</div>
  11. <div class="title-detail">总交易笔数:{{total_number}}笔</div>
  12. </div>
  13. <div class="title-right">
  14. <el-button type="primary" @click="handler_download_excel">导出表单</el-button>
  15. </div>
  16. </div>
  17. <div class="cell-body">
  18. <el-form :inline="true" :model="formInline" class="demo-form-inline">
  19. <el-form-item label="关键字:">
  20. <el-input v-model="formInline.user" clearable placeholder="请输入姓名或身份证"></el-input>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="warning" @click="btn_search">查询</el-button>
  24. </el-form-item>
  25. <el-form-item label="时间筛选:">
  26. <el-date-picker v-model="search_datatime" type="datetimerange" align="right"
  27. start-placeholder="开始日期" end-placeholder="结束日期" @change="search_datetime_change"
  28. :default-time="['12:00:00', '08:00:00']" value-format="yyyy-MM-dd HH:mm:ss"
  29. format="yyyy-MM-dd HH:mm:ss" clearable>
  30. </el-date-picker>
  31. </el-form-item>
  32. <el-form-item label="">
  33. <el-select v-model="formInline.state" placeholder="支付状态" @change="search_state_change">
  34. <el-option label="已支付已到账" value="2"></el-option>
  35. <el-option label="已支付未到账" value="1"></el-option>
  36. <el-option label="未支付" value="0"></el-option>
  37. </el-select>
  38. </el-form-item>
  39. </el-form>
  40. <el-table :data="tableData" height="510" style="width: 100%" :cell-style="cell_style"
  41. v-loading="loading" :header-cell-style="header_cell_style">
  42. <el-table-column label="序号" align="center" width="100">
  43. <template slot-scope="scope">
  44. <span>{{(pagination.currentPage - 1) * pagination.pageSize + scope.$index + 1}}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="姓名" align="center" width="100">
  48. <template slot-scope="scope">
  49. <span>{{ scope.row.user_name }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="手机" align="center" width="180">
  53. <template slot-scope="scope">
  54. <span>{{ scope.row.phone }}</span>
  55. </template>
  56. </el-table-column>
  57. <!-- <el-table-column label="身份证号" align="center" width="150">
  58. <template slot-scope="scope">
  59. {{scope.row.sfzh}}
  60. </template>
  61. </el-table-column> -->
  62. <el-table-column label="到账金额(元)" align="center" width="200">
  63. <template slot-scope="scope">
  64. <span>{{ scope.row.account }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="账户余额(元)" align="center" width="200">
  68. <template slot-scope="scope">
  69. <span>{{ scope.row.balance }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="支付状态" align="center" width="150">
  73. <template slot-scope="scope">
  74. <span v-if="scope.row.state == 0" class="txt-cell-red">未支付</span>
  75. <span v-else-if="scope.row.state == 1" class="txt-cell-red">已支付未到账</span>
  76. <span v-else class="txt-cell-green">已支付已到账</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="交易流水号" align="center">
  80. <template slot-scope="scope">
  81. <span>{{ scope.row.order_num }}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="支付时间" align="center">
  85. <template slot-scope="scope">
  86. <span>{{ scope.row.time }}</span>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. <div class="pagination-table">
  91. <el-pagination @current-change="currentPageChange"
  92. :current-page.sync="pagination.currentPage" :page-size="pagination.pageSize"
  93. layout="prev, pager, next, jumper" :total="pagination.total">
  94. </el-pagination>
  95. </div>
  96. </div>
  97. </div>
  98. </el-col>
  99. </el-row>
  100. </div>
  101. </template>
  102. <script>
  103. import {
  104. getThreeData,
  105. getTableData,
  106. downloadExcel
  107. } from '@/api/rechargeRecord'
  108. export default {
  109. data() {
  110. return {
  111. total_balance: 0.0.toFixed(2), // 总余额
  112. total_recharge: 0.0.toFixed(2), // 总充值
  113. total_number: 0, // 总交易笔数
  114. formLabelWidth: '120px',
  115. // 表格单元格样式
  116. cell_style: {
  117. color: '#1A202B',
  118. 'font-size': '14px',
  119. 'font-family': 'Microsoft YaHei-3970(82674968)'
  120. },
  121. // 表格头部样式
  122. header_cell_style: {
  123. background: '#E6ECFE',
  124. color: '#1A202B',
  125. 'font-size': '16px',
  126. 'font-family': 'Microsoft YaHei-3970(82674968)'
  127. },
  128. search_datatime: '',
  129. // 表单数据
  130. formInline: {
  131. user: '',
  132. startTime: '',
  133. endTime: '',
  134. state: '2'
  135. },
  136. tableData: [],
  137. // 分页参数
  138. pagination: {
  139. currentPage: 1,
  140. pageSize: 9,
  141. total: 0
  142. },
  143. loading: true
  144. }
  145. },
  146. created() {
  147. // 获取3个数据
  148. this.get_three_data()
  149. // 获取消费记录,表格数据
  150. this.get_table_data('list')
  151. },
  152. mounted() {
  153. document.getElementsByClassName("el-pagination__jump")[0].childNodes[0].nodeValue = "跳至";
  154. },
  155. methods: {
  156. /**
  157. * 下载Excel表格
  158. */
  159. handler_download_excel() {
  160. // 开始发送请求,获取配置数据
  161. downloadExcel().then((res) => {
  162. // console.log(res);
  163. if (typeof res.code == 'undefined' || res.code == '') {
  164. this.$message.error('返回数据格式问题,code未获取到!')
  165. return
  166. }
  167. if (res.code == 200) {
  168. this.$message.success('下载成功!')
  169. let xls = 'https://chtech.ncjti.edu.cn/air-conditioner-control/' + res.downurl
  170. window.open(xls)
  171. } else {
  172. this.$message.error(res.message)
  173. }
  174. }).catch((err) => {
  175. // console.log(err);
  176. this.$message.error(err.message)
  177. })
  178. },
  179. /**
  180. * 选取的时间进行格式化,赋值给formInline
  181. */
  182. search_datetime_change() {
  183. // console.log(this.search_datatime);
  184. if (this.search_datatime == null) {
  185. this.formInline.startTime = ''
  186. this.formInline.endTime = ''
  187. } else {
  188. this.formInline.startTime = this.search_datatime[0]
  189. this.formInline.endTime = this.search_datatime[1]
  190. }
  191. // 刷新列表
  192. this.get_table_data('search')
  193. },
  194. /**
  195. * 搜索状态
  196. */
  197. search_state_change() {
  198. // 刷新列表
  199. this.get_table_data('search')
  200. },
  201. /**
  202. * 获取3个数据
  203. */
  204. get_three_data() {
  205. getThreeData().then((res) => {
  206. // console.log(res);
  207. if (res.code == 200) {
  208. this.total_balance = res.TotalYe.toFixed(2) // 总余额
  209. this.total_recharge = res.zongRecharge.toFixed(2) // 总消费
  210. this.total_number = res.zongRecord // 总交易笔数
  211. } else {
  212. this.$message.error(res.message)
  213. }
  214. }).catch((err) => {
  215. // console.log(err);
  216. this.$message.error(err.message)
  217. })
  218. },
  219. /**
  220. * 获取消费记录,表格数据
  221. */
  222. get_table_data(param) {
  223. this.loading = true
  224. let data = {
  225. page: this.pagination.currentPage,
  226. rows: this.pagination.pageSize
  227. }
  228. if (param == 'search') {
  229. data.page = 1
  230. }
  231. if (this.formInline.user !== '') {
  232. data.name_card = this.formInline.user
  233. }
  234. if (this.formInline.startTime !== '') {
  235. data.start_time = this.formInline.startTime
  236. }
  237. if (this.formInline.endTime !== '') {
  238. data.end_time = this.formInline.endTime
  239. }
  240. if (this.formInline.state !== '') {
  241. data.state = this.formInline.state
  242. }
  243. // console.log(data);
  244. getTableData(data).then((res) => {
  245. // console.log(res);
  246. if (typeof res.rows !== 'undefined' && res.rows !== '') {
  247. this.pagination.total = res.total
  248. this.tableData = []
  249. for (var i = 0; i < res.rows.length; i++) {
  250. this.tableData.push(res.rows[i])
  251. }
  252. } else {
  253. this.tableData = []
  254. this.$message.warning('没有符合条件的数据!')
  255. }
  256. }).catch((err) => {
  257. // console.log(err);
  258. this.$message.error(err.message)
  259. });
  260. this.loading = false
  261. },
  262. /**
  263. * 搜索
  264. */
  265. btn_search() {
  266. this.get_table_data('search')
  267. },
  268. /**
  269. * currentPage 改变时会触发
  270. * @param {Object} val
  271. */
  272. currentPageChange(val) {
  273. this.pagination.currentPage = val
  274. this.get_table_data('pages')
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang="scss" scoped>
  280. .app-container {
  281. background-color: #EFF2F7;
  282. padding: 10px;
  283. .el-row {
  284. .el-col {
  285. padding: 10px;
  286. .cell {
  287. padding: 30px;
  288. border-radius: 10px;
  289. background-color: #FFFFFF;
  290. // box-shadow: 5px 5px 15px #979797;
  291. box-shadow: 0px 3px 21px 0px rgba(60, 108, 254, 0.16);
  292. .cell-title {
  293. display: flex;
  294. justify-content: space-between;
  295. align-items: center;
  296. margin-bottom: 30px;
  297. padding-bottom: 30px;
  298. border-bottom: 1px solid #CCCCCC;
  299. .title-left {
  300. display: flex;
  301. align-items: center;
  302. .title {
  303. font-size: 22px;
  304. font-family: Microsoft YaHei-3970(82674968);
  305. font-weight: bold;
  306. color: #1A202B;
  307. }
  308. .title-detail {
  309. margin-left: 50px;
  310. font-size: 18px;
  311. font-family: Microsoft YaHei-3970(82674968);
  312. color: #1A202B;
  313. }
  314. }
  315. .title-right {
  316. display: flex;
  317. justify-content: space-between;
  318. align-items: center;
  319. .el-button {
  320. width: 110px;
  321. height: 46px;
  322. background: #2B4CFE;
  323. font-size: 18px;
  324. color: #FFFFFF;
  325. font-family: Microsoft YaHei-3970(82674968);
  326. border-radius: 5px;
  327. }
  328. .el-button--warning {
  329. background: #F88A64;
  330. }
  331. }
  332. }
  333. .cell-body {
  334. .el-form {
  335. display: flex;
  336. flex-wrap: wrap;
  337. align-items: center;
  338. .el-button--warning {
  339. background: #F88A64;
  340. }
  341. .el-date-editor--datetimerange {
  342. padding: 3px 8px;
  343. width: 370px;
  344. }
  345. .el-select {
  346. width: 130px;
  347. }
  348. }
  349. .btn-cell-blue {
  350. color: #2B4CFE;
  351. border: none;
  352. font-size: 18px;
  353. }
  354. .btn-cell-black {
  355. color: #53575A;
  356. border: none;
  357. font-size: 18px;
  358. }
  359. .txt-cell-green {
  360. color: #67C23A;
  361. }
  362. .txt-cell-red {
  363. color: #F56C6C;
  364. font-size: 16px;
  365. }
  366. .pagination-table {
  367. display: flex;
  368. justify-content: flex-end;
  369. align-items: center;
  370. height: 30px;
  371. margin-top: 20px;
  372. padding-right: 100px;
  373. ::v-deep .el-pagination {
  374. display: flex;
  375. justify-content: flex-end;
  376. align-items: center;
  377. }
  378. ::v-deep .el-pagination ul {
  379. display: flex;
  380. }
  381. ::v-deep .el-pagination button,
  382. ::v-deep .el-pagination li {
  383. display: flex;
  384. justify-content: center;
  385. align-items: center;
  386. width: 50px;
  387. height: 36px;
  388. border: 1px solid #626262;
  389. border-radius: 3px;
  390. font-size: 14px;
  391. margin: 0 5px;
  392. }
  393. ::v-deep .el-pagination span {
  394. margin-left: 10px;
  395. }
  396. ::v-deep .el-pagination .el-pagination__jump {
  397. font-size: 16px;
  398. }
  399. ::v-deep .el-pagination .el-pagination__editor {
  400. width: 50px;
  401. height: 36px;
  402. margin: 0 5px;
  403. }
  404. ::v-deep .el-pagination .el-input__inner {
  405. width: 50px;
  406. height: 36px;
  407. border: 1px solid #626262;
  408. margin: -4px 0 0 0;
  409. }
  410. }
  411. }
  412. }
  413. }
  414. }
  415. ::v-deep .el-dialog {
  416. margin: 0 !important;
  417. width: 400px;
  418. height: 320px;
  419. background: #FFFFFF;
  420. box-shadow: 0px 0px 13px 0px rgba(0, 0, 0, 0.29);
  421. border-radius: 10px;
  422. position: absolute;
  423. top: 50%;
  424. left: 50%;
  425. transform: translate(-50%, -50%);
  426. .el-dialog__header {
  427. display: flex;
  428. align-items: center;
  429. width: 100%;
  430. height: 58px;
  431. padding: 30px;
  432. background: #E6EBFE;
  433. border-radius: 10px 10px 0px 0px;
  434. font-weight: bold;
  435. }
  436. .el-dialog__body {
  437. padding-bottom: 0;
  438. .el-form-item {
  439. margin-bottom: 0;
  440. .el-form-item__label,
  441. .el-form-item__content {
  442. font-size: 16px;
  443. font-family: Microsoft YaHei-3970(82674968);
  444. color: #53575A;
  445. }
  446. .el-input__inner {
  447. width: 100px;
  448. }
  449. }
  450. }
  451. }
  452. }
  453. </style>