<route lang="json5" type="page">
{
  style: { navigationBarTitleText: '脖环绑定' },
}
</route>

<template>
  <view class="container px-2">
    <wd-form ref="form" :model="model">
      <wd-cell-group border custom-class="group" title="绑定信息">
        <wd-input
          label="牛号"
          label-width="100px"
          prop="value2"
          clearable
          v-model="model.value2"
          placeholder="请输入牛号"
          required
        />
        <wd-input
          label="脖环号"
          label-width="100px"
          prop="value2"
          clearable
          v-model="model.value2"
          placeholder="请输入脖环号"
          required
        />
        <!-- <wd-cell title="脖环号" title-width="100px" prop="value1" center required>
          <view style="text-align: left">
            <wd-radio-group v-model="model.value1" inline shape="dot" prop="value2">
              <wd-radio value="1">绑定</wd-radio>
              <wd-radio value="2">解绑</wd-radio>
            </wd-radio-group>
          </view>
        </wd-cell> -->
        <wd-calendar
          label="绑定时间"
          prop="date"
          label-width="100px"
          type="datetime"
          hide-second
          v-model="model.date"
          :min-date="minDate"
          :max-date="maxDate"
          :disabled-date="disableFutureDates"
          required
        />
        <wd-textarea
          label="备注信息"
          label-width="100px"
          v-model="model.remark"
          :maxlength="200"
          clearable
          show-word-limit
          placeholder="请输入备注"
          auto-height
        />
      </wd-cell-group>
      <view class="footer mx-4 mt-6">
        <wd-button type="primary" size="large" @click="handleSubmit" block>提交</wd-button>
      </view>
    </wd-form>
  </view>
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue'

defineOptions({
  name: 'neckRing',
})

// 日期选择器
const today = new Date()
const minDate = ref(new Date(2000, 0, 1)) // 可选择的最早日期
const maxDate = ref(today)

const disableFutureDates = (date: Date) => {
  return date > today
}

const model = reactive<{
  value1: string
  value2: string
  date: number
}>({
  value1: '',
  value2: '',
  date: Date.now(),
})

const form = ref()

function handleSubmit() {
  form.value
    .validate()
    .then(({ valid, errors }) => {
      if (valid) {
        // showSuccess({
        //   msg: '校验通过',
        // })
      }
    })
    .catch((error) => {
      console.log(error, 'error')
    })
}
</script>

<style lang="scss" scoped>
.container {
  background: #fff;
}
</style>
