ticketingSales.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <template>
  2. <div class="app-container app-container-me">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. :rules="rules"
  9. label-width="80px">
  10. <el-form-item label="演出厅" prop="auditoriumId">
  11. <el-select
  12. v-model="queryParams.auditoriumId"
  13. placeholder="演出厅"
  14. clearable
  15. style="width: 100%"
  16. @change="changeTime"
  17. >
  18. <el-option
  19. v-for="dict in merchantTheatreAuditoriumListS"
  20. :key="dict.id"
  21. :label="dict.name"
  22. :value="dict.id"
  23. />
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="演出时间" prop="performDate">
  27. <el-date-picker
  28. type="date"
  29. placeholder="选择演出时间"
  30. v-model="queryParams.performDate"
  31. @change="changeTime"
  32. value-format="yyyy-MM-dd"
  33. ></el-date-picker>
  34. </el-form-item>
  35. <el-form-item label="场次" prop="timeId">
  36. <el-select
  37. v-model="queryParams.timeId"
  38. placeholder="场次"
  39. clearable
  40. style="width: 100%"
  41. @change="changeTime"
  42. >
  43. <el-option
  44. v-for="dict in merchantPerformTimeListS"
  45. :key="dict.id"
  46. :label="dict.timeSnapshot+'('+dict.performTimeStart+'-'+dict.performTimeEnd+')'"
  47. :value="dict.id"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="票务类型" prop="goodsId">
  52. <el-select
  53. v-model="queryParams.goodsId"
  54. placeholder="票务类型"
  55. clearable
  56. style="width: 100%"
  57. @change="changeTime"
  58. >
  59. <el-option
  60. v-for="dict in goodsPageListS"
  61. :key="dict.id"
  62. :label="dict.goodsName"
  63. :value="dict.id"
  64. :disabled="dict.status==1 || dict.goodsPerform.channelWindow != 0"
  65. />
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item>
  69. <el-button :loading="loading" type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  70. <el-button :loading="loading" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  71. </el-form-item>
  72. </el-form>
  73. <div class="seat-tool-box">
  74. <span class="demonstration">座位大小</span>
  75. <div>
  76. <el-slider v-model="scaleNum" :min="30" :max="100"></el-slider>
  77. </div>
  78. </div>
  79. <div class="seat-box" :style="{'--scaleNum': scaleNum/100}">
  80. <!-- 选择座位 -->
  81. <div class="seat-list-box">
  82. <!-- 座位排版 -->
  83. <div v-loading="loading" id="seatbox-me" @scroll="scroll" ref="seatbox" class="dialog">
  84. <div class="dialog-box" :style="{width: width + 'px', margin: justifyContent ? 'auto' : 'unset'}">
  85. <div
  86. style="width: 100%;position: absolute;"
  87. class="seat-box-class clearfix" v-if="seatMapList"
  88. >
  89. <div
  90. class="seat-item-class-box"
  91. v-for="(item1, index1) in Object.keys(seatMapList)"
  92. :key="index1"
  93. >
  94. <div
  95. class="seat-item-class"
  96. :class="item.occupyStatus==0?'occupy-status': item.isDisabled || item.status == 2 ? 'disabled-class' : item.isSelect ? 'select-class' : ''"
  97. v-for="(item, index) in seatMapList[item1]"
  98. @click.stop="seatClick(item)"
  99. :key="index">
  100. <p class="text-class">{{ item.status == 2 ? '不可售':(item.name ? item.name : '暂未命名') }}</p>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <div style="margin-top: 5px; margin-left: 30px;display: flex;">
  107. <div style="flex-shrink: 0;">
  108. 已勾选:{{ seatSelectList.length }}个座位
  109. </div>
  110. <div style="width: 100%;display: flex;justify-content: center;height: 30px;">
  111. <el-button size="mini" type="warning" :loading="lockOrUnLockLoading" @click="lockOrUnLockFun(seatSelectList,0)">锁定</el-button>
  112. <el-button size="mini" type="primary" @click="increaseViewersFun">预约</el-button>
  113. </div>
  114. </div>
  115. </div>
  116. <!-- <div class="seat-select-box">
  117. <div class="seat-select-info">
  118. <div
  119. class="seat-select-item"
  120. :key="index"
  121. v-for="(item,index) in seatSelectList">
  122. <span>{{item.name ? item.name : '暂未命名'}}</span>
  123. </div>
  124. </div>
  125. </div> -->
  126. </div>
  127. <!-- 添加观影人 -->
  128. <increaseViewers ref="increaseViewers" @clearDialogVisible="clearDialogVisible" />
  129. </div>
  130. </template>
  131. <script>
  132. import {
  133. querySeatList,
  134. merchantPerformTimeList,
  135. lockOrUnLock,
  136. merchantTheatreAuditoriumList,
  137. goodsPageList,
  138. } from '@/api/windowTicketSales/ticketingSales'
  139. import increaseViewers from "./model/increaseViewers"
  140. export default {
  141. name: "distributionapplication",
  142. components: {
  143. increaseViewers
  144. },
  145. data() {
  146. return {
  147. // 遮罩层
  148. loading: false,
  149. // 查询参数
  150. queryParams: {
  151. timeId: null,
  152. performDate: null,
  153. auditoriumId: null,
  154. goodsId: null,
  155. },
  156. rules: {
  157. auditoriumId: [
  158. { required: true, message: '请选择选择演出厅', trigger: ['blur','change'] }
  159. ],
  160. performDate: [
  161. { required: true, message: '请选择时间', trigger: ['blur','change'] }
  162. ],
  163. timeId: [
  164. { required: true, message: '请选择场次', trigger: ['blur','change'] }
  165. ],
  166. goodsId: [
  167. { required: true, message: '请选择票务类型', trigger: ['blur','change'] }
  168. ],
  169. },
  170. merchantTheatreAuditoriumListS: [], // 演出厅
  171. merchantPerformTimeListS: [], // 场次
  172. querySeatListS: [], // 座位
  173. goodsPageListS: [], // 票务
  174. setList: [],
  175. seatMapList: [],
  176. seatSelectList: [],
  177. lockOrUnLockLoading: false,
  178. performId: '',// 剧目ID
  179. scaleNum: 30,
  180. width: 0,
  181. justifyContent: false
  182. };
  183. },
  184. created() {
  185. this.merchantTheatreAuditoriumListFun()
  186. this.goodsPageListFun()
  187. },
  188. methods: {
  189. /** 票务信息 */
  190. async goodsPageListFun(){
  191. try {
  192. let res = await goodsPageList({
  193. pageNum: 1,
  194. pageSize: 999,
  195. classifyId: 1,
  196. goodsType: 2,
  197. })
  198. if(res.code == 200){
  199. this.goodsPageListS = res.data.rows
  200. // let list = []
  201. // res.data.rows.forEach((item,index)=>{
  202. // if(item.status != 1) {
  203. // list.push(item)
  204. // }
  205. // })
  206. // this.goodsPageListS = list
  207. }
  208. } catch (error) {
  209. }
  210. },
  211. /** 获取演出厅 */
  212. async merchantTheatreAuditoriumListFun(){
  213. try {
  214. let res = await merchantTheatreAuditoriumList({
  215. pageNum: 1,
  216. pageSize: 999
  217. })
  218. if(res.code == 200){
  219. this.merchantTheatreAuditoriumListS = res.data.rows
  220. }
  221. } catch (error) {
  222. }
  223. },
  224. /** 获取场次 */
  225. async merchantPerformTimeListFun(){
  226. try {
  227. let res = await merchantPerformTimeList({
  228. ...this.queryParams
  229. })
  230. if(res.code == 200){
  231. this.merchantPerformTimeListS = res.data.rows
  232. }
  233. } catch (error) {
  234. }
  235. },
  236. /** 座位锁定/解锁 */
  237. async lockOrUnLockFun(listS,type){
  238. try {
  239. this.lockOrUnLockLoading = true
  240. let list = []
  241. listS.forEach((item,index)=>{
  242. list.push({
  243. "auditoriumId": this.queryParams.auditoriumId,
  244. "seatId": item.id,
  245. "timeId": this.queryParams.timeId
  246. })
  247. })
  248. let res = await lockOrUnLock({
  249. type: type,
  250. seatList: list
  251. })
  252. this.lockOrUnLockLoading = false
  253. if(res.code) {
  254. this.$message({
  255. showClose: true,
  256. message: res.msg,
  257. type: 'success'
  258. });
  259. this.querySeatListFun(true)
  260. }
  261. } catch (error) {
  262. this.lockOrUnLockLoading = false
  263. this.$message({
  264. showClose: true,
  265. message: "操作失败!!!",
  266. type: 'error'
  267. });
  268. console.error('error===',error)
  269. }
  270. },
  271. /** 获取座位 */
  272. async querySeatListFun(type){
  273. try {
  274. this.loading = true
  275. this.performId = ''
  276. if(type) { // 是否清除已选
  277. this.seatSelectList = []
  278. }
  279. this.seatMapList = {}
  280. this.seatList = []
  281. let res = await querySeatList({
  282. ...this.queryParams
  283. })
  284. if(res.code == 200){
  285. this.querySeatListS = res.data;
  286. this.setList = res.data;
  287. if(this.setList && this.setList.length > 0) {
  288. this.setSeatMapList(this.setList);
  289. }
  290. }
  291. this.loading = false
  292. } catch (error) {
  293. this.loading = false
  294. console.error("error===",error)
  295. }
  296. },
  297. /** scroll */
  298. scroll(e){
  299. console.log("滚动位置",e)
  300. },
  301. // 设置座位集合
  302. setSeatMapList(list) {
  303. if(list && list.length > 0) {
  304. let listCopy = {}
  305. let lisyCopy1 = {}
  306. list.forEach(item => {
  307. item.isDisabled = (item.occupyStatus != null && (item.occupyStatus == 0 || item.occupyStatus == 1) ? true : false); // 座位是否已被选择
  308. item.isSelect = this.setIsSelect(item);
  309. if(item.rowNo){
  310. if(listCopy['my'+item.rowNo]){
  311. listCopy['my'+item.rowNo].push(item)
  312. }else {
  313. listCopy['my'+item.rowNo] = [item]
  314. }
  315. }
  316. })
  317. let width = 0
  318. let flog = 0
  319. Object.keys(listCopy).forEach((item)=>{
  320. if(listCopy[item].length>flog) {
  321. flog = listCopy[item].length
  322. }
  323. })
  324. this.width = 70*flog
  325. this.$nextTick(()=>{
  326. if(this.$refs.seatbox) {
  327. var ele = document.getElementById('seatbox-me');
  328. console.log(ele.getBoundingClientRect().width); // 100
  329. if(this.width<ele.getBoundingClientRect().width) {
  330. this.justifyContent = true
  331. }else {
  332. this.justifyContent = false
  333. }
  334. this.$refs.seatbox.scrollTo(this.width/4,0)
  335. }
  336. })
  337. console.log("list====",listCopy)
  338. this.seatMapList = JSON.parse(JSON.stringify(listCopy))
  339. }
  340. },
  341. setIsSelect(item){
  342. if(!this.seatSelectList||this.seatSelectList.length==0){
  343. return false
  344. }
  345. let flog = false
  346. this.seatSelectList.forEach((item1,index1)=>{
  347. if(item.id == item1.id){
  348. flog = true
  349. }
  350. })
  351. return flog
  352. },
  353. /** 选择演出时间 */
  354. changeTime(value){
  355. if(this.queryParam && this.queryParam.timeId) {
  356. this.$set(this.queryParam,'timeId',null)
  357. }
  358. if(this.queryParams.auditoriumId&&this.queryParams.performDate){
  359. this.merchantPerformTimeListFun()
  360. }
  361. this.performId = ''
  362. this.seatSelectList = []
  363. this.seatMapList = {}
  364. this.seatList = []
  365. this.handleQuery()
  366. },
  367. /** 设置 场次 对应得剧目ID */
  368. changePerformId(value){
  369. console.log("value=====",value)
  370. this.performId = ''
  371. this.merchantPerformTimeListS.forEach((item,index)=>{
  372. if(item.id == value){
  373. this.performId = item.performId
  374. }
  375. })
  376. },
  377. /** 搜索按钮操作 */
  378. handleQuery() {
  379. this.$refs.queryForm.validate((valid) => {
  380. if (valid) {
  381. this.querySeatListFun();
  382. } else {
  383. console.log('error submit!!');
  384. return false;
  385. }
  386. });
  387. },
  388. /** 重置按钮操作 */
  389. resetQuery() {
  390. this.$refs.queryForm.resetFields()
  391. this.handleQuery();
  392. },
  393. // 座位点击事件
  394. seatClick(row) {
  395. console.log(row)
  396. if(row.occupyStatus == 0){
  397. console.log("weqwrwerewrer")
  398. this.$confirm('此座已被锁定,请先解锁', '提示', {
  399. confirmButtonText: '确定',
  400. cancelButtonText: '取消',
  401. type: 'warning'
  402. }).then(() => {
  403. this.lockOrUnLockFun([row],1)
  404. }).catch((error) => {
  405. console.log("error====",error)
  406. });
  407. }else if(row.isDisabled || row.status == 2){
  408. return false
  409. }else {
  410. let flog = false;
  411. this.seatSelectList.forEach((item,index)=>{
  412. if(item.seatTypeId != row.seatTypeId ) {
  413. flog = true
  414. }
  415. })
  416. if(flog){
  417. this.$message.error('只能选同一类型得座位');
  418. return
  419. }
  420. row.isSelect = !row.isSelect
  421. if(row.isSelect){
  422. this.seatSelectList.push(JSON.parse(JSON.stringify(row)))
  423. }else {
  424. let list = JSON.parse(JSON.stringify(this.seatSelectList))
  425. list.forEach((item,index)=>{
  426. if(item.id == row.id) {
  427. this.seatSelectList.splice(index, 1)
  428. }
  429. })
  430. }
  431. this.$forceUpdate()
  432. }
  433. },
  434. increaseViewersFun(){
  435. if(this.seatSelectList.length>0){
  436. this.changePerformId(this.queryParams.timeId)
  437. this.$refs.increaseViewers.initData(this.seatSelectList,{
  438. ...this.queryParams,
  439. performId:this.performId
  440. })
  441. }else {
  442. this.$alert('请先选择座位!!!', '提示', {
  443. confirmButtonText: '确定',
  444. callback: action => {
  445. }
  446. });
  447. }
  448. },
  449. /** 弹窗关闭 */
  450. clearDialogVisible(){
  451. //this.
  452. this.querySeatListFun(true)
  453. }
  454. }
  455. };
  456. </script>
  457. <style lang="scss" scoped>
  458. .app-container-me {
  459. width: 100%;
  460. height: calc( 100vh - 120px );
  461. }
  462. .seat-tool-box {
  463. height: 20px;
  464. box-sizing: border-box;
  465. display: flex;
  466. align-items: center;
  467. span{
  468. flex-shrink: 0;
  469. font-size: 12px;
  470. }
  471. >div {
  472. width: 100px;
  473. margin-left: 10px;
  474. }
  475. }
  476. .seat-box {
  477. width: 100%;
  478. height: calc( 100% - 100px ) ;
  479. box-sizing: border-box;
  480. display: flex;
  481. position: relative;
  482. .seat-list-box {
  483. //width: calc(100% - 200px);
  484. width: 100%;
  485. height: 100%;
  486. box-sizing: border-box;
  487. }
  488. .seat-select-box {
  489. width: 200px;
  490. height: 100%;
  491. flex-shrink: 0;
  492. box-sizing: border-box;
  493. .seat-select-info {
  494. width: 100%;
  495. height: 100%;
  496. overflow: hidden;
  497. overflow-y: auto;
  498. .seat-select-item {}
  499. }
  500. }
  501. }
  502. .seat-box::after {
  503. content: "舞台";
  504. position: absolute;
  505. left: 50%;
  506. transform: translateX(-50%);
  507. width: 300px;
  508. height: 30px;
  509. background-color: rgb(204, 204, 204,0.3);
  510. font-size: 18px;
  511. font-weight: 600;
  512. display: flex;
  513. align-items: center;
  514. justify-content: center;
  515. border-radius: 0 0 20px 20px;
  516. }
  517. .dialog {
  518. padding: 30px 10px 10px;
  519. width: 100%;
  520. height: 100%;
  521. box-sizing: border-box;
  522. overflow: auto;
  523. border-radius: 10px;
  524. border: 1px solid #323333;
  525. .dialog-box {
  526. position: relative;
  527. }
  528. .upload-btn {
  529. width: 100px;
  530. height: 100px;
  531. background-color: #fbfdff;
  532. border: dashed 1px #c0ccda;
  533. border-radius: 5px;
  534. i {
  535. font-size: 30px;
  536. margin-top: 20px;
  537. }
  538. &-text {
  539. margin-top: -10px;
  540. }
  541. }
  542. .avatar {
  543. cursor: pointer;
  544. }
  545. .title-class{
  546. font-size: 16px;
  547. font-weight: bold;
  548. color: black;
  549. margin-bottom: 20px;
  550. margin-top: 20px;
  551. }
  552. .item-class{
  553. margin-bottom: 20px;
  554. }
  555. .seat-box-class{
  556. width: 3000px;
  557. padding: 5px;
  558. transform-origin: 50% 0;
  559. transform: scale(var(--scaleNum));
  560. box-sizing: border-box;
  561. .disabled-class{
  562. background-color: #aaabad;
  563. user-select: none;
  564. // pointer-events: none;
  565. cursor: not-allowed !important;
  566. }
  567. .select-class{
  568. //background-color: #e85353 !important;
  569. border: 2px solid #1890ff !important;
  570. // color: #eceaea !important;
  571. position: relative;
  572. }
  573. .occupy-status:after{
  574. content:"";
  575. display:block;
  576. position:absolute;
  577. top:0;
  578. left:0;
  579. width:100%;
  580. height:100%;
  581. background-color:rgba(0,0,0,0.3);
  582. z-index:-1;
  583. background-image: url('../../assets/jinzhi.png');
  584. background-size: 50% 50%;
  585. background-position: 50% 50%;
  586. background-repeat: no-repeat;
  587. z-index: 99;
  588. }
  589. .occupy-status {
  590. //pointer-events: none;
  591. }
  592. .seat-item-class-box {
  593. width: 100%;
  594. display: flex;
  595. flex-wrap: nowrap;
  596. justify-content: center;
  597. margin: auto 0;
  598. text-align: center;
  599. }
  600. .seat-item-class{
  601. flex-shrink: 0;
  602. display: block;
  603. float: left;
  604. width: 60px;
  605. height: 60px;
  606. margin: 5px;
  607. border: 1px solid #4c4d4d;
  608. border-radius: 3px;
  609. cursor: pointer;
  610. position: relative;
  611. user-select: none;
  612. // transform-origin: 50% 50%;
  613. // transform: scale(var(--scaleNum));
  614. &:hover{
  615. opacity: 0.6;
  616. }
  617. .text-class{
  618. font-size: 12px;
  619. padding: 5px;
  620. line-height: 16px;
  621. margin: 0;
  622. }
  623. }
  624. }
  625. }
  626. </style>