index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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. v-loading="loading" :header-cell-style="header_cell_style">
  42. <el-table-column label="序号" align="center" width="80">
  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="70">
  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="60">
  63. <template slot-scope="scope">
  64. <span>{{ scope.row.floors }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="房间号" align="center">
  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="100">
  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" width="150">
  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" width="160">
  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. cond_data: {},
  152. // 分页参数
  153. pagination: {
  154. currentPage: 1,
  155. pageSize: 9,
  156. total: 0
  157. },
  158. loading: true
  159. }
  160. },
  161. created() {
  162. // 获取3个数据
  163. this.get_three_data()
  164. // 获取消费记录,表格数据
  165. this.get_table_data('list')
  166. },
  167. mounted() {
  168. document.getElementsByClassName("el-pagination__jump")[0].childNodes[0].nodeValue = "跳至";
  169. },
  170. methods: {
  171. /**
  172. * 下载Excel表格
  173. */
  174. handler_download_excel() {
  175. this.get_condition();
  176. // 开始发送请求,获取配置数据
  177. downloadExcel(this.cond_data).then((res) => {
  178. // console.log(res);
  179. if (typeof res.code == 'undefined' || res.code == '') {
  180. this.$message.error('返回数据格式问题,code未获取到!')
  181. return
  182. }
  183. if (res.code == 200) {
  184. this.$message.success('下载成功!')
  185. let xls = 'https://chtech.ncjti.edu.cn/air-conditioner-control/' + res.downurl
  186. window.open(xls)
  187. } else {
  188. this.$message.error(res.message)
  189. }
  190. }).catch((err) => {
  191. // console.log(err);
  192. this.$message.error(err.message)
  193. })
  194. },
  195. /**
  196. * 搜索状态
  197. */
  198. search_state_change() {
  199. // 刷新列表
  200. this.get_table_data('search')
  201. },
  202. /**
  203. * 选取的时间进行格式化,赋值给formInline
  204. */
  205. search_datetime_change() {
  206. // console.log(this.search_datatime);
  207. if (this.search_datatime == null) {
  208. this.formInline.startTime = ''
  209. this.formInline.endTime = ''
  210. } else {
  211. this.formInline.startTime = this.search_datatime[0]
  212. this.formInline.endTime = this.search_datatime[1]
  213. }
  214. // 刷新列表
  215. this.get_table_data('search')
  216. },
  217. /**
  218. * 获取消费记录,表格数据
  219. */
  220. get_table_data(param) {
  221. this.loading = true
  222. this.get_condition();
  223. let data = this.cond_data;
  224. if (param == 'search') {
  225. data.page = 1;
  226. this.pagination.currentPage = 1;
  227. }
  228. // console.log(data);
  229. getTableData(data).then((res) => {
  230. // console.log(res);
  231. if (typeof res.rows !== 'undefined' && res.rows !== '') {
  232. this.pagination.total = res.total
  233. this.tableData = []
  234. var item = {}
  235. for (var i = 0; i < res.rows.length; i++) {
  236. item = {
  237. user_name: res.rows[i].user_name,
  238. phone: res.rows[i].phone,
  239. build: res.rows[i].build,
  240. floors: res.rows[i].floors,
  241. dom: res.rows[i].air_name + ' ' + res.rows[i].air_ip,
  242. // dom: res.rows[i].dom.split('-')[1] + ' ' + res.rows[i].air_name + ' ' + res.rows[i].air_ip,
  243. handler_state: res.rows[i].handler_state,
  244. account: res.rows[i].account,
  245. balance: res.rows[i].balance,
  246. state: res.rows[i].state,
  247. order_num: res.rows[i].order_num,
  248. time: res.rows[i].time
  249. }
  250. this.tableData.push(item)
  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. if (param == 'search') {
  262. this.get_three_data();
  263. }
  264. },
  265. /**
  266. * 获取3个数据
  267. */
  268. get_three_data() {
  269. this.get_condition();
  270. getThreeData(this.cond_data).then((res) => {
  271. // console.log(res);
  272. if (res.code == 200) {
  273. this.total_balance = res.TotalYe.toFixed(2) // 总余额
  274. this.total_consumption = res.zongConsume.toFixed(2) // 总消费
  275. this.total_number = res.zongRecord // 总交易笔数
  276. } else {
  277. this.$message.error(res.message)
  278. }
  279. }).catch((err) => {
  280. // console.log(err);
  281. this.$message.error(err.message)
  282. });
  283. },
  284. /**
  285. * 条件
  286. */
  287. get_condition() {
  288. let data = {
  289. page: this.pagination.currentPage,
  290. rows: this.pagination.pageSize
  291. }
  292. if (this.formInline.user !== '') {
  293. data.name_card = this.formInline.user;
  294. }
  295. if (this.formInline.startTime !== '') {
  296. data.start_time = this.formInline.startTime;
  297. }
  298. if (this.formInline.endTime !== '') {
  299. data.end_time = this.formInline.endTime;
  300. }
  301. if (this.formInline.state !== '') {
  302. data.state = this.formInline.state;
  303. }
  304. this.cond_data = data;
  305. },
  306. /**
  307. * 搜索
  308. */
  309. btn_search() {
  310. this.get_table_data('search')
  311. },
  312. /**
  313. * currentPage 改变时会触发
  314. * @param {Object} val
  315. */
  316. currentPageChange(val) {
  317. this.pagination.currentPage = val
  318. this.get_table_data('pages')
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="scss" scoped>
  324. .app-container {
  325. background-color: #EFF2F7;
  326. padding: 10px;
  327. .el-row {
  328. .el-col {
  329. padding: 10px;
  330. .cell {
  331. padding: 30px;
  332. border-radius: 10px;
  333. background-color: #FFFFFF;
  334. // box-shadow: 5px 5px 15px #979797;
  335. box-shadow: 0px 3px 21px 0px rgba(60, 108, 254, 0.16);
  336. .cell-title {
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. margin-bottom: 30px;
  341. padding-bottom: 30px;
  342. border-bottom: 1px solid #CCCCCC;
  343. .title-left {
  344. display: flex;
  345. align-items: center;
  346. .title {
  347. font-size: 22px;
  348. font-family: Microsoft YaHei-3970(82674968);
  349. font-weight: bold;
  350. color: #1A202B;
  351. }
  352. .title-detail {
  353. margin-left: 50px;
  354. font-size: 18px;
  355. font-family: Microsoft YaHei-3970(82674968);
  356. color: #1A202B;
  357. }
  358. }
  359. .title-right {
  360. display: flex;
  361. justify-content: space-between;
  362. align-items: center;
  363. .el-button {
  364. width: 110px;
  365. height: 46px;
  366. background: #2B4CFE;
  367. font-size: 18px;
  368. color: #FFFFFF;
  369. font-family: Microsoft YaHei-3970(82674968);
  370. border-radius: 5px;
  371. }
  372. .el-button--warning {
  373. background: #F88A64;
  374. }
  375. }
  376. }
  377. .cell-body {
  378. .el-form {
  379. display: flex;
  380. flex-wrap: wrap;
  381. align-items: center;
  382. .el-button--warning {
  383. background: #F88A64;
  384. }
  385. .el-date-editor--datetimerange {
  386. padding: 3px 8px;
  387. width: 370px;
  388. }
  389. .el-select {
  390. width: 130px;
  391. }
  392. }
  393. .txt-cell-green {
  394. color: #67C23A;
  395. font-size: 16px;
  396. }
  397. .txt-cell-red {
  398. color: #F56C6C;
  399. font-size: 16px;
  400. }
  401. .pagination-table {
  402. display: flex;
  403. justify-content: flex-end;
  404. align-items: center;
  405. height: 30px;
  406. margin-top: 20px;
  407. padding-right: 100px;
  408. ::v-deep .el-pagination {
  409. display: flex;
  410. justify-content: flex-end;
  411. align-items: center;
  412. }
  413. ::v-deep .el-pagination ul {
  414. display: flex;
  415. }
  416. ::v-deep .el-pagination button,
  417. ::v-deep .el-pagination li {
  418. display: flex;
  419. justify-content: center;
  420. align-items: center;
  421. width: 50px;
  422. height: 36px;
  423. border: 1px solid #626262;
  424. border-radius: 3px;
  425. font-size: 14px;
  426. margin: 0 5px;
  427. }
  428. ::v-deep .el-pagination span {
  429. margin-left: 10px;
  430. }
  431. ::v-deep .el-pagination .el-pagination__jump {
  432. font-size: 16px;
  433. }
  434. ::v-deep .el-pagination .el-pagination__editor {
  435. width: 50px;
  436. height: 36px;
  437. margin: 0 5px;
  438. }
  439. ::v-deep .el-pagination .el-input__inner {
  440. width: 50px;
  441. height: 36px;
  442. border: 1px solid #626262;
  443. margin: -4px 0 0 0;
  444. }
  445. }
  446. }
  447. }
  448. }
  449. }
  450. ::v-deep .el-dialog {
  451. margin: 0 !important;
  452. width: 400px;
  453. height: 320px;
  454. background: #FFFFFF;
  455. box-shadow: 0px 0px 13px 0px rgba(0, 0, 0, 0.29);
  456. border-radius: 10px;
  457. position: absolute;
  458. top: 50%;
  459. left: 50%;
  460. transform: translate(-50%, -50%);
  461. .el-dialog__header {
  462. display: flex;
  463. align-items: center;
  464. width: 100%;
  465. height: 58px;
  466. padding: 30px;
  467. background: #E6EBFE;
  468. border-radius: 10px 10px 0px 0px;
  469. font-weight: bold;
  470. }
  471. .el-dialog__body {
  472. padding-bottom: 0;
  473. .el-form-item {
  474. margin-bottom: 0;
  475. .el-form-item__label,
  476. .el-form-item__content {
  477. font-size: 16px;
  478. font-family: Microsoft YaHei-3970(82674968);
  479. color: #53575A;
  480. }
  481. .el-input__inner {
  482. width: 100px;
  483. }
  484. }
  485. }
  486. }
  487. }
  488. </style>