<template>
  <div id="bfangLjTable">
    <VxeGrid ref="bFangRef" v-bind="gridOptions" />
  </div>
</template>

<script>
import tableConfig from './ljTable';
import {EventBus} from "@/event-bus";
import {getDmppxxbList} from "@/api/jhzxgl/ypp";
import {ppBGong, yppbg} from "@/api/zyjh";

export default {
  name: 'BFangLjTable',
  props:{
    height:{
      type:Number|String,
      default:()=>786
    }
  },
  data(){
    return {
      gridOptions:{},
      zyq:'',
      setInterval0:'',
      active:false,
    }
  },
  created(){
    const {options,columns} = tableConfig();
    this.gridOptions = options;
    this.gridOptions.height=this.$props.height
    this.gridOptions.columns = columns;
    this.zyq=this.$route.query.zyq
    EventBus.$on('detailActive', params => {
      console.log(params)
      this.active=params
    })
    EventBus.$on('detailShow', params => {
      this.initData(params.ljList)
    })
    EventBus.$on('pl', params => {
      this.pl(params)
    })
    EventBus.$on('bfSave', params => {
      this.save()
    })
  },
  methods:{
    save(){
      const data=this.$refs.bFangRef.getCheckboxRecords()
      if (data.length>0){
        const saveList=[]
        data.filter(it=>!!it.qq&&!!it.dw).forEach(lj=>{
          const _lj={
            id:lj.id,
            qq:lj.qq,
            dw:lj.dw,
            ppzt:'02'
          }
          saveList.push(_lj)
        })
        ppBGong(saveList).then((res)=>{
          this.$message.success('成功')
        })
      }
    },
    pl(params){
      if (!this.active){
        return
      }
      const data=this.$refs.bFangRef.getCheckboxRecords()
      if (data.length===0){
        this.$message.warning('请选择需要批量处理的数据')
        return
      }
      data.forEach(item=>{
        item.qq=params.qy
        item.dw=params.dw
      })
    },
    initData(list){
      this.active=true
      this.gridOptions.data=list
    }
  }
}
</script>

<style scoped>

</style>
