<template>
  <VxeGrid v-bind="gridOptions" @cell-click="cellClick" />
</template>

<script>
import paoWanPgdConfig from './pgdTable'
import {getDw, getPgd, getYcldw} from "@/api/zyjh";
export default {
  name:'PwanPgd',
  props:{
    workers:{
      type:Array,
      default:[]
    }
  },
  data(){
    return{
      gridOptions:{},
      setExt:null,
    }
  },
  created(){
    const {options,columns,setExt}=paoWanPgdConfig()
    this.setExt=setExt
    this.gridOptions=options
    this.gridOptions.columns=columns
  },
  methods:{
    initData(worker,zt){
      getDw({type:'ycl'}).then(res=>{
        this.gridOptions.ycldw=res.data
      })
      getPgd({user:worker,zt:zt,field:'pwry'}).then(res=>{
        this.gridOptions.data=res.data
        this.setExt('workers',this.$props.workers)
      })
    },
    cellClick({row}){
      this.$emit('pgdClick',row)
      this.$emit('initPgd',row)
    }
  }
}
</script>
