<template>
  <div class="opBtn">
    <VaButton color="info" :round="false" size="small" icon="edit" class="mr-6 mb-2" @click="setTime">
      设置考勤时间
    </VaButton>
    <VaModal
      :modelValue="showModal"
      :noDismiss="true"
      @cancel="showModal = false"
      @ok="submit"
      ok-text="提交"
      cancelText="取消"
    >
      <h3 class="va-h3">打卡时间设置</h3>
      <timeForm ref="timeForm"></timeForm>
    </VaModal>
  </div>
</template>

<script>
  import timeForm from './timeForm.vue'
  export default {
    name: 'setPointTimeBtn',
    components:{timeForm},
    props:{
      params:{
        default:()=>{}
      }
    },
    methods:{
      setTime(){
        this.showModal = true
        this.$nextTick(()=>{
          this.$refs.timeForm.setData(this.params)
        })
      },
      submit(){
        let params = {
          id:this.params.id,
          ...this.$refs.timeForm.getData()
        }
        this.$api.editWorkPoint(params).then(res=>{
          this.$toast.success({message:res.message})
          this.$emit('after-op')
          this.showModal = false
        })
      },
    },
    data(){
      return {
        showModal:false
      }
    },
  }
</script>

<style scoped>

</style>
