<template>
  <a-modal width="30%" :label-col="16" :wrapper-col="4" :visible="visible" @cancel="onClose">
    <a-divider orientation="left">
      <b>{{ formTitle }}</b>
    </a-divider>
    <div>
      <span style="margin-right: 8px; margin-left: 22px">用车时间结束前</span>
      <a-input-number id="inputNumber" v-model="valueNum" :min="1" :max="1000" @change="onChange" />
      <!-- {{ valueNum }} -->
      <span style="margin-left: 10px">分钟</span>
    </div>
    <div>
      <span>是否确认打开全部箱门</span>
    </div>
    <div slot="footer">
      <a-button type="primary" @click="handleEdit">确定</a-button>
      <a-button @click="onClose">取消</a-button>
    </div>
  </a-modal>
</template>

<script>
import { getWarn, getOpenAll } from '@/api/keys'
export default {
  components: {},
  props: {
    showNum: Number,
  },
  data() {
    return {
      submitLoading: false,
      valueNum: '',
      formTitle: '自动归还提示配置',
      label: '请输入用车归还提前提醒时间:',
      visible: false,
    }
  },
  filters: {},
  created() {},
  computed: {},
  watch: {
    showNum: {
      handler(val) {
        if (val == 1) {
          this.formTitle = '自动归还提示配置'
        } else if (val == 2) {
          this.formTitle = '一键开箱'
        }
      },
      deep: true,
    //   immediate: true,
    },
  },
  mounted() {},
  methods: {
    onClose() {
      this.visible = false
    },
    /** 提交按钮 */
    handleEdit() {
      if (this.showNum == 1) {
        const params = {
          remindId: 4,
          threshold: this.valueNum,
        }
        getWarn(params).then((res) => {
          if (res.code == 200) {
            this.$message.success('配置成功')
            this.onClose()
          }
        })
      } else if (this.showNum == 2) {
        getOpenAll().then((res) => {
          if (res.code == 200) {
            this.$message.success('开箱成功')
          }
          this.funKeyList()
        })
      }
    },
    onChange(val) {
      this.valueNum = val
    },
  },
}
</script>
<style lang="less" scoped>
/deep/.ant-modal-content {
  margin-top: 120px;
  margin-left: 100px;
}
</style>
