
<template>
  <div class='opBtn'>
    <VaButton color="info" :round="false" size="small" icon="edit" class="mr-6 mb-2" @click="getPointDetial">
      编辑考勤点
    </VaButton>
    <VaModal :modelValue="showModal" :noDismiss="true" blur @cancel='showModal=false' @ok="submit" ok-text="提交" cancelText="取消">
      <h3 class="va-h3">考勤点信息</h3>
      <pointForm ref="pointForm"></pointForm>
    </VaModal>
  </div>
</template>

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

<style scoped>

</style>


