<template>
  <div>
    <el-dialog
        title="选择人员"
        :visible.sync="dialogVisible"
        width="700px"
        :before-close="handleClose"
        :append-to-body="true" 
        :close-on-click-modal="false"
        >
        <div>
            <client-table :personIds="personIds" :persons="persons" @getPersonIds="getPersonIds"></client-table>
        </div>
    </el-dialog>
  </div>
</template>

<script>
import ClientTable from './ClientTable.vue';
export default {
  components: {
    ClientTable
  },
  props: {},
  data() {
    return {
        dialogVisible:false,
        personIds:[],
        persons:[],
        submit:false
    };
  },
  watch: {},
  computed: {},
  created() {},
  mounted() {
    
  },
  methods: {
    //关闭弹窗
    handleClose(){
        this.dialogVisible = false
        if(this.submit){
          this.$emit('getPersonIds',{personIds:this.personIds,persons:this.persons})
        }
        
    },
    //打开弹窗
    open(personIds,persons){
      if(personIds){
        this.personIds = JSON.parse(JSON.stringify(personIds))
      }else{
        this.personIds = []
      }
      if(persons){
        this.persons = JSON.parse(JSON.stringify(persons))
      }else{
        this.persons = []
      }
      this.submit= false
        // this.personIds = personIds || []
        // this.persons = persons || []
        this.dialogVisible = true
    },
    getPersonIds({personIds,persons,submit}){
        this.personIds = personIds
        this.persons = persons
        this.submit = submit
        this.handleClose()
    }
  },
    
};
</script>
<style lang="scss" scoped>
</style>