index.vue 17 KB

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