<template>
  <Dialog
    class="OutwardRegistrationBak"
    v-model="dialogVisible"
    :scroll="true"
    max-height="71vh"

    style="max-width: 100vw;min-width: 70vw"
    :title="dialogTitle">


    <el-form ref="formRef" v-loading="formLoading" :model="dataForm" :rules="formRules"  :label-width="labelWidth" style="margin-top: 15px;">
      <div class="info-title"> 基本信息 </div>

      <div class="info-wrap">
        <el-row>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="员工姓名" prop="nickname">
              <el-input v-model="dataForm.nickname" show-word-limit :maxlength="20"/>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="员工编号" prop="userNumber">
              <el-input v-model="dataForm.userNumber" show-word-limit :maxlength="20"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row >
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="手机号码" prop="mobile">
              <el-input v-model="dataForm.mobile" maxlength="11" show-word-limit placeholder="请输入手机号码" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="电子邮箱" prop="email">
              <el-input v-model="dataForm.email" maxlength="50" show-word-limit placeholder="请输入邮箱" />
            </el-form-item>
          </el-col>
        </el-row>

<!--          <el-row >-->
<!--            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">-->
<!--              <el-form-item v-if="dataForm.id === undefined" label="登录账号" prop="username">-->
<!--                <el-input v-model="dataForm.username" placeholder="请输入登录账号" maxlength="30" />-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">-->
<!--              <el-form-item v-if="dataForm.id === undefined" label="登录密码" prop="password">-->
<!--                <el-input v-model="dataForm.password" placeholder="请输入登录密码" maxlength="30" show-password type="password"/>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--          </el-row>-->

          <el-row >
            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
              <el-form-item label="证件类型" prop="idType">
                <TgSelect
                  v-model="dataForm.idType"
                  placeholder="请选择"
                  clearable
                  :list="getDictOptions(DICT_TYPE.PAPERS_TYPE)"
                >
                  <el-option
                    v-for="(item, index) in getStrDictOptions(DICT_TYPE.PAPERS_TYPE)"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                  />
                </TgSelect>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
              <el-form-item label="证件号码" prop="idNumber">
                <el-input maxlength="18" @change="changeCardID" show-word-limit v-model="dataForm.idNumber"/>
              </el-form-item>
            </el-col>
          </el-row>

              <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="员工性别" prop="sex">
<!--                    <el-radio-group v-model="dataForm.sex" style="width: 100%;">-->
                        <div style="display: flex;flex-direction: row;align-items: center;width: 100%;">
                          <div :class="{sexLeft1:dataForm.sex==1,sexLeft2:dataForm.sex==2}" @click="ckSex(1)" :style="{backgroundColor:dataForm.sex==1?systemTheme:'#fff',cursor: 'pointer'}">
                            {{sexStr()[0].label}}
                          </div>
                          <div :class="{sexRight1:dataForm.sex==2,sexRight2:dataForm.sex==1}" @click="ckSex(2)" :style="{backgroundColor:dataForm.sex==2?systemTheme:'#fff',cursor: 'pointer'}">
                            {{sexStr()[1].label}}
                          </div>
<!--                          <el-radio-button    :value="parseInt(sexStr()[0].value)" size="default" >{{sexStr()[0].label}}</el-radio-button>-->
<!--                          <el-radio-button   :value="parseInt(sexStr()[1].value)" size="default" >{{sexStr()[1].label}}</el-radio-button>-->
                        </div>



<!--                    </el-radio-group>-->
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="出生日期" prop="birthday">
                    <el-date-picker
                      v-model="dataForm.birthday"
                      type="date"
                      :disabled="dataForm.dBirthday"
                      :editable="false"
                      value-format="YYYY-MM-DD"
                      placeholder="请选择日期"
                      :style="{ width: '100%' }"
                    />
                  </el-form-item>
                </el-col>

              </el-row>


              <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="民族" prop="nation">
                    <TgSelect
                      v-model="dataForm.nation"
                      placeholder="请选择"
                      clearable
                      :list="getDictOptions(DICT_TYPE.NATION_ARR)"
                    >
                      <el-option
                        v-for="(item, index) in getStrDictOptions(DICT_TYPE.NATION_ARR)"
                        :key="index"
                        :label="item.label"
                        :value="item.value"
                      />
                    </TgSelect>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="籍贯" prop="nativePlace">
                    <el-input
                      v-model="dataForm.nativePlace"
                      placeholder="请输入籍贯"
                      :maxlength="18"
                      :show-word-limit="true"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                  <el-form-item label="居住地址" prop="residentialAddress">
                    <el-input
                      v-model="dataForm.residentialAddress"
                      placeholder="请输入居住地址"
                      :maxlength="1000"
                      :show-word-limit="true"
                      type="textarea"
                      rows="3"
                    />
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="政治面貌" prop="isPartyMember">
                    <TgSelect
                      v-model="dataForm.isPartyMember"
                      placeholder="请选择"
                      clearable
                      :list="getDictOptions(DICT_TYPE.POLITICAL_ARR)"
                    >
                      <el-option
                        v-for="(item, index) in getStrDictOptions(DICT_TYPE.POLITICAL_ARR)"
                        :key="index"
                        :label="item.label"
                        :value="item.value"
                      />
                    </TgSelect>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="婚姻状况" prop="maritalStatus">
                    <TgSelect
                      v-model="dataForm.maritalStatus"
                      placeholder="请选择"
                      clearable
                      :list="getDictOptions(DICT_TYPE.MARITAL_STATUS_ARR)"
                    >
                      <el-option
                        v-for="(item, index) in getStrDictOptions(DICT_TYPE.MARITAL_STATUS_ARR)"
                        :key="index"
                        :label="item.label"
                        :value="item.value"
                      />
                    </TgSelect>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="最高学历" prop="highestDegree">
                    <TgSelect
                      v-model="dataForm.highestDegree"
                      placeholder="请选择"
                      clearable
                      :list="getDictOptions(DICT_TYPE.EDUCATION_BACKGROUND)"
                    >
                      <el-option
                        v-for="(item, index) in getIntDictOptions(DICT_TYPE.EDUCATION_BACKGROUND)"
                        :key="index"
                        :label="item.label"
                        :value="item.value.toString()"
                      />
                    </TgSelect>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="毕业院校" prop="graduateSchool">
                    <el-input :maxlength="225" show-word-limit v-model="dataForm.graduateSchool"/>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="专业" prop="major">
                    <el-input v-model="dataForm.major" show-word-limit :maxlength="255"/>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="毕业年份" prop="graduationYear">
                    <el-date-picker
                      v-model="dataForm.graduationYear"
                      type="year"
                      :editable="false"
                      value-format="YYYY"
                      placeholder="请选择年份"
                      :style="{ width: '100%' }"
                    />
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="护理等级证书" prop="isHaveNursingLevelCertificate">
                    <TgSelect
                      v-model="dataForm.isHaveNursingLevelCertificate"
                      placeholder="是否有护理等级证书"
                      clearable
                      :list="getDictOptions(DICT_TYPE.COMMON_STATUS6)"
                    >
                      <el-option
                        v-for="(item, index) in getIntDictOptions(DICT_TYPE.COMMON_STATUS6)"
                        :key="index"
                        :label="item.label"
                        :value="item.value.toString()"
                      />
                    </TgSelect>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="工作状态" prop="workStatus">
                    <TgSelect
                      v-model="dataForm.workStatus"
                      clearable
                      :list="getDictOptions(DICT_TYPE.WORK_STATUS)"
                    >
                      <el-option
                        v-for="(item, index) in getIntDictOptions(DICT_TYPE.WORK_STATUS)"
                        :key="index"
                        :label="item.label"
                        :value="item.value"
                      />
                    </TgSelect>
                  </el-form-item>
                </el-col>
<!--                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">-->
<!--                  <el-form-item label="缴纳社保" prop="idCard">-->
<!--                    <TgSelect-->
<!--                      v-model="dataForm.degreeEducation"-->
<!--                      placeholder="是否缴纳社保"-->
<!--                      clearable-->
<!--                      :list="getDictOptions(DICT_TYPE.COMMON_STATUS6)"-->
<!--                    >-->
<!--                      <el-option-->
<!--                        v-for="(item, index) in getIntDictOptions(DICT_TYPE.COMMON_STATUS6)"-->
<!--                        :key="index"-->
<!--                        :label="item.label"-->
<!--                        :value="item.value"-->
<!--                      />-->
<!--                    </TgSelect>-->
<!--                  </el-form-item>-->
<!--                </el-col>-->
                <!-- <el-col>
                  <el-form-item label="是否启用企业端登录" prop="isEnableEnterpriseLogin">
                    <TgSelect
                      v-model="dataForm.isEnableEnterpriseLogin"
                      clearable
                      :list="getDictOptions(DICT_TYPE.COMMON_STATUS6)"
                    >
                      <el-option
                        v-for="(item, index) in getIntDictOptions(DICT_TYPE.COMMON_STATUS6)"
                        :key="index"
                        :label="item.label"
                        :value="item.value"
                      />
                    </TgSelect>
                  </el-form-item>
                </el-col> -->
              </el-row>
            </div>

            <div class="info-title"> 人事信息 </div>

            <div class="info-wrap">
              <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="部门名称" prop="deptId">
                    <el-tree-select
                      v-model="dataForm.deptId"
                      :data="deptList"
                      :props="defaultProps"
                      check-strictly
                      node-key="id"
                      placeholder="请选择归属部门"
                    />
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                  <el-form-item label="职务" prop="job">
                    <el-input maxlength="50" show-word-limit v-model="dataForm.job"/>
                  </el-form-item>
                </el-col>
              </el-row>
          <el-row align="top">
            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
              <el-form-item label="员工类型" prop="userType">
              <TgSelect
                  v-model="dataForm.userType"
                  placeholder="请选择"
                  clearable
                  :list="getDictOptions(DICT_TYPE.EMPLOYEE_TYPE)"
                >
                  <el-option
                    v-for="(item, index) in getIntDictOptions(DICT_TYPE.EMPLOYEE_TYPE)"
                    :key="index"
                    :label="item.label"
                    :value="item.value.toString()"
                  />
              </TgSelect>
            </el-form-item>
          </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
              <el-form-item v-if="getDictObj(DICT_TYPE.EMPLOYEE_TYPE,dataForm.userType)?.label==='护理人员'" label="护理等级" prop="nursingStaffLevel">
                <TgSelect
                  v-model="dataForm.nursingStaffLevel"
                  placeholder="请选择"
                  clearable
                  :list="getDictOptions(DICT_TYPE.GRADE_OF_CARE)"
                >
                  <el-option
                    v-for="(item, index) in getIntDictOptions(DICT_TYPE.GRADE_OF_CARE)"
                    :key="index"
                    :label="item.label"
                    :value="item.value.toString()"
                  />
                </TgSelect>
              </el-form-item>
            </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="入职日期" prop="joinedDate">
              <el-date-picker
                v-model="dataForm.joinedDate"
                type="date"
                :editable="false"
                value-format="YYYY-MM-DD"
                placeholder="请选择日期"
                :style="{ width: '100%' }"
              />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="试用期(月)" prop="trialPeriod">
              <el-input v-model="dataForm.trialPeriod" placeholder="请输入" :maxlength="12" type="number" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="试用期工资(元)" prop="probationarySalary">
              <el-input v-model="dataForm.probationarySalary" placeholder="请输入" type="number" :maxlength="12"  >
                <template #append>¥</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="转正工资(元)" prop="regularSalary">
              <el-input v-model="dataForm.regularSalary" placeholder="请输入"  type="number" :maxlength="12"  >
                <template #append>¥</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="岗位类型" prop="postIds">
              <el-select
                v-model="dataForm.postIds"
                collapse-tags
                collapse-tags-tooltip
                :max-collapse-tags="3"
                multiple
                placeholder="请选择">
                <el-option
                  v-for="item in postList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id!"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="是否缴纳社保" prop="isPaySocialSecurity">
              <TgSelect
                  v-model="dataForm.isPaySocialSecurity"
                  placeholder="是否缴纳社保"
                  clearable
                  :list="getDictOptions(DICT_TYPE.COMMON_STATUS6)"
                >
                  <el-option
                    v-for="(item, index) in getIntDictOptions(DICT_TYPE.COMMON_STATUS6)"
                    :key="index"
                    :label="item.label"
                    :value="item.value.toString()"
                  />
                </TgSelect>
            </el-form-item>
          </el-col>
        </el-row>
      </div>

<!-- -----------------------------------     教育背景-->

      <div style="display: flex;align-items: center;flex-direction: row">
        <div class="info-title" style="width: 140px;"> 教育背景 </div>
        <div style="flex-grow: 1"></div>
        <el-button type="primary" plain @click="addEducation(1)" style="margin-right: 15px;">
          <Icon icon="ep:plus" class="mr-4px" />
          添加
        </el-button>
      </div>

      <el-table  style="margin-top: 12px;margin-left: 15px;" :data="dataForm.userEducations"  :header-cell-style="tableHeaderColor">

        <el-table-column header-align="center" align="center" label="序号" width="100">
          <template #default="scope">
            {{scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="elderlyName" header-align="center" align="center" label="起止日期" min-width="268">
          <template #default="scope">
            <el-date-picker
              v-model="scope.row.date"
              type="daterange"
              value-format="YYYY-MM-DD"
              style="width: 100%;"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            />
          </template>
        </el-table-column>

        <el-table-column prop="expectName" header-align="center" align="center" label="学校名称" min-width="220">
          <template #default="scope">
            <el-input v-model="scope.row.schoolName" show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="专业" min-width="220">
          <template #default="scope">
            <el-input v-model="scope.row.major" show-word-limit maxlength="25"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="学历" min-width="180">
          <template #default="scope">
            <TgSelect
              v-model="scope.row.educationalBackground"
              placeholder="请选择"
              clearable
              :list="getDictOptions(DICT_TYPE.EDUCATION_BACKGROUND)"
            >
              <el-option
                v-for="(item, index) in getIntDictOptions(DICT_TYPE.EDUCATION_BACKGROUND)"
                :key="index"
                :label="item.label"
                :value="item.value"
              />
            </TgSelect>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="是否毕业" min-width="160">
          <template #default="scope">
            <TgSelect
              v-model="scope.row.isGraduate"
              placeholder="是否毕业"
              clearable
              :list="getDictOptions(DICT_TYPE.COMMON_STATUS6)"
            >
              <el-option
                v-for="(item, index) in getIntDictOptions(DICT_TYPE.COMMON_STATUS6)"
                :key="index"
                :label="item.label"
                :value="item.value"
              />
            </TgSelect>
          </template>
        </el-table-column>

        <el-table-column label="操作" fixed="right" align="center" min-width="100">
          <template #default="scope">
            <el-button
              link
              type="danger"
              @click="deleteEducation(scope.$index,1)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>

<!-- -----------------------------------     工作经历-->

      <div style="display: flex;align-items: center;flex-direction: row;margin-top: 36px;">
        <div class="info-title" style="width: 140px;"> 工作经历 </div>
        <div style="flex-grow: 1"></div>
        <el-button type="primary" plain @click="addEducation(2)" style="margin-right: 15px;">
          <Icon icon="ep:plus" class="mr-4px" />
          添加
        </el-button>
      </div>

      <el-table  style="margin-top: 12px;margin-left: 15px;" :data="dataForm.userWorkExperiences"  :header-cell-style="tableHeaderColor">

        <el-table-column header-align="center" align="center" label="序号" width="100">
          <template #default="scope">
            {{scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="elderlyName" header-align="center" align="center" label="起止日期" min-width="268">
          <template #default="scope">
            <el-date-picker
              v-model="scope.row.date"
              type="daterange"
              value-format="YYYY-MM-DD"
              style="width: 100%;"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            />
          </template>
        </el-table-column>

        <el-table-column prop="expectName" header-align="center" align="center" label="公司名称" min-width="220">
          <template #default="scope">
            <el-input v-model="scope.row.companyName" show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="职业类型" min-width="220">
          <template #default="scope">
            <TgSelect
              v-model="scope.row.occupationType"
              placeholder="请选择"
              clearable
              :list="getDictOptions(DICT_TYPE.PROFESSION_TYPES)"
            >
              <el-option
                v-for="(item, index) in getIntDictOptions(DICT_TYPE.PROFESSION_TYPES)"
                :key="index"
                :label="item.label"
                :value="item.value.toString()"
              />
            </TgSelect>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="其他职业类型" min-width="180">
          <template #default="scope">
            <el-input v-model="scope.row.otherOccupationType" :disabled="getDictObj(DICT_TYPE.PROFESSION_TYPES,scope.row.occupationType)?.label!=='其他'" show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="职务" min-width="180">
          <template #default="scope">
            <el-input v-model="scope.row.job"  show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="薪资" min-width="180">
          <template #default="scope">
            <el-input v-model="scope.row.salary" type="number" maxlength="12">
              <template #append>
                <el-text>¥</el-text>
              </template>
            </el-input>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="离职原因" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.reasonsForLeaving"  show-word-limit maxlength="150"/>
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" align="center" min-width="100">
          <template #default="scope">
            <el-button
              link
              type="danger"
              @click="deleteEducation(scope.$index,2)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>


      <!-- -----------------------------------     工作家庭状况-->
      <div style="display: flex;align-items: center;flex-direction: row;margin-top: 36px;">
        <div class="info-title" style="width: 140px;"> 工作家庭状况 </div>
        <div style="flex-grow: 1"></div>
        <el-button type="primary" plain @click="addEducation(3)" style="margin-right: 15px;">
          <Icon icon="ep:plus" class="mr-4px" />
          添加
        </el-button>
      </div>

      <el-table  style="margin-top: 12px;margin-left: 15px;" :data="dataForm.userFamilySituations"  :header-cell-style="tableHeaderColor">

        <el-table-column header-align="center" align="center" label="序号" width="100">
          <template #default="scope">
            {{scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="elderlyName" header-align="center" align="center" label="关系" min-width="180">
          <template #default="scope">
            <TgSelect
              v-model="scope.row.relation"
              placeholder="请选择"
              clearable
              :list="getDictOptions(DICT_TYPE.RELATIONSHIP_TYPES)"
            >
              <el-option
                v-for="(item, index) in getIntDictOptions(DICT_TYPE.RELATIONSHIP_TYPES)"
                :key="index"
                :label="item.label"
                :value="item.value.toString()"
              />
            </TgSelect>
          </template>
        </el-table-column>

        <el-table-column prop="expectName" header-align="center" align="center" label="姓名" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.name" show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="年龄" min-width="180">
          <template #default="scope">
            <el-input v-model="scope.row.age" maxlength="5"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="单位名称" min-width=" 220">
          <template #default="scope">
            <el-input v-model="scope.row.organizationName" show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="职务" min-width="180">
          <template #default="scope">
            <el-input v-model="scope.row.job"  show-word-limit maxlength="25"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="联系方式" min-width="180">
          <template #default="scope">
            <el-input v-model="scope.row.contactInformation"  show-word-limit maxlength="25"/>
          </template>
        </el-table-column>

        <el-table-column label="操作" fixed="right" align="center" min-width="100">
          <template #default="scope">
            <el-button
              link
              type="danger"
              @click="deleteEducation(scope.$index,3)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>


      <!-- -----------------------------------     培训经历-->
      <div style="display: flex;align-items: center;flex-direction: row;margin-top: 36px;">
        <div class="info-title" style="width: 140px;"> 培训经历 </div>
        <div style="flex-grow: 1"></div>
        <el-button type="primary" plain @click="addEducation(4)" style="margin-right: 15px;">
          <Icon icon="ep:plus" class="mr-4px" />
          添加
        </el-button>
      </div>

      <el-table  style="margin-top: 12px;margin-left: 15px;" :data="dataForm.userTrainingExperiences"  :header-cell-style="tableHeaderColor">

        <el-table-column header-align="center" align="center" label="序号" width="100">
          <template #default="scope">
            {{scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="elderlyName" header-align="center" align="center" label="起止时间" min-width="268">
          <template #default="scope">
            <el-date-picker
              v-model="scope.row.date"
              type="daterange"
              style="width: 100%;"
              value-format="YYYY-MM-DD"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            />
          </template>
        </el-table-column>

        <el-table-column prop="expectName" header-align="center" align="center" label="培训项目" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.trainingProgram" show-word-limit maxlength="25"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="培训内容" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.trainingContent" show-word-limit maxlength="225"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="所获成就" min-width=" 200">
          <template #default="scope">
            <el-input v-model="scope.row.achievement" show-word-limit maxlength="25"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="培训机构" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.trainingOrganization"  show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="培训班" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.trainingCourse"  show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="培训补贴" min-width="200">
          <template #default="scope">
            <TgSelect
              v-model="scope.row.isSubsidy"
              placeholder="请选择"
              clearable
              :list="getDictOptions(DICT_TYPE.TRAINING_SUBSIDY)"
            >
              <el-option
                v-for="(item, index) in getIntDictOptions(DICT_TYPE.TRAINING_SUBSIDY)"
                :key="index"
                :label="item.label"
                :value="item.value.toString()"
              />
            </TgSelect>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="补贴金额" min-width="200">
          <template #default="scope">
            <el-input type="number" v-model="scope.row.subsidyAmount" :disabled="getDictObj(DICT_TYPE.TRAINING_SUBSIDY,scope.row.isSubsidy)?.label!=='享受'" show-word-limit maxlength="50"/>
          </template>
        </el-table-column>

        <el-table-column label="操作" fixed="right" align="center" min-width="100">
          <template #default="scope">
            <el-button
              link
              type="danger"
              @click="deleteEducation(scope.$index,4)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>


      <!-- -----------------------------------     奖惩记录-->
      <div style="display: flex;align-items: center;flex-direction: row;margin-top: 36px;">
        <div class="info-title" style="width: 140px;"> 奖惩记录 </div>
        <div style="flex-grow: 1"></div>
        <el-button type="primary" plain @click="addEducation(5)" style="margin-right: 15px;">
          <Icon icon="ep:plus" class="mr-4px" />
          添加
        </el-button>
      </div>

      <el-table  style="margin-top: 12px;margin-left: 15px;" :data="dataForm.userRewardsPunishments"  :header-cell-style="tableHeaderColor">

        <el-table-column header-align="center" align="center" label="序号" width="100">
          <template #default="scope">
            {{scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="elderlyName" header-align="center" align="center" label="分类" min-width="180">
          <template #default="scope">
            <TgSelect
              v-model="scope.row.type"
              placeholder="请选择"
              clearable
              :list="getDictOptions(DICT_TYPE.REWARD_MECHANISM)"
            >
              <el-option
                v-for="(item, index) in getIntDictOptions(DICT_TYPE.REWARD_MECHANISM)"
                :key="index"
                :label="item.label"
                :value="item.value.toString()"
              />
            </TgSelect>
          </template>
        </el-table-column>

        <el-table-column prop="expectName" header-align="center" align="center" label="奖惩日期" min-width="200">
          <template #default="scope">
            <el-date-picker
              v-model="scope.row.rewardPunishmentDate"
              type="date"
              value-format="YYYY-MM-DD"
              style="width: 100%;"
              placeholder="请选择"
            />
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="奖惩原因" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.reason" show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="奖惩内容" min-width=" 200">
          <template #default="scope">
            <el-input v-model="scope.row.context" show-word-limit maxlength="100"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="奖惩单位" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.organizational"  show-word-limit maxlength="50"/>
          </template>
        </el-table-column>


        <el-table-column label="操作" fixed="right" align="center" min-width="100">
          <template #default="scope">
            <el-button
              link
              type="danger"
              @click="deleteEducation(scope.$index,5)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>


      <!-- -----------------------------------     补贴列表-->
      <div style="display: flex;align-items: center;flex-direction: row;margin-top: 36px;">
        <div class="info-title" style="width: 140px;"> 补贴列表 </div>
        <div style="flex-grow: 1"></div>
        <el-button type="primary" plain @click="addEducation(6)" style="margin-right: 15px;">
          <Icon icon="ep:plus" class="mr-4px" />
          添加
        </el-button>
      </div>

      <el-table  style="margin-top: 12px;margin-left: 15px;" :data="dataForm.userSubsidy"  :header-cell-style="tableHeaderColor">

        <el-table-column header-align="center" align="center" label="序号" width="100">
          <template #default="scope">
            {{scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="elderlyName" header-align="center" align="center" label="补贴类型" min-width="180">
          <template #default="scope">
            <TgSelect
              v-model="scope.row.subsidyType"
              placeholder="请选择"
              clearable
              :list="getDictOptions(DICT_TYPE.ALLOWANCE_TYPES)"
            >
              <el-option
                v-for="(item, index) in getIntDictOptions(DICT_TYPE.ALLOWANCE_TYPES)"
                :key="index"
                :label="item.label"
                :value="item.value.toString()"
              />
            </TgSelect>
          </template>
        </el-table-column>

        <el-table-column prop="expectName" header-align="center" align="center" label="补贴标准" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.subsidyStandard" show-word-limit maxlength="25"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="补贴金额" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.subsidyAmount" type="number"  maxlength="12"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="接受补贴日期" min-width=" 200">
          <template #default="scope">
            <el-date-picker
              v-model="scope.row.subsidyDate"
              type="date"
              value-format="YYYY-MM-DD"
              style="width: 100%;"
              placeholder="请选择"
            />
          </template>
        </el-table-column>

        <el-table-column label="操作" fixed="right" align="center" min-width="100">
          <template #default="scope">
            <el-button
              link
              type="danger"
              @click="deleteEducation(scope.$index,6)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>


      <!-- -----------------------------------     资质列表-->
      <div style="display: flex;align-items: center;flex-direction: row;margin-top: 36px;">
        <div class="info-title" style="width: 140px;"> 资质列表 </div>
        <div style="flex-grow: 1"></div>
        <el-button type="primary" plain @click="addEducation(7)" style="margin-right: 15px;">
          <Icon icon="ep:plus" class="mr-4px" />
          添加
        </el-button>
      </div>

      <el-table  style="margin-top: 12px;margin-left: 15px;" :data="dataForm.userQualifications"  :header-cell-style="tableHeaderColor">

        <el-table-column header-align="center" align="center" label="序号" width="100">
          <template #default="scope">
            {{scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="elderlyName" header-align="center" align="center" label="证书/资质名称" min-width="180">
          <template #default="scope">
            <el-input v-model="scope.row.certificateQualificationName" show-word-limit maxlength="25"/>
          </template>
        </el-table-column>

        <el-table-column prop="expectName" header-align="center" align="center" label="证书编号" min-width="200">
          <template #default="scope">
            <el-input v-model="scope.row.certificateNumber" show-word-limit maxlength="50"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="获取日期" min-width="200">
          <template #default="scope">
            <el-date-picker
              v-model="scope.row.acquisitionDate"
              type="date"
              value-format="YYYY-MM-DD"
              style="width: 100%;"
              placeholder="请选择"
            />
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="颁发单位" min-width=" 200">
          <template #default="scope">
            <el-input v-model="scope.row.issue" show-word-limit maxlength="25"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="有效期(天)" min-width=" 200">
          <template #default="scope">
            <el-input v-model="scope.row.validity" show-word-limit maxlength="6"/>
          </template>
        </el-table-column>
        <el-table-column prop="changeDate" header-align="center" align="center" label="备注" min-width=" 200">
          <template #default="scope">
            <el-input v-model="scope.row.remarks" show-word-limit maxlength="100"/>
          </template>
        </el-table-column>

        <el-table-column label="操作" fixed="right" align="center" min-width="100">
          <template #default="scope">
            <el-button
              link
              type="danger"
              @click="deleteEducation(scope.$index,7)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- -----------------------------------     附件上传-->

      <div class="info-title" style="width: 140px;margin-top: 36px;margin-bottom: 22px"> 附件上传 </div>
      <el-row>
        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
          <el-form-item label="员工头像">
            <SelectUpload
              :is-detail="dataForm.avatar.length>0"
              v-model="dataForm.avatar"
              fun-name="附件"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row style="margin-top: 20px">
        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
          <el-form-item label="身份证人像照">
            <SelectUpload
              :is-detail="dataForm.idCardPortraitPhoto.length>0"
              v-model="dataForm.idCardPortraitPhoto"
              fun-name="附件"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row style="margin-top: 20px">
        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
          <el-form-item label="身份证国徽照">
            <SelectUpload
              :is-detail="dataForm.nationalEmblemPhoto.length>0"
              v-model="dataForm.nationalEmblemPhoto"
              fun-name="附件"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row style="margin-top: 20px">
        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
          <el-form-item label="银行卡正面">
            <SelectUpload
              :is-detail="dataForm.bankCardFrontPhoto.length>0"
              v-model="dataForm.bankCardFrontPhoto"
              fun-name="附件"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row style="margin-top: 20px">
        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
          <el-form-item label="银行卡反面">
            <SelectUpload
              :is-detail="dataForm.bankCardBackPhoto.length>0"
              v-model="dataForm.bankCardBackPhoto"
              fun-name="附件"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row >
        <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
          <el-form-item label="银行卡号" prop="bankCardNumber">
            <el-input v-model="dataForm.bankCardNumber"  :maxlength="50" show-word-limit placeholder="请输入银行卡号" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
          <el-form-item label="银行名称" prop="bankCardName">
            <el-input v-model="dataForm.bankCardName" maxlength="50" show-word-limit placeholder="请输入银行名称" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row style="margin-top: 20px">
        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
          <el-form-item label="入职告知书">
            <SelectUpload
              :is-detail="dataForm.employmentNoticeFile.length>0"
              v-model="dataForm.employmentNoticeFile"
              fun-name="附件"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row style="margin-top: 20px">
        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
          <el-form-item label="技能证书">
            <SelectUpload
              v-model="dataForm.skillsCertificateFile"
              fun-name="附件"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row style="margin-top: 20px">
        <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
          <el-form-item label="体检报告">
            <SelectUpload
              v-model="dataForm.medicalReport"
              fun-name="附件"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <div style="height: 10px;"></div>

    </el-form>


    <template #footer>
      <el-button @click="dialogVisible = false">关 闭</el-button>
      <el-button :disabled="formLoading" type="primary" @click="submitForm">保存并关闭</el-button>
    </template>
  </Dialog>
</template>
<script lang="ts" setup>
import {
  DICT_TYPE,
  getDictObj,
  getDictOptions,
  getIntDictOptions,
  getStrDictOptions
} from '@/utils/dict'
import { CommonStatusEnum } from '@/utils/constants'
import { defaultProps, handleTree } from '@/utils/tree'
import * as PostApi from '@/api/system/post'
import * as DeptApi from '@/api/system/dept'
import * as UserApi from '@/api/system/user'
import { FormRules } from 'element-plus'
import {useMediaQuery} from "@vueuse/core";
import {useAppStore} from "@/store/modules/app";
const appStore = useAppStore()
const systemTheme = ref(appStore.getTheme.elColorPrimary)
defineOptions({ name: 'SystemUserForm' })

const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗

const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const sexIndex = ref(false) //
const formLoading = ref(false) // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用
const formType = ref('') // 表单的类型：create - 新增；update - 修改
const dataForm = ref({
  id: undefined,
  nickname: '',
  username: '',
  userNumber: '',
  remark: '',
  deptId: '',
  postIds: [],
  mobile: '',
  email: '',
  sex: 1,
  avatar:[],
  userType:'',
  idType:'',//证件类型,示例值(1)
  idNumber:'',//证件号码
  birthday:'',//出生日期
  dBirthday:false,//出生日期
  nation:'',//民族
  nativePlace:'',//籍贯
  residentialAddress:'',//居住地址
  isPartyMember:'',//是否党员
  maritalStatus:'',//婚姻状况,示例值(1)
  highestDegree:'',//最高学历
  graduateSchool:'',//毕业院校
  major:'',//专业
  graduationYear:'',//毕业年份
  isHaveNursingLevelCertificate:'',//是否有护理等级证书
  workStatus: '', // 工作状态
  isPaySocialSecurity:'',//是否缴纳社保
  job:'',//职务
  joinedDate:'',//入职日期
  trialPeriod:'',//试用期（月）
  probationarySalary:'',//试用期工资(元)
  regularSalary:'',//转正工资(元)
  idCardPortraitPhoto:[],//身份证人像照
  nationalEmblemPhoto:[],//身份证国徽照
  bankCardFrontPhoto:[],//银行卡正面照
  bankCardBackPhoto:[],//银行卡反面照
  bankCardNumber:'',//银行卡号
  bankCardName:'',//银行名称
  employmentNoticeFile:[],//入职告知书
  skillsCertificateFile:[],//技能证书
  medicalReport:[],//体检报告
  nursingStaffLevel:'',//护理员等级
  userEducations:[],//用户教育经历
  userFamilySituations:[],//工作家庭状况
  userQualifications:[],//用户资质列表
  userRewardsPunishments:[],//用户奖惩列表
  userSubsidy:[],//用户补贴
  userTrainingExperiences:[],//用户培训经历
  userWorkExperiences:[],//用户工作经历
  //password: '',
  status: CommonStatusEnum.ENABLE,
  isEnableEnterpriseLogin: '',// 集团账号是否登录企业端
  roleIds: []
})
const formRules = reactive<FormRules>({
  username: [{ required: true, message: '登录账号不能为空', trigger: 'blur' }],
  nickname: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }],
  //password: [{ required: true, message: '登录密码不能为空', trigger: 'blur' }],
  idType: [{ required: true, message: '证件类型不能为空', trigger: 'blur' }],
  idNumber: [{ required: true, message: '证件号码不能为空', trigger: 'blur' }],
  sex: [{ required: true, message: '性别不能为空', trigger: 'change' }],
  email: [
    {
      type: 'email',
      message: '请输入正确的邮箱地址',
      trigger: ['blur', 'change']
    }
  ],
  mobile: [
    { required: true,
      pattern: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
      message: '请输入正确的手机号码',
      trigger: 'blur'
    }
  ]
})
const formRef = ref() // 表单 Ref
const deptList = ref<Tree[]>([]) // 树形结构
const postList = ref([] as PostApi.PostVO[]) // 岗位列表

/** 打开弹窗 */
const open = async (type: string, id?: number) => {
  dialogVisible.value = true
  dialogTitle.value = t('action.' + type)
  formType.value = type
  console.log("身份证",extractInfoFromIdCard("430224198911054252"))
  resetForm()
  // 修改时，设置数据
  if (id) {
    formLoading.value = true
    try {
      let obj1 = await UserApi.getUser(id)
      console.log("dddFA",obj1)
      let tempData = { ...dataForm.value, ...obj1 }
      if(tempData.sex==0){
        tempData.sex=1
      }
      if(tempData.userEducations){
        for (const p of tempData.userEducations) {
          p.date=[p.startDate,p.endDate]
        }
      }
      if(tempData.userWorkExperiences){
        for (const p of tempData.userWorkExperiences) {
          p.date=[p.startDate,p.endDate]
        }
      }
      if(tempData.userTrainingExperiences){
        for (const p of tempData.userTrainingExperiences) {
          p.date=[p.startDate,p.endDate]
        }
      }
      if(tempData.userType){
        tempData.userType=tempData.userType.toString()
      }
      tempData.avatar = (obj1.avatar!=null && obj1.avatar!="" && obj1.avatar!="null") ? [{fileUrl:obj1.avatar,fileName:'avatar.png'}] : []
      tempData.idCardPortraitPhoto = (obj1.idCardPortraitPhoto!=null && obj1.idCardPortraitPhoto!='' && obj1.idCardPortraitPhoto!='null') ? JSON.parse(obj1.idCardPortraitPhoto) : []
      tempData.nationalEmblemPhoto = (obj1.nationalEmblemPhoto!=null && obj1.nationalEmblemPhoto!='' && obj1.nationalEmblemPhoto!='null') ? JSON.parse(obj1.nationalEmblemPhoto) : []
      tempData.bankCardFrontPhoto = (obj1.bankCardFrontPhoto!=null && obj1.bankCardFrontPhoto!='' && obj1.bankCardFrontPhoto!='null') ? JSON.parse(obj1.bankCardFrontPhoto) : []
      tempData.bankCardBackPhoto = (obj1.bankCardBackPhoto!=null && obj1.bankCardBackPhoto!='' && obj1.bankCardBackPhoto!='null') ? JSON.parse(obj1.bankCardBackPhoto) : []
      tempData.employmentNoticeFile = (obj1.employmentNoticeFile!=null && obj1.employmentNoticeFile!='' && obj1.employmentNoticeFile!='null') ? JSON.parse(obj1.employmentNoticeFile) : []
      tempData.skillsCertificateFile = (obj1.skillsCertificateFile!=null && obj1.skillsCertificateFile!='' && obj1.skillsCertificateFile!='null') ? JSON.parse(obj1.skillsCertificateFile) : []
      tempData.medicalReport = (obj1.medicalReport!=null && obj1.medicalReport!='' && obj1.medicalReport!='null') ? JSON.parse(obj1.medicalReport) : []

      // tempData.avatar =  []
      // tempData.idCardPortraitPhoto =  []
      // tempData.nationalEmblemPhoto = []
      // tempData.bankCardFrontPhoto =  []
      // tempData.bankCardBackPhoto = []
      // tempData.employmentNoticeFile =  []
      // tempData.skillsCertificateFile = []
      // tempData.medicalReport =  []

      dataForm.value = tempData
        console.log("dddF",dataForm.value)
    } finally {
      formLoading.value = false
    }
  }
  // 加载部门树
  deptList.value = handleTree(await DeptApi.getSimpleDeptList())
  // 加载岗位列表
  postList.value = await PostApi.getSimplePostList()
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗



/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件，用于操作成功后的回调
const submitForm = async () => {
  console.log("性别",dataForm.value)
  //return
  // 校验表单
  if (!formRef) return
  const valid = await formRef.value.validate()
  if (!valid) return
  // 提交请求
  formLoading.value = true
  try {
    const data = dataForm.value as unknown as UserApi.UserVO
    if (formType.value === 'create') {
      await UserApi.createUser(data)
      message.success(t('common.createSuccess'))
    } else {
      try {
        for (const d of dataForm.value.userEducations) {//教育背景
          d.startDate = d.date[0]
          d.endDate = d.date[1]
        }
      }catch(error) {}
      try {
        for (const d of dataForm.value.userWorkExperiences) {//工作经历
          d.startDate = d.date[0]
          d.endDate = d.date[1]
        }
      }catch(error) {}
      try {
        for (const d of dataForm.value.userTrainingExperiences) {//培训经历
          d.startDate = d.date[0]
          d.endDate = d.date[1]
        }
      }catch(error) {}

      let upData = {...dataForm.value,
        avatar: dataForm.value.avatar.length>0?dataForm.value.avatar[0].fileUrl:'',
        idCardPortraitPhoto: JSON.stringify(dataForm.value.idCardPortraitPhoto),
        nationalEmblemPhoto: JSON.stringify(dataForm.value.nationalEmblemPhoto),
        bankCardFrontPhoto: JSON.stringify(dataForm.value.bankCardFrontPhoto),
        bankCardBackPhoto: JSON.stringify(dataForm.value.bankCardBackPhoto),
        employmentNoticeFile: JSON.stringify(dataForm.value.employmentNoticeFile),
        skillsCertificateFile: JSON.stringify(dataForm.value.skillsCertificateFile),
        medicalReport: JSON.stringify(dataForm.value.medicalReport),
      }
      console.log("性别",upData)
      await UserApi.updateUser(upData)
      message.success(t('common.updateSuccess'))
    }
    dialogVisible.value = false
    // 发送操作成功的事件
    emit('success')
  } finally {
    formLoading.value = false
  }
}

//添加教育背景
const addEducation = (i) => {
  switch (i) {
    case 1://教育背景
      dataForm.value.userEducations.push({userId:dataForm.value.id,startDate:'',endDate:'',date:[],schoolName:'',major:'',educationalBackground:'',isGraduate:''})
      break;
    case 2://工作经历
      dataForm.value.userWorkExperiences.push({userId:dataForm.value.id,startDate:'',endDate:'',date:[],companyName:'',occupationType:'',job:'',salary:'',reasonsForLeaving:'',otherOccupationType:''})
      break;
    case 3://工作家庭状况
      dataForm.value.userFamilySituations.push({userId:dataForm.value.id,relation:'',name:'',age:'',organizationName:'',job:'',contactInformation:''})
      break;
    case 4://培训经历
      dataForm.value.userTrainingExperiences.push({userId:dataForm.value.id,startDate:'',endDate:'',date:[],trainingProgram:'',trainingContent:'',achievement:'',trainingOrganization:'',trainingCourse:'',isSubsidy:'',subsidyAmount:''})
      break;
    case 5://奖惩记录
      dataForm.value.userRewardsPunishments.push({userId:dataForm.value.id,type:'',rewardPunishmentDate:'',reason:'',context:'',organizational:''})
      break;
    case 6://补贴列表
      dataForm.value.userSubsidy.push({userId:dataForm.value.id,subsidyType:'',subsidyStandard:'',subsidyAmount:'',subsidyDate:'',organizational:''})
      break;
    case 7://资质列表
      dataForm.value.userQualifications.push({userId:dataForm.value.id,certificateQualificationName:'',certificateNumber:'',acquisitionDate:'',issue:'',validity:'',remarks:''})
      break;
  }



}

//删除教育背景
const deleteEducation = (index:number,type:number) => {
  switch (type) {
    case 1://教育背景
      dataForm.value.userEducations.splice(index,1)
      break;
    case 2://工作经历
      dataForm.value.userWorkExperiences.splice(index,1)
      break;
    case 3://工作家庭状况
      dataForm.value.userFamilySituations.splice(index,1)
      break;
    case 4://培训经历
      dataForm.value.userTrainingExperiences.splice(index,1)
      break;
    case 5://奖惩记录
      dataForm.value.userRewardsPunishments.splice(index,1)
      break;
    case 6://补贴列表
      dataForm.value.userSubsidy.splice(index,1)
      break;
    case 7://资质列表
      dataForm.value.userQualifications.splice(index,1)
      break;
  }

}

/** 重置表单 */
const resetForm = () => {
  dataForm.value = {
    id: undefined,
    nickname: '',
    userNumber: '',
    username: '',
    remark: '',
    deptId: '',
    postIds: [],
    mobile: '',
    email: '',
    sex: 1,
    avatar:[],
    userType:'',
    idType:'',//证件类型,示例值(1)
    idNumber:'',//证件号码
    birthday:'',//出生日期
    dBirthday:false,//出生日期
    nation:'',//民族
    nativePlace:'',//籍贯
    residentialAddress:'',//居住地址
    isPartyMember:'',//是否党员
    maritalStatus:'',//婚姻状况,示例值(1)
    highestDegree:'',//最高学历
    graduateSchool:'',//毕业院校
    major:'',//专业
    graduationYear:'',//毕业年份
    isHaveNursingLevelCertificate:'',//是否有护理等级证书
    workStatus: '', // 工作状态
    isPaySocialSecurity:'',//是否缴纳社保
    job:'',//职务
    joinedDate:'',//入职日期
    trialPeriod:'',//试用期（月）
    probationarySalary:'',//试用期工资(元)
    regularSalary:'',//转正工资(元)
    idCardPortraitPhoto:[],//身份证人像照
    nationalEmblemPhoto:[],//身份证国徽照
    bankCardFrontPhoto:[],//银行卡正面照
    bankCardBackPhoto:[],//银行卡反面照
    bankCardNumber:'',//银行卡号
    bankCardName:'',//银行名称
    employmentNoticeFile:[],//入职告知书
    skillsCertificateFile:[],//技能证书
    medicalReport:[],//体检报告
    nursingStaffLevel:'',//护理员等级
    userEducations:[],//用户教育经历
    userFamilySituations:[],//用户家庭情况
    userQualifications:[],//用户资质列表
    userRewardsPunishments:[],//用户奖惩列表
    userSubsidy:[],//用户补贴
    userTrainingExperiences:[],//用户培训经历
    userWorkExperiences:[],//用户工作经历
    //password: '',
    status: CommonStatusEnum.ENABLE,
    isEnableEnterpriseLogin: '',
    roleIds: []
  }
  formRef.value?.resetFields()
  sexIndex.value=false
}

const sexStr = () => {
  if(getStrDictOptions(DICT_TYPE.SYSTEM_USER_SEX).length>1){
    return getStrDictOptions(DICT_TYPE.SYSTEM_USER_SEX);
  }else {
    return [{value:'',name:''},{value:'',name:''}]
  }
}

const changeCardID = (e) => {
  console.log(e)
   let res = extractInfoFromIdCard(e)
  if(res){
    dataForm.value.birthday=res.birthDateStr
    dataForm.value.sex=res.gender
    dataForm.value.dBirthday=true
    sexIndex.value = true
  }else {
    dataForm.value.dBirthday=false
    sexIndex.value = false
  }

}

const ckSex = (i) => {
  if(!sexIndex.value){
    dataForm.value.sex=i;
  }

}

const extractInfoFromIdCard = (idCard)=> {
  if (!/^\d{17}[\dXx]$/.test(idCard)) {
    return null
  }

  let birthDate = idCard.substring(6, 14); // 提取出生日期部分，格式为YYYYMMDD
  let birthDateStr = `${birthDate.substring(0,4)}-${birthDate.substring(4,6)}-${birthDate.substring(6,8)}`
  const genderBit = parseInt(idCard.substring(16, 17), 10); // 提取性别位，第17位
  const gender = genderBit % 2 === 0 ? 2 : 1; // 奇数表示男性，偶数表示女性

  return {
    birthDateStr: birthDateStr,
    gender: gender
  };
}

// 表头格式
const tableHeaderColor = ({ rowIndex }: any) => {
  if (rowIndex === 0) {
    return {
      backgroundColor: '#f8f8f9',
      color: '#666666',
      fontWeight: 'bold'
    }
  }
}
// 计算窗口大小
const currentWidth = useMediaQuery('(max-width: 800px)')
// 计算文字大小
const labelWidth = computed(() => {
 let widthScreen = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
  return widthScreen*0.06+'px'
})
</script>
<style lang="scss" scoped>
.OutwardRegistrationBak {
  .el-form {

  }

  @media (max-width: 1200) {
    :deep(.el-form-item--default .el-form-item__label) {
      line-height: 0 !important;
    }
  }
}

.info-title {
  min-width: 75px;
  max-width: 140px;
  padding: 15px;
  margin-left: 0px !important;
  font-weight: bolder;
  background-color: #f3f6fb;
  border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
}
.info-wrap {
  margin: 15px;
}

 .sexLeft1{
   flex-grow: 1;
   height: 30px;
   color: white;
   font-size: 14px;
   border-top-left-radius: 4px;
   border-bottom-left-radius: 4px;
   display: flex;
   align-items: center;
   justify-content: center;
 }

.sexLeft2{
  flex-grow: 1;
  height: 30px;
  background-color: white;
  font-size: 14px;
  color: #333333;
  border: #eeeeee solid 1px;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;

}

.sexRight1{
  flex-grow: 1;
  height: 30px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.sexRight2{
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  background-color: white;
  font-size: 14px;
  color: #333333;
  border: #eeeeee solid 1px;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}


:deep(.el-radio-button__inner) {
  padding: 8px 0 !important;


}

</style>
