<template>
  <div>
    <LHeader :text="text"></LHeader>
    <van-form
      @submit="onSubmit"
      :show-error-message="false"
      :scroll-to-error="true"
    >
      <van-field name="radio" label="隐患复查结果">
        <template #input>
          <van-radio-group
            v-model="radio"
            direction="horizontal"
            @change="selectResult"
          >
            <van-radio name="1">合格</van-radio>
            <van-radio name="2">退回</van-radio>
          </van-radio-group>
        </template>
      </van-field>

      <!-- 同意时的选项 -->
      <div class="agree" v-if="radio == 1">
        <van-field
          v-model="detail"
          label="详情描述"
          name="详情描述"
          rows="3"
          type="textarea"
          placeholder="请输入"
          :rules="[{ required: true, message: '详情描述不能为空' }]"
        />
        <van-field
          name="uploader"
          label="隐患复查照片"
          :rules="[{ required: true, message: '请上传图像' }]"
        >
          <template #input>
            <van-uploader v-model="uploaderImg" />
          </template>
        </van-field>
      </div>

      <!-- 退回是的选项 -->
      <div class="disagree" v-else>
        <van-field
          v-model="returnReason"
          label="退回原因"
          name="退回原因"
          rows="3"
          type="textarea"
          placeholder="请输入"
          :rules="[{ required: true, message: '退回原因不能为空' }]"
        />
      </div>

      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit"
          >保存</van-button
        >
      </div>
    </van-form>
    <div style="margin:10px 16px 0px;padding-bottom:16px">
      <van-button round block type="warning" @click.native="cancel"
        >取消</van-button
      >
    </div>
  </div>
</template>

<script>
import LHeader from "@/components/header.vue";
export default {
  components: {
    LHeader
  },
  data() {
    return {
      radio: "1",
      text: "隐患复查",
      detail: "",
      uploaderImg: [],
      returnReason: ""
    };
  },
  mounted() {},
  methods: {
    selectResult(val) {
      this.radio = val;
    },

    onSubmit(values) {
      console.log("submit", values);
    },
    cancel() {
      this.$router.go(-1);
    }
  }
};
</script>
<style lang="less" scoped>
/* @import url(); 引入css类 */
</style>
