<template>
  <div class="g-main" v-loading="loading">
    <div class="left">
      <div class="user">
        <div v-if="resiDetailObj.baseInfoDto">
          <img :src="require(`@/assets/images/index/${familyStatus}.png`)" alt="" />
        </div>
        <span v-if="resiDetailObj.baseInfoDto">
          {{ resiDetailObj.baseInfoDto.name }}（{{ resiDetailObj.baseInfoDto.age }}岁）</span
        >
        <span v-else> -- </span>
      </div>
      <div class="menu">
        <div class="progress">
          <div class="text">
            <span>信息完整度</span> <span>{{ score }}</span>
          </div>
          <el-progress :percentage="70" :show-text="false"></el-progress>
        </div>

        <div class="list">
          <div
            :class="{ item: true, active: index == active }"
            v-for="(item, index) in menuList" :key="index"
            @click="handelCLickMenu(item.id, index)"
          >
            <span>{{ item.name }}</span
            ><span
            v-if="item.id != 'businessRecord' && item.id != 'updateRecord' "
              :class="{
                incomplete: item.filledQty != item.totalQty && index != active,
                full: item.filledQty == item.totalQty,
              }"
              >（{{ item.filledQty }}/{{ item.totalQty }}）</span
            >
          </div>
        </div>
      </div>
    </div>
    <div class="right">
      <div class="editBtn">
        <el-button
          class="diy-button--add"
          type="primary"
          size="small"
          @click.native="handelClickJumpEdit"
          >编辑</el-button
        >
      </div>
      <div class="title-small" id="base">基础信息</div>
      <div class="flex_box">
        <div  class="f-flex">
          <div class="f-label"><b>国籍：</b></div>
          <div
            class="f-left8 f-font-color"
            v-if="this.resiDetailObj.baseInfoDto"
          >
            {{ nationalityText() }}
          </div>
          <div class="f-left8 f-font-color" v-else>--</div>
        </div>
        <div  class="f-flex">
          <div class="f-label"><b>证件类型：</b></div>
          <div
            class="f-left8 f-font-color"
            v-if="this.resiDetailObj.baseInfoDto"
          >
            {{ idTypeText() }}
          </div>
          <div class="f-left8 f-font-color" v-else>--</div>
        </div>
        <div  class="f-flex">
          <div class="f-label"><b>证件号：</b></div>
          <div class="f-left8 f-font-color">
            {{
              resiDetailObj.baseInfoDto && resiDetailObj.baseInfoDto.idNum
                ? resiDetailObj.baseInfoDto.idNum
                : "--"
            }}
          </div>
          <img
            v-show="showFlagIdCardBtn"
            src="@/assets/img/yanjing1.png"
            alt=""
            width="14px"
            style="margin-left: 10px"
          />
          <img
            v-show="!showFlagIdCardBtn"
            src="@/assets/img/yanjing2.png"
            alt=""
            width="14px"
            style="margin-left: 10px"
          />
          <el-button
            type="text"
            class="div-table-button--blue"
            size="small"
            @click="handelCLickShowCheckPassword('idCard')"
            >{{ showFlagIdCardBtn ? "显示" : "隐藏" }}</el-button
          >
        </div>
        <div  class="f-flex">
          <div class="f-label"><b>联系电话：</b></div>
          <div class="f-left8 f-font-color">
            {{
              resiDetailObj.baseInfoDto && resiDetailObj.baseInfoDto.mobile
                ? resiDetailObj.baseInfoDto.mobile
                : "--"
            }}
          </div>
          <img
            v-show="showFlagMobileBtn"
            src="@/assets/img/yanjing1.png"
            alt=""
            width="14px"
            style="margin-left: 10px"
          />
          <img
            v-show="!showFlagMobileBtn"
            src="@/assets/img/yanjing2.png"
            alt=""
            width="14px"
            style="margin-left: 10px"
          />
          <el-button
            type="text"
            class="div-table-button--blue"
            size="small"
            @click="handelCLickShowCheckPassword('mobile')"
            >{{ showFlagMobileBtn ? "显示" : "隐藏" }}</el-button
          >
        </div>
     
        <div  class="f-flex">
          <div class="f-label">性别：</div>
          <div class="f-left8 f-font-color">
            {{
              resiDetailObj.baseInfoDto && resiDetailObj.baseInfoDto.genderName
                ? resiDetailObj.baseInfoDto.genderName
                : "--"
            }}
          </div>
        </div>
        <div  class="f-flex">
          <div class="f-label">出生日期：</div>
          <div class="f-left8 f-font-color" v-if="resiDetailObj.baseInfoDto">
            {{ resiDetailObj.baseInfoDto.birthday || "--" }}
          </div>
        </div>
        <div  class="f-flex">
          <div class="f-label">民族：</div>
          <div class="f-left8 f-font-color">
            {{
              resiDetailObj.baseInfoDto && resiDetailObj.baseInfoDto.nationName
                ? resiDetailObj.baseInfoDto.nationName
                : "--"
            }}
          </div>
        </div>
        <div  class="f-flex">
          <div class="f-label">文化程度：</div>
          <span class="f-left8 f-font-color">
            {{
              resiDetailObj.eduInfoDto &&
              resiDetailObj.eduInfoDto.cultureLevelName
                ? resiDetailObj.eduInfoDto.cultureLevelName
                : "--"
            }}</span
          >
        </div>
        <div  class="f-flex">
            <div class="f-label">婚姻状况：</div>
            <span
              class="f-left8 f-font-color"
              v-if="resiDetailObj.familyInfoDto"
            >
              {{ categoryDictText() }}</span
            >
            <span v-else> -- </span>
        </div>
        <div  class="f-flex">
            <div class="f-label">配偶情况：</div>
            <span
              class="f-left8 f-font-color"
              v-if="resiDetailObj.familyInfoDto"
              >{{ spouseText() }}</span
            >
            <span v-else> -- </span>
        </div>
        <div class="f-flex">
            <div class="f-label">籍贯：</div>
            <span class="f-left8 f-font-color">{{
              resiDetailObj.baseInfoDto
                ? resiDetailObj.baseInfoDto.nativePlace
                  ? resiDetailObj.baseInfoDto.nativePlace
                  : "--"
                : "--"
            }}</span>
        </div>
        <div  class="f-flex">
          <div class="f-label">备注：</div>
          <div class="f-left8 f-font-color" v-if="resiDetailObj.baseInfoDto">
            {{
              resiDetailObj.baseInfoDto.remark
                ? resiDetailObj.baseInfoDto.remark
                : "--"
            }}
          </div>
        </div>
        <div  class="f-flex">
          <div class="f-label">创建时间：</div>
          <span class="f-left8 f-font-color" v-if="resiDetailObj.baseInfoDto">
            {{
              resiDetailObj.baseInfoDto.createdTime
                ? resiDetailObj.baseInfoDto.createdTime
                : "--"
            }}</span
          >
        </div>
        <div  class="f-flex">
            <div class="f-label">更新时间：</div>
            <span class="f-left8 f-font-color" v-if="resiDetailObj.baseInfoDto">
              {{
                resiDetailObj.baseInfoDto.updatedTime
                  ? resiDetailObj.baseInfoDto.updatedTime
                  : "--"
              }}</span
            >
          </div>
      </div>
      <div class="title-small" id="reside">居住信息</div>
      <section
        v-for="(item, indexK) in resiDetailObj.resideInfoDtos"
        :key="indexK"
      >
      <div  class="flex_box">
        <div class="f-flex">
              <div class="f-label"><b>所属网格：</b></div>
              <span class="f-left8 f-font-color">
                {{ item.gridName || "--" }}
              </span>
            </div>
            <div class="f-flex" style="width: 600px">
              <div class="f-label"><b>所属房屋：</b></div>
              <span class="f-left8 f-font-color">
                {{ item.agencyName + item.homeName  }}
              </span>
            </div>
        </div>
      <div  class="flex_box">
        <div class="f-flex">
              <div class="f-label"><b>人房关系：</b></div>
              <span class="f-left8 f-font-color">
                {{
                  item.resiHouseRel != null
                    ? item.resiHouseRel === 0
                      ? "自住"
                      : item.resiHouseRel === 1
                      ? "租住"
                      : "--"
                    : "--"
                }}
              </span>
          </div>
            <div class="f-flex">
              <div class="f-label"><b>人户状况：</b></div>
              <span class="f-left8 f-font-color">{{
                householdSituationText(indexK)
              }}</span>
            </div>
          <div  class="f-flex">
            <div class="f-label">户籍所在地：</div>
            <div class="f-left8 f-font-color">
              {{ item.placeOfDomicile || "--" }}
            </div>
          </div>
          <div  class="f-flex">
            <div class="f-label"><b>与户主关系：</b></div>
            <span class="f-left8 f-font-color">{{
              houseHolderRelText(indexK)
            }}</span>
          </div>
      </div>
    </section>

      <div class="title-small" id="ext">拓展信息</div>
          <section class="flex_box">
            <div class="f-flex">
            <div class="f-label">宗教信仰：</div>
            <span class="f-left8 f-font-color">{{
              resiDetailObj.religionDto && resiDetailObj.religionDto.religion
                ? resiDetailObj.religionDto.religion
                : "--"
            }}</span>
          </div>
          
        <div  class="f-flex">
          <div class="f-label"><b>就业状态：</b></div>
          <span class="f-left8 f-font-color" v-if="resiDetailObj.workInfoDto">
            {{ careerStatusText() }}
          </span>
          <span v-else>--</span>
        </div>
        <div
          
          class="f-flex"
          v-if="
            resiDetailObj.workInfoDto &&
            resiDetailObj.workInfoDto.careerStatus >= 1 &&
            resiDetailObj.workInfoDto.careerStatus <= 5
          "
        >
          <div class="f-label">工作单位：</div>
          <span class="f-left8 f-font-color">{{
            resiDetailObj.workInfoDto
              ? resiDetailObj.workInfoDto.workUnit
                ? resiDetailObj.workInfoDto.workUnit
                : "--"
              : "--"
          }}</span>
        </div>
        <div
          
          class="f-flex"
          v-if="
            resiDetailObj.workInfoDto &&
            (resiDetailObj.workInfoDto.careerStatus == 0 ||
              resiDetailObj.workInfoDto.careerStatus == 6)
          "
        >
          <div class="f-label">原工作单位：</div>
          <span class="f-left8 f-font-color">{{
            resiDetailObj.unemployedDto
              ? resiDetailObj.unemployedDto.originWorkUnit
                ? resiDetailObj.unemployedDto.originWorkUnit
                : "--"
              : "--"
          }}</span>
        </div>
        <div
          
          class="f-flex"
          v-if="
            resiDetailObj.workInfoDto &&
            resiDetailObj.workInfoDto.careerStatus >= 1 &&
            resiDetailObj.workInfoDto.careerStatus <= 5
          "
        >
            <div class="f-label">职业：</div>
            <span class="f-left8 f-font-color">{{
              resiDetailObj.workInfoDto
                ? resiDetailObj.workInfoDto.occupation
                  ? resiDetailObj.workInfoDto.occupation
                  : "--"
                : "--"
            }}</span>
        </div>
        <div
          
          class="f-flex"
          v-if="
            resiDetailObj.workInfoDto &&
            (resiDetailObj.workInfoDto.careerStatus == 0 ||
              resiDetailObj.workInfoDto.careerStatus == 6)
          "
        >
          <div class="f-label">失业时间：</div>
          <span class="f-left8 f-font-color">{{
            resiDetailObj.unemployedDto
              ? resiDetailObj.unemployedDto.unemploymentTime
                ? resiDetailObj.unemployedDto.unemploymentTime
                : "--"
              : "--"
          }}</span>
        </div>
        <div
          
          class="f-flex"
          v-if="
            resiDetailObj.workInfoDto &&
            resiDetailObj.workInfoDto.careerStatus >= 1 &&
            resiDetailObj.workInfoDto.careerStatus <= 5
          "
        >
            <div class="f-label">月收入：</div>
            <span class="f-left8 f-font-color">{{
              resiDetailObj.economyDto
                ? resiDetailObj.economyDto.monthIncome
                  ? resiDetailObj.economyDto.monthIncome
                  : "--"
                : "--"
            }}</span>
          </div>
        <div
          class="f-flex"
          v-if="
            resiDetailObj.workInfoDto &&
            (resiDetailObj.workInfoDto.careerStatus == 0 ||
              resiDetailObj.workInfoDto.careerStatus == 6)
          "
        >
          <div class="f-label">失业证号：</div>
          <span class="f-left8 f-font-color">{{
            resiDetailObj.unemployedDto
              ? resiDetailObj.unemployedDto.unemploymentNum
                ? resiDetailObj.unemployedDto.unemploymentNum
                : "--"
              : "--"
          }}</span>
        </div>
        <div
          class="f-flex"
          v-if="
            resiDetailObj.workInfoDto &&
            (resiDetailObj.workInfoDto.careerStatus == 0 ||
              resiDetailObj.workInfoDto.careerStatus == 6)
          "
        >
          <div class="f-label">失业原因：</div>
          <span class="f-left8 f-font-color">{{
            resiDetailObj.unemployedDto
              ? resiDetailObj.unemployedDto.unemploymentReason
                ? resiDetailObj.unemployedDto.unemploymentReason
                : "--"
              : "--"
          }}</span>
        </div>
        <div class="f-flex">
          <div class="f-label">有无赡养人：</div>
          <div class="f-left8 f-font-color">
            {{
              resiDetailObj.familyInfoDto &&
              resiDetailObj.familyInfoDto.elderlyFlag == 1
                ? "有"
                : resiDetailObj.familyInfoDto &&
                  resiDetailObj.familyInfoDto.elderlyFlag == 0
                ? "无"
                : "--"
            }}
          </div>
        </div>
        <div
          class="f-flex"
          v-if="
            resiDetailObj.workInfoDto &&
            (resiDetailObj.workInfoDto.careerStatus == 0 ||
              resiDetailObj.workInfoDto.careerStatus == 6)
          "
        >
          <div class="f-label" style="width: 113px">再就业优惠证号：</div>
          <span class="f-left8 f-font-color">{{
            resiDetailObj.unemployedDto
              ? resiDetailObj.unemployedDto.employmentNum
                ? resiDetailObj.unemployedDto.employmentNum
                : "--"
              : "--"
          }}</span>
        </div>
      
        <div  class="f-flex"  v-if="
          resiDetailObj.workInfoDto &&
          (resiDetailObj.workInfoDto.careerStatus == 0 ||
            resiDetailObj.workInfoDto.careerStatus == 6)
        ">
          <div class="f-label" style="width: 113px">技术特长：</div>
          <span class="f-left8 f-font-color">{{
            resiDetailObj.unemployedDto
              ? resiDetailObj.unemployedDto.specialSkill
                ? resiDetailObj.unemployedDto.specialSkill
                : "--"
              : "--"
          }}</span>
        </div>
        <div  class="f-flex"  v-if="
          resiDetailObj.workInfoDto &&
          (resiDetailObj.workInfoDto.careerStatus == 0 ||
            resiDetailObj.workInfoDto.careerStatus == 6)
        ">
          <div class="f-label" style="width: 113px">是否领取失业金：</div>
          <span class="f-left8 f-font-color" v-if="resiDetailObj.unemployedDto">
            {{
              resiDetailObj.unemployedDto.unempCompensationFlag != null
                ? resiDetailObj.unemployedDto.unempCompensationFlag === 0
                  ? "否"
                  : resiDetailObj.unemployedDto.unempCompensationFlag === 1
                  ? "是"
                  : "--"
                : "--"
            }}
          </span>
          <span v-else>--</span>
        </div>
        <div  class="f-flex"  v-if="
          resiDetailObj.workInfoDto &&
          (resiDetailObj.workInfoDto.careerStatus == 0 ||
            resiDetailObj.workInfoDto.careerStatus == 6)
        ">
          <div class="f-label" style="width: 113px">是否就业困难对象：</div>
          <span class="f-left8 f-font-color" v-if="resiDetailObj.unemployedDto">
            {{
              resiDetailObj.unemployedDto.employmentHardFlag != null
                ? resiDetailObj.unemployedDto.employmentHardFlag === 0
                  ? "否"
                  : resiDetailObj.unemployedDto.employmentHardFlag === 1
                  ? "是"
                  : "--"
                : "--"
            }}
          </span>
          <span v-else>--</span>
        </div>
        <div  class="f-flex"  v-if="
          resiDetailObj.workInfoDto &&
          (resiDetailObj.workInfoDto.careerStatus == 0 ||
            resiDetailObj.workInfoDto.careerStatus == 6)
        ">
          <div class="f-label" style="width: 113px">劳动就业愿望：</div>
          <span class="f-left8 f-font-color">
            {{
              resiDetailObj.workInfoDto
                ? resiDetailObj.workInfoDto.employmentWish
                  ? resiDetailObj.workInfoDto.employmentWish
                  : "--"
                : "--"
            }}
          </span>
        </div>
     
        
          </section>
      <div class="title-small">关系图谱</div>
      <graph
        :userInfo="resiDetailObj.baseInfoDto"
        v-if="resiDetailObj.baseInfoDto"
      />
      <div class="title-small">人员标签</div>
      <staff-tag
        :userInfo="resiDetailObj"
        ref="staffTag"
        v-if="Object.keys(resiDetailObj).length !== 0"
        :formType="'detail'"
      ></staff-tag>
      <section
        v-for="(sectionItem, sectionIndex) in expandList"
        :key="sectionIndex"
      >
        <div class="title-small" :id="sectionItem.scrollId">
          {{ sectionItem.title }}
        </div>
        <section class="flex_box">
          <div
          class="f-flex"
          v-for="(row, rowIndex) in sectionItem.children"
          :key="rowIndex + sectionItem.id"
        >
         
              <div class="f-label">{{ row.label }}：</div>
              <span class="f-left8 f-font-color">{{
                row.value ? row.value : "--"
              }}</span>
          </div>
        </section>
       
      </section>

      <div class="title-small" id="businessRecord">业务记录</div>
      <business-record :userInfo="resiDetailObj"></business-record>
      <div class="title-small" id="updateRecord">更新记录</div>
      <change-record :tableData="changeRecordList"></change-record>
    </div>
    <el-dialog title="密码验证" :visible.sync="showCheckPassword">
      <el-form :model="form" :rules="rules" ref="form">
        <el-form-item label="密码" prop="password">
          <el-input
            v-model.trim="form.password"
            autocomplete="off"
            type="password"
            placeholder="请输入当前账号密码"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showCheckPassword = false">取 消</el-button>
        <el-button type="primary" @click="handelClickCheckPassword"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { requestPost } from "@/js/dai/request";
import graph from "./cpts/graph.vue";
import staffTag from "./cpts/staffTag.vue";
import businessRecord from "./cpts/businessRecord.vue";
import changeRecord from "./cpts/table/changeRecord.vue";
import { idTypeList } from "@/js/columns/constants";

export default {
  data() {
    return {
      loading: false,
      checkType: "edit", //edit或者view
      changeRecordList: [], //更新记录
      resiDetailObj: {}, //居民详情
      showFlagIdCardBtn: true,
      showFlagMobileBtn: true,
      active: 0,
      menuList: [],
      score: null,

      nationalityList: [], //国籍字典
      marriageArr: [], //婚姻状况字典
      spouseArr: [], //配偶情况字典
      careerStatusArr: [], //就业状况字典
      householdSituationArr: [], //户籍情况字典
      houseHolderRelArr: [], //与户主关系字典
      idTypeList, //证件类型字典
      showCheckPassword: false,
      originalExpandList: [
        {
          id: "healthDto",
          title: "残疾信息",
          scrollId: "disability",
          children: [
            {
              label: "残疾类别",
              itemType: "select1",
              formName: "disabilityCategoryCode",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "disability_category_code" },
              opction: [],
            },
            {
              label: "残疾等级",
              itemType: "select1",
              formName: "disabilityLevel",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "disability_level" },
              opction: [],
            },
            {
              label: "残疾证号",
              itemType: "input1",
              formName: "disabilityNum",
            },
            {
              label: "残疾说明",
              itemType: "input1",
              formName: "disabilityDesc",
            },
            {
              label: "监护人",
              itemType: "radio1",
              formName: "guardianFlag",
              opction: [
                { label: "有", formName: "", value: 1 },
                { label: "无", formName: "", value: 0 },
              ],
            },
            {
              label: "监护人姓名",
              itemType: "input1",
              formName: "guardianName",
            },
            {
              label: "监护人联系电话",
              itemType: "input1",
              formName: "guardianMobile",
            },
            {
              label: "技能特长",
              itemType: "radio1",
              formName: "specialSkillFlag",
              opction: [
                { label: "有", formName: "", value: 1 },
                { label: "无", formName: "", value: 0 },
              ],
            },
            {
              label: "劳动能力",
              itemType: "radio1",
              formName: "workCapacityFlag",
              opction: [
                { label: "有", formName: "", value: 1 },
                { label: "无", formName: "", value: 0 },
              ],
            },
          ],
        },
        {
          id: "seriousIllnessDto",
          title: "大病信息",
          scrollId: "serious_illness",
          children: [
            {
              label: "所患大病",
              itemType: "checkbox",
              formName: "illnessCodes",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "illness_code" },
              opction: [],
            },
          ],
        },
        {
          id: "chronicDiseaseDto",
          title: "慢病信息",
          scrollId: "chronic_disease",
          children: [
            {
              label: "所患慢病",
              itemType: "checkbox",
              formName: "chronicDiseaseCodes",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "chronic_disease_code" },
              opction: [],
            },
          ],
        },
        {
          id: "deathDto",
          title: "死亡信息",
          scrollId: "death",
          children: [
            {
              label: "死亡时间",
              itemType: "datepicker1",
              formName: "deathTime",
            },
          ],
        },
        {
          id: "oldPeopleDto",
          title: "老年人信息",
          scrollId: "old_people",
          children: [
            {
              label: "老年人分类",
              itemType: "checkbox",
              multiple: true,
              formName: "oldPeopleCategories",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "oldPeople_categories" },
            },
            {
              label: "居住情况",
              itemType: "select1",
              formName: "resideSituation",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "reside_situation" },
            },
            {
              label: "高龄补助",
              itemType: "inputNum",
              formName: "oldSubsidy",
            },
          ],
        },
        {
          id: "subsistenceAllowanceDto",
          title: "低保信息",
          scrollId: "subsistence_allowance",
          children: [
            {
              label: "低保类别",
              itemType: "select1",
              formName: "category",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "subsistence_allowance_category" },
            },
            {
              label: "低保享受原因",
              itemType: "checkbox",
              formName: "reasons",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "subsistence_allowance_reasons" },
              opction: [],
            },
          ],
        },
        {
          id: "parymemberInfoDto",
          title: "党员信息",
          scrollId: "party_member",
          children: [
            {
              label: "入党时间",
              itemType: "datepicker1",
              formName: "joinTime",
              opction: [],
            },
            {
              label: "转正时间",
              itemType: "datepicker1",
              formName: "positiveTime",
              opction: [],
            },
            {
              label: "所属党组织",
              itemType: "cascader1",
              formName: "partyOrgId",
              opction: [],
            },
            {
              label: "流动党员",
              itemType: "radio1",
              formName: "flowFlag",
              opction: [
                { label: "是", value: 1 },
                { label: "否", value: 0 },
              ],
            },
            {
              label: "流动党员活动证号",
              itemType: "input1",
              formName: "flowActNum",
            },
            {
              label: "职务",
              itemType: "select1",
              formName: "partyJob",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "party_job" },
              opction: [],
            },
            {
              label: "工作职责",
              itemType: "input1",
              formName: "duty",
            },
            {
              label: "是否退休",
              itemType: "radio1",
              formName: "retiredFlag",
              opction: [
                { label: "是", value: 1 },
                { label: "否", value: 0 },
              ],
            },
            {
              label: "党员中心户",
              itemType: "radio1",
              formName: "centerFlag",
              opction: [
                { label: "是", value: 1 },
                { label: "否", value: 0 },
              ],
            },
            {
              label: "免学习",
              itemType: "radio1",
              formName: "studyNotNeed",
              opction: [
                { label: "是", value: 1 },
                { label: "否", value: 0 },
              ],
            },
            {
              label: "入党时所在党支部",
              itemType: "input1",
              formName: "joinBranchName",
            },
            {
              label: "组织关系转入社区时间",
              itemType: "datepicker1",
              formName: "joinCommunityTime",
              opction: [],
            },
          ],
        },
        {
          id: "ensureHouseDto",
          title: "保障房信息",
          scrollId: "ensure_house",
          children: [
            {
              label: "所在社区",
              itemType: "input1",
              formName: "liveCommunity",
            },
            {
              label: "住房性质",
              itemType: "select1",
              formName: "housingNature",
              opctionUrl: "sys/dict/data/house",
              opctionParams: { formCode: "resi_base_info" },
              opction: [],
            },
          ],
        },
        {
          id: "veteranDto",
          title: "退役军人信息",
          scrollId: "veteran",
          children: [
            {
              label: "入伍时间",
              itemType: "datepicker1",
              formName: "joinArmyTime",
              opction: [],
            },
            {
              label: "退伍时间",
              itemType: "datepicker1",
              formName: "leaveArmyTime",
              opction: [],
            },
            {
              label: "服役单位",
              itemType: "input1",
              formName: "serviceUnit",
            },
            {
              label: "接收单位",
              itemType: "input1",
              formName: "receiveUnit",
            },
            {
              label: "待安置补助金",
              itemType: "inputNum",
              formName: "settlementAmount",
              opction: [],
            },
            {
              label: "培训状况",
              itemType: "input1",
              formName: "trainDesc",
            },
            {
              label: "现就业情况",
              itemType: "input1",
              formName: "employmentSituation",
            },
            {
              label: "是否办理公益性岗位",
              itemType: "radio1",
              formName: "pubWelfareJobFlag",
              opction: [
                { label: "是", value: 1 },
                { label: "否", value: 0 },
              ],
            },
          ],
        },
        {
          id: "unitedFrontDto",
          title: "统战人员信息",
          scrollId: "united_front",
          children: [
            {
              label: "统战类型",
              itemType: "input1",
              formName: "unitedFrontType",
            },
          ],
        },
        {
          id: "volunteerDto",
          title: "志愿者信息",
          children: [
            {
              label: "志愿者类别",
              itemType: "checkbox",
              formName: "volunteerCategory",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "VOLUNTEER_CATEGORY" },
              opction: [],
            },
          ],
        },
        {
          id: "specialSupportDto",
          title: "特扶人员信息",
          scrollId: "special_support",
          children: [
            {
              //0
              label: "特扶类别",
              itemType: "select1",
              formName: "specialSupportType",
              opction: [
                {
                  value: "1",
                  label: "失独",
                },
                {
                  value: "2",
                  label: "伤残",
                },
              ],
            },
            {
              //1
              label: "子女姓名",
              itemType: "input1",
              formName: "childName",
              opction: [],
            },
            {
              //2
              label: "子女性别",
              itemType: "select1",
              formName: "childGender",
              opction: [
                {
                  value: "1",
                  label: "男",
                },
                {
                  value: "2",
                  label: "女",
                },
              ],
            },
            {
              label: "子女死亡日期",
              itemType: "datepicker1",
              formName: "childDeathDate",
              opction: [],
            },
            {
              label: "子女伤残类别",
              itemType: "select1",
              formName: "childDisabilityCategoryCode",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "disability_category_code" },
              opction: [],
            },
            {
              label: "子女伤残等级",
              itemType: "select1",
              formName: "childDisabilityLevel",
              opctionUrl: "sys/dict/data/dictlist",
              opctionParams: { dictType: "disability_level" },
              opction: [],
            },
          ],
        },
      ],
      expandList: [],
      form: {
        password: "", //脱敏确认密码
      },
      rules: {
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
      incidence: {
        parymemberInfoDto: {
          formId: "parymemberInfoDto",
          formType: "parymemberInfoDto",
          title: "党员信息",
        },
        disabilityFlag: {
          formId: "healthDto",
          formType: "healthDto",
          title: "残疾信息",
        },
        seriousIllnessFlag: {
          formId: "seriousIllnessDto",
          formType: "seriousIllnessDto",
          title: "大病信息",
        },
        chronicDiseaseFlag: {
          formId: "chronicDiseaseDto",
          formType: "chronicDiseaseDto",
          title: "慢病信息",
        },
        deathFlag: { formId: "deathDto", formType: "deathDto", title: "死亡" },
        oldPeopleFlag: {
          formId: "oldPeopleDto",
          formType: "oldPeopleDto",
          title: "老年人信息",
        },
        subsistenceAllowanceFlag: {
          formId: "subsistenceAllowanceDto",
          formType: "subsistenceAllowanceDto",
          title: "低保人员信息",
        },
        veteranFlag: {
          formId: "veteranDto",
          formType: "veteranDto",
          title: "退役军人信息",
        },
        ensureHouseFlag: {
          formId: "ensureHouseDto",
          formType: "ensureHouseDto",
          title: "保障性住房信息",
        },
        specialSupportFlag: {
          formId: "specialSupportDto",
          formType: "specialSupportDto",
          title: "特扶人员",
        },
        unitedFrontFlag: {
          formId: "unitedFrontDto",
          formType: "unitedFrontDto",
          title: "统战人员",
        },
        volunteerFlag: {
          formId: "volunteerDto",
          formType: "volunteerDto",
          title: "志愿者",
        },
      },
    };
  },
  components: { graph, staffTag, businessRecord, changeRecord },
  created() {},
  mounted() {},
  activated() {},
  methods: {
    // 更新记录
    async getChangeRecordDetailById() {
      try {
        const { data } = await this.$http.post(
          `/actual/base/residentChangeRecord/getChangeRecordsById/${this.resiId}`
        );
        if (data.data == null) {
          this.changeRecordList = [];
        } else {
          this.changeRecordList = data.data;
        }
      } catch (error) {
        console.log(error);
      }
    },
    async getNationalityList() {
      try {
        const { data } = await this.$http.post("sys/dict/data/dictlist", {
          dictType: "nationality",
        });
        this.nationalityList = data.data;
      } catch (error) {
        console.log(error, `获取 ${dictType} 字典`);
      }
    },
    getResiDetail() {
      this.$http
        .get(`/actual/base/residentIntegratedInfo/detail/masked/${this.resiId}`)
        .then(async (res) => {
          if (res.data.code === 0) {
            this.resiDetailObj = res.data.data || {};
            const nameMap = {
              reside: "居住信息",
              ext: "拓展信息",
              united_front: "统战人员信息",
              party_member: "党员信息",
              death: "死亡信息",
              disability: "残疾信息",
              subsistence_allowance: "低保信息",
              serious_illness: "大病信息",
              veteran: "退役军人信息",
              special_support: "特扶人员信息",
              old_people: "老年人信息",
              ensure_house: "保障房信息",
              chronic_disease: "慢病信息",
              base: "基本信息",
              business_record:'业务记录',
              update_record:'更新记录'
            };
            const keysWithValueOne = [];
            for (const key in this.resiDetailObj.baseInfoDto.categoryInfo) {
                if (this.resiDetailObj.baseInfoDto.categoryInfo[key] === 1 && this.incidence[key]) {
                    keysWithValueOne.push(this.incidence[key].formId);
                }
            }
            const keysWithValueOneName= keysWithValueOne.map(str => {
                const matchedObject = this.originalExpandList.find(obj => obj.id === str);
                return matchedObject ? matchedObject.title : null;
            });
            this.menuList = Object.entries(
              res.data.data.integrityData.integrityQtyMap
            )
            
              .map(([key, value]) => ({
                name: nameMap[key],
                id: key,
                filledQty: value.filledQty,
                totalQty: value.totalQty,
              }))
              .reverse();
             
            for(let i in keysWithValueOneName){
              for(let k in this.originalExpandList){
                if(keysWithValueOneName[i] === this.originalExpandList[k].title){
                  for(let c in this.menuList){
                      if(this.menuList[c].name === keysWithValueOneName[i] || this.menuList[c].name === '基本信息' || this.menuList[c].name === '拓展信息' || this.menuList[c].name === '居住信息' ){
                        if(this.menuList.findIndex(item=>item.name === keysWithValueOneName[i]) === -1){
                          this.menuList.push(this.menuList[c])
                        }
                      }
                  }

                }
              }
            }
            this.menuList = this.menuList.filter((itemA) => {
              return  keysWithValueOneName.some((itemB) => itemB === itemA.name)|| itemA.name === '基本信息' || itemA.name === '拓展信息' || itemA.name === '居住信息';
            });
            this.menuList.push(
              {
                name: "业务记录",
                id: "businessRecord",
              },
              {
                name: "更新纪录",
                id: "updateRecord",
              }
            );
            const orderIds = ["base", "reside", "ext"];
            // 新建一个数组存放按顺序排列的项
            let sortedData = [];
            // 遍历 orderIds 数组，将对应的项从 data 中取出并放入 sortedData
            orderIds.forEach(id => {
                const item = this.menuList.find(item => item.id === id);
                if (item) {
                    sortedData.push(item);
                }
            });
            console.log(sortedData);
            // 将 data 中剩余的项放入 sortedData
            this.menuList.forEach(item => {
                if (!orderIds.includes(item.id)) {
                    sortedData.push(item);
                }
            });
            this.menuList = sortedData;
            this.expandList = this.originalExpandList.filter((itemA) => {
              return keysWithValueOne.some((itemB) => itemB === itemA.id);
            });
            await Promise.all(
              this.expandList.map(async (item) => {
                await Promise.all(
                  item.children.map(async (child) => {
                    const key = child.formName;
                    if(this.resiDetailObj[item.id]){
                      if (this.resiDetailObj[item.id].hasOwnProperty(key)) {
                      child.value = await this.getDictName(
                        child.opctionUrl,
                        child.opctionParams,
                        this.resiDetailObj[item.id][
                          key == "partyOrgId" ? "branchId" : key
                        ],
                        child.itemType,
                        child.opction
                      );
                    }
                    }
                    
                  })
                );
              })
            );
            this.score = res.data.data.integrityData.score;
          } else if (res.data.code >= 8000) {
            this.resiDetailObj = {};
            this.$message.error(res.data.msg);
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // async handleSaveTuomin1() {
    //   const url = `/actual/base/residentBaseInfo/getResiUserInfo/${this.resiId}`;
    //   let parm = {
    //     password,
    //   };
    //   const { data, code, msg } = await requestPost(url, parm);
    // },
   async  handelClickJumpEdit() {
      const url = `/actual/base/residentCategoryUpdateInfo/isUpdater/${this.resiId}`;
      const { data, code, msg } = await requestPost(url);
      if(code==0){
          if(data==true){
            this.handleSaveTuomin()
          }
          else{
            this.checkType = "edit";
            this.showCheckPassword = true;
          }
      }
      else{
        this.$message.error(msg);
      }
    },
    async getDictName(url, params, value, itemType, opction) {
      try {
        if (url) {
          const { data } = await this.$http.post(url, params);
          const dictData = data.data;
          if (itemType == "checkbox") {
            const matchedLabels = value
              .map((item) => {
                const matchedItems = dictData.filter(
                  (obj) => obj.value === item
                );
                if (matchedItems.length > 0) {
                  return matchedItems
                    .map((matchedItem) => matchedItem.label)
                    .join(",");
                } else {
                  return "";
                }
              })
              .join("，");
            return matchedLabels ? matchedLabels : "--";
          } else if (itemType == "select1") {
            const matchedItem = dictData.find((item) => item.value === value);
            return matchedItem ? matchedItem.label : "--";
          }
        } else {
          if (itemType == "radio1") {
            const matchedItem = opction.find((item) => item.value === value);
            return matchedItem ? matchedItem.label : "--";
          } else if (
            itemType == "input1" ||
            itemType == "datepicker1" ||
            itemType == "cascader1"
          ) {
            return value ? value : "--";
          }
        }
      } catch (error) {
        console.log(error);
      }
    },

      handelCLickMenu(id, index) {
      this.active = index;
      const bottomElement = document.getElementById(`${id}`);
      const topOffset = -120; // 减少的高度值
      const topPos = bottomElement.getBoundingClientRect().top + window.pageYOffset + topOffset;
      window.scrollTo({ top: topPos, behavior: "smooth" });
    },


    handelCLickShowCheckPassword(type) {
      this.form.password = "";
      this.checkType = "view";
      if (type === "idCard") {
        if (this.showFlagIdCardBtn) {
          this.showCheckPassword = true;
        } else {
          this.showFlagIdCardBtn = true;
          this.$set(
            this.resiDetailObj.baseInfoDto,
            "idNum",
            this.resiDetailObj.baseInfoDto.idNum.substr(0, 11) +
              "****" +
              this.resiDetailObj.baseInfoDto.idNum.substr(16, 2)
          );
        }
      } else if (type === "mobile") {
        if (this.showFlagMobileBtn) {
          this.showCheckPassword = true;
        } else {
          this.showFlagMobileBtn = true;
          this.$set(
            this.resiDetailObj.baseInfoDto,
            "mobile",
            this.resiDetailObj.baseInfoDto.mobile.substr(0, 3) +
              "****" +
              this.resiDetailObj.baseInfoDto.mobile.substr(7, 4)
          );
        }
      }
      this.tuominType = type;
    },
    nationalityText() {
      let text = "--";
      this.nationalityList.forEach((item) => {
        if (item.value == this.resiDetailObj.baseInfoDto.nationality) {
          text = item.label;
        }
      });
      return text;
    },
    categoryDictText() {
      let text = "--";
      this.marriageArr.forEach((item) => {
        if (item.value == this.resiDetailObj.familyInfoDto.marriage) {
          text = item.label;
        }
      });
      return text;
    },
    spouseText() {
      let text = "--";
      this.spouseArr.forEach((item) => {
        if (item.value == this.resiDetailObj.familyInfoDto.spouseSituation) {
          text = item.label;
        }
      });
      return text;
    },
    careerStatusText() {
      let text = "--";
      this.careerStatusArr.forEach((item) => {
        if (item.value == this.resiDetailObj.workInfoDto.careerStatus) {
          text = item.label;
        }
      });
      return text;
    },
    idTypeText() {
      let text = "--";
      this.idTypeList.forEach((item) => {
        if (item.value == this.resiDetailObj.baseInfoDto.idType) {
          text = item.label;
        }
      });
      return text;
    },
    handelClickCheckPassword() {
      this.$refs.form.validate((vali) => {
        if (vali) {
          this.handleSaveTuomin(this.form.password);
        } else {
          return false;
        }
      });
    },
    async handleSaveTuomin(password) {
      const url = `/actual/base/residentBaseInfo/getResiUserInfo/${this.resiId}`;
      let parm = {
        password,
      };
      const { data, code, msg } = await requestPost(url, parm);
      if (code === 0) {
        if (this.checkType == "view") {
          if (this.tuominType === "mobile") {
            this.$set(this.resiDetailObj.baseInfoDto, "mobile", data.mobile);
            this.showFlagMobileBtn = !this.showFlagMobileBtn;
          }
          if (this.tuominType === "idCard") {
            this.$set(this.resiDetailObj.baseInfoDto, "idNum", data.idNum);
            this.showFlagIdCardBtn = !this.showFlagIdCardBtn;
          }
          this.showCheckPassword = false;
        } else if (this.checkType == "edit") {
          this.showCheckPassword = false;
          this.$router.push({
            name: "edit-resi",
            query: { id: data.id },
            params: { idNum: data.idNum, mobile: data.mobile ,name:data.name},
          });
        }
      } else {
        this.$message.error(msg);
      }
    },

    // 婚姻状况字典
    async getMarriage() {
      try {
        const { data } = await this.$http.post("sys/dict/data/dictlist", {
          dictType: "marriage",
        });
        this.marriageArr = data.data;
      } catch (error) {
        console.log(error, "获取婚姻状况字典");
      }
    },
    // 就业状态字典
    async getCareerStatus() {
      try {
        const { data } = await this.$http.post("sys/dict/data/dictlist", {
          dictType: "career_status",
        });
        this.careerStatusArr = data.data;
      } catch (error) {
        console.log(error, "获取就业状态字典");
      }
    },
    // 人户状况
    async getHouseholdSituation() {
      try {
        const { data } = await this.$http.post("sys/dict/data/dictlist", {
          dictType: "household_situation",
        });
        this.householdSituationArr = data.data;
      } catch (error) {
        console.log(error, "获取人户状况");
      }
    },
    // 配偶情况
    async getSpouse() {
      try {
        const { data } = await this.$http.post("sys/dict/data/dictlist", {
          dictType: "spouse_situation",
        });
        this.spouseArr = data.data;
      } catch (error) {
        console.log(error, "获取配偶情况字典");
      }
    },
    // 与户主关系
    async gethouseHolderRel() {
      try {
        const { data } = await this.$http.post("sys/dict/data/relationship", {
          formCode: "resi_base_info",
        });
        this.houseHolderRelArr = data.data;
        this.loading = false;
      } catch (error) {
        console.log(error, "获取与户主关系");
        this.loading = false;
      }
    },
    houseHolderRelText(index) {
      let text = "--";
      this.houseHolderRelArr.forEach((item) => {
        if (
          item.value == this.resiDetailObj.resideInfoDtos[index].houseHolderRel
        ) {
          text = item.label;
        }
      });
      return text;
    },
    householdSituationText(index) {
      let text = "--";
      this.householdSituationArr.forEach((item) => {
        if (
          item.value ==
          this.resiDetailObj.resideInfoDtos[index].householdSituation
        ) {
          text = item.label;
        }
      });
      return text;
    },
  },
  computed: {
    familyStatus(){
      var status = '';
      if(this.resiDetailObj.baseInfoDto){
          if(this.resiDetailObj.baseInfoDto.gender =='1' && this.resiDetailObj.baseInfoDto.age <=18){
            status =  'son'
          }else if(this.resiDetailObj.baseInfoDto.gender =='1' && this.resiDetailObj.baseInfoDto.age >18 && this.resiDetailObj.baseInfoDto.age <60){
              status =  'father'
          }else if(this.resiDetailObj.baseInfoDto.gender =='1' && this.resiDetailObj.baseInfoDto.age >=60){
              status =  'grandpa'
          }else if(this.resiDetailObj.baseInfoDto.gender =='2' && this.resiDetailObj.baseInfoDto.age >=60){
              status =  'grandma'
          }else if(this.resiDetailObj.baseInfoDto.gender =='2' && ( this.resiDetailObj.baseInfoDto.age >18 && this.resiDetailObj.baseInfoDto.age <60)){
              status =  'mother'
          } else if(this.resiDetailObj.baseInfoDto.gender =='2' && this.resiDetailObj.baseInfoDto.age <= 18){
                status =  'girl'
          }else if(this.resiDetailObj.baseInfoDto.gender =='0'){
            status =  'father'
          }
      } 
      return status
    }
  },
  watch: {
    "$store.state.huaXiang.userInfo.resiId": {
      handler(newValue, oldValue) {
        this.loading = true;
        this.resiId = newValue;
        this.resiDetailObj = {};
        this.getNationalityList();
        this.getResiDetail();
        this.getMarriage();
        this.getSpouse();
        this.getCareerStatus();
        this.getChangeRecordDetailById();
        this.getHouseholdSituation();
        this.gethouseHolderRel();
      },
      deep: true, // 开启深度监听
      immediate: true, // 立即触发一次handler
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/assets/scss/pages/resiInfo.scss";
@import "@/assets/scss/modules/management/list-main.scss";
</style>
