<template>
  <el-form
    ref="form"
    :model="value"
    :rules="rules"
    :label-width="labelWidth + 'px'"
  >
    <div class="form_title" v-if="showTitle">基本信息</div>

    <el-row>
      <el-col :span="24">
        <el-form-item label="姓名:" prop="name">
          <el-input
            v-model="value.name"
            :disabled="isAdd ? false : true"
          ></el-input>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <el-form-item label="手机号:" prop="mobile">
          <el-input
            v-model="value.mobile"
            :disabled="isAdd ? false : true"
          ></el-input>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <el-form-item label="身份证号:" prop="id_card">
          <el-input
            v-model="value.id_card"
            :disabled="isAdd ? false : true"
          ></el-input>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <el-form-item label="工作所在地:" prop="work_place">
          <el-input v-model="value.work_place" />
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <el-form-item label="工作经历:" prop="work_experience">
          <el-input
            v-model="value.work_experience"
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 6 }"
          />
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <el-form-item label="所属站点:" prop="tenant_id">
          <SiteOptions :size="''" :limitWidth="false" v-model="value" />
        </el-form-item>
      </el-col>
    </el-row>

    <!-- <FieldOptions v-model="value" :labelWidth="labelWidth" ref="fieldForm" /> -->

    <InputBoxAdd
      :labelWidth="labelWidth"
      v-model="value"
      title="擅长领域"
      placeholder="请输入擅长领域"
      fieldKey="researchs"
      ref="researchsForm"
    />

    <InputBoxAdd
      :labelWidth="labelWidth"
      v-model="value"
      title="关键词"
      placeholder="应用场景关键词+技术产品关键词"
      fieldKey="keywords"
      ref="keywordsForm"
    />

    <el-row v-if="value.id_image">
      <el-col :span="24">
        <el-form-item label="身份证:" required>
          <el-row :gutter="20" type="flex" justify="space-between">
            <el-col :span="8">
              <el-form-item prop="id_image.front">
                <ImageUpload
                  v-model="value.id_image.front"
                  :isShowTip="false"
                  :limit="1"
                />
              </el-form-item>
              <div style="text-align: center">身份证人像面</div>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="id_image.behind">
                <ImageUpload
                  v-model="value.id_image.behind"
                  :isShowTip="false"
                  :limit="1"
                />
              </el-form-item>
              <div style="text-align: center">身份证国徽面</div>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="id_image.hold">
                <ImageUpload
                  v-model="value.id_image.hold"
                  :isShowTip="false"
                  :limit="1"
                />
              </el-form-item>
              <div style="text-align: center">手持身份证人像面</div>
            </el-col>
          </el-row>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <el-form-item label="成果经纪资格证书:" prop="credential_image">
          <el-row :gutter="20" type="flex" justify="space-between">
            <el-col :span="8">
              <ImageUpload
                v-model="value.credential_image"
                :isShowTip="false"
                :limit="1"
              />
            </el-col>
          </el-row>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>
<script>
import CityOptions from "@/views/components/CityOptions";
import FieldOptions from "@/views/components/FieldOptions";
import InputBoxAdd from "@/views/components/InputBoxAdd";
import { researchSelect } from "@/api/dataList/research";
import { laboratorySelect } from "@/api/dataList/laboratory";
export default {
  components: {
    CityOptions,
    FieldOptions,
    InputBoxAdd,
  },
  props: {
    value: Object,
    isAdd: {
      type: Boolean,
      default: true,
    },
    showTitle: {
      type: Boolean,
      default: false,
    },
    formType: {
      type: Number,
      default: 1,
    },
    labelWidth: {
      type: Number,
      default: 120,
    },
  },
  data() {
    return {
      researchOptions: [],
      rules: {
        name: [{ required: true, message: "请输入", trigger: "blur" }],
        mobile: [
          { required: true, message: "请输入", trigger: "blur" },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur",
          },
        ],
        id_card: [{ required: true, message: "请输入", trigger: "blur" }],
        work_place: [{ required: true, message: "请输入", trigger: "blur" }],
        work_experience: [
          { required: true, message: "请输入", trigger: "blur" },
        ],
        tenant_id: [
          {
            required: true,
            message: "请选择",
            trigger: ["blur", "change"],
          },
        ],
        "id_image.front": [
          {
            required: true,
            message: "请上传",
            trigger: ["blur", "change"],
          },
        ],
        "id_image.behind": [
          {
            required: true,
            message: "请上传",
            trigger: ["blur", "change"],
          },
        ],
        "id_image.hold": [
          {
            required: true,
            message: "请上传",
            trigger: ["blur", "change"],
          },
        ],
      },
    };
  },
  methods: {
    submitForm() {
      let flag = false;
      this.$refs["form"].validate((valid) => {
        const keywordsForm = this.$refs.keywordsForm.submitForm(); // 关键词
        const researchsForm = this.$refs.researchsForm.submitForm(); // 研究方向
        if (valid && keywordsForm && researchsForm) {
          flag = !flag;
        }
      });
      return flag;
    },
  },
};
</script>
<style lang="scss" scoped>
.form_title {
  font-weight: 700;
  margin-bottom: 30px;
}
::v-deep .el-upload--picture-card {
  width: 100%;
}
::v-deep .hide {
  height: 148px;
}
::v-deep .el-upload-list--picture-card .el-upload-list__item {
  width: 100%;
}
// 上传图片框限制
// ::v-deep .el-upload--picture-card {
//   width: 120px;
//   height: 120px;
//   line-height: 120px;
// }
.el-select,
.el-date-editor {
  display: block;
  width: 100%;
}
</style>