<template>
  <div id="loginMain">
    <el-row class="loginMains">
      <el-col :span="6"><p>&nbsp;</p></el-col>
      <el-col :span="12">
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="登录" name="first">
            <el-col :span="24">
              <el-form ref="form" :model="form" label-width="80px">
                <!-- <el-form-item label="用户类别">
                  <el-radio v-model="form.role" label="1">管理员</el-radio>
                  <el-radio v-model="form.role" label="2">个人</el-radio>
                  <el-radio v-model="form.role" label="3">企业管理员</el-radio>
                </el-form-item> -->
                <el-form-item label="手机号">
                  <el-input v-model="form.phone" placeholder="请输入手机号" :minlength="11" :maxlength="11"></el-input>
                </el-form-item>
                <el-form-item label="登录密码">
                  <el-input v-model="form.passwd" placeholder="请输入登录密码" show-password></el-input>
                </el-form-item>
                <el-form-item label="用户类别">
                  <el-radio v-model="form.role" label="1">管理员</el-radio>
                  <el-radio v-model="form.role" label="4">合作机构&业务管理员</el-radio>
                </el-form-item>
                <el-col :span="24" class="loginSubmit"><el-button type="primary" @click="loginSubmit">登录</el-button></el-col>
              </el-form>
            </el-col>
          </el-tab-pane>
          <el-tab-pane label="注册" name="second" style="display:none;">
            <el-col :span="24">
              <el-form ref="forms" :model="forms" label-width="120px">
                <el-form-item label="用户名称">
                  <el-input v-model="forms.name" placeholder="请输入用户名称"></el-input>
                </el-form-item>
                <el-form-item label="登录密码">
                  <el-input v-model="forms.password" placeholder="请输入登录密码" show-password></el-input>
                </el-form-item>
                <el-form-item label="身份证号">
                  <el-input v-model="forms.cardnumber" placeholder="请输入身份证号" :minlength="18" :maxlength="18"></el-input>
                </el-form-item>
                <el-form-item label="手机号">
                  <el-input v-model="forms.phone" placeholder="请输入手机号" :minlength="11" :maxlength="11"></el-input>
                </el-form-item>
                <el-form-item label="邮箱">
                  <el-input v-model="forms.email" placeholder="请输入邮箱"></el-input>
                </el-form-item>
                <el-form-item label="地址">
                  <el-input v-model="forms.addr" placeholder="请输入地址"></el-input>
                </el-form-item>
                <el-form-item label="头像图片" prop="img_path">
                  <upload :limit="1" :data="forms.img_path" type="img_path" :url="'/files/imgpath/upload'" @upload="uploadSuccess"></upload>
                </el-form-item>
                <el-form-item label="用户类别">
                  <!-- <el-radio v-model="forms.role" label="1">管理员</el-radio> -->
                  <el-radio-group v-model="forms.role" @change="setIsQy">
                    <el-radio label="2">个人</el-radio>
                    <el-radio label="3">企业管理员</el-radio>
                  </el-radio-group>
                </el-form-item>
                <!-- <el-form-item label="个人/法人">
                  <el-radio v-model="forms.is_qy" label="0">个人</el-radio>
                  <el-radio v-model="forms.is_qy" label="1">法人</el-radio>
                </el-form-item> -->
                <el-form-item label="身份证正面">
                  <upload :limit="1" :data="forms.cardfile_a" type="cardfile_a" :url="'/files/cardfilea/upload'" @upload="uploadSuccess"></upload>
                </el-form-item>
                <el-form-item label="身份证背面">
                  <upload :limit="1" :data="forms.cardfile_b" type="cardfile_b" :url="'/files/cardfileb/upload'" @upload="uploadSuccess"></upload>
                </el-form-item>
                <el-form-item label="组织机构图片" v-if="forms.role == '3'">
                  <upload :limit="1" :data="forms.img_qy" type="img_qy" :url="'/files/imgqy/upload'" @upload="uploadSuccess"></upload>
                </el-form-item>
                <el-form-item label="简介" placeholder="请输入简介">
                  <el-input type="textarea" v-model="forms.resume"></el-input>
                </el-form-item>
                <el-form-item label="专业领域" placeholder="请输入专业领域">
                  <el-input v-model="forms.major"></el-input>
                </el-form-item>
                <template v-if="forms.role == '3'">
                  <el-form-item label="机构类型" placeholder="请输入机构类型">
                    <el-input v-model="forms.institution_type"></el-input>
                  </el-form-item>
                  <el-form-item label="机构名称" placeholder="请输入机构名称">
                    <el-input v-model="forms.institution_name"></el-input>
                  </el-form-item>
                  <el-form-item label="机构代码" placeholder="请输入机构代码">
                    <el-input v-model="forms.institution_code"></el-input>
                  </el-form-item>
                  <el-form-item label="机构性质" placeholder="请输入机构性质">
                    <el-input v-model="forms.institution_nature"></el-input>
                  </el-form-item>
                </template>
                <el-form-item label="办公电话" placeholder="请输入办公电话">
                  <el-input v-model="forms.office_phone"></el-input>
                </el-form-item>
                <el-form-item label="所属行业" placeholder="请输入所属行业">
                  <el-input v-model="forms.profession"></el-input>
                </el-form-item>
                <el-col :span="24" class="loginSubmit"><el-button type="primary" @click="registerSubmit">注册</el-button></el-col>
              </el-form>
            </el-col>
          </el-tab-pane>
        </el-tabs>
      </el-col>
      <el-col :span="6"><p>&nbsp;</p></el-col>
    </el-row>
  </div>
</template>

<script>
import upload from '@/components/upload.vue';
export default {
  name: 'loginMain',
  props: {
    form: null,
    forms: null,
  },
  components: {
    upload,
  },
  data: () => ({
    activeName: 'first',
  }),
  created() {},
  computed: {},
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    loginSubmit() {
      this.$emit('submitDate', this.form);
    },
    registerSubmit() {
      this.$emit('submitDates', { data: this.forms, id: this.forms.id });
    },
    uploadSuccess({ type, data }) {
      this.$set(this.forms, `${type}`, data.uri);
    },
    setIsQy(data) {
      let val = '0';
      data == '2' ? (val = '0') : (val = '1');
      this.$set(this.forms, `is_qy`, val);
    },
  },
};
</script>

<style lang="less" scoped>
.loginMains {
  min-height: 800px;
  padding: 40px 0;
  background-color: #fff;
}
/deep/.el-tabs__header {
  margin: 0;
}
/deep/.el-tabs__nav-wrap::after {
  background-color: transparent;
}
/deep/.el-tabs--top .el-tabs__item.is-top:nth-child(2) {
  padding-left: 136px;
}
/deep/.el-tabs--top .el-tabs__item.is-top:last-child {
  padding-right: 50px;
  display: none;
}
/deep/.el-tabs__active-bar {
  background-color: transparent;
}
/deep/.el-tabs__nav {
  margin: 0 130px;
}
/deep/.el-tabs__item {
  padding: 0 60px;
  height: 70px;
  line-height: 70px;
  font-size: 30px;
}
.loginSubmit {
  text-align: center;
}
</style>
