upgradeBox.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template>
  2. <!-- 改签对话框 -->
  3. <el-dialog
  4. title="订单升舱"
  5. :visible.sync="rebookDialog"
  6. width="95%"
  7. append-to-body
  8. class="rebook1_dialog"
  9. :close-on-click-modal="false"
  10. :close-on-press-escape="false"
  11. :modal="false"
  12. :before-close="handleClose"
  13. center
  14. >
  15. <div class="rebook1_box" v-loading="loading">
  16. <div class="rebook1_from-box">
  17. <div class="rebook1_from">
  18. <el-form :model="rebookForm" ref="rebookForm" label-width="100px" :rules="rules">
  19. <el-form-item label="剧目名称:" style="margin-bottom: 0px;">
  20. <span>{{ rebookForm.performName }}</span>
  21. </el-form-item>
  22. <el-form-item label="票务名称:" style="margin-bottom: 0px;">
  23. <span>{{ rebookForm.goodsName }}</span>
  24. </el-form-item>
  25. <el-form-item label="座位类型:" style="margin-bottom: 0px;">
  26. <span>{{ rebookForm.seatTypeName }}</span>
  27. </el-form-item>
  28. <el-form-item label="订单座位数:" style="margin-bottom: 0px;">
  29. <span>{{ rebookForm.touristNum }}个</span>
  30. </el-form-item>
  31. <el-form-item label="选择日期:" prop="performDate" style="margin-bottom: 0px;">
  32. <span>{{ rebookForm.performDate }}</span>
  33. </el-form-item>
  34. <el-form-item label="选择场次:" prop="performTimeId" style="margin-bottom: 0px;">
  35. <span>{{ rebookForm.performTimeStart }} — {{ rebookForm.performTimeEnd }} </span>
  36. </el-form-item>
  37. <el-form-item label="票档:" prop="seatTypeId">
  38. <el-select
  39. v-model="rebookForm.seatTypeId"
  40. placeholder="请选择票档"
  41. style="width: 100%"
  42. @change="querySeatListFun"
  43. >
  44. <el-option
  45. v-for="item in intervalList"
  46. :key="item.seatTypeId"
  47. :label="item.seatTypeName"
  48. :value="item.seatTypeId"
  49. />
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item label="订单总额:">
  53. <span>{{ rebookForm.realPrice || 0 }}元</span>
  54. </el-form-item>
  55. <el-form-item v-if="rebookForm.diffPrice < 0" label="升舱费用:">
  56. <span>退费{{ Math.abs(rebookForm.diffPrice) }}元</span>
  57. </el-form-item>
  58. <el-form-item v-if="rebookForm.diffPrice > 0" label="升舱费用:">
  59. <el-input-number
  60. v-model="rebookForm.goodsDiffAmount"
  61. controls-position="right"
  62. :min="0"></el-input-number>
  63. </el-form-item>
  64. <el-form-item v-if="rebookForm.diffPrice > 0 && !rebookForm.timeId" label="支付方式 :" prop="paymentType">
  65. <el-radio-group v-model="rebookForm.paymentType">
  66. <el-radio label="1">扫码支付</el-radio>
  67. <el-radio label="2">现金支付</el-radio>
  68. </el-radio-group>
  69. </el-form-item>
  70. <el-form-item v-if="rebookForm.diffPrice > 0 && rebookForm.timeId" label="支付方式 :" prop="paymentType">
  71. <el-radio-group v-model="rebookForm.paymentType">
  72. <el-radio label="3">对公支付</el-radio>
  73. <el-radio label="6">挂账</el-radio>
  74. <el-radio label="7">链接支付</el-radio>
  75. <el-radio label="4">账户余额</el-radio>
  76. <el-radio label="5">授信余额</el-radio>
  77. </el-radio-group>
  78. </el-form-item>
  79. <el-form-item v-if="rebookForm.diffPrice > 0 && rebookForm.paymentType == 2 " label="收取现金 :" prop="realPrice_1">
  80. <el-input @input="setRealPrice_1" style="width: 200px;" v-model="rebookForm.realPrice_1"></el-input>
  81. <span>元</span>
  82. </el-form-item>
  83. <el-form-item label="找零金额 :" v-if="rebookForm.diffPrice > 0 && ruleForm.paymentType == 2">
  84. ¥{{ rebookForm.small }}元
  85. </el-form-item>
  86. <el-form-item label="备注:">
  87. <el-input
  88. v-model="rebookForm.resubmitRemark"
  89. placeholder="请输入备注"
  90. clearable
  91. type="textarea"
  92. />
  93. </el-form-item>
  94. </el-form>
  95. <div class="tip-box">
  96. <p style="font-size: 12px;">温馨提示:仅限升舱一次,且升舱后禁止退款,确认要继续升舱吗。</p>
  97. </div>
  98. </div>
  99. <div class="rebook1_seat" v-loading="seatLoading" :element-loading-text="seatLoadText">
  100. <seatBox
  101. ref="seatBox"
  102. :seatTypeLimit="configStockNumObj"
  103. @selectSeat="selectSeat"
  104. height="100%"
  105. />
  106. </div>
  107. </div>
  108. <div style="width: 100%;display: flex;justify-content: center;">
  109. <el-button @click="rebookDialog = false">取 消</el-button>
  110. <el-button type="primary" @click="submitRebook">确认升舱</el-button>
  111. </div>
  112. <!-- 支付过程 控制 -->
  113. <div v-if="payStatus" class="increase-viewers-pay-status">
  114. <div class="increase-viewers-pay-status-info" v-if="!loading">
  115. <span style="font-weight: 600;font-size: 20px;">提示</span>
  116. <span style="padding: 10px 0;">
  117. {{ payStatus==1 ? '生成订单失败!!!' :
  118. payStatus==2 ? '生成订单生成成功,请点击调取扫码盒子' :
  119. payStatus==4 ? '扫码支付失败!!!' :
  120. payStatus==5 ? '请出示付款码!!!' :
  121. payStatus==5.5 ? '扫码成功,支付中...' :
  122. payStatus==5.6 ? '扫码成功,支付中...' :
  123. payStatus==6 ? '连接扫码器失败!!!' :
  124. payStatus==7 ? '用户支付失败或未支付,请重新连接支付!!!' :
  125. payStatus==8 ? '用户支付成功,请点击打印票!!!' :
  126. payStatus==9 ? '支付超时!!!' :
  127. payStatus==10 ? '订单已关闭,请重新选择座位,再购买!!!' :
  128. payStatus==3 ? '现金支付记录入库失败,请重新提交' : '未知状态' }}
  129. </span>
  130. <span v-if="payStatus==2">需支付{{ rebookForm.payAmount }}元</span>
  131. <!-- 重新生成订单 1 -->
  132. <div v-if="payStatus==1" style="display: flex;">
  133. <el-button @click="payStatus = null" type="success">修改信息</el-button>
  134. <el-button @click="orderInfoSubmitFun()" style="margin-left: 20px;" type="primary">重新生成订单</el-button>
  135. </div>
  136. <!-- 生成订单成功 选择支付方式 -->
  137. <div>
  138. <!-- 扫码支付 2 -->
  139. <el-button v-if="payStatus==2" @click="vbar_open(orderId)" type="success">扫码支付</el-button>
  140. <!-- 扫码支付 4 -->
  141. <el-button v-if="payStatus==4" @click="vbar_open(orderId)" type="success">重新扫码支付</el-button>
  142. <!-- 重新支付 3 -->
  143. <el-button v-if="payStatus==3" @click="gotoCashPayFun(orderId)" type="success">重新提交入库</el-button>
  144. <!-- 重新支付 6 7 -->
  145. <el-button v-if="payStatus==6 || payStatus==7" @click="vbar_open(orderId)" type="success">重新连接扫码支付</el-button>
  146. <!-- 现金支付 -->
  147. <el-button v-if="payStatus==2" @click="vbar_open(orderId)" type="success">扫码支付</el-button>
  148. <!-- 现金支付 -->
  149. <el-button v-if="payStatus==2" @click="vbar_open(orderId)" type="success">扫码支付</el-button>
  150. </div>
  151. <!-- 打印 8 -->
  152. <div v-if="payStatus==8">
  153. <el-select v-model="printListId" placeholder="选择打印机">
  154. <el-option
  155. :label="item.deviceName"
  156. :key="item.id"
  157. :value="item.id"
  158. v-for="(item) in printList"></el-option>
  159. </el-select>
  160. <el-button style="margin-left: 15px" @click="print" type="success">打印门票</el-button>
  161. <el-button style="margin-left: 15px" @click="goTicketingCollections" type="success">跳转取票界面</el-button>
  162. </div>
  163. <!-- 支付超时 9 -->
  164. <div v-if="payStatus==9">
  165. <!-- <el-button @click="print" type="danger">取消支付</el-button> -->
  166. <el-button @click="orderInfoSubmitFun()" type="primary">重新扫码</el-button>
  167. </div>
  168. <!-- 订单被关闭 10 -->
  169. <div v-if="payStatus==10">
  170. <!-- <el-button @click="print" type="danger">取消支付</el-button> -->
  171. <el-button @click="handleClose()" type="primary">关闭</el-button>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. </el-dialog>
  177. </template>
  178. <script>
  179. import {
  180. querySeatListNew,
  181. } from '@/api/windowTicketSales/ticketingSales'
  182. import { rebookApi,getTimeSeatTypeAllApi,resubmitInfoApi } from '@/api/windowTicketSales/rebook'
  183. import { countBySeatTyp } from '@/api/ticketMr/InventoryTemplate'
  184. import { pageList as getSeatType } from '@/api/seatTypeMr/seatTypeMr'
  185. import { getSelectById } from '@/api/order/orderMr'
  186. import seatBox from '@/components/seatBox/index.vue';
  187. import payJs from "../mixins/pay"
  188. const mathM = require('mathjs')
  189. export default {
  190. name: "RebookBox",
  191. components: { seatBox },
  192. mixins: [payJs],
  193. data() {
  194. return {
  195. // 改签对话框
  196. rebookDialog: false,
  197. loading: false,
  198. // 改签表单
  199. rebookForm: {
  200. orderId: undefined,
  201. performDate: undefined,
  202. performTimeId: undefined,
  203. performInterval: undefined,
  204. performId: undefined,
  205. auditoriumId: undefined
  206. },
  207. rules: {
  208. seatTypeId: [{ required: true, message: '请选择票档', trigger: ['blur','change'] }]
  209. },
  210. // 场次列表
  211. intervalList: [],
  212. intervalListLoading: false,
  213. // 支付相关
  214. payDialog: false,
  215. payStatus: null,
  216. code: '',
  217. websocketData: null,
  218. codeTime: null,
  219. // 成功对话框
  220. successDialog: false,
  221. newOrderId: '',
  222. printList: [],
  223. configStockNumObj: {},
  224. countBySeatTypList:[],
  225. seatTypeListAll: [],
  226. seatLoading: false,
  227. seatLoadText: '获取座位中...',
  228. setList: [],
  229. }
  230. },
  231. created(){
  232. this.getSeatTypeAllList()
  233. },
  234. methods: {
  235. async initData(row) {
  236. this.rebookDialog = true
  237. this.payStatus = null
  238. this.rebookForm = {
  239. resubmitType: 2, // 改签类型: 1-改签 2-升舱 不传默认为改签
  240. goodsDiffAmount: undefined,
  241. performName: row.performName,
  242. goodsName: row.goodsName,
  243. seatTypeName: row.seatTypeName,
  244. seatTypeId: null,
  245. goodsId: row.goodsId,
  246. orderId: row.orderId,
  247. performDate: row.performDate,
  248. performTimeId: null,
  249. performId: row.performId,
  250. auditoriumId: row.auditoriumId,
  251. paymentType: "1", // 支付方式'
  252. touristNum: row.touristNum,
  253. seatList: [],
  254. performTimeEnd: row.performTimeEnd,
  255. performTimeStart: row.performTimeStart
  256. }
  257. await this.getSelectByIdApi()
  258. await this.handleDateChange()
  259. this.$nextTick(()=>{
  260. this.$refs.rebookForm.clearValidate()
  261. })
  262. },
  263. /** 获取详情 */
  264. async getSelectByIdApi() {
  265. try {
  266. let res = await getSelectById(this.rebookForm.orderId)
  267. this.rebookForm = {
  268. ...this.rebookForm,
  269. performTimeId: res.data.performTimeId,
  270. }
  271. } catch (error) {
  272. }
  273. },
  274. /** 获取票档 */
  275. async handleDateChange() {
  276. try {
  277. this.intervalListLoading = true
  278. this.intervalList = []
  279. let res = await getTimeSeatTypeAllApi({
  280. orderId: this.rebookForm.orderId,
  281. })
  282. this.intervalList = res.data.list || []
  283. if(this.intervalList.length == 0){
  284. this.$message.error('没有可升舱的票档!!!');
  285. }
  286. this.intervalListLoading = false
  287. } catch (error) {
  288. this.intervalListLoading = true
  289. }
  290. },
  291. /** 提交表单 */
  292. submitRebook() {
  293. this.$refs.rebookForm.validate((valid) => {
  294. if (valid) {
  295. if(!this.rebookForm.seatList||this.rebookForm.seatList.length==0) {
  296. this.$message.error('请选择座位!!!');
  297. return
  298. }
  299. if( this.rebookForm.seatList.length < this.rebookForm.touristNum ) {
  300. this.$message.error(`请选择${ this.rebookForm.touristNum }座位!!!`);
  301. return
  302. }
  303. this.orderInfoSubmitFun()
  304. } else {
  305. return false;
  306. }
  307. });
  308. },
  309. /** 退出窗口 */
  310. handleClose(done) {
  311. // if(this.payStatus==8) {
  312. // this.$message.error('请daying');
  313. // return
  314. // }
  315. this.$confirm('确认关闭?')
  316. .then(_ => {
  317. if(this.orderId){
  318. document.removeEventListener('keydown',this.keydownAdd);
  319. this.orderInfoCancelFun(true)
  320. }else {
  321. this.$refs.seatBox.querySeatListFun(true,[],[],[])
  322. this.rebookDialog = false
  323. }
  324. })
  325. .catch(_ => {});
  326. },
  327. /**
  328. *
  329. * 获取升舱/改签信息
  330. *
  331. */
  332. async resubmitInfoFun() {
  333. try {
  334. let res = await resubmitInfoApi({
  335. orderId: this.rebookForm.orderId,
  336. timeId: this.rebookForm.performTimeId,
  337. seatTypeId: this.rebookForm.seatTypeId,
  338. //goodsDiffAmount: this.rebookForm.goodsDiffAmount,
  339. })
  340. this.rebookForm = {
  341. ...this.rebookForm,
  342. realPrice: res.data.reSubmitInfo.realPrice,
  343. diffPrice: res.data.reSubmitInfo.diffPrice
  344. }
  345. if(this.rebookForm.diffPrice <= 0) {
  346. this.rebookForm.paymentType == "2"
  347. }
  348. } catch (error) {
  349. }
  350. },
  351. /** 获取座位 */
  352. async querySeatListFun(type){
  353. try {
  354. await this.countBySeatTypFun(this.rebookForm.auditoriumId)
  355. await this.resubmitInfoFun()
  356. let res = await querySeatListNew({
  357. auditoriumId: this.rebookForm.auditoriumId,
  358. timeId: this.rebookForm.performTimeId,
  359. goodsId: this.rebookForm.goodsId,
  360. channelType: this.rebookForm.timeId ? 'group' : 'window'
  361. })
  362. if(res.code == 200){
  363. let list1 = []
  364. res.data.forEach((item,index)=>{
  365. list1.push({
  366. ...item,
  367. isSame: this.rebookForm.seatTypeId != item.seatTypeId
  368. })
  369. })
  370. this.setList = list1;
  371. let list = []
  372. let list3 = []
  373. this.countBySeatTypList.forEach((item,index)=>{
  374. list3.push(item.seatTypeId)
  375. })
  376. let list4 = []
  377. this.seatTypeListAll.forEach((item,index)=>{
  378. if(list3.includes(item.id)) {
  379. list4.push({...item})
  380. }
  381. })
  382. this.$nextTick(() =>{
  383. this.$refs.seatBox.querySeatListFun(true,this.setList,list,list4)
  384. })
  385. }
  386. this.loading = false
  387. } catch (error) {
  388. this.loading = false
  389. console.error("error===",error)
  390. }
  391. },
  392. /** 获取座位类型 */
  393. async countBySeatTypFun(value) {
  394. try {
  395. if(!value) return
  396. let res = await countBySeatTyp({auditoriumId: value})
  397. this.countBySeatTypList = res.data ? res.data : []
  398. let obj = {}
  399. this.countBySeatTypList.forEach((item,index)=>{
  400. obj['seatNum_'+item.seatTypeId] = {
  401. stockTotal: item.stock,
  402. stockSelect: item.stock,
  403. stockYes: item.stock,
  404. stockNo: 0,
  405. isNoSelect: true,
  406. }
  407. if(item.seatTypeId == this.rebookForm.seatTypeId){
  408. obj['seatNum_'+item.seatTypeId].stockYes = item.stock-this.rebookForm.touristNum
  409. obj['seatNum_'+item.seatTypeId].isNoSelect = false
  410. }
  411. })
  412. this.configStockNumObj = obj
  413. } catch (error) {
  414. console.error("error1====",error)
  415. }
  416. },
  417. /** 获取座位类型 说明 */
  418. async getSeatTypeAllList() {
  419. try {
  420. let res = await getSeatType({
  421. pageNum: 1,
  422. pageSize: 999,
  423. })
  424. if(res.code == 200) {
  425. this.seatTypeListAll = res.data.rows || [];
  426. }
  427. } catch (error) {
  428. }
  429. },
  430. /** 选择座位 */
  431. selectSeat(list) {
  432. let list1 = []
  433. list.forEach((item)=>{
  434. list1.push({
  435. seatId: item.id
  436. })
  437. })
  438. this.rebookForm.seatList = list1
  439. console.log("已选择的====",list)
  440. },
  441. setRealPrice_1(value) {
  442. if(this.rebookForm.realPrice && !isNaN(this.rebookForm.realPrice) && value && !isNaN(value)) {
  443. this.$set(this.rebookForm,'small',mathM.format(Number(value) - Number(this.rebookForm.realPrice),10) )
  444. }
  445. },
  446. }
  447. }
  448. </script>
  449. <style lang="scss" scoped>
  450. .rebook1_dialog ::v-deep .el-dialog__body {
  451. padding: 0 !important;
  452. }
  453. .rebook1_box {
  454. width: 100%;
  455. height: 100%;
  456. padding-bottom: 10px;
  457. .rebook1_from-box {
  458. display: flex;
  459. width: 100%;
  460. height: 80vh;
  461. box-sizing: border-box;
  462. padding: 0 20px 20px;
  463. }
  464. .rebook1_from {
  465. width: 100%;
  466. height: 100%;
  467. overflow: hidden;
  468. overflow-y: auto;
  469. padding: 0 20px 0 0;
  470. width: 400px;
  471. box-sizing: border-box;
  472. .tip-box {
  473. >p {
  474. color: red;
  475. }
  476. }
  477. }
  478. .rebook1_seat {
  479. width: calc( 100% - 400px );
  480. height: 100%;
  481. }
  482. }
  483. .increase-viewers-pay-status {
  484. width: 100%;
  485. height: 100%;
  486. position: absolute;
  487. z-index: 999;
  488. background-color: rgba(0,0,0,0.3);
  489. top: 0;
  490. left: 0;
  491. .increase-viewers-pay-status-info {
  492. width: 100%;
  493. height: 100%;
  494. display: flex;
  495. flex-direction: column;
  496. justify-content: center;
  497. align-items: center;
  498. color: #fff;
  499. }
  500. }
  501. </style>