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