| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648 | <template>    <div class="app-container app-container-me">      <el-form       :model="queryParams"       ref="queryForm"       size="small"       :inline="true"       :rules="rules"      label-width="80px">        <el-form-item label="演出厅" prop="auditoriumId">          <el-select            v-model="queryParams.auditoriumId"            placeholder="演出厅"            clearable            style="width: 100%"            @change="changeTime"          >            <el-option              v-for="dict in merchantTheatreAuditoriumListS"              :key="dict.id"              :label="dict.name"              :value="dict.id"            />          </el-select>        </el-form-item>        <el-form-item label="演出时间" prop="performDate">            <el-date-picker             type="date"             placeholder="选择演出时间"             v-model="queryParams.performDate"            @change="changeTime"            value-format="yyyy-MM-dd"            ></el-date-picker>        </el-form-item>        <el-form-item label="场次" prop="timeId">          <el-select            v-model="queryParams.timeId"            placeholder="场次"            clearable            style="width: 100%"            @change="changeTime"          >            <el-option              v-for="dict in merchantPerformTimeListS"              :key="dict.id"              :label="dict.timeSnapshot+'('+dict.performTimeStart+'-'+dict.performTimeEnd+')'"              :value="dict.id"            />          </el-select>        </el-form-item>        <el-form-item label="票务类型" prop="goodsId">          <el-select            v-model="queryParams.goodsId"            placeholder="票务类型"            clearable            style="width: 100%"            @change="changeTime"          >            <el-option              v-for="dict in goodsPageListS"              :key="dict.id"              :label="dict.goodsName"              :value="dict.id"              :disabled="dict.status==1 || dict.goodsPerform.channelWindow != 0"            />          </el-select>        </el-form-item>        <el-form-item>          <el-button :loading="loading" type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>          <el-button :loading="loading" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>        </el-form-item>      </el-form>      <div class="seat-tool-box">        <span class="demonstration">座位大小</span>        <div>            <el-slider v-model="scaleNum" :min="30" :max="100"></el-slider>        </div>              </div>      <div class="seat-box" :style="{'--scaleNum': scaleNum/100}">        <!-- 选择座位  -->        <div class="seat-list-box">            <!--  座位排版  -->            <div v-loading="loading" id="seatbox-me" @scroll="scroll" ref="seatbox" class="dialog">                <div class="dialog-box" :style="{width: width + 'px', margin: justifyContent ? 'auto' : 'unset'}">                    <div                     style="width: 100%;position: absolute;"                    class="seat-box-class clearfix" v-if="seatMapList"                    >                            <div                                                       class="seat-item-class-box"                             v-for="(item1, index1) in Object.keys(seatMapList)"                             :key="index1"                            >                                <div                                 class="seat-item-class"                                 :class="item.occupyStatus==0?'occupy-status': item.isDisabled || item.status == 2 ? 'disabled-class' : item.isSelect ? 'select-class' : ''"                                v-for="(item, index) in seatMapList[item1]"                                 @click.stop="seatClick(item)"                                 :key="index">                                    <p class="text-class">{{ item.status == 2 ? '不可售':(item.name ? item.name : '暂未命名') }}</p>                                </div>                            </div>                    </div>                </div>                            </div>            <div style="margin-top: 5px; margin-left: 30px;display: flex;">                <div style="flex-shrink: 0;">                    已勾选:{{ seatSelectList.length }}个座位                </div>                <div style="width: 100%;display: flex;justify-content: center;height: 30px;">                    <el-button size="mini" type="warning" :loading="lockOrUnLockLoading" @click="lockOrUnLockFun(seatSelectList,0)">锁定</el-button>                    <el-button size="mini" type="primary" @click="increaseViewersFun">预约</el-button>                </div>            </div>        </div>        <!-- <div class="seat-select-box">            <div class="seat-select-info">                <div                 class="seat-select-item"                :key="index"                 v-for="(item,index) in seatSelectList">                    <span>{{item.name ? item.name : '暂未命名'}}</span>                </div>            </div>        </div> -->      </div>      <!--  添加观影人  -->      <increaseViewers ref="increaseViewers" @clearDialogVisible="clearDialogVisible" />    </div>  </template>    <script>  import {   querySeatList,  merchantPerformTimeList,  lockOrUnLock,  merchantTheatreAuditoriumList,  goodsPageList, } from '@/api/windowTicketSales/ticketingSales' import increaseViewers from "./model/increaseViewers"  export default {    name: "distributionapplication",    components: {        increaseViewers    },    data() {      return {        // 遮罩层        loading: false,        // 查询参数        queryParams: {            timeId: null,            performDate: null,            auditoriumId: null,            goodsId: null,        },        rules: {            auditoriumId: [                { required: true, message: '请选择选择演出厅', trigger: ['blur','change'] }            ],            performDate: [                { required: true, message: '请选择时间', trigger: ['blur','change'] }            ],            timeId: [                { required: true, message: '请选择场次', trigger: ['blur','change'] }            ],            goodsId: [                { required: true, message: '请选择票务类型', trigger: ['blur','change'] }            ],        },        merchantTheatreAuditoriumListS: [], // 演出厅        merchantPerformTimeListS: [], // 场次        querySeatListS: [], // 座位        goodsPageListS: [], // 票务        setList: [],        seatMapList: [],        seatSelectList: [],        lockOrUnLockLoading: false,        performId: '',// 剧目ID        scaleNum: 30,        width: 0,        justifyContent: false      };    },    created() {        this.merchantTheatreAuditoriumListFun()        this.goodsPageListFun()    },    methods: {        /**  票务信息  */        async goodsPageListFun(){            try {                let res = await goodsPageList({                    pageNum: 1,                    pageSize: 999,                    classifyId: 1,                    goodsType: 2,                })                if(res.code == 200){                    this.goodsPageListS = res.data.rows                    // let list = []                    // res.data.rows.forEach((item,index)=>{                    //     if(item.status != 1) {                    //         list.push(item)                    //     }                    // })                    // this.goodsPageListS = list                }            } catch (error) {                            }        },        /**  获取演出厅  */        async merchantTheatreAuditoriumListFun(){            try {                let res = await merchantTheatreAuditoriumList({                    pageNum: 1,                    pageSize: 999                })                if(res.code == 200){                    this.merchantTheatreAuditoriumListS = res.data.rows                }            } catch (error) {                            }        },        /**  获取场次  */        async merchantPerformTimeListFun(){            try {                let res = await merchantPerformTimeList({                    ...this.queryParams                })                if(res.code == 200){                    this.merchantPerformTimeListS = res.data.rows                }            } catch (error) {                            }        },        /**  座位锁定/解锁  */        async lockOrUnLockFun(listS,type){            try {                this.lockOrUnLockLoading = true                let list = []                listS.forEach((item,index)=>{                    list.push({                        "auditoriumId": this.queryParams.auditoriumId,                        "seatId": item.id,                        "timeId": this.queryParams.timeId                    })                })                let res = await lockOrUnLock({                    type: type,                    seatList: list                })                this.lockOrUnLockLoading = false                if(res.code) {                    this.$message({                        showClose: true,                        message: res.msg,                        type: 'success'                    });                    this.querySeatListFun(true)                }                            } catch (error) {                this.lockOrUnLockLoading = false                this.$message({                        showClose: true,                        message: "操作失败!!!",                        type: 'error'                    });                console.error('error===',error)            }                    },        /**  获取座位  */        async querySeatListFun(type){            try {                this.loading = true                this.performId = ''                if(type) { // 是否清除已选                    this.seatSelectList = []                }                this.seatMapList = {}                this.seatList = []                let res = await querySeatList({                    ...this.queryParams                })                if(res.code == 200){                    this.querySeatListS = res.data;                    this.setList = res.data;                    if(this.setList && this.setList.length > 0) {                        this.setSeatMapList(this.setList);                    }                }                this.loading = false            } catch (error) {                this.loading = false                console.error("error===",error)            }        },        /** scroll */        scroll(e){            console.log("滚动位置",e)        },        // 设置座位集合        setSeatMapList(list) {            if(list && list.length > 0) {                let listCopy = {}                let lisyCopy1 = {}                list.forEach(item => {                    item.isDisabled = (item.occupyStatus != null && (item.occupyStatus == 0 || item.occupyStatus == 1) ? true : false); // 座位是否已被选择                    item.isSelect = this.setIsSelect(item);                    if(item.rowNo){                        if(listCopy['my'+item.rowNo]){                            listCopy['my'+item.rowNo].push(item)                        }else {                            listCopy['my'+item.rowNo] = [item]                         }                    }                })                let width = 0                let flog = 0                Object.keys(listCopy).forEach((item)=>{                    if(listCopy[item].length>flog) {                        flog = listCopy[item].length                    }                })                this.width = 70*flog                this.$nextTick(()=>{                    if(this.$refs.seatbox) {                        var ele = document.getElementById('seatbox-me');                        console.log(ele.getBoundingClientRect().width); // 100                        if(this.width<ele.getBoundingClientRect().width) {                            this.justifyContent = true                        }else {                            this.justifyContent = false                        }                        this.$refs.seatbox.scrollTo(this.width/4,0)                    }                })                                console.log("list====",listCopy)                this.seatMapList = JSON.parse(JSON.stringify(listCopy))            }        },        setIsSelect(item){            if(!this.seatSelectList||this.seatSelectList.length==0){                return false            }            let flog = false            this.seatSelectList.forEach((item1,index1)=>{                if(item.id == item1.id){                    flog = true                }            })            return flog        },        /**  选择演出时间  */        changeTime(value){            if(this.queryParam && this.queryParam.timeId) {                this.$set(this.queryParam,'timeId',null)            }            if(this.queryParams.auditoriumId&&this.queryParams.performDate){                this.merchantPerformTimeListFun()            }            this.performId = ''            this.seatSelectList = []            this.seatMapList = {}            this.seatList = []            this.handleQuery()                    },        /**  设置 场次 对应得剧目ID */        changePerformId(value){            console.log("value=====",value)            this.performId = ''            this.merchantPerformTimeListS.forEach((item,index)=>{                if(item.id == value){                    this.performId = item.performId                }            })        },        /** 搜索按钮操作 */        handleQuery() {            this.$refs.queryForm.validate((valid) => {            if (valid) {                this.querySeatListFun();            } else {                console.log('error submit!!');                return false;            }            });                    },        /** 重置按钮操作 */        resetQuery() {            this.$refs.queryForm.resetFields()            this.handleQuery();        },        // 座位点击事件        seatClick(row) {            console.log(row)            if(row.occupyStatus == 0){                console.log("weqwrwerewrer")                this.$confirm('此座已被锁定,请先解锁', '提示', {                    confirmButtonText: '确定',                    cancelButtonText: '取消',                    type: 'warning'                }).then(() => {                    this.lockOrUnLockFun([row],1)                }).catch((error) => {                    console.log("error====",error)                });            }else if(row.isDisabled || row.status == 2){                return false            }else {                let flog = false;                this.seatSelectList.forEach((item,index)=>{                    if(item.seatTypeId != row.seatTypeId ) {                        flog = true                    }                })                if(flog){                    this.$message.error('只能选同一类型得座位');                    return                }                row.isSelect = !row.isSelect                if(row.isSelect){                    this.seatSelectList.push(JSON.parse(JSON.stringify(row)))                }else {                    let list = JSON.parse(JSON.stringify(this.seatSelectList))                    list.forEach((item,index)=>{                        if(item.id == row.id) {                            this.seatSelectList.splice(index, 1)                        }                    })                }                this.$forceUpdate()            }                    },        increaseViewersFun(){            if(this.seatSelectList.length>0){                this.changePerformId(this.queryParams.timeId)                this.$refs.increaseViewers.initData(this.seatSelectList,{                    ...this.queryParams,                    performId:this.performId                })            }else {                this.$alert('请先选择座位!!!', '提示', {                    confirmButtonText: '确定',                    callback: action => {                                            }                });            }                    },        /**  弹窗关闭 */        clearDialogVisible(){            //this.            this.querySeatListFun(true)        }    }     };  </script>  <style lang="scss" scoped>  .app-container-me {    width: 100%;    height: calc( 100vh - 120px );  }  .seat-tool-box {    height: 20px;    box-sizing: border-box;    display: flex;    align-items: center;    span{        flex-shrink: 0;        font-size: 12px;    }    >div {        width: 100px;        margin-left: 10px;    }  }  .seat-box {    width: 100%;    height: calc( 100% - 100px ) ;    box-sizing: border-box;    display: flex;    position: relative;    .seat-list-box {        //width: calc(100% - 200px);        width: 100%;        height: 100%;        box-sizing: border-box;    }    .seat-select-box {        width: 200px;        height: 100%;        flex-shrink: 0;        box-sizing: border-box;        .seat-select-info {            width: 100%;            height: 100%;            overflow: hidden;            overflow-y: auto;            .seat-select-item {}        }    }  }  .seat-box::after {    content: "舞台";    position: absolute;    left: 50%;    transform: translateX(-50%);    width: 300px;    height: 30px;    background-color: rgb(204, 204, 204,0.3);    font-size: 18px;    font-weight: 600;    display: flex;    align-items: center;    justify-content: center;    border-radius: 0 0 20px 20px;  }  .dialog {    padding: 30px 10px 10px;    width: 100%;    height: 100%;    box-sizing: border-box;    overflow: auto;    border-radius: 10px;    border: 1px  solid #323333;    .dialog-box {        position: relative;    }    .upload-btn {      width: 100px;      height: 100px;      background-color: #fbfdff;      border: dashed 1px #c0ccda;      border-radius: 5px;      i {        font-size: 30px;        margin-top: 20px;      }      &-text {        margin-top: -10px;      }    }    .avatar {      cursor: pointer;    }    .title-class{      font-size: 16px;      font-weight: bold;      color: black;      margin-bottom: 20px;      margin-top: 20px;    }    .item-class{      margin-bottom: 20px;    }    .seat-box-class{      width: 3000px;      padding: 5px;      transform-origin: 50% 0;      transform: scale(var(--scaleNum));      box-sizing: border-box;      .disabled-class{        background-color: #aaabad;        user-select: none;        // pointer-events: none;        cursor: not-allowed !important;      }      .select-class{        //background-color: #e85353 !important;        border: 2px solid #1890ff !important;       // color: #eceaea !important;       position: relative;      }      .occupy-status:after{        content:"";        display:block;        position:absolute;        top:0;        left:0;        width:100%;        height:100%;        background-color:rgba(0,0,0,0.3);        z-index:-1;        background-image: url('../../assets/jinzhi.png');        background-size: 50% 50%;        background-position: 50% 50%;        background-repeat: no-repeat;        z-index: 99;    }      .occupy-status {        //pointer-events: none;      }      .seat-item-class-box {        width: 100%;        display: flex;        flex-wrap: nowrap;        justify-content: center;        margin: auto 0;        text-align: center;      }      .seat-item-class{        flex-shrink: 0;        display: block;        float: left;        width: 60px;        height: 60px;        margin: 5px;        border: 1px solid #4c4d4d;        border-radius: 3px;        cursor: pointer;        position: relative;        user-select: none;        // transform-origin: 50% 50%;        // transform: scale(var(--scaleNum));        &:hover{          opacity: 0.6;        }          .text-class{          font-size: 12px;          padding: 5px;          line-height: 16px;          margin: 0;        }      }    }  }  </style>
 |