export default {
    data() {
        return {
            /**  多选  */
            selectList: [],
            selectTabelList: [],
            multipleSelection_1: []
        }
    },
    methods: {
        /**  当前选择  开始   */
        /**  多选  */
        dragSelectChange(e){
            console.log("e===",e)
            if(e && e.div) {
                let  list = JSON.parse(JSON.stringify(e.div))
                this.selectList = [...new Set(list)]
                console.log("e===",this.selectList)
                if(this.activeName=='select'){
                    this.addSelectTabelList()
                }
            }
            
        },
        dragLostItemChange(){},
        reSelect() {

        },
        addSelectTabelList(){
            if(this.selectList && this.selectList.length > 0) {
                let listTabel = []
                for(let i=0;i<this.selectList.length;i++){
                    for(let j=0;j<this.tableDataAll.length;j++){

                        if(this.selectList[i] == this.tableDataAll[j].styleCss.id){
                            listTabel.push({
                                ...this.tableDataAll[j],
                            })
                            break;
                        }    
                    }
                }
                console.log("listTabel=====",listTabel)
                this.selectTabelList = JSON.parse(JSON.stringify(listTabel))
            }else { 
                this.selectTabelList = []
            }
        },
        //  清除已选
        delSelectTabelList(){
            this.selectList = []
            this.selectTabelList = []
        },
        /**  当前选择  结束   */

        /**  批量修改   */

        // 座位状态
        selectBatchSetaDisableFun() {
            let listTabel = JSON.parse(JSON.stringify(this.tableDataAll))
            for(let i=0;i<this.selectTabelList.length;i++){
                for(let j=0;j<this.tableDataAll.length;j++){
                    if(this.selectTabelList[i].styleCss.id == this.tableDataAll[j].styleCss.id){
                        listTabel[j] = {
                            ...this.tableDataAll[j],
                            status: this.formAll.status,
                        }
                        break;
                    }    
                }
            }
            this.tableDataAll = JSON.parse(JSON.stringify(listTabel))
            console.log("this.tableDataAll=====",this.tableDataAll)
            // this.batchTableList = JSON.parse(JSON.stringify(this.tableDataAll))
            this.formDialogVisible = false
            this.handleQuery()
            this.dataProcess()
        },
        //批量修改座位类型 
        selectBatchSetaTypeFun() {
            let color = ''
            let seatLabel = ''
            let listTabel = JSON.parse(JSON.stringify(this.tableDataAll))
            this.seatTypeList.forEach((item,index)=>{
                if(this.formAll.seatTypeId == item.id) {
                    color = item.color
                    seatLabel = item.name 
                }
            })
            for(let i=0;i<this.selectTabelList.length;i++){
                for(let j=0;j<this.tableDataAll.length;j++){
                    if(this.selectTabelList[i].styleCss.id == this.tableDataAll[j].styleCss.id){
                        listTabel[j] = {
                            ...this.tableDataAll[j],
                            seatLabel: seatLabel,
                            color: color,// 座位类型对应的颜色
                            seatTypeId: this.formAll.seatTypeId,
                        }
                        break;
                    }    
                }
            }
            this.tableDataAll = JSON.parse(JSON.stringify(listTabel))
            console.log("this.tableDataAll=====",this.tableDataAll)
            // this.batchTableList = JSON.parse(JSON.stringify(this.tableDataAll))
            this.formDialogVisible = false
            this.dataProcess()
            this.addSelectTabelList()
        },  
        // 批量修改名称
        selectBatchSetaNameFun() {
            if(this.formAll.seatWay == 1){ // 相同的
                let listTabel = JSON.parse(JSON.stringify(this.tableDataAll))
                for(let i=0;i<this.selectTabelList.length;i++){
                    for(let j=0;j<this.tableDataAll.length;j++){
                        if(this.selectTabelList[i].styleCss.id == this.tableDataAll[j].styleCss.id){
                            listTabel[j] = {
                                ...this.tableDataAll[j],
                                name: this.formAll.name
                            }
                            break;
                        }    
                    }
                }
                this.tableDataAll = JSON.parse(JSON.stringify(listTabel))
            }else if(this.formAll.seatWay == 2){
                let name = (this.formAll.name1?this.formAll.name1:'') + '${row}' + (this.formAll.name?this.formAll.name:'') + '${col}' + (this.formAll.name2?this.formAll.name2:'')
                let listTabel = JSON.parse(JSON.stringify(this.tableDataAll))
                for(let i=0;i<this.selectTabelList.length;i++){
                    for(let j=0;j<this.tableDataAll.length;j++){
                        if(this.selectTabelList[i].styleCss.id == this.tableDataAll[j].styleCss.id){
                            listTabel[j] = {
                                ...this.tableDataAll[j],
                                name: name.replace('${row}',this.tableDataAll[j].rowNo).replace('${col}',this.tableDataAll[j].columnNo)
                            }
                            break;
                        }    
                    }
                }
                this.tableDataAll = JSON.parse(JSON.stringify(listTabel))
            }
            this.formDialogVisible = false
            this.dataProcess()
            this.addSelectTabelList()
        },
        // 批量修改优先级
        selectBatchSetaPriorityFun(){
            if(this.formAll.seatPriorityWay == 1){
                let listTabel = JSON.parse(JSON.stringify(this.tableDataAll))
                for(let i=0;i<this.selectTabelList.length;i++){
                    for(let j=0;j<this.tableDataAll.length;j++){
                        if(this.selectTabelList[i].styleCss.id == this.tableDataAll[j].styleCss.id){
                            listTabel[j] = {
                                ...this.tableDataAll[j],
                                priority: this.formAll.setaPriorityNum
                            }
                            break;
                        }    
                    }
                }
                this.tableDataAll = JSON.parse(JSON.stringify(listTabel))
            }else{
                let listTabel = JSON.parse(JSON.stringify(this.tableDataAll))
                let num = Number(this.formAll.setaPriorityNum)
                for(let i=0;i<this.selectTabelList.length;i++){
                    for(let j=0;j<this.tableDataAll.length;j++){
                        if(this.selectTabelList[i].styleCss.id == this.tableDataAll[j].styleCss.id){
                            listTabel[j] = {
                                ...this.tableDataAll[j],
                                priority: num
                            }
                            if(this.formAll.seatPriorityWay == 2){
                                num = num + 1
                            }else if(this.formAll.seatPriorityWay == 3){
                                num = num - 1
                            }
                            break;
                        }    
                    }
                }
                this.tableDataAll = JSON.parse(JSON.stringify(listTabel))
            }
            this.formDialogVisible = false
            this.dataProcess()
            this.addSelectTabelList()
        },
    },
}