<template>
  <div id="register-2">
    <van-row>
      <van-col span="24" class="main">
        <van-form @submit="onSubmit" label-width="5em">
          <van-field v-model="form.institution_code" name="institution_code" label="统一社会信用代码" />
          <van-field v-model="form.companytype" name="companytype" label="注册类型" />
          <van-field readonly clickable name="calendar" :value="form.companydate" label="注册时间" placeholder="点击选择日期" @click="showCalendar = true" />
          <van-calendar v-model="showCalendar" @confirm="onConfirm" />
          <van-field v-model="form.companycapital" name="companycapital" label="注册资金" />
          <van-field v-model="form.companyperson" name="companyperson" label="企业法人" />
          <van-field v-model="form.sndqyzsr" name="sndqyzsr" label="企业总收入" />
          <van-field v-model="form.sndyffy" name="sndyffy" label="研发费用" />
          <van-field v-model="form.companytotal" name="companytotal" label="企业总人数" />
          <van-field v-model="form.zjzyfrs" name="zjzyfrs" label="研发人数" />
          <van-field v-model="form.companybrief" name="companybrief" label="企业简介" rows="1" autosize type="textarea" />
          <van-field v-model="form.mainproduct" name="mainproduct" label="主要产品" rows="1" autosize type="textarea" />
          <van-field v-model="form.qualifications" name="qualifications" label="资质&荣誉" rows="1" autosize type="textarea" />
          <div class="btn">
            <van-button round type="danger" size="normal" @click="reseat">取消注册</van-button>
            <van-button round type="info" size="normal" @click="up">上一步</van-button>
            <van-button round type="primary" size="normal" native-type="submit">提交注册</van-button>
          </div>
        </van-form>
      </van-col>
    </van-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
const _ = require('lodash');
const moment = require('moment');
export default {
  name: 'register-2',
  props: {
    form: { type: Object },
  },
  components: {},
  data: function () {
    return {
      showCalendar: false,
    };
  },
  created() {},
  methods: {
    // 取消注册
    reseat() {
      this.$emit('reseat');
    },
    onSubmit(values) {
      this.$emit('onSubmit', values);
    },
    // 上一步
    up() {
      this.$emit('up');
    },
    // 选择注册时间
    onConfirm(value) {
      this.$set(this.form, `companydate`, moment(value).format('YYYY-MM-DD'));
      this.showCalendar = 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 {
  .btn {
    margin: 16px;
    text-align: center;
    .van-button {
      margin: 0 10px;
    }
  }
}
</style>
