<template>
  <div id="search-1">
    <van-row>
      <van-col span="24" class="main">
        <van-col span="24" class="one">
          <van-form>
            <van-field v-model="form.labName" name="labName" label="实验室主任姓名" placeholder="实验室主任姓名" />
            <van-field
              readonly
              clickable
              name="calendar"
              :value="form.labCardtime"
              label="实验室主任出生年月"
              placeholder="点击选择"
              @click="changeCreate('labCardtime')"
            />
            <van-field v-model="form.labJob" name="labJob" label="实验室主任职称" placeholder="实验室主任职称" />
            <van-field v-model="form.labArea" name="labArea" label="实验室主任专业领域" placeholder="实验室主任专业领域" />
            <van-field
              readonly
              clickable
              name="calendar"
              :value="form.labJobtime"
              label="实验室主任任职时间"
              placeholder="点击选择"
              @click="changeCreate('labJobtime')"
            />
            <van-field v-model="form.labPosition" name="labPosition" label="实验室主任依托专业职务" placeholder="实验室主任依托专业职务" />
            <van-field v-model="form.committeeName" name="committeeName" label="学术委员会主任姓名" placeholder="学术委员会主任姓名" />
            <van-field
              readonly
              clickable
              name="calendar"
              :value="form.committeeCardtime"
              label="学术委员会主任出生年月"
              placeholder="点击选择"
              @click="changeCreate('committeeCardtime')"
            />
            <van-field v-model="form.assistantJob" name="assistantJob" label="学术委员会主任职称" placeholder="学术委员会主任职称" />
            <van-field v-model="form.committeeArea" name="committeeArea" label="学术委员会主任专业领域" placeholder="学术委员会主任专业领域" />
            <van-field
              readonly
              clickable
              name="calendar"
              :value="form.committeeJobtime"
              label="学术委员会主任任职时间"
              placeholder="点击选择"
              @click="changeCreate('committeeJobtime')"
            />
            <van-field v-model="form.committeePosition" name="committeePosition" label="学术委员会主任依托专业职务" placeholder="学术委员会主任依托专业职务" />
            <van-field v-model="form.assistantName" name="assistantName" label="科研助理姓名" placeholder="科研助理姓名" />
            <van-field
              readonly
              clickable
              name="calendar"
              :value="form.assistantCardtime"
              label="科研助理出生年月"
              placeholder="点击选择"
              @click="changeCreate('assistantCardtime')"
            />
            <van-field v-model="form.assistantJob" name="assistantJob" label="科研助理职称" placeholder="科研助理职称" />
            <van-field v-model="form.assistantArea" name="assistantArea" label="科研助理专业领域" placeholder="科研助理专业领域" />
            <van-field
              readonly
              clickable
              name="calendar"
              :value="form.assistantJobtime"
              label="科研助理任职时间"
              placeholder="点击选择"
              @click="changeCreate('assistantJobtime')"
            />
            <van-field v-model="form.assistantPosition" name="assistantPosition" label="科研助理所在单位职务" placeholder="科研助理所在单位职务" />
            <van-calendar v-model="oneShow" @confirm="oneChange" position="right" :min-date="minDate" :max-date="maxDate" />
            <div class="btn">
              <van-button type="info" size="small" @click="reseat">重置条件</van-button>
              <van-button type="primary" size="small" @click="onSubmit">提交查询</van-button>
            </div>
          </van-form>
        </van-col>
      </van-col>
    </van-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
const moment = require('moment');
export default {
  name: 'search-1',
  props: { form: { type: Object } },
  components: {},
  data: function () {
    return {
      // 选择申请日
      oneShow: false,
      minDate: new Date(1900, 1, 1),
      maxDate: new Date(2050, 1, 1),
      type: '',
    };
  },
  created() {},
  methods: {
    reseat() {
      this.$emit('reseat');
    },
    onSubmit() {
      this.$emit('onSubmit', { data: this.form });
    },
    changeCreate(type) {
      this.$set(this, `type`, type);
      this.oneShow = true;
    },
    // 日期
    oneChange(value) {
      this.$set(this.form, this.type, moment(value).format('YYYY-MM-DD'));
      this.oneShow = false;
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .one {
    .btn {
      text-align: center;
      margin: 10px 0;
      .van-button {
        margin: 0 5px;
      }
    }
  }
}
</style>
