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

<template>
  <view class="container">
    <wd-form ref="form" :model="model" class="px-2">
      <wd-cell-group border custom-class="group" title="解绑信息">
        <wd-input
          label="牛号"
          label-width="100px"
          prop="value2"
          clearable
          v-model="model.value2"
          placeholder="请输入牛号"
          required
        />

        <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"
        />
        <wd-picker
          :columns="columns"
          label="解绑原因"
          v-model="model.value1"
          @confirm="handleConfirm"
          placeholder="请选择解绑原因"
        />
        <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 mt-5 pb-20 center">
        <wd-button type="info" size="medium" class="mr-4" @click="goBack">取消</wd-button>
        <wd-button type="primary" size="medium" @click="handleSubmit">提交</wd-button>
      </view>
    </wd-form>
  </view>
</template>

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

defineOptions({
  name: 'neckRing',
})
// 品种选择
const columns = ref(['选项1', '选项2', '选项3', '选项4', '选项5', '选项6', '选项7'])

function handleConfirm({ value }) {
  value.value = value
}

// 日期选择器
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>
