<template>
  <div id="loginMain">
    <el-row class="loginMains">
      <el-col :span="24" class="top">
        <el-col :span="6" class="info"> </el-col>
        <el-col :span="12" class="context">
          <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-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-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">
              <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.phone" placeholder="请输入手机号" :minlength="11" :maxlength="11"></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.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-group v-model="forms.role">
                      <el-radio label="2">个人</el-radio>
                      <el-radio label="3">企业管理员</el-radio>
                      <el-radio label="6">专家</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="身份证正面" v-if="forms.role == '2' || forms.role == '3'">
                    <upload :limit="1" :data="forms.cardfile_a" type="cardfile_a" :url="'/files/cardfilea/upload'" @upload="uploadSuccess"></upload>
                  </el-form-item>
                  <el-form-item label="身份证背面" v-if="forms.role == '2' || forms.role == '3'">
                    <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>
                  <template v-if="forms.role == '3'">
                    <el-form-item label="机构类型">
                      <el-input v-model="forms.institution_type" placeholder="请输入机构类型"></el-input>
                    </el-form-item>
                    <el-form-item label="机构名称">
                      <el-input v-model="forms.institution_name" placeholder="请输入机构名称"></el-input>
                    </el-form-item>
                    <el-form-item label="机构代码">
                      <el-input v-model="forms.institution_code" placeholder="请输入机构代码"></el-input>
                    </el-form-item>
                    <el-form-item label="机构性质">
                      <el-input v-model="forms.institution_nature" placeholder="请输入机构性质"></el-input>
                    </el-form-item>
                  </template>
                  <el-form-item label="办公电话" v-if="forms.role == '2' || forms.role == '3'">
                    <el-input v-model="forms.office_phone" placeholder="请输入办公电话"></el-input>
                  </el-form-item>
                  <el-form-item label="所属行业" v-if="forms.role == '2' || forms.role == '3'">
                    <el-input v-model="forms.profession" placeholder="请输入所属行业"></el-input>
                  </el-form-item>
                  <el-form-item label="性别" v-if="forms.role == '6'">
                    <el-select v-model="forms.gender" placeholder="请选择民性别">
                      <el-option v-for="(item, index) in gender_list" :key="index" :label="item.name" :value="item.name"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="出生日期" v-if="forms.role == '6'">
                    <el-date-picker v-model="forms.birthday" type="date" placeholder="选择日期" value-format="yyyy-MM-dd"> </el-date-picker>
                  </el-form-item>
                  <el-form-item label="职称级别" v-if="forms.role == '6'">
                    <el-input v-model="forms.level" placeholder="请输入职称级别"></el-input>
                  </el-form-item>
                  <el-form-item label="职称" v-if="forms.role == '6'">
                    <el-input v-model="forms.levelname" placeholder="请输入职称"></el-input>
                  </el-form-item>
                  <el-form-item label="职务" v-if="forms.role == '6'">
                    <el-input v-model="forms.position" placeholder="请输入职务"></el-input>
                  </el-form-item>
                  <el-form-item label="院校" v-if="forms.role == '6'">
                    <el-input v-model="forms.school" placeholder="请输入院校"></el-input>
                  </el-form-item>
                  <el-form-item label="学历" v-if="forms.role == '6'">
                    <el-select v-model="forms.xl" placeholder="请选择学历要求">
                      <el-option v-for="(item, index) in edu_list" :key="index" :label="item.name" :value="item.name"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="学位" v-if="forms.role == '6'">
                    <el-select v-model="forms.xw" placeholder="请选择学位">
                      <el-option v-for="(item, index) in degree_list" :key="index" :label="item.name" :value="item.name"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="专业" v-if="forms.role == '6'">
                    <el-input v-model="forms.major" placeholder="请输入专业"></el-input>
                  </el-form-item>
                  <el-form-item label="从事专业" v-if="forms.role == '6'">
                    <el-input v-model="forms.professional" placeholder="请输入从事专业"></el-input>
                  </el-form-item>
                  <el-form-item label="个人简历" v-if="forms.role == '2' || forms.role == '6'">
                    <el-input type="textarea" v-model="forms.resume" placeholder="请输入个人简介"></el-input>
                  </el-form-item>
                  <el-form-item label="项目" v-if="forms.role == '6'">
                    <el-input v-model="forms.project" placeholder="请输入项目"></el-input>
                  </el-form-item>
                  <el-form-item label="学术成就" v-if="forms.role == '6'">
                    <el-input v-model="forms.academic" placeholder="请输入学术成就"></el-input>
                  </el-form-item>
                  <el-form-item label="论文" v-if="forms.role == '6'">
                    <el-input v-model="forms.paper" placeholder="请输入论文"></el-input>
                  </el-form-item>
                  <el-form-item label="备注" v-if="forms.role == '6'">
                    <el-input v-model="forms.remark" placeholder="请输入备注"></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" class="info"></el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import upload from '@/components/uploadone.vue';
export default {
  name: 'loginMain',
  props: {
    form: null,
    forms: null,
  },
  components: {
    upload,
  },
  data: () => ({
    activeName: 'first',
    // 性别
    gender_list: [
      {
        name: '男',
      },
      {
        name: '女',
      },
    ],
    // 学历
    edu_list: [
      {
        name: '中专及以上',
      },
      {
        name: '大专及以上',
      },
      {
        name: '本科及以上',
      },
      {
        name: '研究生及以上',
      },
    ],
    // 学位
    degree_list: [
      {
        name: '学士',
      },
      {
        name: '学士',
      },
      {
        name: '博士',
      },
      {
        name: '其他',
      },
    ],
  }),
  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);
    },
  },
};
</script>

<style lang="less" scoped>
.loginMains {
  min-height: 800px;
  padding: 10px 0;
  background-color: #fff;
}
.top {
  width: 100%;
  padding: 20px;
  overflow: hidden;
  box-shadow: 0 0 10px #2d64b3;
  background: #ffffff;
}
.info {
  width: 25%;
  height: 800px;
}
.context {
  width: 50%;
}
/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: 50px;
}
/deep/.el-tabs--top .el-tabs__item.is-top:last-child {
  padding-right: 50px;
}
/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>
