batchLock.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <el-dialog :title="title" :visible.sync="dialogVisible" custom-class="custom-dialog" width="75%"
  3. :before-close="handleClose">
  4. <div class="dialog-content">
  5. <div>
  6. <span class="demonstration">选择月份:</span>
  7. <el-date-picker v-model="performMonth" type="month" value-format="yyyy-MM" placeholder="选择月"
  8. @change="hanldeChange">
  9. </el-date-picker>
  10. </div>
  11. <div style="display: flex;justify-content: flex-end;margin-bottom: 20px;">
  12. <el-button type="primary" icon="el-icon-finished" @click="handleCheckAllChange">{{ checkAll ?
  13. '取消全选' : '全选' }}</el-button>
  14. </div>
  15. <div v-loading="loading" style="margin: 0 20px;height: 430px;overflow-y: auto;">
  16. <!-- <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll"
  17. @change="handleCheckAllChange">全选</el-checkbox> -->
  18. <el-checkbox-group v-model="checkedList" @change="handleCheckedChange">
  19. <el-checkbox v-for="item in performTimeList" :label="item.id" :key="item.id" :value="item.id">
  20. <span>{{ item.performDate + ' (' +
  21. item.performTimeStart + '-' + item.performTimeEnd + ')' }}</span>
  22. </el-checkbox>
  23. </el-checkbox-group>
  24. </div>
  25. <div v-loading="loading" style="margin-top: 20px;">
  26. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  27. <el-form-item label="锁定原因" prop="remark">
  28. <el-input type="textarea" :rows="4" placeholder="请输入锁定原因" maxlength="250"
  29. v-model="ruleForm.remark" style="width: 80%;"></el-input>
  30. </el-form-item>
  31. </el-form>
  32. </div>
  33. </div>
  34. <span slot="footer" class="dialog-footer">
  35. <el-button @click="handleClose">取 消</el-button>
  36. <el-button :loading="loading" type="primary" @click="lockOrUnLockFun">提交</el-button>
  37. </span>
  38. </el-dialog>
  39. </template>
  40. <script>
  41. import {
  42. batchLockApi,
  43. merchantPerformTimeListNew
  44. } from "@/api/windowTicketSales/ticketingSales"
  45. import moment from "moment"
  46. export default {
  47. name: "LockSeat",
  48. data() {
  49. return {
  50. loading: false,
  51. dialogVisible: false,
  52. list: [],
  53. title: '',
  54. auditoriumId: '',
  55. timeId: '',
  56. ruleForm: {
  57. remark: null
  58. },
  59. rules: {
  60. remark: [
  61. { required: true, message: '请输入锁定原因', trigger: ['blur', 'change'] },
  62. ]
  63. },
  64. checkAll: false,
  65. checkedList: [],
  66. performTimeList: [], // 场次
  67. isIndeterminate: true,
  68. performMonth: '',
  69. }
  70. },
  71. methods: {
  72. /**
  73. * @param list 解锁列表
  74. * @param list1 上锁列表
  75. */
  76. async openDialog(list = [], list1 = [], auditoriumId = null, timeId = null) {
  77. this.auditoriumId = auditoriumId
  78. // this.timeId = timeId
  79. this.performMonth = moment().format("yyyy-MM")
  80. this.merchantPerformTimeListFun();
  81. this.list = list.length > 0 ? list : list1
  82. this.title = '批量锁定座位'
  83. // console.log(list, list1)
  84. this.dialogVisible = true
  85. this.$nextTick(() => {
  86. if (list.length == 0) {
  87. this.$refs.ruleForm.clearValidate()
  88. }
  89. })
  90. },
  91. // 全选
  92. handleCheckAllChange() {
  93. this.checkAll = !this.checkAll
  94. let ids = this.performTimeList.map(ele => ele.id)
  95. this.isIndeterminate = false;
  96. this.checkedList = this.checkAll ? ids : [];
  97. },
  98. handleCheckedChange(value) {
  99. let checkedCount = value.length;
  100. this.checkAll = checkedCount === this.performTimeList.length;
  101. this.isIndeterminate = checkedCount > 0 && checkedCount < this.performTimeList.length;
  102. },
  103. // 选月份
  104. hanldeChange() {
  105. if (!this.performMonth) {
  106. this.$message.info(`请选择月份查询场次!`);
  107. return
  108. }
  109. // console.log(this.performMonth, 'this.performMonth');
  110. this.merchantPerformTimeListFun();
  111. },
  112. /** 获取场次 */
  113. async merchantPerformTimeListFun() {
  114. try {
  115. let param = {
  116. auditoriumId: this.auditoriumId,
  117. performMonth: this.performMonth,
  118. status: 1,
  119. };
  120. let res = await merchantPerformTimeListNew(param)
  121. if (res.code == 200) {
  122. this.performTimeList = res.data.list
  123. }
  124. } catch (error) {
  125. }
  126. },
  127. handleClose() {
  128. this.ruleForm = {}
  129. this.dialogVisible = false
  130. this.checkAll = false
  131. this.isIndeterminate = false;
  132. this.checkedList = []
  133. },
  134. /** 批量座位锁定 */
  135. async lockOrUnLockFun(type) {
  136. try {
  137. if (this.checkedList.length <= 0) {
  138. this.$message.info(`请勾选需要批量锁定座位的场次`);
  139. return
  140. }
  141. if (!this.ruleForm.remark) {
  142. this.$message.info(`请输入锁定原因`);
  143. return
  144. }
  145. this.loading = true
  146. let list = []
  147. this.list.forEach((item, index) => {
  148. list.push({
  149. "auditoriumId": this.auditoriumId,
  150. "seatId": item.id,
  151. })
  152. })
  153. let res = await batchLockApi({
  154. type: 0, // 类型 0锁定,1解锁
  155. seatList: list,
  156. remark: this.ruleForm.remark,
  157. timeIds: this.checkedList
  158. })
  159. this.loading = false
  160. if (res.code) {
  161. this.$message({
  162. showClose: true,
  163. message: res.msg,
  164. type: 'success'
  165. });
  166. this.$emit('querySeatListFun', true)
  167. this.handleClose()
  168. }
  169. } catch (error) {
  170. this.loading = false
  171. this.$message({
  172. showClose: true,
  173. message: "操作失败!!!",
  174. type: 'error'
  175. });
  176. console.error('error===', error)
  177. }
  178. },
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. ::v-deep .el-checkbox {
  184. color: #606266;
  185. font-weight: 500;
  186. font-size: 14px;
  187. position: relative;
  188. cursor: pointer;
  189. display: inline-block;
  190. white-space: nowrap;
  191. -webkit-user-select: none;
  192. -moz-user-select: none;
  193. -ms-user-select: none;
  194. user-select: none;
  195. margin-right: 20px;
  196. margin-bottom: 10px;
  197. padding: 5px;
  198. border: 1px solid #dcdada;
  199. border-radius: 6px;
  200. }
  201. .dialog-content {
  202. height: 660px;
  203. overflow-y: auto;
  204. }
  205. </style>