<template>
  <div class="g-main ">
    <el-form class="m-search"
             :model="form"
             ref="formId">
      <div>

        <el-form-item v-if="formType==='add'"
                      prop="gridId"
                      :rules="rulesForm.gridId"
                      label="所属组织"
                      label-width="100px">
          <el-cascader class="item-agency"
                       ref="myCascader"
                       clearable
                       size="small"
                       v-model=" selGridId"
                       :options="orgOptions"
                       :props="orgOptionProps"
                       @change="handleChangeAgency"></el-cascader>

        </el-form-item>
        <el-form-item v-else
                      prop="gridId"
                      :rules="rulesForm.gridId"
                      label="所属组织"
                      label-width="100px">
          <span>{{form.gridName||'--'}}</span>

        </el-form-item>
      </div>
      <div class="resi-form">
        <el-form-item label="所属房屋"
                      label-width="100px"
                      :required="true">
          <div class="f-flex">
            <el-form-item prop="villageId"
                          class="u-item-width-communitycascader f-bto0"
                          :rules="rulesForm.villageId">
              <el-select v-model.trim="form.villageId"
                         placeholder="请选择小区"
                         size="small"
                         class="u-item-width-communitycascader f-bto0"
                         clearable
                         @change="handleChangeV">
                <el-option v-for="item in optionsV"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="buildId"
                          :rules="rulesForm.buildId">
              <el-select v-model.trim="form.buildId"
                         placeholder="楼号"
                         size="small"
                         clearable
                         class="u-item-width-buildcascader f-bto0"
                         @change="handleChangeB">
                <el-option v-for="item in optionsB"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="unitId"
                          :rules="rulesForm.unitId">
              <el-select v-model.trim="form.unitId"
                         placeholder="单元"
                         size="small"
                         clearable
                         class="u-item-width-buildcascader f-bto0"
                         @change="handleChangeD">
                <el-option v-for="item in optionsD"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="homeId"
                          :rules="rulesForm.homeId">
              <el-select v-model.trim="form.homeId"
                         placeholder="房号"
                         size="small"
                         clearable
                         class="u-item-width-buildcascader f-bto0"
                         @change="handleChangeH">
                <el-option v-for="item in optionsH"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </div>
        </el-form-item>
        <el-form-item v-for="(item,index)  in basicInformation"
                      :label-width="'100px'"
                      :label="item.label"
                      :key="index"
                      :class="item.itemType=='textarea'?'textareaDidth':''"
                      :rules="item.rules"
                      :prop="item.formName">
          <template v-if="item.itemType == 'radio'">
            <section class="u-item-width-normal">
              <el-radio v-for="ns in item.opction"
                        :key="ns.value"
                        size="small"
                        v-model.trim="form[item.formName]"
                        :label="ns.value">
                {{ ns.label }}</el-radio>
            </section>
          </template>
          <template v-if="item.itemType == 'input'">
            <el-input clearable
                      size="small"
                      :placeholder="`请输入${item.label}`"
                      v-model.trim="form[item.formName]"
                      class="u-item-width-normal"
                      @blur="handleValidBlur(item)">
            </el-input>
          </template>
          <template v-else-if="item.itemType == 'select'">
            <el-select v-model="form[item.formName]"
                       :placeholder="`请选择${item.label}`"
                       size="small"
                       clearable
                       class="u-item-width-normal">
              <el-option v-for="items in item.opction "
                         :key="items.value"
                         :label="items.label"
                         :value="items.value">
              </el-option>
            </el-select>
          </template>
          <template v-else-if="item.itemType == 'textarea'">
            <el-input type="textarea"
                      placeholder="请输入内容"
                      class="item-width-textarea"
                      maxlength="120"
                      show-word-limit
                      resize="none"
                      rows="3"
                      v-model.trim="form[item.formName]">
            </el-input>
          </template>
          <template v-else-if="item.itemType == 'checkbox'"
                    :label="item.label">
            <el-checkbox v-for="(items,indexs) in item.opction"
                         style="width:70px"
                         :key="indexs"
                         :label="items.label"
                         :true-label="'1'"
                         :false-label="'0'"
                         size="small"
                         v-model="form[items.formName]"
                         @change="val => handleChangeCheckbox(items,val)">
            </el-checkbox>
          </template>
          <template v-else-if="item.itemType == 'datepicker'"
                    :label="item.label">
            <el-date-picker v-model.trim="form.birthday"
                            class="u-item-width-normal"
                            type="date"
                            size="small"
                            clearable
                            placeholder="选择日期"
                            format="yyyy 年 MM 月 dd 日"
                            value-format="yyyy-MM-dd">
            </el-date-picker>
          </template>

        </el-form-item>
      </div>
      <!-- 这里开始就是底部的input了------------------------------------------------------------------->
      <el-tabs v-model="activeName"
               @tab-click="handleClickTab">
        <el-tab-pane v-for="item in tabsList"
                     :key="item.groupId"
                     :label="item.label"
                     :name="'group' + item.groupId">
          <template v-for="itemj in footerInputList">
            <section v-if="item.groupId == itemj.id"
                     class="f-flex"
                     style="flex-wrap: wrap;">
              <template v-if="itemj.id==='specialSupportDto'">

                <el-form-item label-width="105px"
                              label="特扶类别">

                  <el-select v-model="form[itemj.id].specialSupportType"
                             :placeholder="`请选择特扶类别`"
                             size="small"
                             clearable
                             class="u-item-width-normal">
                    <el-option v-for="items in itemj.children[0].opction"
                               :key="items.value"
                               :label="items.label"
                               :value="items.value">
                    </el-option>
                  </el-select>

                </el-form-item>
                <el-form-item v-if="form[itemj.id].specialSupportType==='2'"
                              label-width="105px"
                              label="子女姓名">
                  <el-input :placeholder="`请输入子女姓名`"
                            class="u-item-width-normal"
                            size="small"
                            v-model.trim="form[itemj.id].childName"
                            clearable>
                  </el-input>
                </el-form-item>
                <el-form-item label-width="105px"
                              label="子女性别">
                  <el-select v-model="form[itemj.id].childGender"
                             :placeholder="`请选择子女性别`"
                             size="small"
                             clearable
                             class="u-item-width-normal">
                    <el-option v-for="items in itemj.children[2].opction"
                               :key="items.value"
                               :label="items.label"
                               :value="items.value">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item v-if="form[itemj.id].specialSupportType==='1'"
                              label-width="105px"
                              label="子女死亡日期">
                  <el-date-picker v-model.trim="form[itemj.id].childDeathDate"
                                  class="u-item-width-normal"
                                  type="date"
                                  size="small"
                                  clearable
                                  placeholder="选择日期"
                                  format="yyyy 年 MM 月 dd 日"
                                  value-format="yyyy-MM-dd">
                  </el-date-picker>
                </el-form-item>
                <el-form-item v-if="form[itemj.id].specialSupportType==='2'"
                              label-width="105px"
                              label="伤残类别">
                  <el-select v-model="form[itemj.id].childDisabilityCategoryCode"
                             :placeholder="`请选择伤残类别`"
                             size="small"
                             clearable
                             class="u-item-width-normal">
                    <el-option v-for="items in itemj.children[4].opction"
                               :key="items.value"
                               :label="items.label"
                               :value="items.value">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item v-if="form[itemj.id].specialSupportType==='2'"
                              label-width="105px"
                              label="伤残等级">
                  <el-select v-model="form[itemj.id].childDisabilityLevel"
                             :placeholder="`请选择伤残等级`"
                             size="small"
                             clearable
                             class="u-item-width-normal">
                    <el-option v-for="items in itemj.children[5].opction"
                               :key="items.value"
                               :label="items.label"
                               :value="items.value">
                    </el-option>
                  </el-select>
                </el-form-item>

                <el-form-item label-width="105px"
                              label="备注"
                              class="textareaDidth">
                  <el-input type="textarea"
                            :placeholder="`请输入备注`"
                            class="item-width-textarea"
                            maxlength="120"
                            size="small"
                            show-word-limit
                            resize="none"
                            rows="3"
                            v-model.trim="form[itemj.id].remark">
                  </el-input>
                </el-form-item>
              </template>
              <template v-else>
                <el-form-item v-for="(itemk,index) in itemj.children"
                              :key="index"
                              label-width="105px"
                              :label="itemk.label"
                              :class="itemk.itemType=='textarea'?'textareaDidth':''">
                  <template v-if="itemk.itemType == 'radio1'">
                    <section class="u-item-width-normal">
                      <el-radio v-for="ns in itemk.opction"
                                :key="ns.value"
                                size="small"
                                v-model.trim="form[itemj.id][itemk.formName]"
                                :label="ns.value">
                        {{ ns.label }}
                      </el-radio>
                    </section>
                  </template>
                  <template v-else-if="itemk.itemType=='select1' &&itemk.showFlag!=='0' ">
                    <el-select v-model="form[itemj.id][itemk.formName]"
                               :placeholder="`请选择${itemk.label}`"
                               size="small"
                               :multiple="itemk.multiple"
                               :collapse-tags="itemk.collapseTags"
                               clearable
                               :style="{'width':itemk.formName=='specialCategoryCode'?'183px':''}"
                               class="u-item-width-normal">
                      <el-option v-for="items in itemk.opction"
                                 :key="items.value"
                                 :label="items.label"
                                 :value="items.value">
                      </el-option>
                    </el-select>
                  </template>
                  <template v-else-if="itemk.itemType=='textarea1'">
                    <el-input type="textarea"
                              :placeholder="`请输入${itemk.label}`"
                              class="item-width-textarea"
                              maxlength="120"
                              size="small"
                              show-word-limit
                              resize="none"
                              rows="3"
                              v-model.trim="form[itemj.id][itemk.formName]">
                    </el-input>
                  </template>
                  <template v-else-if="itemk.itemType=='input1'">
                    <el-input :placeholder="`请输入${itemk.label}`"
                              class="u-item-width-normal"
                              size="small"
                              :style="{'margin-right':itemk.label == '备注'?'50px':''}"
                              v-model.trim="form[itemj.id][itemk.formName]"
                              clearable>
                    </el-input>
                  </template>
                  <template v-else-if="itemk.itemType=='inputNum'">
                    <el-input :placeholder="`请输入${itemk.label}`"
                              size="small"
                              class="u-item-width-normal-text"
                              :style="{'margin-right':itemk.label == '备注'?'50px':''}"
                              v-model.trim="form[itemj.id][itemk.formName]"
                              clearable
                              @blur="checkNumberInput(itemj.id,itemk.formName)">
                    </el-input><span class="u-data-tag">元</span>
                  </template>
                  <template v-else-if="itemk.itemType=='checkbox'">
                    <el-checkbox-group size="small"
                                       v-model="form[itemj.id][itemk.formName]">
                      <el-checkbox v-for="items in itemk.opction"
                                   :label="items.value"
                                   :style="{'margin-right':items.label != itemk.label? '' :'19px'}"
                                   :key="items.value"
                                   :value="items.value">{{items.label}}</el-checkbox>
                    </el-checkbox-group>
                  </template>
                  <template v-else-if="itemk.itemType == 'datepicker1' &&itemk.showFlag!=='0'">
                    <el-date-picker v-model.trim="form[itemj.id][itemk.formName]"
                                    class="u-item-width-normal"
                                    type="date"
                                    size="small"
                                    clearable
                                    placeholder="选择日期"
                                    format="yyyy 年 MM 月 dd 日"
                                    value-format="yyyy-MM-dd">
                    </el-date-picker>
                  </template>
                  <template v-else-if="itemk.itemType == 'cascader1'">
                    <el-cascader v-model="form.parymemberInfoDto.partyOrgId"
                                   :props="casProps"
                                   :options="itemk.opction"
                                   class="u-item-width-normal"
                                   clearable
                                   size="small"
                                   @change="handlePartyOrgCascadarChange"
                                  ></el-cascader>
                  </template>
                  <template v-else-if="itemk.itemType == 'number'">
                    <el-input-number class="u-item-width-normal"
                                     size="small"
                                     :min="1"
                                     :max="10"
                                     v-model.trim="form[itemj.id][itemk.formName]"></el-input-number>
                  </template>

                </el-form-item>
              </template>
            </section>
          </template>
        </el-tab-pane>
      </el-tabs>
    </el-form>
  </div>
</template>

<script>
import { isCard, isPassport, isMobile, isPhone } from '@/utils/validate'
import { computedCard } from '@/utils/index'
import { idTypeList } from "@/js/columns/constants";
import {requestGet}  from "@/js/dai/request";
export default {
  name: 'resiForm',
  props: {
    formId: {
      type: String,
      default: 'resiForm'
    },
    formType: {
      type: String,
      default: 'add'
    },
  },
  data () {
    return {
      selGridId: [],
      optionsV: [],
      optionsB: [],
      optionsH: [],
      optionsD: [],
      optionsG: [],
      casProps:{
        value: 'id', 
        label: 'partyOrgName', 
        lazy:true,
        lazyLoad: (node, resolve) => {
          this.handleNextOrgTreeClick(node, resolve)
        },
        checkStrictly: true,
        multiple: false
      },
      activeName: 'groupeduInfoDto',
      validateFlag: null,
      disabilityCategoryCode: [],
      tabFlag: true,

      orgOptions: [],
      orgOptionProps: {
        value: 'agencyId',
        label: 'agencyName',
        children: 'subAgencyList',
        emitPath: false,
        multiple: false,
        checkStrictly: true
      },

      // 基本信息input
      basicInformation: [
        {
          label: "本地户籍",
          itemType: "radio",
          formName: "localResidenceFlag",
          opction: [
            { label: '是', value: '1' },
            { label: '否', value: '0' }
          ],
        },
        {
          label: "居民姓名",
          itemType: "input",
          requiredFlag: true,
          formName: "name",
          rules: [{ required: true, message: '居民姓名不能为空', trigger: 'blur' }],
          opction: [],
        },
        {
          label: "联系电话",
          itemType: "input",
          formName: "mobile",
          // rules:[{required:true,message:'联系电话不能为空',trigger:'change' | blur },],
          opction: [],
        },
        {
          label: '国籍',
          itemType: "select",
          rules: [{ required: true, message: '国籍不能为空' }],
          formName: 'nationality',
          opction: [],
        },
        {
          label: '证件类型',
          itemType: "select",
          formName: 'idType',
          rules: [{ required: true, message: '证件类型不能为空' }],
          opction: idTypeList,
        },
        {
          label: "证件号",
          itemType: "input",
          formName: "idNum",
          rules: [{ required: true, message: '证件号不能为空' },
          {
            validator: (rule, value, callback) => {
              if (!/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/.test(value)) {

                return callback(new Error('证件格式不符合'));
              }
              callback()
            }, trigger: 'change' | blur
          }
          ],
          opction: [],
        },
        {
          label: "性别",
          itemType: "radio",
          formName: "gender",
          opction: [
            { label: '男', value: '1' },
            { label: '女', value: '2' }
          ],
        },
        {
          label: "民族",
          itemType: "select",
          formName: "nation",
          // rules:[{required:true,message:'民族不能为空',trigger:'change' | blur },],
          opction: [],
        },
        {
          label: '生日',
          itemType: "datepicker",
          formName: 'birthday'
        },

        {
          label: '备注',
          itemType: "textarea",
          formName: 'remark'
        },
        {
          label: '居民分类',
          itemType: "checkbox",
          opction: [
            { label: '党员', value: '0', formName: "partyFlag" },
            { label: '低保人员', value: '0', formName: "subsistenceAllowanceFlag" },
            { label: '保障房人员', value: '0', formName: "ensureHouseFlag" },
            { label: '失业人员', value: '0', formName: "unemployedFlag" },
            { label: '育龄妇女', value: '0', formName: "fertileWomanFlag" },
            { label: '退役军人', value: '0', formName: "veteranFlag" },
            { label: '统战人员', value: '0', formName: "unitedFrontFlag" },
            { label: '信访人员', value: '0', formName: "petitionOfficerFlag" },
            { label: '志愿者', value: '0', formName: "volunteerFlag" },
            { label: '特扶人员', value: '0', formName: "specialSupportFlag" },
            { label: '租户', value: '0', formName: "tenantFlag" },
            { label: '流动人口', value: '0', formName: "floatingFlag" },
            { label: '特殊人群', value: '0', formName: "specialCrowdFlag" },
            { label: '老年人', value: '0', formName: "oldPeopleFlag" },
            { label: '空巢老人', value: '0', formName: "emptyNesterFlag" },
            { label: '独居老人', value: '0', formName: "liveAloneFlag" },
            { label: '失能老人', value: '0', formName: "disabledFlag" },
            { label: '失智老人', value: '0', formName: "dementedFlag" },
            { label: '残疾', value: '0', formName: "disabilityFlag" },
            { label: '大病', value: '0', formName: "seriousIllnessFlag" },
            { label: '慢病', value: '0', formName: "chronicDiseaseFlag" },
            { label: '公益岗人员', value: '0', formName: "publicWelfareFlag" }

          ]
        }
      ],
      // 底部input
      footerInputList: [
        {
          id: 'eduInfoDto',
          children: [
            {
              label: "文化程度",
              itemType: "select1",
              formName: "cultureLevel",
              opction: []
            },
            {
              label: "备注",
              itemType: "textarea1",
              formName: "eduRemark",
              opction: []
            }
          ]
        },
        {
          id: 'hobbyInfoDto',
          children: [{
            label: "兴趣特长",
            itemType: "checkbox",
            formName: "hobbyCode",
            opction: []
          },
          {
            label: '兴趣',
            itemType: "input1",
            formName: "interestDesc",
          },
          {
            label: '备注',
            itemType: "textarea1",
            formName: "hobbyRemark",
          }]
        },
        {
          id: 'religionDto',
          children: [
            {
              label: "宗教",
              itemType: "input1",
              formName: "religion",
              opction: []
            },
            {
              label: "备注",
              itemType: "textarea1",
              formName: "religionRemark",
              opction: []
            }
          ]
        },
        {
          id: 'healthDto',
          children: [
            {
              label: "残疾类别",
              itemType: "select1",
              formName: "disabilityCategoryCode",
              opction: this.disabilityCategoryCode
            },
            {
              label: "残疾等级",
              itemType: "select1",
              formName: "disabilityLevel",
              opction: [
                { label: '一级', value: '0' },
                { label: '二级', value: '1' }
              ]
            },
            {
              label: "残疾证号",
              itemType: "input1",
              formName: "disabilityNum",
              opction: []
            },
            {
              label: "残疾说明",
              itemType: "input1",
              formName: "disabilityDesc",
              opction: []
            },
            {
              label: "监护人",
              itemType: "radio1",
              formName: "guardianFlag",
              opction: [
                { label: '有', formName: '', value: 1 },
                { label: '无', formName: '', value: 0 }
              ]
            },
            {
              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 }
              ]
            },
            {
              label: "非义务教育阶段助学",
              itemType: "radio1",
              formName: "voluntaryEducationFlag",
              opction: [
                { label: '有', formName: '', value: 1 },
                { label: '无', formName: '', value: 0 }
              ]
            },
            {
              label: "所患大病",
              itemType: "select1",
              formName: "illnessCode",
              opction: []
            },
            {
              label: "大病患病时间",
              itemType: "datepicker1",
              formName: "illnessTime",
              opction: []
            },
            {
              label: "所患慢性病",
              itemType: "select1",
              formName: "chronicDiseaseCode",
              opction: []
            },
            {
              label: "慢病患病时间",
              itemType: "datepicker1",
              formName: "chronicDiseaseTime",
              opction: []
            },
            {
              label: "是否参保",
              itemType: "radio1",
              formName: "insuredFlag",
              opction: [
                { label: '是', formName: '', value: 1 },
                { label: '否', formName: '', value: 0 }
              ]
            },
            {
              label: "自付金额",
              itemType: "inputNum",
              formName: "selfPayAmount",
              opction: []
            },
            {
              label: "救助金额",
              itemType: "inputNum",
              formName: "deliveranceAmount",
              opction: []
            },
            {
              label: "救助时间",
              itemType: "datepicker1",
              formName: "deliveranceTime",
              opction: []
            },
            {
              label: "享受救助明细序号",
              itemType: "input1",
              formName: "deliveranceNum",
              opction: []
            },
            {
              label: "备注",
              itemType: "textarea1",
              formName: "healthRemark",
              opction: []
            }
          ]
        },
        {
          id: 'workInfoDto',
          children: [
            {
              label: "工作单位",
              itemType: "input1",
              formName: "workUnit",
              opction: []
            },
            {
              label: "职业",
              itemType: "input1",
              formName: "occupation",
              opction: []
            },
            {
              label: "离退休时间",
              itemType: "datepicker1",
              formName: "retireTime",
              opction: []
            },
            {
              label: "备注",
              itemType: "textarea1",
              formName: "workRemark",
              opction: []
            }
          ]
        }, {
          id: "economyDto",
          children: [
            {
              label: "退休金额",
              itemType: "inputNum",
              formName: "retirementAmount",
              opction: []
            },
            {
              label: "月收入",
              itemType: "inputNum",
              formName: "monthIncome",
              opction: []
            },
            {
              label: "银行账号",
              itemType: "input1",
              formName: "bankAccount",
              opction: []
            },
          ]
        },
        {
          id: "resideInfoDto",
          children: [
            {
              label: "籍贯",
              itemType: "input1",
              formName: "nativePlace",
              opction: []
            },
            {
              label: "户籍所在地",
              itemType: "input1",
              formName: "placeOfDomicile",
              opction: []
            },
            {
              label: "现居住地址",
              itemType: "input1",
              formName: "currentResidence",
              opction: []
            },
            {
              label: "人户状况",
              itemType: "select1",
              formName: "householdSituation",
              opction: []
            },
            {
              label: "备注",
              itemType: "textarea1",
              formName: "resiRemark",
              opction: []
            }
          ]
        },
        {
          id: "familyInfoDto",
          children: [
            {
              label: "与户主关系",
              itemType: "select1",
              formName: "houseHolderRel",
              opction: []
            },
            {
              label: "居住情况",
              itemType: "select1",
              formName: "resideSituation",
              opction: []
            },
            {
              label: "婚姻状况",
              itemType: "select1",
              formName: "marriage",
              opction: []
            },
            {
              label: "配偶情况",
              itemType: "select1",
              formName: "spouseSituation",
              opction: []
            },
            {
              label: "该居民有无赡养人",
              itemType: "radio1",
              formName: "elderlyFlag",
              opction: [
                { label: '有', value: 1 },
                { label: '无', value: 0 }
              ]
            },
            {
              label: "该居民与赡养人关系",
              itemType: "select1",
              formName: "elderlyRelation",
              opction: []
            },
            {
              label: "赡养人联系电话",
              itemType: "input1",
              formName: "dependantMobile",
              opction: [
              ]
            }, {
              label: "备注",
              itemType: "textarea1",
              formName: "familyInfoRemark",
              opction: [
              ]
            }
          ]
        }, {
          id: "parymemberInfoDto",
          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",
              opction: []
            },
            {
              label: "职务",
              itemType: "select1",
              formName: "partyJob",
              opction: [
              ]
            },
            {
              label: "工作职责",
              itemType: "input1",
              formName: "duty",
              opction: []
            },
            {
              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",
              opction: [

              ]
            }, {
              label: "组织关系转入社区时间",
              itemType: "datepicker1",
              formName: "joinCommunityTime",
              opction: [
              ]
            },
            // {
            // label:"是否请长假",
            // itemType:"radio1",
            // formName:"longHolidayFlag",
            // opction:[
            //   {label:'是',value:1},
            //   {label:'否',value:0},
            // ]}
          ]
        }, {
          id: 'ensureHouseDto',
          children: [
            {
              label: "住房性质",
              itemType: "select1",
              formName: "housingNature",
              opction: [
              ]
            },
            {
              label: "保障类型",
              itemType: "input1",
              formName: "securityType",
              opction: [
              ]
            }, {
              label: "发证日期",
              itemType: "datepicker1",
              formName: "certificateDate",
              opction: []
            },
            {
              label: "补贴编号",
              itemType: "input1",
              formName: "subsidyNum",
              opction: []
            },
            {
              label: "补贴金额	",
              itemType: "inputNum",
              formName: "subsidyAmount",
              opction: [
              ]
            },
            {
              label: "房东姓名",
              itemType: "input1",
              formName: "landlordName",
              opction: []
            },
            {
              label: "房东证件号",
              itemType: "input1",
              formName: "landlordIdNum",
              opction: []
            },
            {
              label: "通知书领取日期",
              itemType: "datepicker1",
              formName: "notificationRcvDate",
              opction: []
            },
          ]
        }, {
          id: 'unemployedDto',
          children: [
            {
              label: "原工作单位",
              itemType: "input1",
              formName: "originWorkUnit",
            },
            {
              label: "失业时间",
              itemType: "datepicker1",
              formName: "unemploymentTime",
              opction: [
                { label: '是', value: 1 },
                { label: '否', value: 0 },
              ]
            }, {
              label: "失业证号",
              itemType: "input1",
              formName: "unemploymentNum",
              opction: [
              ]
            },
            {
              label: "再就业优惠证号",
              itemType: "input1",
              formName: "employmentNum",
              opction: [

              ]
            },
            {
              label: "技术特长",
              itemType: "input1",
              formName: "specialSkill",
              opction: [
              ]
            }, {
              label: "失业原因",
              itemType: "select1",
              formName: "unemploymentReason",
              opction: [
              ]
            }, {
              label: "是否就业困难对象",
              itemType: "radio1",
              formName: "employmentHardFlag",
              opction: [
                { label: '是', value: 1 },
                { label: '否', value: 0 }
              ]
            }, {
              label: "劳动能力就业愿望",
              itemType: "select1",
              formName: "employmentWish",
              opction: [
              ]
            }
          ]
        }, {
          id: 'veteranDto',
          children: [
            {
              label: "入伍时间",
              itemType: "datepicker1",
              formName: "joinArmyTime",
              opction: [
              ]
            },
            {
              label: "退伍时间",
              itemType: "datepicker1",
              formName: "leaveArmyTime",
              opction: [
              ]
            },
            {
              label: "服役单位",
              itemType: "input1",
              formName: "serviceUnit",
              opction: [
              ]
            },
            {
              label: "接收单位",
              itemType: "input1",
              formName: "receiveUnit	",
              opction: [
              ]
            },
            {
              label: "待安置补助金",
              itemType: "inputNum",
              formName: "settlementAmount",
              opction: [

              ]
            },
            {
              label: "培训状况",
              itemType: "input1",
              formName: "trainDesc",
              opction: [
              ]
            },
            // {
            //   label: "参战时间开始日期",
            //   itemType: "datepicker1",
            //   formName: "joinWarStartTime",
            //   opction: [
            //   ]
            // },
            // {
            //   label: "参战时间截止日期",
            //   itemType: "datepicker1",
            //   formName: "joinWarEndTime",
            //   opction: [
            //   ]
            // },
            {
              label: "现就业情况",
              itemType: "input1",
              formName: "employmentSituation",
              opction: [
              ]
            },
            {
              label: "是否办理公益性岗位",
              itemType: "radio1",
              formName: "pubWelfareJobFlag",
              opction: [
                { label: '是', value: 1 },
                { label: '否', value: 0 },
              ]
            }
          ]
        },
        {
          id: 'unitedFrontDto',
          children: [{
            label: "职务",
            itemType: "input1",
            formName: "duty",
          },
          {
            label: "探亲情况	",
            itemType: "input1",
            formName: "visitation",
          }]
        }, {
          id: 'volunteerDto',
          children: [{
            label: "志愿者类别",
            itemType: "checkbox",
            formName: "volunteerCategory",
            opction: [
            ]
          },
          {
            label: '备注',
            itemType: "textarea1",
            formName: "volunteerRemark",
          }
          ]
        }, {
          id: 'oldPeopleDto',
          children: [{
            label: '高龄补助',
            itemType: "inputNum",
            formName: "oldSubsidy",
          },]
        }, {
          id: 'specialDto',
          children: [{
            label: '人群类别',
            itemType: "select1",
            formName: "specialCategoryCode",
            multiple:true,
            collapseTags:true,
            opction: []
          },]
        },
        {
          id: 'birthRecordDTO',
          children: [{
            label: '出生地',
            itemType: "input1",
            formName: "birthplace",
          },
          {
            label: '父亲姓名',
            itemType: "input1",
            formName: "father",
          },
          {
            label: '母亲姓名',
            itemType: "input1",
            formName: "mother",
          },
          {
            label: '胎次',
            itemType: "number",
            formName: "count",
          },
          {
            label: '申报日期',
            itemType: "datepicker1",
            formName: "reportDate",
          }]
        }, {
          id: 'postDto',
          children: [{
            label: '入职时间',
            itemType: "datepicker1",
            formName: "hiredate",
            opction: []
          }, {
            label: '岗位类型',
            itemType: "select1",
            formName: "jobPost",
            multiple:true,
            collapseTags:true,
            opction: []
          },
          ]
        },
        {
          id: 'tenantDto',
          children: [
            {
              label: "合同开始时间",
              itemType: "datepicker1",
              formName: "contractStartDate",
              opction: []
            },
            {
              label: "合同结束时间",
              itemType: "datepicker1",
              formName: "contractEndDate",
              opction: []
            },
          ]
        },
        {
          id: 'specialSupportDto',
          children: [

            {//0
              label: "特扶类别",
              itemType: "select2",
              formName: "specialSupportType",
              opction: [
                {
                  value: '1',
                  label: '失独'
                },
                {
                  value: '2',
                  label: '伤残'
                }
              ]
            },
            {//1
              label: "子女姓名",
              itemType: "input1",
              formName: "childName",
              opction: [
              ]
            },
            {//2
              label: "子女性别",
              itemType: "input1",
              formName: "childGender",
              opction: [
                {
                  value: '1',
                  label: '男'
                },
                {
                  value: '2',
                  label: '女'
                }
              ]
            },
            {//3
              label: "子女死亡日期",
              itemType: "datepicker1",
              formName: "certificateDate",
              opction: [],
              showFlag: '0'//不显示
            },
            {//4
              label: "伤残类别",
              itemType: "select1",
              formName: "childDisabilityCategoryCode",
              opction: [
              ],
              showFlag: '0'//不显示
            },
            {//5
              label: "伤残等级",
              itemType: "select1",
              formName: "childDisabilityLevel",
              opction: [
              ],
              showFlag: '0'//不显示
            },
            {
              label: '备注',
              itemType: "textarea",
              formName: 'remark'
            },
          ]
        },
      ],
      newForm: {},
      form: {
        agencyName: this.$store.state.user.agencyName,
        agencyId: this.$store.state.user.agencyId,
        resiId: '', // 详情拿到
        houseMergeId: '', // 详情拿到
        categoryId: '', // 详情拿到
        gridName: '',
        gridId: '', //所属网格id
        villageId: '', //小区id
        buildId: '', //楼栋id
        unitId: '', //单元id
        homeId: '', //房屋id
        name: '', //姓名
        nation: '', //民族
        nationality: '', //国籍
        remark: '', //备注
        localResidenceFlag: '1', //本地户籍
        birthday: '', //生日
        idType: '', //证件类别
        idNum: '', //证件号
        gender: '', // 性别
        mobile: '', //联系电话
        partyFlag: '0',//党员
        subsistenceAllowanceFlag: '0', //低保
        ensureHouseFlag: '0', //保障房
        unemployedFlag: '0',//失业
        fertileWomanFlag: '0', //育龄妇女
        veteranFlag: '0', //退役军人
        unitedFrontFlag: '0',//统战人员
        petitionOfficerFlag: '0',//信访人员
        volunteerFlag: '0', //志愿者
        specialSupportFlag: '0', //特扶人员
        tenantFlag: '0', //租户
        floatingFlag: '0',//流动人口
        specialCrowdFlag: '0',//特殊人群
        oldPeopleFlag: '0', //老年人
        emptyNesterFlag: '0', //空巢
        liveAloneFlag: '0', //独居老人
        publicWelfareFlag: '0',
        disabledFlag: '0', //失能老人
        dementedFlag: '0', //失智老人
        disabilityFlag: '0',//是否残疾
        seriousIllnessFlag: '0', //大病
        chronicDiseaseFlag: '0', //慢病

        eduInfoDto: { // 教育信息
          cultureLevel: '',
          eduRemark: ''
        },
        hobbyInfoDto: { //兴趣爱好
          hobbyCode: [],//兴趣特长
          interestDesc: '',//兴趣
          hobbyRemark: ''//备注
        },
        religionDto: {
          religion: '',
          religionRemark: ''
        },
        healthDto: { // 健康
          disabilityCategoryCode: '',//残疾类别
          disabilityLevel: '',//残疾等级
          disabilityNum: '',//残疾证号
          disabilityDesc: '',//残疾说明
          guardianFlag: 1,//有无监护人
          specialSkillFlag: 1,//有无技能特长【有:1 无:0】
          workCapacityFlag: 1,//有无劳动能力【有:1 无:0】
          voluntaryEducationFlag: 1,//有无非义务教育阶段助学【有:1 无:0】
          illnessCode: '',//所患大病字典code
          illnessTime: '',//大病患病时间yyyy-MM-dd
          chronicDiseaseCode: '',//所患慢性病code
          chronicDiseaseTime: '',//慢病患病时间
          insuredFlag: '',//是否参保【是:1 否:0】
          selfPayAmount: '',//自付金额
          deliveranceAmount: '',//救助金额
          deliveranceTime: '',//救助时间
          deliveranceNum: '',//享受救助明细序号
          healthRemark: ''//备注
        },
        workInfoDto: { //工作
          workUnit: '',//工作单位
          occupation: '',//职业
          retireTime: '',//离退休时间
          workRemark: '',//备注
        },
        economyDto: {//经济
          retirementAmount: '',//退休金额
          monthIncome: '',//月收入
          bankAccount: '',//银行账号
        },
        resideInfoDto: {//居住信息
          nativePlace: '',//籍贯
          placeOfDomicile: '',//户籍所在地
          currentResidence: '',//现居住地
          householdSituation: '',//人户情况，字典code
          resiRemark: '',//备注
        },
        familyInfoDto: {//家庭
          houseHolderRel: '',//与户主关系
          resideSituation: '',//居住情况
          marriage: '',//婚姻状况
          spouseSituation: '',//配偶情况
          elderlyFlag: 1,//有无赡养人【有:1 无:0】
          elderlyRelation: '',//与赡养人关系【字典表】
          dependantMobile: '',//赡养人联系电话
          familyInfoRemark: '',//备注
        },
        parymemberInfoDto: {//党员信息
          joinTime: '',//入党时间yyyy-MM-dd
          positiveTime: '',//转正时间yyyy-MM-dd
          partyOrgId: '',//所属支部
          flowFlag: 1,//是否流动党员：1是，0否
          flowActNum: '',//流动党员活动证号
          partyJob: '',//职务，字典code
          duty: '',//职责，字典code
          retiredFlag: 1,//是否退休：1是，0否
          centerFlag: 1,//是否党员中心户：1是，0否
          studyNotNeed: 1,//免学习：1是，0否
          joinBranchName: '',//入党时所在党支部
          joinCommunityTime: '',//组织关系转入社区时间yyyy-MM-dd
          // longHolidayFlag: 1,//是否请长假：1是，0否
        },
        ensureHouseDto: {//保障房信息
          housingNature: '',//住房性质，字典code
          securityType: '',//保障类型
          certificateDate: '',//发证日期yyyy-MM-dd
          subsidyNum: '',//补贴编号
          subsidyAmount: '',//补贴金额
          landlordName: '',//房东姓名
          landlordIdNum: '',//房东证件号
          notificationRcvDate: '',//通知书领取日期
        },
        unemployedDto: {//失业信息
          originWorkUnit: '',//原工作单位
          unemploymentTime: '',//失业时间yyyy-MM-dd
          unemploymentNum: '',//失业证号
          employmentNum: '',//再就业优惠证号
          specialSkill: '',//技术特长
          unemploymentReason: '',//失业原因【字典表】code
          employmentHardFlag: 1,//是否就业困难对象；1是0不是
          employmentWish: '',//劳动能力就业愿望
        },
        veteranDto: {//退役军人
          joinArmyTime: '',//入伍时间
          leaveArmyTime: '',//退伍时间
          serviceUnit: '',//服役单位
          receiveUnit: '',//接收单位
          settlementAmount: '',//待安置补助金
          trainDesc: '',//培训状况
          employmentSituation: '',//现就业情况
          joinWarStartTime: '',//参战时间开始日期yyyy-MM-dd
          joinWarEndTime: '',//参战时间截止日期yyyy-MM-dd
          pubWelfareJobFlag: 1,//是否办理公益性岗位;1是0否
        },
        unitedFrontDto: {//统战人员
          duty: '',//职务
          visitation: '',//探亲情况
        },
        volunteerDto: {//志愿者信息
          volunteerCategory: [],//志愿者类别
          volunteerRemark: ''//备注

        },
        oldPeopleDto: {
          oldSubsidy: ''//高龄补助
        },

        specialDto: {//特殊人群
          id: '',//人群类别【字典表】,可多选，以英文逗号隔开；
          specialCategoryCode: []
        },
        postDto: {
          hiredate: '',//入职时间
          jobPost: [],//岗位类型
          userId: ''
        },
        birthRecordDTO: {
          birthplace: '',
          father: '',
          mother: '',
          count: 0,
          reportDate: ''
        },
        //租户
        tenantDto: {
          contractStartDate: '',//合同开始时间
          contractEndDate: '',//合同结束时间
        },
        //特扶人员
        specialSupportDto: {
          specialSupportType: '',//特扶类别
          childName: '',//子女姓名
          childGender: '',//子女性别
          childDeathDate: '',//子女死亡日期
          childDisabilityCategoyCode: '',//伤残类别
          childDisabilityLevel: '',//伤残等级
          remark: ''//备注
        },
      },
      rulesForm: {
        villageId: [{ required: true, message: `请选择小区`, trigger: 'blur' }],
        gridId: [{ required: true, message: `请选择网格`, trigger: 'blur' }],
        buildId: [{ required: true, message: `请选择楼号`, trigger: 'blur' }],
        unitId: [{ required: true, message: `请选择单元`, trigger: 'blur' }],
        homeId: [{ required: true, message: `请选择房号`, trigger: 'blur' }],
        NAME: [{ required: true, message: `请选择房号`, trigger: 'blur' }]
      },
      // 底部tabs选项
      tabsList: [
        { groupId: 'eduInfoDto', label: '教育' },
        { groupId: 'hobbyInfoDto', label: '兴趣爱好' },
        { groupId: 'religionDto', label: '宗教信仰' },
        { groupId: 'healthDto', label: '健康' },
        { groupId: 'workInfoDto', label: '工作' },
        { groupId: 'economyDto', label: '经济情况' },
        { groupId: 'resideInfoDto', label: '居住' },
        { groupId: 'familyInfoDto', label: '家庭' },
        { groupId: 'birthRecordDTO', label: '出生信息' },
      ]
    }
  },
  computed: {
  },
  watch: {
    form: {
      handler (val, val2) {
        for (let i in this.form) {
          if (typeof (this.form[i]) === "object") {
            this.tabFlag = false
          }
        }
      },
      deep: true,
      immediate: true
    },
  },
  created () {
    this.getOrgTreeList()
    this.getAllDict()

    this.setNewForm()
  },
  methods: {

    getOrgTreeList () {
      const { user } = this.$store.state;
      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('网络错误');
        });
    },
    handleChangeAgency (val) {

      let obj = this.$refs['myCascader'].getCheckedNodes()[0] ? this.$refs['myCascader'].getCheckedNodes()[0].data : null;
      console.log('obj', obj);
      console.log('gridId', this.gridId);
      console.log('val', val);

      if (obj) {
        if (obj.level === 'grid') {

          this.form.gridId = obj.agencyId;
          this.form.agencyId = obj.pid

          this.form.villageId = '';
          this.form.buildId = '';
          this.form.unitId = '';
          this.form.homeId = '';

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

      }

    },
    submit_from () {
      this.setJSON()

      var flag = false
      this.$refs.formId.validate(v => {
        this.validateFlag = v
        flag = v

      })
      if (flag) {
        return JSON.stringify(this.newForm)
      }

      return false
    },
    async old_from (data) {
      this.getFormData(data)
      await this.getValiheList()
      await this.getBuildList()
      await this.getUniList()
      await this.getHouseList()
      await this.residentEduInfo(this.form.resiId)
    },
    handlePartyOrgCascadarChange(selectedNode) {
      this.form.parymemberInfoDto.partyOrgId = selectedNode[selectedNode.length - 1];
    },
    async getAllDict () {
      try {
        await Promise.all([
          this.getDictList(),
          this.getGuojiDictList(),
          this.getSclbDictList(),
          this.getScdjDictList(),
          this.getRelationship(),
          this.getEducation(),
          this.getdisabilityDict(),
          this.getdisabilityDictClass(),
          this.getillnessDict(),
          this.getchronicDict(),
          this.getHouseholdDict(),
          this.getMarriageDict(),
          this.getResideDict(),
          this.getSpouseDict(),
          this.getPartyDict(),
          this.getResidentDict(),
          this.getHousing(),
          this.getVolunteerDict(),
          this.gethobbyDict(),
          this.getWelfareDict(),
          this.getUnemployment(),
          this.getCareer(),
          this.getListPartyOrgTreeRoot4Select()
        ]);
      } catch (error) {
        console.error("Error fetching dictionaries: ", error);
      }
    },


    getValiheList () {
      const { user } = this.$store.state
      this.$http.post('/actual/base/communityQuarters/listQuartersOptions', { gridId: this.form.gridId, agencyId: user.agencyId }).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        } else {

          this.optionsV = res.data
        }
      }).catch(() => {
        return this.$message.error('网络错误')
      })
    },
    async handleNextOrgTreeClick (node,resolve) {
      console.log(node,resolve);
       await this.getTreeChildenList(node,resolve)      
    },
  
    async getTreeChildenList (node, resolve) {
      console.log(node,resolve);
      const url = "/actual/base/party/org/listNextLevelPartyOrgTreeNodesByPid"
      console.log('级联', node.value)
      let params = {
        partyOrgPid: node.data.id
      }
      const { data, code, msg } = await requestGet(url, params)
      if (code === 0) {
        resolve(data)
      } else {
        this.$message.error(msg)
      }
  },
    //获取国籍字典
    async getGuojiDictList () {
      await this.getDictDataBasic('nationality', 'nationality')
    },

    //获取伤残类别字典
    async getSclbDictList () {
      await this.getDictData('disability_category_code', 'childDisabilityCategoryCode')
    },
    //获取伤残等级字典
    async getScdjDictList () {
      await this.getDictData('disability_level', 'childDisabilityLevel')
    },
    async getdisabilityDict () {
      await this.getDictData('disability_category_code', 'disabilityCategoryCode')
    },
    async getVolunteerDict () {
      await this.getDictData('VOLUNTEER_CATEGORY', 'volunteerCategory')
    },
    async gethobbyDict () {
      await this.getDictData('SPECIAL_SKILL', 'hobbyCode')
    },
    async getdisabilityDictClass () {
      await this.getDictData('disability_level', 'disabilityLevel')
    },
    async getillnessDict () {
      await this.getDictData('illness_code', 'illnessCode')
    },
    async getchronicDict () {
      await this.getDictData('chronic_disease_code', 'chronicDiseaseCode')
    },
    async getWelfareDict () {
      await this.getDictData('public_welfare_post_type', 'jobPost')
    },
    async getUnemployment () {
      await this.getDictData('unemployment_cause', 'unemploymentReason')
    },
    async getCareer () {
      await this.getDictData('career_goals', 'employmentWish')
    },

    async getHouseholdDict () {
      await this.getDictData('household_situation', 'householdSituation')
    },
    async getMarriageDict () {
      await this.getDictData('marriage', 'marriage')
    },
    async getResideDict () {
      await this.getDictData('reside_situation', 'resideSituation')
    },
    async getPartyDict () {
      await this.getDictData('party_job', 'partyJob')
    },
    async getSpouseDict () {
      await this.getDictData('spouse_situation', 'spouseSituation')
    },
    async getResidentDict () {
      await this.getDictData('special_resident_category', 'specialCategoryCode')
    },
    // 底部form  运营端控制字典统一调用
    async getDictData (dictType, formName) {

      try {
        const { data } = await this.$http.post('sys/dict/data/dictlist', { 'dictType': dictType });
        this.footerInputList.forEach(c => {
          for (let i of c.children) {
            if (i.formName == formName) {
              i.opction = data.data;
            }
          }
        });

      } catch (error) {
        console.log(error, `获取 ${dictType} 字典`);
      }
    },
    // 基础信息 运营端控制字典统一调用
    async getDictDataBasic (dictType, formName) {
      try {
        const { data } = await this.$http.post('sys/dict/data/dictlist', { 'dictType': dictType });
        this.basicInformation.forEach(c => {

          if (c.formName == formName) {
            c.opction = data.data;
          }

        });
      } catch (error) {
        console.log(error, `获取 ${dictType} 字典`);
      }
    },

    getBuildList () {
      this.$http.post('/actual/base/communityBuilding/buildingoption', { quartersId: this.form.villageId }).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        } else {
          this.optionsB = res.data
        }
      }).catch(() => {
        return this.$message.error('网络错误')
      })
    },
    getUniList () {
      this.$http.post('/actual/base/communityBuildingUnit/unitoption', { buildingId: this.form.buildId }).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        } else {
          this.optionsD = res.data
        }
      }).catch(() => {
        return this.$message.error('网络错误')
      })
    },
    getHouseList () {
      this.$http.post('/actual/base/communityHouse/houseoption', { unitId: this.form.unitId }).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        } else {
          this.optionsH = res.data
        }
      }).catch(() => {
        return this.$message.error('网络错误')
      })
    },
    handleChangeCheckbox (item, val) {
      this.handleTabShow(item, val)
    },
    handleTabShow (item, val) {
      console.log(item,val);
      const mapping = {
        partyFlag: { label: '党员', id: '0', groupId: 'parymemberInfoDto' },
        ensureHouseFlag: { label: '保障房信息', id: '1', groupId: 'ensureHouseDto' },
        unemployedFlag: { label: '失业', id: '2', groupId: 'unemployedDto' },
        veteranFlag: { label: '退役军人', id: '3', groupId: 'veteranDto' },
        unitedFrontFlag: { label: '统战', id: '4', groupId: 'unitedFrontDto' },
        volunteerFlag: { label: '志愿者信息', id: '5', groupId: 'volunteerDto' },
        oldPeopleFlag: { label: '老年人', id: '6', groupId: 'oldPeopleDto' },
        specialCrowdFlag: { label: '特殊人群', id: '7', groupId: 'specialDto' },
        publicWelfareFlag: { label: '公益岗人员', id: '8', groupId: 'postDto' },
        tenantFlag: { label: '租户', id: '9', groupId: 'tenantDto' },
        specialSupportFlag: { label: '特扶人员', id: '10', groupId: 'specialSupportDto' },
      };

      if (val == 1 && mapping[item.formName]) {
        this.tabsList.push(mapping[item.formName]);
      } else if (val != 1 && mapping[item.formName]) {
        this.tabsList = this.tabsList.filter(tab => tab.id !== mapping[item.formName].id);
        // delete this.form[mapping[item.formName].groupId];
        let group = this.form[mapping[item.formName].groupId];
        for (let key in group) {
            if (group.hasOwnProperty(key)) {
                if (typeof group[key] === "string") {
                    group[key] = "";
                } else if (typeof group[key] === "number") {
                    group[key] = null;
                }
            }
        }
      }
    },

    checkNumberInput (itemj, itemk) {
      if (this.form[itemj][itemk]) {
        if (isNaN(this.form[itemj][itemk])) {
          this.$message.error("请输入数字");
          this.form[itemj][itemk] = "";
        } else {
          this.form[itemj][itemk] = parseFloat(
            this.form[itemj][itemk]
          );
        }
      }

    },

    validateIdcard (idCard, type) {
      this.$http
        .post('/epmetuser/icresiuser/getUserRoleByIdCard', { idCard })
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          } else {


            if (res.data.isVolunteer == '1') this.form.volunteerFlag = true
            else this.form.volunteerFlag = false

            if (res.data.isPartyMember == '1') {
              this.form.partyFlag = true
              this.isParty = true
              this.partyInfo = res.data.detail.ic_party_member
            } else this.form.partyFlag = false
          }
        })
        .catch(() => {
          return this.$message.error('网络错误')
        })
    },
    // 证件号失去焦点事件
    handleValidBlur (item) {

      if (item.formName !== 'idNum') return
      if (!isCard(this.form.idNum) && !isPassport(this.form.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.idNum.length === 18 || this.form.idNum.length === 15) {
        const _id = this.form.idNum.substr(0, 6)
        const { sex, birth, age } = computedCard(this.form.idNum)
        this.form.birthday = birth
        this.form.gender = sex == 1 ? '1' : '2'
        this.form.oldPeopleFlag = age >= 60 ? 1 : 0
        // this.form.IS_BDHJ = huji == _id ? '1' : ''
        // 身份证前端验证角色方法 因原型没有注释
        // this.validateIdcard(this.form.idNum)

      }

    },
    handleChangeV (val) {

      this.form.buildId = ''
      this.form.unitId = ''
      this.form.homeId = ''
      this.getBuildList()
      this.getUniList()
      this.getHouseList()
    },
    handleChangeB (val) {

      this.form.unitId = ''
      this.form.homeId = ''
      this.getUniList()
      this.getHouseList()
    },
    handleChangeD () {
      this.form.homeId = ''
      this.getHouseList()
    },
    async handleClickTab (tab, event) {

      const tabMapping = {
        '教育': {
          dtoKey: 'eduInfoDto',
          fn: this.residentEduInfo
        },
        '兴趣爱好': {
          dtoKey: 'hobbyInfoDto',
          fn: this.residentHobbyInfo
        },
        '宗教信仰': {
          dtoKey: 'religionDto',
          fn: this.residentReligion
        },
        '健康': {
          dtoKey: 'healthDto',
          fn: this.getHealthInfoDetailById
        },
        '工作': {
          dtoKey: 'workInfoDto',
          fn: this.residentWorkInfo
        },
        '经济情况': {
          dtoKey: 'economyDto',
          fn: this.getEconomyDetailById
        },
        '居住': {
          dtoKey: 'resideInfoDto',
          fn: this.getResideInfoDetailById
        },
        '家庭': {
          dtoKey: 'familyInfoDto',
          fn: this.getFamilyInfoDetailById
        },
        '出生信息': {
          dtoKey: 'birthRecordDTO',
          fn: this.residentBirthRecord
        },
        '党员': {
          dtoKey: 'parymemberInfoDto',
          fn: this.residentPartyMemberInfo
        },
        '保障房信息': {
          dtoKey: 'ensureHouseDto',
          fn: this.residentEnsureHouse
        },
        '失业': {
          dtoKey: 'unemployedDto',
          fn: this.residentUnemployed
        },
        '退役军人': {
          dtoKey: 'veteranDto',
          fn: this.getVeteranDetailById
        },
        '统战': {
          dtoKey: 'unitedFrontDto',
          fn: this.residentUnitedFront
        },
        '志愿者信息': {
          dtoKey: 'volunteerDto',
          fn: this.getVolunteerDetailById
        },
        '特殊人群': {
          dtoKey: 'specialDto',
          fn: this.residentSpecial
        },
        '老年人': {
          dtoKey: 'oldPeopleDto',
          fn: this.getOldPeopleDetailById
        },
        '公益岗人员': {
          dtoKey: 'postDto',
          fn: this.getWelfareDetailById
        },
        '租户': {
          dtoKey: 'tenantDto',
          fn: this.getTenantInfo
        },
        '特扶人员': {
          dtoKey: 'specialSupportDto',
          fn: this.getSpecialSupportInfo
        },
      };
      let currentTab = tabMapping[tab._props.label];

      if (currentTab) {
        if (!this.form.resiId) {
          this.newForm[currentTab.dtoKey] = this.form[currentTab.dtoKey];
        } else {
          await currentTab.fn(this.form.resiId);
        }
      }
    },
    handleForm () {
      let newForm = []
      this.$refs[this.formId].validate((valid) => {
        if (valid) {
          var hash = {}
          var i = 0
          var res = []
          this.tempFormList.forEach(function (item) {
            var name = item.tableName
            hash[name] ? res[hash[name] - 1].list.push(item) : hash[name] = ++i && res.push({
              list: [item],
              tableName: name
            })
          })
          const itemTypes = ['cascader', 'daterange', 'timerange']
          res.forEach(item => {
            let _form = {}
            item.list.filter(n => n.isChange).forEach(r => {
              _form[r.columnName] = r.multiSelect || itemTypes.includes(r.itemType) ? this.form[r.columnName].toString() : this.form[r.columnName]
              // return _form
            })
            if (this.fixed) {
              for (let n in this.fixedList) {
                _form[n] = this.fixedList[n]
              }
            }
            newForm.push({
              tableName: item.tableName,
              supportAdd: this.supportAdd,
              list: Object.keys(_form).length > 0 ? [{ ..._form }] : []
            })
            console.log(newForm);
          })
          return newForm
        } else {
          console.log('error submit!!')
          return false
        }
      })
      if (this.supportAdd) newForm = this.handlerMuscForm()
      return newForm
    },
    // 为了实现根据房屋类型改版是否租户的需求
    handleChangeH (val) {
      let item = this.optionsH.find(item => item.value === val);
      if (item && item.type == '1') {
        this.form.IS_TENANT = '1'
        console.log('item-----', item)
      } else this.form.IS_TENANT = '0'
    },
    //获取民族字典
    async getDictList () {
      try {
        const { data } = await this.$http.post('sys/dict/data/nation', { formCode: "resi_base_info" })
        this.dictList = data
        this.basicInformation.forEach(c => {
          if (c.formName == 'nation') {
            c.opction = data.data

          }
        })
      } catch (error) {

      }
    },
      // 获取全部党组织树
    async getOrgTree(){
      try {
        const { data } = await requestGet('/actual/base/party/org/listPartyOrgTreeRoot4Select',{ depth: 8 })
        this.footerInputList.forEach(c => {
          for (let i of c.children) {
            if (i.formName == 'partyOrgId') {
              i.opction = [data];
            }
          }
        })
      } catch (error) {
        console.log(error);
      }
    },
    async getListPartyOrgTreeRoot4Select(){
      try {
        const { data } = await this.$http.get('actual/base/party/org/listPartyOrgTreeRoot4Select')
        console.log(data,'data懒加载');
        this.footerInputList.forEach(c => {
          for (let i of c.children) {
            if (i.formName == 'partyOrgId') {
              i.opction = [data.data];
              console.log(i.opction,'option懒加载');
            }
          }
        })
      } catch (error) {

      }
    },
    // 获取人物关系字典
    async getRelationship () {
      try {
        const { data } = await this.$http.post('sys/dict/data/relationship', { formCode: "resi_base_info" })
        this.footerInputList.forEach(c => {
          for (let i of c.children) {
            if (i.formName == 'houseHolderRel' || i.formName == 'elderlyRelation') {
              i.opction = data.data
            }
          }
        })
      } catch (error) {

      }
    },

    getTreeData (data) {
      if (!Array.isArray(data)) return [];
      let arr = data.map((item) => {
        let _item = {};
        if (item.children) {
          if (item.children.length === 0)
            _item = { ...item, children: undefined };
          else _item = { ...item, children: this.getTreeData(item.children) };
        } else {
          _item = { ...item };
        }
        return _item;
      });
      return arr;
    },
    async getEducation () {
      try {
        let { data } = await this.$http.post('sys/dict/data/education', { formCode: "resi_base_info" })
        data.data = this.getTreeData(data.data)
        this.footerInputList.forEach(c => {
          for (let i of c.children) {
            if (i.formName == 'cultureLevel') {
              i.opction = data.data

            }
          }
        })
      } catch (error) {

      }
    },
    async getHousing () {
      try {
        let { data } = await this.$http.post('sys/dict/data/house', { formCode: "resi_base_info" })
        data.data = this.getTreeData(data.data)
        this.footerInputList.forEach(c => {
          for (let i of c.children) {
            if (i.formName == 'housingNature') {
              i.opction = data.data
            }
          }
        })
      } catch (error) {
      }
    },
    getFormData (data) {
      this.form.resiId = data.resiId
      this.form.buildId = data.houseInfo.buildId
      this.form.gridId = data.houseInfo.gridId
      this.form.gridName = data.houseInfo.gridName
      this.form.homeId = data.houseInfo.homeId
      this.form.homeName = data.houseInfo.homeName
      this.form.houseMergeId = data.houseInfo.mergeId
      this.form.unitId = data.houseInfo.unitId
      this.form.villageId = data.houseInfo.villageId
      this.form.birthday = data.birthday
      this.form.gender = data.gender
      this.form.idType = data.idType
      this.form.idNum = data.idNum
      this.form.localResidenceFlag = (data.localResidenceFlag !== null && data.localResidenceFlag !== undefined) ? data.localResidenceFlag.toString() : '';
      this.form.mobile = data.mobile ? data.mobile : ''
      this.form.name = data.name
      this.form.nation = data.nation ? data.nation : ''
      this.form.nationality = data.nationality ? data.nationality : ''
      this.form.remark = data.remark ? data.remark : ''
      if (data.categoryInfo) {
        this.form.categoryId = data.categoryInfo.id,// 临时写死
          this.form.partyFlag = data.categoryInfo.partyFlag.toString()
        this.form.subsistenceAllowanceFlag = data.categoryInfo.subsistenceAllowanceFlag.toString()
        this.form.ensureHouseFlag = data.categoryInfo.ensureHouseFlag.toString()
        this.form.unemployedFlag = data.categoryInfo.unemployedFlag.toString()
        this.form.fertileWomanFlag = data.categoryInfo.fertileWomanFlag.toString()
        this.form.veteranFlag = data.categoryInfo.veteranFlag.toString()
        this.form.unitedFrontFlag = data.categoryInfo.unitedFrontFlag.toString()
        this.form.petitionOfficerFlag = data.categoryInfo.petitionOfficerFlag.toString()
        this.form.volunteerFlag = data.categoryInfo.volunteerFlag.toString()
        this.form.oldPeopleFlag = data.categoryInfo.oldPeopleFlag.toString()
        this.form.emptyNesterFlag = data.categoryInfo.emptyNesterFlag.toString()
        this.form.specialSupportFlag = data.categoryInfo.specialSupportFlag.toString()
        this.form.disabledFlag = data.categoryInfo.disabledFlag.toString()
        this.form.dementedFlag = data.categoryInfo.dementedFlag.toString()
        this.form.disabilityFlag = data.categoryInfo.disabilityFlag.toString()
        this.form.seriousIllnessFlag = data.categoryInfo.seriousIllnessFlag.toString()
        this.form.chronicDiseaseFlag = data.categoryInfo.chronicDiseaseFlag.toString()
        this.form.specialCrowdFlag = data.categoryInfo.specialCrowdFlag.toString()
        this.form.tenantFlag = data.categoryInfo.tenantFlag.toString()
        this.form.floatingFlag = data.categoryInfo.floatingFlag.toString()
        this.form.liveAloneFlag = data.categoryInfo.liveAloneFlag.toString()
        this.form.publicWelfareFlag = data.categoryInfo.publicWelfareFlag.toString()
        this.form.publicWelfareFlag = data.categoryInfo.publicWelfareFlag.toString()

        if (this.form.partyFlag == '1') this.tabsList.push({ label: '党员', id: '0', groupId: 'parymemberInfoDto' })
        if (this.form.ensureHouseFlag == '1') this.tabsList.push({ label: '保障房信息', id: '1', groupId: 'ensureHouseDto' })
        if (this.form.unemployedFlag == '1') this.tabsList.push({ label: '失业', id: '2', groupId: 'unemployedDto' })
        if (this.form.veteranFlag == '1') this.tabsList.push({ label: '退役军人', id: '3', groupId: 'veteranDto' })
        if (this.form.unitedFrontFlag == '1') this.tabsList.push({ label: '统战', id: '4', groupId: 'unitedFrontDto' })
        if (this.form.volunteerFlag == '1') this.tabsList.push({ label: '志愿者信息', id: '5', groupId: 'volunteerDto' })
        if (this.form.oldPeopleFlag == '1') this.tabsList.push({ label: '老年人', id: '6', groupId: 'oldPeopleDto' })
        if (this.form.specialCrowdFlag == '1') this.tabsList.push({ label: '特殊人群', id: '7', groupId: 'specialDto' })
        if (this.form.publicWelfareFlag == '1') this.tabsList.push({ label: '公益岗人员', id: '8', groupId: 'postDto' })
        if (this.form.tenantFlag == '1') this.tabsList.push({ label: '租户', id: '9', groupId: 'tenantDto' })
        if (this.form.specialSupportFlag == '1') this.tabsList.push({ label: '特扶人员', id: '10', groupId: 'specialSupportDto' })

      }
      let { categoryId, resiId, buildId, gridId, gridName, homeId, homeName, houseMergeId, unitId,
        villageId, birthday, gender, idType, idNum, localResidenceFlag, mobile, name, nation, nationality, remark,
        partyFlag, subsistenceAllowanceFlag, ensureHouseFlag, unemployedFlag, fertileWomanFlag, veteranFlag, unitedFrontFlag,
        petitionOfficerFlag, volunteerFlag, oldPeopleFlag, emptyNesterFlag, specialSupportFlag, disabledFlag,
        dementedFlag, disabilityFlag, seriousIllnessFlag, chronicDiseaseFlag, specialCrowdFlag, tenantFlag, floatingFlag, liveAloneFlag, publicWelfareFlag } = this.form
      this.newForm = {
        categoryId,
        resiId,
        buildId,
        gridId,
        gridName,
        homeId,
        homeName,
        houseMergeId,
        unitId,
        villageId,
        birthday,
        gender,
        idType,
        idNum,
        localResidenceFlag,
        mobile,
        name,
        nation,
        nationality,
        remark,
        partyFlag,
        subsistenceAllowanceFlag,
        ensureHouseFlag,
        unemployedFlag,
        fertileWomanFlag,
        veteranFlag,
        unitedFrontFlag,
        petitionOfficerFlag,
        volunteerFlag,
        oldPeopleFlag,
        emptyNesterFlag,
        specialSupportFlag,
        disabledFlag,
        dementedFlag,
        disabilityFlag,
        seriousIllnessFlag,
        chronicDiseaseFlag,
        specialCrowdFlag,
        tenantFlag,
        floatingFlag,
        liveAloneFlag,
        publicWelfareFlag,

      }
    },
    // 教育信息详情
    residentEduInfo (id) {
      if (this.newForm.eduInfoDto) return
      this.$http.get(`/actual/base/residentEduInfo/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.eduInfoDto = res.data ? res.data : { // 教育信息
            cultureLevel: '',
            eduRemark: ''
          }
          this.newForm.eduInfoDto = this.form.eduInfoDto
        }
      })
    },
    // 兴趣爱好详情
    residentHobbyInfo (id) {
      if (this.newForm.hobbyInfoDto) return
      this.$http.get(`/actual/base/residentHobbyInfo/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          if (res.data) {
            res.data.hobbyCode = res.data.hobbyCode.split(',')
          }
          this.form.hobbyInfoDto = res.data ? res.data : { //兴趣爱好
            hobbyCode: [],//兴趣特长
            interestDesc: '',//兴趣
            hobbyRemark: ''//备注
          }
          this.newForm.hobbyInfoDto = this.form.hobbyInfoDto
        }
      })
    },
    // 宗教信仰详情
    residentReligion (id) {
      if (this.newForm.religionDto) return
      this.$http.get(`/actual/base/residentReligion/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.religionDto = res.data ? res.data : {
            religion: '',
            religionRemark: ''
          }

          this.newForm.religionDto = this.form.religionDto
        }
      })
    },
    // 健康信息详情
    getHealthInfoDetailById (id) {
      if (this.newForm.healthDto) return
      this.$http.post(`/actual/base/residentHealthInfo/getHealthInfoDetailById/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.healthDto = res.data ? res.data : { // 健康
            disabilityCategoryCode: '',//残疾类别
            disabilityLevel: '',//残疾等级
            disabilityNum: '',//残疾证号
            disabilityDesc: '',//残疾说明
            guardianFlag: 1,//有无监护人
            specialSkillFlag: 1,//有无技能特长【有:1 无:0】
            workCapacityFlag: 1,//有无劳动能力【有:1 无:0】
            voluntaryEducationFlag: 1,//有无非义务教育阶段助学【有:1 无:0】
            illnessCode: '',//所患大病字典code
            illnessTime: '',//大病患病时间yyyy-MM-dd
            chronicDiseaseCode: '',//所患慢性病code
            chronicDiseaseTime: '',//慢病患病时间
            insuredFlag: 1,//是否参保【是:1 否:0】
            selfPayAmount: '',//自付金额
            deliveranceAmount: '',//救助金额
            deliveranceTime: '',//救助时间
            deliveranceNum: '',//享受救助明细序号
            healthRemark: ''//备注
          }
          this.newForm.healthDto = this.form.healthDto
        }
      })

    },
    // 工作信息详情
    residentWorkInfo (id) {
      if (this.newForm.healthDto) return
      this.$http.get(`/actual/base/residentWorkInfo/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.workInfoDto = res.data ? res.data : { //工作
            workUnit: '',//工作单位
            occupation: '',//职业	
            retireTime: '',//离退休时间		
            workRemark: '',//备注		
          }

          this.newForm.workInfoDto = this.form.workInfoDto
        }
      })
    },
    // 经济状况详情
    getEconomyDetailById (id) {
      if (this.newForm.economyDto) return
      this.$http.post(`/actual/base/residentEconomy/getEconomyDetailById/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.economyDto = res.data ? res.data : {//经济
            retirementAmount: '',//退休金额	
            monthIncome: '',//月收入
            bankAccount: '',//银行账号
          }
          this.newForm.economyDto = this.form.economyDto
        }
      })
    },
    // 居住信息详情
    getResideInfoDetailById (id) {
      if (this.newForm.resideInfoDto) return
      this.$http.post(`/actual/base/residentResideInfo/getResideInfoDetailById/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.resideInfoDto = res.data ? res.data : {//居住信息
            nativePlace: '',//籍贯
            placeOfDomicile: '',//户籍所在地	
            currentResidence: '',//现居住地	
            householdSituation: '',//人户情况，字典code
            resiRemark: '',//备注
          }
          this.newForm.resideInfoDto = this.form.resideInfoDto
        }
      })
    },
    // 家庭信息详情
    getFamilyInfoDetailById (id) {
      if (this.newForm.familyInfoDto) return
      this.$http.post(`/actual/base/residentFamilyInfo/getFamilyInfoDetailById/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.familyInfoDto = res.data ? res.data : {//家庭
            houseHolderRel: '',//与户主关系	
            resideSituation: '',//居住情况		
            marriage: '',//婚姻状况		
            spouseSituation: '',//配偶情况		
            elderlyFlag: 1,//有无赡养人【有:1 无:0】		
            elderlyRelation: '',//与赡养人关系【字典表】		
            dependantMobile: '',//赡养人联系电话			
            familyInfoRemark: '',//备注		
          }
          this.newForm.familyInfoDto = this.form.familyInfoDto
        }
      })
    },
    // 出生信息
    residentBirthRecord (id) {
      if (this.newForm.birthRecordDTO) return
      this.$http.post(`/actual/base/residentBirthRecord/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.birthRecordDTO = res.data ? res.data : { //出生
            birthplace: '',
            father: '',
            mother: '',
            count: 0,
            reportDate: ''
          }
          this.newForm.birthRecordDTO = this.form.birthRecordDTO
        }
      })
    },
    // 党员信息详情
   async residentPartyMemberInfo (id) {
      if (this.newForm.parymemberInfoDto) return
      if(this.formId == 'resiForm'){
         await this.getOrgTree()
      }
      await this.$http.get(`/actual/base/residentPartyMemberInfo/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.parymemberInfoDto = res.data ? res.data : {//党员信息
            joinTime: '',//入党时间yyyy-MM-dd
            positiveTime: '',//转正时间yyyy-MM-dd	
            partyOrgId: '',//所属党组织
            flowFlag: null,//是否流动党员：1是，0否	
            flowActNum: '',//流动党员活动证号	
            duty: '',//职责
            partyJob: '',//职务，字典code
            retiredFlag: null,//是否退休：1是，0否
            centerFlag: null,//是否党员中心户：1是，0否
            studyNotNeed: null,//免学习：1是，0否
            joinBranchName: '',//入党时所在党支部
            joinCommunityTime: '',//组织关系转入社区时间yyyy-MM-dd
            joinCommunityTime: '',//组织关系转入社区时间yyyy-MM-dd
            // longHolidayFlag: null,//是否请长假：1是，0否
          }
          this.newForm.parymemberInfoDto = this.form.parymemberInfoDto
        }
      })
    },
    // 保障房信息详情
    residentEnsureHouse (id) {
      if (this.newForm.ensureHouseDto) return
      this.$http.get(`/actual/base/residentEnsureHouse/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.ensureHouseDto = res.data ? res.data : {//保障房信息
            housingNature: '',//住房性质，字典code
            securityType: '',//保障类型	
            certificateDate: '',//发证日期yyyy-MM-dd
            subsidyNum: '',//补贴编号	
            subsidyAmount: null,//补贴金额	
            landlordName: '',//房东姓名	
            landlordIdNum: '',//房东证件号	
            notificationRcvDate: '',//通知书领取日期	
          }
          this.newForm.ensureHouseDto = this.form.ensureHouseDto
        }
      })
    },
    // 失业信息详情
    residentUnemployed (id) {
      if (this.newForm.unemployedDto) return
      this.$http.get(`/actual/base/residentUnemployed/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.unemployedDto = res.data ? res.data : {//失业信息
            originWorkUnit: '',//原工作单位
            unemploymentTime: '',//失业时间yyyy-MM-dd	
            unemploymentNum: '',//失业证号	
            employmentNum: '',//再就业优惠证号	
            specialSkill: '',//技术特长	
            unemploymentReason: '',//失业原因【字典表】code	
            employmentHardFlag: null,//是否就业困难对象；1是0不是	
            employmentWish: '',//劳动能力就业愿望	
          }
          this.newForm.unemployedDto = this.form.unemployedDto
        }
      })
    },
    // 退役军人信息详情
    getVeteranDetailById (id) {
      if (this.newForm.veteranDto) return
      this.$http.post(`/actual/base/residentVeteran/getVeteranDetailById/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.veteranDto = res.data ? res.data : {//退役军人
            joinArmyTime: '',//入伍时间
            leaveArmyTime: '',//退伍时间
            serviceUnit: '',//服役单位	
            receiveUnit: '',//接收单位	
            settlementAmount: '',//待安置补助金	
            trainDesc: '',//培训状况	
            employmentSituation: '',//现就业情况	
            joinWarStartTime: '',//参战时间开始日期yyyy-MM-dd	
            joinWarEndTime: '',//参战时间截止日期yyyy-MM-dd	
            pubWelfareJobFlag: null,//是否办理公益性岗位;1是0否
          }
          this.newForm.veteranDto = this.form.veteranDto
        }
      })
    },
    // 统战人员详情
    residentUnitedFront (id) {
      if (this.newForm.unitedFrontDto) return
      this.$http.get(`/actual/base/residentUnitedFront/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.unitedFrontDto = res.data ? res.data : {//统战人员
            duty: '',//职务
            visitation: '',//探亲情况	
          }
          this.newForm.unitedFrontDto = this.form.unitedFrontDto
        }
      })
    },
    // 志愿者信息详情
    getVolunteerDetailById (id) {
      if (this.newForm.volunteerDto) return
      this.$http.post(`/actual/base/residentVolunteer/getVolunteerDetailById/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          if (res.data) {
            res.data.volunteerCategory = res.data.volunteerCategory.split(',')
          }
          this.form.volunteerDto = res.data ? res.data : {//志愿者信息	
            volunteerCategory: [],//志愿者类别
            volunteerRemark: ''//备注
          }

          this.newForm.volunteerDto = this.form.volunteerDto
        }
      })
    },
    // 老年人信息详情
    getOldPeopleDetailById (id) {
      if (this.newForm.oldPeopleDto) return
      this.$http.post(`/actual/base/residentOldPeople/getOldPeopleDetailById/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.oldPeopleDto = res.data ? res.data : {
            oldSubsidy: ''//高龄补助	
          }

          this.newForm.oldPeopleDto = this.form.oldPeopleDto
        }
      })
    },
    // 公益岗人员信息详情
    getWelfareDetailById (id) {
      if (this.newForm.postDto) return
      this.$http.post(`/actual/base/publicWelfarePost/detail`, { id: id }).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.postDto = res.data ? res.data : {
            hiredate: '',//入职时间
            jobPost: [],	//岗位类型
            userId: id
          }

          this.newForm.postDto = this.form.postDto
        }
      })
    },
    // 特殊人群信息
    residentSpecial (id) {
      if (this.newForm.specialDto) return
      this.$http.get(`/actual/base/residentSpecial/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          if (res.data) {
            res.data.specialCategoryCode = res.data.specialCategoryCode.split(',')
          }
          this.form.specialDto = res.data ? res.data : {//特殊人群
            specialCategoryCode: []//人群类别【字典表】,可多选，以英文逗号隔开；	
          }

          this.newForm.specialDto = this.form.specialDto
        }
      })
    },

    // 租户详情
    getTenantInfo (id) {
      if (this.newForm.tenantDto) return//???
      this.$http.get(`/actual/base/residentTenant/detailByResiId/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.tenantDto = res.data ? res.data : {//租户信息
            contractStartDate: '',//合同开始时间
            contractEndDate: '',//合同结束时间
          }
          this.newForm.tenantDto = this.form.tenantDto
        }
      })
    },

    // 特扶人员信息详情
    getSpecialSupportInfo (id) {
      if (this.newForm.specialSupportDto) return//???
      this.$http.get(`/actual/base/resiCategorized/specialSupport/detail/${id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        } else {
          this.form.specialSupportDto = res.data ? res.data : {//特扶人员信息
            specialSupportType: '',//特扶类别
            childName: '',//子女姓名
            childGender: '',//子女性别
            childDeathDate: '',//子女死亡日期
            childDisabilityCategoyCode: '',//伤残类别
            childDisabilityLevel: '',//伤残等级
            remark: ''//备注
          }
          this.newForm.specialSupportDto = this.form.specialSupportDto
        }
      })
    },

    setNewForm () {
      this.newForm = {
        agencyName: this.$store.state.user.agencyName,
        agencyId: this.$store.state.user.agencyId,
        resiId: '', // 详情拿到
        houseMergeId: '', // 详情拿到
        categoryId: '', // 详情拿到
        gridName: '',
        gridId: '', //所属网格id
        villageId: '', //小区id
        buildId: '', //楼栋id
        unitId: '', //单元id
        homeId: '', //房屋id
        name: '', //姓名
        nation: '', //民族
        nationality: '',//国籍
        remark: '', //备注
        localResidenceFlag: '', //本地户籍
        birthday: '', //生日
        idType: '', //证件类型
        idNum: '', //证件号
        gender: '', // 性别
        mobile: '', //联系电话
        partyFlag: '0',//党员
        subsistenceAllowanceFlag: '0', //低保
        ensureHouseFlag: '0', //保障房
        unemployedFlag: '0',//失业
        fertileWomanFlag: '0', //育龄妇女
        veteranFlag: '0', //退役军人
        unitedFrontFlag: '0',//统战人员
        petitionOfficerFlag: '0',//信访人员
        volunteerFlag: '0', //志愿者
        specialSupportFlag: '0',//特扶人员
        tenantFlag: '0', //租户
        floatingFlag: '0',//流动人口
        specialCrowdFlag: '0',//特殊人群
        oldPeopleFlag: '0', //老年人
        emptyNesterFlag: '0', //空巢
        liveAloneFlag: '0', //独居老人
        disabledFlag: '0', //失能老人
        dementedFlag: '0', //失智老人
        disabilityFlag: '0',//是否残疾
        seriousIllnessFlag: '0', //大病
        chronicDiseaseFlag: '0', //慢病
        publicWelfareFlag: '0',//公益岗

      }

      this.newForm.eduInfoDto = this.form.eduInfoDto
      console.log(this.newForm.specialDto);
    },
    setJSON () {
      this.newForm.agencyName = this.form.agencyName,
        this.newForm.agencyId = this.form.agencyId,
        this.newForm.resiId = this.form.resiId,
        this.newForm.houseMergeId = this.form.houseMergeId,
        this.newForm.categoryId = this.form.categoryId,
        this.newForm.gridName = this.form.gridName,
        this.newForm.gridId = this.form.gridId,
        this.newForm.villageId = this.form.villageId,
        this.newForm.buildId = this.form.buildId,
        this.newForm.unitId = this.form.unitId,
        this.newForm.homeId = this.form.homeId,
        this.newForm.name = this.form.name,
        this.newForm.vnation = this.form.vnation,
        this.newForm.remark = this.form.remark,
        this.newForm.localResidenceFlag = this.form.localResidenceFlag,
        this.newForm.birthday = this.form.birthday,
        this.newForm.idNum = this.form.idNum,
        this.newForm.idType = this.form.idType,
        this.newForm.nationality = this.form.nationality,
        this.newForm.nation = this.form.nation,
        this.newForm.gender = this.form.gender,
        this.newForm.mobile = this.form.mobile,
        this.newForm.partyFlag = this.form.partyFlag,
        this.newForm.subsistenceAllowanceFlag = this.form.subsistenceAllowanceFlag,
        this.newForm.ensureHouseFlag = this.form.ensureHouseFlag,
        this.newForm.unemployedFlag = this.form.unemployedFlag,
        this.newForm.fertileWomanFlag = this.form.fertileWomanFlag,
        this.newForm.veteranFlag = this.form.veteranFlag,
        this.newForm.unitedFrontFlag = this.form.unitedFrontFlag,
        this.newForm.petitionOfficerFlag = this.form.petitionOfficerFlag,
        this.newForm.volunteerFlag = this.form.volunteerFlag,
        this.newForm.specialSupportFlag = this.form.specialSupportFlag,
        this.newForm.tenantFlag = this.form.tenantFlag,
        this.newForm.floatingFlag = this.form.floatingFlag,
        this.newForm.specialCrowdFlag = this.form.specialCrowdFlag,
        this.newForm.oldPeopleFlag = this.form.oldPeopleFlag,
        this.newForm.emptyNesterFlag = this.form.emptyNesterFlag,
        this.newForm.liveAloneFlag = this.form.liveAloneFlag,
        this.newForm.disabledFlag = this.form.disabledFlag,
        this.newForm.dementedFlag = this.form.dementedFlag,
        this.newForm.disabilityFlag = this.form.disabilityFlag,
        this.newForm.seriousIllnessFlag = this.form.seriousIllnessFlag,
        this.newForm.chronicDiseaseFlag = this.form.chronicDiseaseFlag,
        this.newForm.publicWelfareFlag = this.form.publicWelfareFlag

      if (this.newForm.eduInfoDto) {
        this.newForm.eduInfoDto = this.form.eduInfoDto
      }
      if (this.newForm.hobbyInfoDto) {
        this.newForm.hobbyInfoDto = this.form.hobbyInfoDto
      }
      if (this.newForm.religionDto) {
        this.newForm.religionDto = this.form.religionDto
      }
      if (this.newForm.healthDto) {
        this.newForm.healthDto = this.form.healthDto
      }
      if (this.newForm.workInfoDto) {
        this.newForm.workInfoDto = this.form.workInfoDto
      }
      if (this.newForm.economyDto) {
        this.newForm.economyDto = this.form.economyDto
      }

      if (this.newForm.resideInfoDto) {
        this.newForm.resideInfoDto = this.form.resideInfoDto
      }
      if (this.newForm.familyInfoDto) {
        this.newForm.familyInfoDto = this.form.familyInfoDto
      }
      if (this.newForm.birthRecordDTO) {
        this.newForm.birthRecordDTO = this.form.birthRecordDTO
      }

      if (this.newForm.parymemberInfoDto) {
        this.newForm.parymemberInfoDto = this.form.parymemberInfoDto
      }

      if (this.newForm.ensureHouseDto) {
        this.newForm.ensureHouseDto = this.form.ensureHouseDto
      }

      if (this.newForm.unemployedDto) {
        this.newForm.unemployedDto = this.form.unemployedDto
      }

      if (this.newForm.veteranDto) {
        this.newForm.veteranDto = this.form.veteranDto
      }
      if (this.newForm.unitedFrontDto) {
        this.newForm.unitedFrontDto = this.form.unitedFrontDto
      }

      if (this.newForm.volunteerDto) {

        this.newForm.volunteerDto = this.form.volunteerDto
      }

      if (this.newForm.oldPeopleDto) {
        this.newForm.oldPeopleDto = this.form.oldPeopleDto
      }
      if (this.newForm.specialDto) {
        this.newForm.specialDto = this.form.specialDto
      }
      if (this.newForm.postDto) {
        this.newForm.postDto = this.form.postDto
      }
      if (this.newForm.tenantDto) {

        this.newForm.tenantDto = this.form.tenantDto
      }

      if (this.newForm.specialSupportDto) {

        this.newForm.specialSupportDto = this.form.specialSupportDto
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@import "@/assets/scss/modules/management/list-main.scss";
.resi-form {
  display: flex;
  flex-wrap: wrap;
}
.textareaDidth {
  width: 100%;
}
.f-flex ::v-deep .el-form-item--medium {
  margin-right: 2px;
}
.item-width-textarea {
  width: 437px;
  height: 80px;
}
::v-deep .el-textarea__inner {
  padding: 6px 15px;
}
::v-deep .el-tabs--top {
  width: 100%;
  .el-tabs__content {
    width: 100%;
    display: flex;
  }
}
.m-search {
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
}
.f-bto0 {
  margin-bottom: 0px !important;
}
.item-agency {
  width: 400px;
}
</style>
