<template>
    <div class="div_form">
        <div class="form">
            <el-form :model="form" :rules="rules" label-width="105px" ref="addForm">
                <h5 style="margin-top: 6px;">基础信息登记</h5>
                <div class="flex_box">
                            <el-form-item label="姓名" prop="baseInfoDto.name" class="font-color-orange flex_item_width1">
                                <el-input class="list_item_width_1" v-model.trim="form.baseInfoDto.name" placeholder="请输入内容"
                                    size="small" clearable></el-input>
                            </el-form-item>
                      
                            <el-form-item label="证件类型" prop="baseInfoDto.idType" class="font-color-orange flex_item_width1">
                                <el-select v-model.trim="form.baseInfoDto.idType" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in idTypeList" :key="index" :label="item.label"
                                        :value="item.value" @click.native="handelCLickIdType(item.value)"></el-option>
                                </el-select>
                            </el-form-item>
                      
                            <el-form-item label="证件号" prop="baseInfoDto.idNum" class="font-color-orange flex_item_width1">
                                <el-input v-model.trim="form.baseInfoDto.idNum" placeholder="请输入内容" clearable size="small"
                                    class="list_item_width_1" @blur="handleValidBlur"></el-input>
                            </el-form-item>
                        
                            <el-form-item label="国籍" prop="baseInfoDto.nationality" class="font-color-orange flex_item_width1">
                                <el-select v-model.trim="form.baseInfoDto.nationality" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in dicts.nationalityList" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                  
                            <el-form-item label="联系电话" prop="baseInfoDto.mobile" class="font-color-orange flex_item_width1">
                                <el-input class="list_item_width_1" v-model.trim="form.baseInfoDto.mobile"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                       
                            <el-form-item label="性别" class="flex_item_width1">
                                <el-select v-model.trim="form.baseInfoDto.gender" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in genderList" :key="index" :label="item.label"
                                        :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                      
                            <el-form-item label="出生日期" class="flex_item_width1">
                                <el-date-picker v-model.trim="form.baseInfoDto.birthday" class="list_item_width_1"
                                    type="date" size="small" clearable placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                                    value-format="yyyy-MM-dd">
                                </el-date-picker>
                            </el-form-item>
                      
                            <el-form-item label="民族" class="flex_item_width1">
                                <el-select v-model.trim="form.baseInfoDto.nation" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in dicts.nationList" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                      
                            <el-form-item label="文化程度" class="flex_item_width1">
                                <el-select v-model.trim="form.eduInfoDto.cultureLevel" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in dicts.educationList" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                        
                            <el-form-item label="婚姻状况" class="flex_item_width1">
                                <el-select v-model.trim="form.familyInfoDto.marriage" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in dicts.marriageList" :key="index"
                                        :label="item.label" :value="item.value"
                                        @click.native="handelClickMarriage(item.value)"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="配偶情况"  v-if="form.familyInfoDto.marriage == 'chuhun' || form.familyInfoDto.marriage == 'zaihun' || form.familyInfoDto.marriage == 'fuhun'" class="flex_item_width1">
                                <el-select v-model.trim="form.familyInfoDto.spouseSituation" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in dicts.spouseSituationList" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="籍贯" class="flex_item_width1">
                                <el-input v-model.trim="form.baseInfoDto.nativePlace" placeholder="请输入内容" clearable
                                    size="small" class="list_item_width_1"></el-input>
                                <el-radio v-model.trim="form.baseInfoDto.localResidenceFlag" style="margin-left: 10px;"
                                    @click.native="handleLocalRadio($event)" :label="1">本地</el-radio>
                            </el-form-item>
                    <el-form-item label="备注" class="flex_item_width2" >
                        <el-input type="textarea" class="item_width_1" :rows="3" placeholder="请输入内容"
                            v-model.trim="form.baseInfoDto.remark" clearable>
                        </el-input>
                    </el-form-item>
                </div>
                <h5>居住信息登记</h5>
                    <section v-for="(item, index) in this.form.resideInfoDtos" :key="index" >
                               <div class="flex_box">
                                <el-form-item label="所属组织" class="font-color-orange flex_item_width1"
                                    :prop="`resideInfoDtos[${index}].gridId`" :rules="[
                                    { required: true, message: '请选择所属组织', trigger: 'blur' },
                                ]">
                                    <el-cascader class="list_item_width_1" ref="myCascader" clearable size="small"
                                        v-model.trim="form.resideInfoDtos[index].gridId" :options="orgOptions"
                                        :props="orgOptionProps" @change="handleChangeAgency(index)"></el-cascader>
                                </el-form-item>
                          
                                <el-form-item :prop="`resideInfoDtos[${index}].villageId`" label="所属房屋"
                                    label-width="100px" class="font-color-orange flex_item_width4" :rules="[
                                    { required: true, message: '请选择小区', trigger: 'blur' },
                                ]">
                                    <el-select v-model.trim="form.resideInfoDtos[index].villageId" placeholder="请选择小区"
                                        size="small" class="f-bto0" clearable>
                                        <el-option v-for="item in item.optionsV" :key="item.value" :label="item.label"
                                            :value="item.value" @click.native="handleChangeV(index)">
                                        </el-option>
                                    </el-select>
                                </el-form-item>


                                <el-form-item :prop="`resideInfoDtos[${index}].buildId`" label-width="0"
                                    style="margin:0px" :rules="[
                                    { required: true, message: '请选择楼栋', trigger: 'blur' },
                                ]" class="flex_item_width3">
                                    <el-select v-model.trim="form.resideInfoDtos[index].buildId" placeholder="楼号"
                                        size="small" clearable @change="handleChangeB(index)"
                                        class=" f-bto0">
                                        <el-option v-for="item in item.optionsB" :key="item.value" :label="item.label"
                                            :value="item.value">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item :prop="`resideInfoDtos[${index}].unitId`" label-width="0"
                                    style="margin:0px" :rules="[
                                    { required: true, message: '请选择单元', trigger: 'blur' },
                                ]"  class="flex_item_width3">
                                    <el-select v-model.trim="form.resideInfoDtos[index].unitId" placeholder="单元"
                                        size="small" clearable class=" f-bto0"
                                        @change="handleChangeD(index)">
                                        <el-option v-for="item in item.optionsD" :key="item.value" :label="item.label"
                                            :value="item.value">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item :prop="`resideInfoDtos[${index}].homeId`" label-width="0"
                                    style="margin:0px " :rules="[
                                    { required: true, message: '请选择房屋', trigger: 'blur' },
                                ]"  class="flex_item_width3">
                                    <el-select v-model.trim="form.resideInfoDtos[index].homeId" placeholder="房号"
                                        size="small" clearable class=" f-bto0"
                                        @change="handleChangeH(index)">
                                        <el-option v-for="item in item.optionsH" :key="item.value" :label="item.label"
                                            :value="item.value">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                                <el-button type="primary" size="mini" icon="el-icon-plus" circle
                                    @click="handelClickAddHouse" style="margin-left: 16px; height: 30px;"></el-button>
                                <el-button type="danger" v-if="form.resideInfoDtos.length > 1" size="small"
                                    icon="el-icon-minus" @click="handelClickDelHouse(index)" style="height: 30px;"
                                    circle>
                                </el-button>
                               </div>
                               <div  class="flex_box">
                                <el-form-item label="人房关系" class="font-color-blue flex_item_width1">
                                    <el-select v-model.trim="form.resideInfoDtos[index].resiHouseRel" placeholder="请选择"
                                        size="small" class="list_item_width_1"
                                        @change="handelChangeResiHouseRel($event, index)" clearable>
                                        <el-option v-for="(item, i) in dicts.resiHouseRelList" :key="i"
                                            :label="item.label" :value="item.value"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="人户状况" class="font-color-blue flex_item_width1">
                                    <el-select v-model.trim="form.resideInfoDtos[index].householdSituation" placeholder="请选择"
                                        size="small" class="list_item_width_1" clearable>
                                        <el-option v-for="(item, index) in dicts.householdSituationList" :key="index"
                                            :label="item.label" :value="item.value"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item class="flex_item_width1" label="户籍所在地" v-if="form.resideInfoDtos[index].householdSituation == 'rzhbz'">
                                    <el-input 
                                        v-model.trim="form.resideInfoDtos[index].placeOfDomicile" placeholder="请输入内容"
                                        size="small" clearable></el-input>
                                </el-form-item>
                                <el-form-item class="flex_item_width1" label="现居住地址" v-else-if="form.resideInfoDtos[index].householdSituation == 'hzrbz'">
                                    <el-input 
                                        v-model.trim="form.resideInfoDtos[index].currentResidence" placeholder="请输入内容"
                                        size="small" clearable></el-input>
                                </el-form-item>
                          
                                <el-form-item class="flex_item_width1" label="迁出时间" v-else-if="form.resideInfoDtos[index].householdSituation == 'rhdbz'">
                                    <el-date-picker v-model.trim="form.resideInfoDtos[index].outOfTime"
                                        class="list_item_width_1" type="date" size="small" clearable placeholder="选择日期"
                                        format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd">
                                    </el-date-picker>
                                </el-form-item>
                                <el-form-item class="flex_item_width1 font-color-blue font-color-blue2" label="与户主关系" >
                                    <el-select v-model.trim="form.resideInfoDtos[index].houseHolderRel" placeholder="请选择"
                                        size="small" class="list_item_width_1" clearable>
                                        <el-option v-for="(item, index) in dicts.houseHolderRelList" :key="index"
                                            :label="item.label" :value="item.value"></el-option>
                                    </el-select>
                                </el-form-item>
                               </div>
                                
                              
                    </section>
                <h5>拓展信息登记</h5>
                <div class="flex_box">
                 
                            <el-form-item label="宗教信仰" class="flex_item_width1">
                                <el-input class="list_item_width_1" v-model.trim="form.religionDto.religion"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                    
                            <el-form-item label="就业状态" class="font-color-blue flex_item_width1">
                                <el-select v-model.trim="form.workInfoDto.careerStatus" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in dicts.careerStatusList" :key="index"
                                        :label="item.label" :value="item.value"
                                        @click.native="handelClickCareerStatus(item.value)"></el-option>
                                </el-select>
                            </el-form-item>
                     
                            <el-form-item label="工作单位" class="flex_item_width1"   v-if="form.workInfoDto.careerStatus >= 1 && form.workInfoDto.careerStatus <= 5">
                                <el-input class="list_item_width_1" v-model.trim="form.workInfoDto.workUnit"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                       
                            <el-form-item label="职业" class="flex_item_width1" v-if="form.workInfoDto.careerStatus >= 1 && form.workInfoDto.careerStatus <= 5">
                                <el-input class="list_item_width_1" v-model.trim="form.workInfoDto.occupation"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                      
                            <el-form-item label="原工作单位" class="flex_item_width1"  v-if="(form.workInfoDto.careerStatus == 0 || form.workInfoDto.careerStatus == 6) && form.workInfoDto.careerStatus">
                                <el-input class="list_item_width_1" v-model.trim="form.unemployedDto.originWorkUnit"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                      
                            <el-form-item label="失业时间" class="flex_item_width1"  v-if="(form.workInfoDto.careerStatus == 0 || form.workInfoDto.careerStatus == 6) && form.workInfoDto.careerStatus">
                                <el-date-picker v-model.trim="form.unemployedDto.unemploymentTime"
                                    class="list_item_width_1" type="date" size="small" clearable placeholder="选择日期"
                                    format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd">
                                </el-date-picker>
                            </el-form-item>
                  
                  
                            <el-form-item label="月收入" class="flex_item_width1" v-if="form.workInfoDto.careerStatus >= 1 && form.workInfoDto.careerStatus <= 5">
                                <el-input class="list_item_width_1" v-model.trim="form.economyDto.monthIncome"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                  
                            <el-form-item label="失业证号" class="flex_item_width1" v-if="(form.workInfoDto.careerStatus == 0 || form.workInfoDto.careerStatus == 6) && form.workInfoDto.careerStatus">
                                <el-input class="list_item_width_1" v-model.trim="form.unemployedDto.unemploymentNum"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                      
                            <el-form-item label="失业原因" class="flex_item_width1" v-if="(form.workInfoDto.careerStatus == 0 || form.workInfoDto.careerStatus == 6) && form.workInfoDto.careerStatus">
                                <el-select v-model.trim="form.unemployedDto.unemploymentReason" placeholder="请选择"
                                    size="small" class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in dicts.unemploymentReasonList" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                    
                            <el-form-item label="再就业优惠证号" class="flex_item_width1"  v-if="(form.workInfoDto.careerStatus == 0 || form.workInfoDto.careerStatus == 6) && form.workInfoDto.careerStatus">
                                <el-input class="list_item_width_1" v-model.trim="form.unemployedDto.employmentNum"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                      
                            <el-form-item label="技术特长"class="flex_item_width1"  v-if="(form.workInfoDto.careerStatus == 0 || form.workInfoDto.careerStatus == 6) && form.workInfoDto.careerStatus">
                                <el-input class="list_item_width_1" v-model.trim="form.unemployedDto.specialSkill"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                      
                 
                            <el-form-item label="是否领取失业金" class="flex_item_width1" v-if="(form.workInfoDto.careerStatus == 0 || form.workInfoDto.careerStatus == 6) && form.workInfoDto.careerStatus">
                                <el-radio-group v-model.trim="form.unemployedDto.unempCompensationFlag">
                                    <el-radio :label="item.value" v-for="item in disabilityFlagList" :key="item.value">{{
                item.label
            }}</el-radio>
                                </el-radio-group>
                            </el-form-item>
                       
                            <el-form-item label="是否就业困难对象" class="flex_item_width1" v-if="(form.workInfoDto.careerStatus == 0 || form.workInfoDto.careerStatus == 6) && form.workInfoDto.careerStatus">
                                <el-radio-group v-model.trim="form.unemployedDto.employmentHardFlag">
                                    <el-radio :label="item.value" v-for="item in disabilityFlagList" :key="item.value">{{
                item.label
            }}</el-radio>
                                </el-radio-group>
                            </el-form-item>
                       
                            <el-form-item label="劳动就业愿望" class="flex_item_width1"  v-if="(form.workInfoDto.careerStatus == 0 || form.workInfoDto.careerStatus == 6) && form.workInfoDto.careerStatus">
                                <el-select v-model.trim="form.workInfoDto.employmentWish" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in dicts.employmentWishList" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                 
                            <el-form-item label="有无赡养人" class="flex_item_width1">
                                <el-radio-group v-model.trim="form.familyInfoDto.elderlyFlag">
                                    <el-radio :label="item.value" v-for="item in hasOptions" :key="item.value"
                                        @click.native="handelClickelderly">{{ item.label
                                        }}</el-radio>
                                </el-radio-group>
                            </el-form-item>
                       
                            <el-form-item label="与赡养人关系" class="flex_item_width1" v-if="form.familyInfoDto.elderlyFlag == 1">
                                <el-select v-model.trim="form.familyInfoDto.elderlyRelation" placeholder="请选择" size="small"
                                    class="list_item_width_1" clearable>
                                    <el-option v-for="(item, index) in dicts.houseHolderRelList" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                       
                            <el-form-item label="赡养人联系电话" class="flex_item_width1"v-if="form.familyInfoDto.elderlyFlag == 1">
                                <el-input class="list_item_width_1" v-model.trim="form.familyInfoDto.dependantMobile"
                                    placeholder="请输入内容" size="small" clearable></el-input>
                            </el-form-item>
                </div>
                <h5>人员标签</h5>
                <div class="stafftag">
                    <stafftag :formType="'add'" ref="stafftag" @showDialog="showDialog"></stafftag>
                </div>
            </el-form>
            <el-row style="margin:24px">
                <el-col :span="24" align="center">
                    <el-button size="small" class="diy-button--white" @click="handlerCancle" plain>取消</el-button>
                    <el-button type="primary" size="small" :loading="btnLoading"
                        @click="handleClickSubmit">保存</el-button>
                    <el-button type="primary" size="small" :loading="btnLoading"
                        @click="handleClickSubmit('house')">提交并补充家庭人员信息</el-button>
                </el-col>
            </el-row>
        </div>
        <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" destroy-on-close width="1028px">
            <resi-expand ref="resiExpand" @submitExpand="submitExpand" @hideExpand="hideExpand"
                :operationType="'add'"></resi-expand>
        </el-dialog>
        <el-dialog title="密码验证" :visible.sync="showCheckPassword">
        <el-form :model="checkPasswordFrom" :rules="checkPasswordRulse" ref="checkPasswordFrom">
            <el-form-item label="密码" prop="password">
            <el-input v-model.trim="checkPasswordFrom.password" autocomplete="off" type="password" placeholder="请输入当前账号密码"
                @keydown.native.enter="handelClickCheckPassword"></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 { requestGet, requestPost } from "@/js/dai/request";
import {
  isCard,
  isPassport,
  isMobile,
  isPhone,
  isHKPassport,
  isTwPassport,
  isSoldier,
} from "@/utils/validate";
import { computedCard } from "@/utils/index";
import {
  idTypeList,
  genderList,
  hasOptions,
  disabilityFlagList,
} from "@/js/columns/constants";
import stafftag from "../modules/portrayal/jumin/cpts/staffTag.vue";
import resiExpand from "./resiExpand";
export default {
  data() {
    return {
    resiId:null,
    showCheckPassword:false,
    checkPasswordFrom: {
        password: "",
    },
    checkPasswordRulse: {
        password: [
          { required: true, message: "请输入密码", trigger: "blur" },
          {
            min: 6,
            max: 18,
            message: "长度在 6 到 18 个字符",
            trigger: "blur",
          },
        ],
    },
    dialogVisible: false,
    dialogTitle: "",
    formList: [],
    orgOptions: [],
    orgOptionProps: {
        value: 'agencyId',
        label: 'agencyName',
        children: 'subAgencyList',
        emitPath: false,
        multiple: false,
        checkStrictly: true
    },
    form: {
                baseInfoDto: {
                    name: null,//姓名
                    idType: null,//证件类型
                    idNum: null,//身份证号
                    nationality: null,//国籍
                    mobile: null,//手机号
                    gender: null,//性别
                    birthday: null,//出生日期
                    nation: null,//民族
                    localResidenceFlag: 0,//是否本地户籍
                    nativePlace: null,//籍贯,
                    remark: null,//备注
                    categoryInfo: {
                        partyFlag: 0,
                        subsistenceAllowanceFlag: 0,
                        ensureHouseFlag: 0,
                        unemployedFlag: 0,
                        fertileWomanFlag: 0,
                        veteranFlag: 0,
                        unitedFrontFlag: 0,
                        petitionOfficerFlag: 0,
                        volunteerFlag: 0,
                        oldPeopleFlag: 0,
                        emptyNesterFlag: 0,
                        specialSupportFlag: 0,
                        disabledFlag: 0,
                        dementedFlag: 0,
                        disabilityFlag: 0,
                        seriousIllnessFlag: 0,
                        chronicDiseaseFlag: 0,
                        specialCrowdFlag: 0,
                        tenantFlag: 0,
                        floatingFlag: 0,
                        liveAloneFlag: 0,
                        publicWelfareFlag: 0,
                        buildingChiefFlag: 0,
                        unitChiefFlag: 0,
                        riskyFlag: 0,
                        delFlag: 0,
                    }
                },
                eduInfoDto: {
                    cultureLevel: null,//文化程度
                },
                familyInfoDto: {
                    marriage: null,//婚姻状况
                    spouseSituation: null,//配偶情况
                    elderlyFlag: null,//有无赡养人
                    elderlyRelation: null,//与赡养人关系
                    dependantMobile: null,//赡养人联系电话	
                },
                resideInfoDtos: [
                    {
                        agencyName: this.$store.state.user.agencyName,
                        agencyId: this.$store.state.user.agencyId,
                        gridId: this.$route.params.gridId,//所属网格id
                        villageId: this.$route.params.villageId,//小区id
                        buildId: this.$route.params.buildId,//楼栋id
                        unitId: this.$route.params.unitId,//单元id
                        moveOutFlag: null,
                        outOfTime: null,//迁出时间
                        homeId: this.$route.params.homeId, //房屋id
                        placeOfDomicile: null,//户籍所在地	
                        currentResidence: null,//现居住地
                        householdSituation: null,//人户状况
                        houseHolderRel: null,//与户主关系
                        resiHouseRel: null,//人房关系
                        optionsV: [],
                        optionsB: [],
                        optionsH: [],
                        optionsD: [],
                    }
                ],
                religionDto: {
                    religion: null,//宗教信仰
                },
                workInfoDto: {
                    careerStatus: null,//就业状况
                    workUnit: null,//工作单位
                    occupation: null,//职业
                },
                specialDto: {
                    specialCategoryCodes: []
                },
                unemployedDto: {
                    originWorkUnit: null,//原工作单位
                    unemploymentTime: null,//失业时间yyyy-MM-dd	
                    unemploymentNum: null,//失业证号	
                    employmentNum: null,//再就业优惠证号	
                    specialSkill: null,//技术特长	
                    unempCompensationFlag: null,//是否领取失业补助金
                    unemploymentReason: null,//失业原因【字典表】code	
                    employmentHardFlag: null,//是否就业困难对象；1是0不是	
                    employmentWish: null,//劳动能力就业愿望	 
                },
                economyDto: {
                    monthIncome: null,//月收入
                },
                oldPeopleDto:{
                    oldPeopleCategories:[],
                    resideSituation: null,
                    oldSubsidy:null
                }
    },
    footerInputList: [
                {
                    id: 'healthDto',
                    children: [
                        {
                            label: "残疾类别",
                            itemType: "select1",
                            formName: "disabilityCategoryCode",
                            opctionUrl: 'sys/dict/data/dictlist',
                            check:'fourFont',
                            opctionParams: { dictType: 'disability_category_code' },
                            opction: []
                        },
                        {
                            label: "残疾等级",
                            check:'fourFont',
                            itemType: "select1",
                            formName: "disabilityLevel",
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: 'disability_level' },
                            opction: []
                        },
                        {
                            label: "残疾证号",
                            check:'fourFont',
                            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',
                    children: [
                        {
                            label: "所患大病",
                            itemType: "checkbox",
                            formName: "illnessCodes",
                            check:'fourFont',
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: 'illness_code' },
                            opction: []
                        },]
                },
                {
                    id: 'chronicDiseaseDto',
                    children: [
                        {
                            label: "所患慢病",
                            check:'fourFont',
                            itemType: "checkbox",
                            formName: "chronicDiseaseCodes",
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: 'chronic_disease_code' },
                            opction: []
                        },
                    ]
                },
                {
                    id: 'baseInfoDto',
                    children: [
                        {
                            label: "死亡时间",
                            itemType: "datepicker1",
                            formName: "deathDate",
                            check:'fourFont'
                        },
                    ]
                },
                {
                    id: 'oldPeopleDto',
                    children: [
                        {
                            label: "老年人分类",
                            itemType: "checkbox",
                            check:'fiveFont',
                            formName: "oldPeopleCategories",
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: 'oldPeople_categories' },
                            opction:[]
                        },
                        {
                            label: "居住情况",
                            itemType: "select1",
                            check:'fourFont',
                            formName: "resideSituation",
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: 'reside_situation' },
                            opction:[]
                        },
                        {
                            label: "高龄补助",
                            // check:'fourFont',
                            itemType: "inputNum",
                            formName: "oldSubsidy",
                        },
                    ]
                },
                {
                    id: 'subsistenceAllowanceDto',
                    children: [
                        {
                            label: "低保类别",
                            itemType: "select1",
                            check:'fourFont',
                            formName: "category",
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: 'subsistence_allowance_category' },
                            opction:[]
                        },
                        {
                            label: "低保享受原因",
                            itemType: "checkbox",
                            check:'sixFont',
                            formName: "reasons",
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: 'subsistence_allowance_reasons' },
                            opction: []
                        },

                    ]
                },
                {
                    id: "parymemberInfoDto",
                    children: [
                        {
                            label: "入党时间",
                            itemType: "datepicker1",
                            formName: "joinTime",
                            check:'fourFont',
                            opction: [
                            ]
                        },
                        {
                            label: "转正时间",
                            itemType: "datepicker1",
                            formName: "positiveTime",
                            opction: [
                            ]
                        },
                        {
                            label: "所属党组织",
                            itemType: "cascader1",
                            check:'fiveFont',
                            formName: "partyOrgId",
                            opction: [
                            ]
                        },
                        {
                            label: "流动党员",
                            itemType: "radio1",
                            formName: "flowFlag",
                            opction: [
                                { label: '是', value: 1 },
                                { label: '否', value: 0 },
                            ]
                        },
                        {
                            label: "流动党员活动证号",
                            itemType: "input1",
                            formName: "flowActNum",
                        },
                        {
                            label: "党组织职务",
                            itemType: "select1",
                            check:'fiveFont',
                            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",
                            check:'fiveFont',
                            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',
                    children: [
                        {
                            label: "所在社区",
                            check:'fourFont',
                            itemType: "input1",
                            formName: "liveCommunity",
                        },
                        {
                            label: "住房性质",
                            check:'fourFont',
                            itemType: "select1",
                            formName: "housingNature",
                            opctionUrl: 'sys/dict/data/house',
                            opctionParams: { formCode: "resi_base_info" },
                            opction: [
                            ]
                        }
                    ]
                },
                {
                    id: 'veteranDto',
                    children: [
                        {
                            label: "入伍日期",
                            itemType: "datepicker1",
                            formName: "joinArmyTime",
                            check:'fourFont',
                            opction: [
                            ]
                        },
                        {
                            label: "退伍日期",
                            check:'fourFont',
                            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",
                            check:'nineFont',
                            formName: "pubWelfareJobFlag",
                            opction: [
                                { label: '是', value: 1 },
                                { label: '否', value: 0 },
                            ]
                        }
                    ]
                },
                {
                    id: 'unitedFrontDto',
                    children: [{
                        label: "统战类型",
                        check:'fourFont',
                        itemType: "input1",
                        formName: "unitedFrontType",
                    }]
                },
                {
                    id: 'volunteerDto',
                    children: [
                        {
                            label: "志愿者类别",
                            itemType: "checkbox",
                            formName: "volunteerCategory",
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: "VOLUNTEER_CATEGORY" },
                            opction: [
                            ]
                        }
                    ]
                },
                {
                    id: 'specialSupportDto',
                    children: [

                        {//0
                            label: "特扶类别",
                            check:'fourFont',
                            itemType: "select1",
                            formName: "specialSupportType",
                            opction: [
                                {
                                    value: '1',
                                    label: '失独'
                                },
                                {
                                    value: '2',
                                    label: '伤残'
                                }
                            ]
                        },
                        {//1
                            label: "子女姓名",
                            // check:'fourFont',
                            itemType: "input1",
                            formName: "childName",
                            opction: []
                        },
                        {//2
                            label: "子女性别",
                            // check:'fourFont',
                            itemType: "select1",
                            formName: "childGender",
                            opction: [
                                {
                                    value: '1',
                                    label: '男'
                                },
                                {
                                    value: '2',
                                    label: '女'
                                }
                            ]
                        },
                        {
                            label: "子女死亡日期",
                            // check:'sixFont',
                            itemType: "datepicker1",
                            formName: "certificateDate",
                            opction: [],
                        },
                        {
                            label: "子女伤残类别",
                            check:'sixFont',
                            itemType: "select1",
                            formName: "childDisabilityCategoryCode",
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: 'disability_category_code' },
                            opction: []
                        },
                        {
                            label: "子女伤残等级",
                            // check:'sixFont',
                            itemType: "select1",
                            formName: "childDisabilityLevel",
                            opctionUrl: 'sys/dict/data/dictlist',
                            opctionParams: { dictType: 'disability_level' },
                            opction: []
                        }

                    ]
                },
    ],
    idTypeList,
    genderList,
    hasOptions,
    disabilityFlagList,
    btnLoading: false,
    rules: {
        "baseInfoDto.name": [
          { required: true, message: "请输入姓名", trigger: "blur" },
        ],
        "baseInfoDto.idType": [
          { required: true, message: "请选择证件类型", trigger: "blur" },
        ],
        "baseInfoDto.idNum": [
          { required: true, message: "请输入证件号码", trigger: "blur" },
        ],
        "baseInfoDto.mobile": [
          { required: true, message: "请输入电话", trigger: "blur" },
        ],
        "baseInfoDto.nationality": [
          { required: true, message: "请选择国籍", trigger: "blur" },
        ],
    },
    dicts: {
        educationList: [], //文化程度
        nationList: [], //民族
        nationalityList: [], //国籍
        marriageList: [], //婚姻状况
        householdSituationList: [], //人户状况
        houseHolderRelList: [], //与户主关系
        careerStatusList: [], //就业状况
        spouseSituationList: [], //配偶情况
        unemploymentReasonList: [], //失业原因
        employmentWishList: [], //就业意愿
        resiHouseRelList: [
          {
            label: "自住",
            value: 0,
          },
          {
            label: "租住",
            value: 1,
          },
        ],
    },
    logLevelChecked: 0,
    };
  },
  created() {
    this.getDicts();
    this.getOrgTreeList();

    this.initHouseBind();
  },
  methods: {
    handelClickCheckPassword() {
      this.$refs.checkPasswordFrom.validate((vali) => {
        if (vali) {
          this.saveCheckPassword(this.checkPasswordFrom.password);
        } else {
          return false;
        }
      });
    },
    async saveCheckPassword(password){
      const url = `/actual/base/residentBaseInfo/getResiUserInfo/${this.resiId}`;
          let parm = {
            password,
          };
          const { data, code, msg } = await requestPost(url, parm);
          if (code === 0) {
            this.showCheckPassword = false;
            this.$router.push({
              name: "edit-resi",
              query: { id: this.resiId },
              params: { idNum: data.idNum, mobile: data.mobile, name: data.name, nationality: data.nationality },
            });
            this.checkPasswordFrom.password = "";
          } else {
            this.$message.error(msg);
          }
    },
    // 从房屋画像进行添加居民时绑定房屋信息
    initHouseBind() {
      for (let i in this.form.resideInfoDtos) {
        this.getValiheList(i);
        this.getBuildList(i);
        this.getHouseList(i);
        this.getUniList(i);
        this.form.resideInfoDtos[i].orgOptions = [];
        this.getOrgTreeList(this.form.resideInfoDtos[i].agencyId, i);
      }
    },
    async getDicts() {
      try {
        const requests = [
          this.$http.post("sys/dict/data/dictlist", {
            dictType: "nationality",
          }),
          this.$http.post("sys/dict/data/nation", {
            formCode: "resi_base_info",
          }),
          this.$http.post("sys/dict/data/education", {
            formCode: "resi_base_info",
          }),
          this.$http.post("sys/dict/data/dictlist", {
            dictType: "marriage",
          }),
          this.$http.post("sys/dict/data/dictlist", {
            dictType: "household_situation",
          }),
          this.$http.post("sys/dict/data/relationship", {
            formCode: "resi_base_info",
          }),
          this.$http.post("sys/dict/data/dictlist", {
            dictType: "career_status",
          }),
          this.$http.post("sys/dict/data/dictlist", {
            dictType: "spouse_situation",
          }),
          this.$http.post("sys/dict/data/dictlist", {
            dictType: "unemployment_reason",
          }),
          this.$http.post("sys/dict/data/dictlist", {
            dictType: "career_goals",
          }),
        ];
        const dictKeys = [
          "nationalityList",
          "nationList",
          "educationList",
          "marriageList",
          "householdSituationList",
          "houseHolderRelList",
          "careerStatusList",
          "spouseSituationList",
          "unemploymentReasonList",
          "employmentWishList",
        ]; // 对应的键名

        const results = await Promise.all(requests);
        results.forEach((result, index) => {
          if (result.data.code === 0) {
            this.dicts[dictKeys[index]].push(...result.data.data);
          } else {
            console.log(`获取${dictKeys[index]}失败: ${result.data.msg}`);
          }
        });
      } catch (error) {
        console.log("获取字典失败: ", error);
      }
    },
    getOrgTreeList() {
      this.$http
        .post("/gov/org/customeragency/agencygridtree", {})
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          } else {
            console.log("获取组织树成功", res.data);
            this.orgOptions = [];
            this.orgOptions.push(res.data);
          }
        })
        .catch(() => {
          return this.$message.error("网络错误");
        });
    },
    handelChangeResiHouseRel(val, index) {
      this.form.resideInfoDtos[index].householdSituation =
        val == 0 ? "rhyz" : "rzhbz";
    },
    handleChangeV(index) {
      console.log(this.form.resideInfoDtos[index].villageId);
      this.form.resideInfoDtos[index].buildId = "";
      this.form.resideInfoDtos[index].unitId = "";
      this.form.resideInfoDtos[index].homeId = "";
      this.getBuildList(index);
      this.getUniList(index);
      this.getHouseList(index);
    },
    handleChangeB(index) {
      this.form.resideInfoDtos[index].unitId = "";
      this.form.resideInfoDtos[index].homeId = "";
      this.getUniList(index);
      this.getHouseList(index);
    },
    handleChangeD(index) {
      this.form.resideInfoDtos[index].homeId = "";
      this.getHouseList(index);
    },
    handleChangeH(i) {
      // let item = this.optionsH.find((item, index) => index === i);
      // if (item && item.type == '1') {
      //     // this.form.IS_TENANT = '1'
      //     console.log('item-----', item)
      // }
      // else
      //  this.form.IS_TENANT = '0'
    },
    handleChangeAgency(index) {
      let obj = this.$refs[`myCascader`][index].getCheckedNodes()[0]
        ? this.$refs["myCascader"][index].getCheckedNodes()[0].data
        : null;
      if (obj) {
        if (obj.level === "grid") {
          this.form.resideInfoDtos[index].gridId = obj.agencyId;
          this.form.resideInfoDtos[index].agencyId = obj.pid;

          this.form.resideInfoDtos[index].villageId = "";
          this.form.resideInfoDtos[index].buildId = "";
          this.form.resideInfoDtos[index].unitId = "";
          this.form.resideInfoDtos[index].homeId = "";

                    this.getValiheList(index);
                } else {
                    // this.selGridId = []
                    this.form.resideInfoDtos[index].gridId = ''
                    this.form.resideInfoDtos[index].agencyId = ''
                    this.$message.info('请选择网格')
                    return false
                }

            }

        },
        getValiheList(index) {
            console.log(this.form.resideInfoDtos[index].gridId, '小区接口');
            console.log(this.form.resideInfoDtos);
            const { user } = this.$store.state
            this.$http.post('/actual/base/communityQuarters/listQuartersOptions', { gridId: this.form.resideInfoDtos[index].gridId, agencyId: user.agencyId }).then(({ data: res }) => {
                if (res.code !== 0) {
                    return this.$message.error(res.msg)
                } else {
                    this.form.resideInfoDtos[index].optionsV = []
                    this.form.resideInfoDtos[index].optionsV.push(...res.data)
                }
            }).catch((err) => {
                console.log(err);
                return this.$message.error('网络错误')
            })
        },
        getBuildList(index) {
            this.$http.post('/actual/base/communityBuilding/buildingoption', { quartersId: this.form.resideInfoDtos[index].villageId }).then(({ data: res }) => {
                if (res.code !== 0) {
                    return this.$message.error(res.msg)
                } else {
                    this.form.resideInfoDtos[index].optionsB = res.data
                }
            }).catch(() => {
                return this.$message.error('网络错误')
            })
        },
        getUniList(index) {
            this.$http.post('/actual/base/communityBuildingUnit/unitoption', { buildingId: this.form.resideInfoDtos[index].buildId }).then(({ data: res }) => {
                if (res.code !== 0) {
                    return this.$message.error(res.msg)
                } else {
                    this.form.resideInfoDtos[index].optionsD = res.data
                }
            }).catch(() => {
                return this.$message.error('网络错误')
            })
        },
        getHouseList(index) {
            this.$http.post('/actual/base/communityHouse/houseoption', { unitId: this.form.resideInfoDtos[index].unitId }).then(({ data: res }) => {
                if (res.code !== 0) {
                    return this.$message.error(res.msg)
                } else {
                    this.form.resideInfoDtos[index].optionsH = res.data
                }
            }).catch(() => {
                return this.$message.error('网络错误')
            })
        },
        handelClickAddHouse() {
            this.form.resideInfoDtos.push(
                {
                    agencyName: this.$store.state.user.agencyName,
                    agencyId: this.$store.state.user.agencyId,
                    gridId: null,//所属网格id
                    villageId: null,//小区id
                    buildId: null,//楼栋id
                    unitId: null,//单元id
                    moveOutFlag: null,
                    outOfTime: null,//迁出时间
                    homeId: null, //房屋id
                    placeOfDomicile: null,//户籍所在地	
                    currentResidence: null,//现居住地
                    householdSituation: null,//人户状况
                    houseHolderRel: null,//与户主关系
                    resiHouseRel: null,//人房关系
                    optionsV: [],
                    optionsB: [],
                    optionsH: [],
                    optionsD: [],
                }
            )
        },
        handelClickDelHouse(i) {
            this.form.resideInfoDtos = this.form.resideInfoDtos.filter((item, index) => index != i)
        },
        handelCLickIdType(val){
          if(val === 1){
            this.getResidentInfoByIdNum()
          }
        },
        handleValidBlur() {
            if (this.form.baseInfoDto.idType == 1) {
              this.getResidentInfoByIdNum()
            }
            if (!isCard(this.form.baseInfoDto.idNum) && !isPassport(this.form.baseInfoDto.idNum)) return
            const { user } = this.$store.state
            let huji = '', i = 0
            if (user.areaCodePath && user.areaCodePath.length > 0) {
                i = user.areaCodePath.length - 1
                huji = user.areaCodePath[i].length > 6 ? user.areaCodePath[i].substr(0, 6) : user.areaCodePath[i]
            }

            if (this.form.baseInfoDto.idNum.length === 18 || this.form.baseInfoDto.idNum.length === 15) {
                const _id = this.form.baseInfoDto.idNum.substr(0, 6)
                const { sex, birth, age } = computedCard(this.form.baseInfoDto.idNum);
                this.form.baseInfoDto.birthday = birth;
                this.form.baseInfoDto.gender = sex == 1 ? '1' : '2';
                // this.form.baseInfoDto.categoryInfo.oldPeopleFlag = age >= 60 ? 1 : 0;
                let obj = {oldPeopleFlag:age >= 60 ? 1 : 0,fertileWomanFlag:this.form.baseInfoDto.gender == 2 && (age >= 18 && age < 49)? 1 : 0}
                this.$refs['stafftag'].updatedForm(obj);
                this.form.oldPeopleDto.oldPeopleCategories = ['oldPeopleFlag'];
                // this.form.IS_BDHJ = huji == _id ? '1' : ''
                // 身份证前端验证角色方法 因原型没有注释
                // this.validateIdcard(this.form.idNum)

            }

        },
        async getResidentInfoByIdNum(){
            try {
                let url = '/actual/base/residentBaseInfo/getResidentInfoByIdNum'
                let parm = {
                    idType: this.form.baseInfoDto.idType,
                    idNum: this.form.baseInfoDto.idNum
                }
                let { code, data, msg } = await requestGet(url,parm)
                if (code == 0 && data != null) {
                    this.$confirm(`该居民已存在于“${data.homeNames.join(',')}”是否继续填写`, {
                    confirmButtonText: '前往修改',
                    cancelButtonText: '继续填写',
                    type: 'warning'
                }).then(() => {
                    this.resiId = data.id
                    this.showCheckPassword = true;

                }).catch(() => {
                    
                });

                } else if (code >= 8000) {
                    this.$message.error(msg);
                    this.btnLoading = false;
                }
            }
            catch (error) {
                // this.$message.error(msg);
                console.log(msg);
            }
        },
        handleLocalRadio(e) {
            if (e.target.type === 'radio') return
            this.form.baseInfoDto.localResidenceFlag = this.form.baseInfoDto.localResidenceFlag === 0 ? 1 : 0;
            console.log(this.form.baseInfoDto.localResidenceFlag);
        },
        handelClickMarriage() {
            this.form.familyInfoDto.spouseSituation = null
        },
        handelClickelderly() {
            this.form.familyInfoDto.elderlyRelation = null
            this.form.familyInfoDto.dependantMobile = null
        },
        handelClickCareerStatus(val) {
            this.form.unemployedDto = {
                originWorkUnit: null,//原工作单位
                unemploymentTime: null,//失业时间yyyy-MM-dd	
                unemploymentNum: null,//失业证号	
                employmentNum: null,//再就业优惠证号	
                specialSkill: null,//技术特长	
                unempCompensationFlag: null,//是否领取失业补助金
                unemploymentReason: null,//失业原因【字典表】code	
                employmentHardFlag: null,//是否就业困难对象；1是0不是	
                employmentWish: null,//劳动能力就业愿望

            }
            this.form.workInfoDto = {
                careerStatus: val,//就业状况
                workUnit: null,//工作单位
                occupation: null,//职业
            }
            if (val == 0) {
                this.form.baseInfoDto.categoryInfo.unemployedFlag = 1
            }else{
                this.form.baseInfoDto.categoryInfo.unemployedFlag = 0
            }
        },
        handlerCancle() {
            this.$store.state.contentTabs = this.$store.state.contentTabs.filter(
                (item) => item.name !== 'add-resi'
            );
            let tab =
                this.$store.state.contentTabs[
                this.$store.state.contentTabs.length - 1
                ];
            this.$router.push({
                name: tab.name,
                params: { ...tab.params },
                query: { ...tab.query },
            });
        },
        handleClickSubmit(house) {
            this.$refs['addForm'].validate((valid) => {
                if (valid) {
                    this.form.resideInfoDtos.forEach(item => {
                        delete item.optionsV;
                        delete item.optionsB;
                        delete item.optionsH;
                        delete item.optionsD;
                    });
                    this.submitForm(house);
                }
            })
        },
        async submitForm(house) {
            this.btnLoading = true;
            try {
                let url = '/actual/base/residentBaseInfo/save'
                let parm = {
                    ...this.form
                }
                let { code, data, msg } = await requestPost(url, parm)
                if (code == 0) {
                    if (house != 'house') {
                        this.$message.success('保存成功');
                        this.$refs['addForm'].resetFields();
                        this.handlerCancle();
                    } else {
                        this.$message.success('保存成功');
                        let homeArr = JSON.parse(JSON.stringify(this.form.resideInfoDtos));
                        this.$refs['addForm'].resetFields();
                        this.form.resideInfoDtos = homeArr
                    }
                    this.btnLoading = false;

                } else if (code >= 8000) {
                    this.$message.error(msg);
                    this.btnLoading = false;
                }
            }
            catch (error) {
                this.$message.error(msg);
            }
        },
        showDialog({ index, value }, event) {
            if (value == 1) {
                value = 'parymemberInfoDto'
                this.form.baseInfoDto.categoryInfo.partyFlag = 1;
            } else if (value == 0) {
                this.form.baseInfoDto.categoryInfo.partyFlag = 0;
            } else if (value == 2) {
                this.form.baseInfoDto.categoryInfo.partyFlag = 2;
            }
            if (index != 3 && index) {
                if(value === 'deathFlag'){
                  this.form.baseInfoDto.deathFlag = event?1:0
                }else{
                  this.form.baseInfoDto.categoryInfo[value] = event ? 1 : 0;
                }
                this.form.baseInfoDto.categoryInfo[value] = event ? 1 : 0;
            } else if (index == 3) {
                if (event) {
                    this.form.baseInfoDto.categoryInfo.specialCrowdFlag = 1;
                    if (value == 'unitedFrontFlag' || value == 'petitionOfficerFlag') {
                        this.form.baseInfoDto.categoryInfo[value] = 1
                    }
                    this.form.specialDto.specialCategoryCodes.push(value);
                } else {
                    this.form.specialDto.specialCategoryCodes = this.form.specialDto.specialCategoryCodes.filter(item => item != value);
                    if (value == 'unitedFrontFlag' || value == 'petitionOfficerFlag') {
                        this.form.baseInfoDto.categoryInfo[value] = 0
                    }
                }
            }
            const map = {
                '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: 'baseInfoDto', formType: 'baseInfoDto', 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: '志愿者' },
            };

      if (map[value]) {
        this.dialogTitle = map[value].title;
        this.dialogVisible =
          (event == true || value == "parymemberInfoDto") &&
          this.dialogTitle != "";
        this.$nextTick(() => {
          this.$refs["resiExpand"].formList = [
            this.footerInputList.find((item) => item.id === map[value].formId),
          ];
          this.$refs["resiExpand"].formType = map[value].formType;
          this.$refs["resiExpand"].showForm();
        });
      }
    },
    // 提交扩展信息
    submitExpand(form, formType) {
      this.form[formType] = form[formType];
      this.dialogVisible = false;
    },
    hideExpand(formType) {
        if(formType!= 'baseInfoDto'){
        delete this.form[formType];
      }else{
        this.form['baseInfoDto'].deathFlag = 0;
      }
      this.dialogVisible = false;
    },
  },
  components: { stafftag, resiExpand },
  computed: {},
  watch: {},
};
</script>

<style lang='scss' scoped>
@import "@/assets/scss/modules/management/form-main.scss";
@import "@/assets/scss/pages/resiAdd.scss";
</style>
