<template>
  <div id="person">
    <el-col :span="24" class="info">
      <van-form @submit="onSubmit">
        <van-field
          v-model="form.title"
          name="对接会标题"
          label="对接会标题"
          placeholder="请输入对接会标题"
          :rules="[{ required: true, message: '请输入对接会标题' }]"
        />

        <van-cell title="开始时间" is-link :value="form.start_time" @click="birthdayPopup" />
        <van-popup v-model="birthdayShow" position="bottom">
          <van-datetime-picker type="date" @cancel="birthdayShow = false" @confirm="birthdayPicker" />
        </van-popup>

        <van-cell title="截止时间" is-link :value="form.join_end" @click="birthdayPopups" />
        <van-popup v-model="newShow" position="bottom">
          <van-datetime-picker type="date" @cancel="newShow = false" @confirm="birthdayPickers" />
        </van-popup>
      </van-form>

      <el-form ref="form" :model="form" label-width="58px">
        <el-form-item label="省份">
          <el-select v-model="form.province" placeholder="请选择省份" @change="changeshenge">
            <el-option v-for="item in option" :key="item.code" :label="item.name" :value="item.code"> </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="市">
          <el-select v-model="form.place" placeholder="请选择市">
            <el-option v-for="item in options" :key="item.code" :label="item.name" :value="item.code"> </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="简介">
          <el-input type="textarea" v-model="form.desc"></el-input>
        </el-form-item>

        <el-form-item label="对接会视频">
          <upload :limit="1" :data="form.file_path" type="file_path" listType="" :url="'/files/imgpath/upload'" @upload="uploadSuccess"></upload>
        </el-form-item>
      </el-form>
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit" @click="onSubmit">
          保存
        </van-button>
      </div>
    </el-col>
  </div>
</template>

<script>
import upload from '@/components/upload.vue';
export default {
  name: 'person',
  props: {
    form: null,
    option: null,
    options: null,
  },
  components: {
    upload,
  },
  data: () => ({
    // 出生日期
    birthday: '',
    birthdayShow: false,
    newShow: false,
    // 学历
    xlPicker: false,
    xlList: ['中专及以上', '大专及以上', '本科及以上', '研究生及以上'],
    // 学位
    xwPicker: false,
    xwList: ['学士', '硕士', '博士', '其他'],
  }),
  created() {},
  computed: {
    id() {
      return this.$route.query.id;
    },
  },
  methods: {
    // 出生日期
    birthdayPopup() {
      this.birthdayShow = true;
    },

    birthdayPopups() {
      this.newShow = true;
    },
    // 确认选择之后的时间
    birthdayPicker(val) {
      let year = val.getFullYear();
      let month = val.getMonth() + 1;
      let day = val.getDate();
      let birthday = `${year}-${month}-${day}`;
      this.$set(this.form, `start_time`, birthday);
      this.birthdayShow = false;
    },
    birthdayPickers(val) {
      let year = val.getFullYear();
      let month = val.getMonth() + 1;
      let day = val.getDate();
      let birthday = `${year}-${month}-${day}`;
      this.$set(this.form, `join_end`, birthday);
      this.newShow = false;
    },

    changeshenge(value) {
      this.$emit('placesubmit', { value });
    },
    onSubmit() {
      console.log(this.form);

      this.$emit('onSubmit', { data: this.form });
    },
    // 图片上传
    uploadSuccess({ type, data }) {
      console.log(type, data);
      this.$set(this.form, `${type}`, data.uri);
    },
  },
};
</script>

<style lang="less" scoped>
.info {
  margin: 0 0 50px 0;
}
</style>
