lockSeat.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <el-dialog :title="title" :visible.sync="dialogVisible" width="40%" :before-close="handleClose">
  3. <div v-if="type == 1" v-loading="loading">
  4. <el-table :data="tableData" style="width: 100%">
  5. <el-table-column prop="date" label="座位号" width="180">
  6. </el-table-column>
  7. <el-table-column prop="name" label="锁定人" width="180">
  8. </el-table-column>
  9. <el-table-column prop="address" label="锁定原因">
  10. </el-table-column>
  11. </el-table>
  12. </div>
  13. <div v-if="type == 0" v-loading="loading">
  14. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  15. <el-form-item label="锁定原因" prop="remark">
  16. <el-input type="textarea" :rows="4" placeholder="请输入锁定原因" maxlength="250" v-model="ruleForm.remark"></el-input>
  17. </el-form-item>
  18. </el-form>
  19. </div>
  20. <span slot="footer" class="dialog-footer">
  21. <el-button @click="handleClose">取 消</el-button>
  22. <el-button :loading="loading" type="primary" @click="lockOrUnLockFun">提交</el-button>
  23. </span>
  24. </el-dialog>
  25. </template>
  26. <script>
  27. import { lockOrUnLockApi, lockOrUnLock } from "@/api/windowTicketSales/ticketingSales"
  28. export default {
  29. name: "LockSeat",
  30. data() {
  31. return {
  32. loading: false,
  33. dialogVisible: false,
  34. tableData: [],
  35. type: null,
  36. list: [],
  37. title: '',
  38. auditoriumId: '',
  39. timeId: '',
  40. ruleForm: {
  41. remark: null
  42. },
  43. rules: {
  44. remark: [
  45. { required: true, message: '请输入锁定原因', trigger: ['blur', 'change'] },
  46. ]
  47. }
  48. }
  49. },
  50. methods: {
  51. /**
  52. *
  53. * @param list 解锁列表
  54. * @param list1 上锁列表
  55. */
  56. async open(list = [], list1 = [], auditoriumId = null, timeId = null) {
  57. this.auditoriumId = auditoriumId
  58. this.timeId = timeId
  59. this.list = list.length > 0 ? list : list1
  60. this.type = list.length > 0 ? 1 : 0 // 1 解锁 0 上锁
  61. this.title = list.length > 0 ? '解锁提示' : '锁定提示' // 1 解锁 0 上锁
  62. console.log(list, list1)
  63. if (list.length > 0) {
  64. await this.lockOrUnLockDeatilFun()
  65. }
  66. this.dialogVisible = true
  67. this.$nextTick(() => {
  68. if (list.length == 0) {
  69. this.$refs.ruleForm.clearValidate()
  70. }
  71. })
  72. },
  73. handleClose() {
  74. this.ruleForm = {}
  75. this.dialogVisible = false
  76. },
  77. /** */
  78. async lockOrUnLockDeatilFun() {
  79. try {
  80. let list = []
  81. this.list.forEach((item, index) => {
  82. list.push({
  83. "auditoriumId": this.auditoriumId,
  84. "seatId": item.id,
  85. "timeId": this.timeId
  86. })
  87. })
  88. let res = await lockOrUnLockApi({
  89. seatList: list
  90. })
  91. if (res.code == 200) {
  92. console.log("ssssss====", res)
  93. } else {
  94. this.handleClose()
  95. }
  96. } catch (error) {
  97. this.handleClose()
  98. }
  99. },
  100. /** 座位锁定/解锁 */
  101. async lockOrUnLockFun(type) {
  102. try {
  103. this.loading = true
  104. let list = []
  105. this.list.forEach((item, index) => {
  106. list.push({
  107. "auditoriumId": this.auditoriumId,
  108. "seatId": item.id,
  109. "timeId": this.timeId
  110. })
  111. })
  112. let res = await lockOrUnLock({
  113. type: this.type,
  114. seatList: list,
  115. remark: this.ruleForm.remark
  116. })
  117. this.loading = false
  118. if (res.code) {
  119. this.$message({
  120. showClose: true,
  121. message: res.msg,
  122. type: 'success'
  123. });
  124. this.$emit('querySeatListFun', true)
  125. this.handleClose()
  126. }
  127. } catch (error) {
  128. this.loading = false
  129. this.$message({
  130. showClose: true,
  131. message: "操作失败!!!",
  132. type: 'error'
  133. });
  134. console.error('error===', error)
  135. }
  136. },
  137. }
  138. }
  139. </script>