<template>
  <el-dialog title="输入结算天数" 
    center 
    width="400px"
    :visible="_visible" 
    :append-to-body="true" 
    :close-on-click-modal="false"
     @close="handleClose"
     style="z-index:999999"
    >
    <el-form label-width="0"
     size="mini"
    >
      <el-form-item prop="settle_day">
        <digital-input
            :values="ruleForm.settle_day"
            :placeholder="'结算天数'"
            :min="0"
            :max="100000000000"
            :position="'right'"
            :precision="0"
            :size="'mini'"
            :controls="false"
            :append="'天'"
            @reschange="number_change($event)"
          />
      </el-form-item>

      <el-form-item class="flex-end">
        <el-button type="primary" @click="onSubmit">保存</el-button>
      </el-form-item>
    </el-form>

  </el-dialog>
</template>

<script>
export default {
  name: 'SettleDayModal',
  props: ['visible'],
  data(){
    return {
      ruleForm:{
       settle_day: 0 
      },
    }
  },
  computed:{
    _visible:{
      get(){
        return this.visible
      },
      set(newValue){
        this.$emit('update:visible',newValue)
      }
    }
  },
  methods:{
    handleClose(){
      this.ruleForm.settle_day = 0
      this._visible = false
    },
    number_change(day){
      this.ruleForm.settle_day = Number(day)
    },
    onSubmit(){
      if(Number(this.ruleForm.settle_day) === 0){
        this.$message.warning('结算天数不能为零！')
        return
      }

      this.$emit('change', this.ruleForm.settle_day)
      this._visible = false
    }
  }
}
</script>
