<template>
  <VxeGrid ref="hxPgd" v-bind="gridOptions" @cell-click="cellClick" @current-change="getCurrentData" />
</template>

<script>
import paoWanPgdConfig from './pgdTable'
import {getDw, getPgd} from "@/api/zyjh";
export default {
  name:'HxianPgd',
  props:{
    workers:{
      type:Array,
      default:[]
    },
  },
  data(){
    return{
      gridOptions:{},
      list:{},
      setExt:null,
    }
  },
  created(){
    const {options,columns,setExt}=paoWanPgdConfig()
    this.setExt=setExt
    this.gridOptions=options
    this.gridOptions.columns=columns
  },
  methods:{
    initData(worker,zt){
      getDw({type:'llj'}).then(res=>{
        this.gridOptions.ycldw=res.data
      })
      getPgd({user:worker,zt:zt,field:'hxry'}).then(res=>{
        this.gridOptions.data=res.data
        this.setExt('workers',this.$props.workers)
      })
    },
    getCurrentData(){
      const data= this.$refs.hxPgd.getCurrentRecord()
      window.localStorage.setItem("hxfk",JSON.stringify(data))
    },
    cellClick({row}){
      this.$emit('pgdClick',row)
      this.$emit('initPgd',row)
    }
  }
}
</script>
