index.vue 19 KB

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