<template>
  <div>
    <div class="contradiction-div">
      <div class="search-div">
        <Row type="flex" class="">
          <Col span="4">
            <span>姓名：</span>
            <Input
              v-model="params.name"
              placeholder="请输入"
              style="width: 65%"
            />
          </Col>
          <Col span="4">
            <span>身份证号：</span>
            <Input
              v-model="params.cardNo"
              placeholder="请输入"
              style="width: 55%"
            />
          </Col>
          <Col span="4">
            <span>选择市：</span>
            <Select
              v-model="params.cityId"
              clearable
              style="width: 55%"
              @on-change="changeCity"
            >
              <Option
                v-for="(item, index) in cityList"
                :key="index"
                :value="item.parent_id"
                >{{ item.name }}</Option
              >
            </Select>
          </Col>
          <Col span="4">
            <span>选择区：</span>
            <Select
              v-model="params.areaId"
              clearable
              style="width: 55%"
              @on-change="changeArea"
            >
              <Option
                v-for="(item, index) in areaList"
                :key="index"
                :value="item.parent_id"
                >{{ item.name }}</Option
              >
            </Select>
          </Col>
          <Col span="4">
            <span>选择街道：</span>
            <Select
              v-model="params.streetId"
              clearable
              style="width: 55%"
              @on-change="changeStreet"
            >
              <Option
                v-for="(item, index) in streetList"
                :key="index"
                :value="item.parent_id"
                >{{ item.name }}</Option
              >
            </Select>
          </Col>
          <Col span="4">
            <span>选择社区：</span>
            <Select style="width: 55%" v-model="params.communityId" clearable>
              <Option
                v-for="(item, index) in communityList"
                :key="index"
                :value="item.parent_id"
                >{{ item.name }}</Option
              >
            </Select>
          </Col>
        </Row>
        <Row class="" style="margin-top: 15px" type="flex">
          <Col span="4">
            <span>风险等级：</span>
            <Select style="width: 53%" placeholder="请选择" v-model="params.ratingLevel">
              <Option v-for="(item, index) in ratingLevelDict" :key="index" :value="item.value">{{ item.label }}</Option>
            </Select>
          </Col>
          <!--          <Col span="4">-->
          <!--            <span>是否涉矛盾纠纷：</span>-->
          <!--            <Select style="width: 42%" v-model="params.involvingConflictsDisputes ">-->
          <!--              <Option value="1">是</Option>-->
          <!--              <Option value="2">否 </Option>-->
          <!--            </Select>-->
          <!--          </Col>-->
          <Col span="4" v-if="params.involvingConflictsDisputes === '1'">
            <span>矛盾风险等级：</span>
            <Select style="width: 42%" v-model="params.riskLevel">
              <Option value="1">一级</Option>
              <Option value="2">二级</Option>
              <Option value="3">三级</Option>
            </Select>
          </Col>
          <Col span="4" v-if="cityType">
            <span>评分状态：</span>
              <Select style="width: 55%" v-model="params.doStatus">
                <Option value="0">待评</Option>
                <Option value="1">已评</Option>
                <Option value="2">超期待办</Option>
              </Select>
          </Col>
          <Col span="4" v-if="cityType">
            <span>是否临期：</span>
              <Select style="width: 49%" v-model="params.isOverdue">
                <Option value="1">是</Option>
                <Option value="0">否</Option>
              </Select>
          </Col>
          <Col span="6" v-if="cityType">
            <span>危险性评估等级：</span>
            <Select style="width: 66%" v-model="params.hazardAssessmentLevel">
              <Option value="3">3</Option>
              <Option value="4">4</Option>
              <Option value="5">5</Option>
            </Select>
          </Col>
          <!-- <Col span="8">
            <span>高度关注情形：</span>
            <Select style="width: 69%" v-model="params.is_zdry">
              <Option value="0">是</Option>
              <Option value="1">否 </Option>
            </Select>
          </Col> -->
          <Col
            style="text-align: right"
          >
            <Button
              type="primary"
              @click="searchData"
              style="margin-right: 10px"
              >搜索</Button
            >
            <Button type="primary" v-if="showImport()" @click="importShow = true" style="margin-right: 10px;">导入</Button>
            <!--            <Button type="primary" @click="handleDownload" style="margin-right: 10px;">导出</Button>-->
            <!--            v-if="severUserInfo.company_grade === '6'"-->
            <Button type="primary" @click="searchPeople">新增</Button>
            <Button style="margin-left: 10px" type="primary" @click="revert"
              >重置</Button
            >

            <Button
              type="primary"
              style="margin-left: 10px"
              @click="getDistCard"
              >身份证查重</Button
            >
            <Button type="primary" style="margin-left: 10px;" @click="$router.go(-1)" v-if="this.$route.query.riskLevel || this.$route.query.doStatus || this.$route.query.isOverdue">返回重点人员统计</Button>
          </Col>
        </Row>
      </div>
      <div style="margin-top: 10px;margin-bottom: 10px;" v-if="cityType">
        <!-- <span>正常待办：{{ this.doneCount }}</span> -->
        <span>临期待办：{{ this.todoCount }}</span>
      </div>
      <Table border :columns="canRatingColumn() && cityType?changChunTableColumns:tableColumns" :data="tableData">
        <template
          slot="keyPersonHighlyConcernedRel"
          slot-scope="{ row, index }"
        >
          {{ getHighlyConcernedRelStr(row.keyPersonHighlyConcernedRel) }}
        </template>
        <template slot-scope="{ row, index }" slot="involvingConflictsDisputes">
          {{ row.involvingConflictsDisputes == "1" ? "是" : "否" }}
        </template>
        <template slot-scope="{ row, index }" slot="isOverdue" v-if="cityType">
          <div v-if="row.isOverdue === '0'">否</div>
          <div v-else-if="row.isOverdue === '1'">是</div>
        </template>
        <template slot-scope="{ row, index }" slot="doStatus" v-if="cityType">
          <div v-if="row.doStatus === '0'">待评</div>
          <div v-else-if="row.doStatus === '1'">已评</div>
          <div v-else-if="row.doStatus === '2'">超期未评</div>
        </template>
        <template slot-scope="{ row, index }" slot="action">
          <Button
            type="info"
            size="small"
            style="margin-right: 5px"
            @click="showFamily(row)"
            :disabled="row.dualPerson == '1'"
            >家庭成员</Button
          >
          <Button
            size="small"
            style="margin-right: 5px"
            type="warning"
            @click="showDetail(row)"
            >详情</Button
          >
          <Button
            type="success"
            size="small"
            style="margin-right: 5px"
            @click="updatePeopleInfo(row)"
            :disabled="row.dualPerson == '1'"
            >编辑</Button
          >
          <Button
            type="error"
            size="small"
            style="margin-right: 5px"
            @click="deletePeopleInfo(row)"
            :disabled="row.dualPerson == '1'"
            >删除</Button
          >
          <Button
            type="info"
            size="small"
            v-if="canShowVisit(row) && cityType"
            :disabled="(row.canClick == '1' && row.doStatus !== '2' && row.dualPersonBelong != '1')?false:true"
            style="margin-right: 5px"
            @click="showRatingList(row)"
            >评分</Button
          >
          <Button
            type="info"
            size="small"
            v-if="canShowRating(row) && cityType"
            style="margin-right: 5px"
            @click="showRatingHistoryList(row)"
            >评分列表</Button
          >
          <!--         <Button type="info" size="small" @click="findPeopleZFLogList(row)">走访日志</Button>-->
        </template>
      </Table>
      <Page
        class="page_style"
        :total="params.totalRecord"
        :current="params.pageNo"
        :page-size="params.pageSize"
        @on-change="changePageNo"
        show-total
        show-sizer
        @on-page-size-change="size"
      />
      <Modal v-model="controlData.show" title="输入证件号码" width="500">
        <Row>
          <Col span="6" style="text-align: right; margin-right: 10px; margin-top: 6px">证件号码:</Col>
          <Col span="14">
            <Input v-model="controlData.cardnoInput" :maxlength="64" placeholder=""></Input>
          </Col>
        </Row>
        <div slot="footer">
          <Button type="text" size="large" @click="controlData.show = false"
            >取消</Button
          >
          <Button type="primary" size="large" @click="searchConfirm"
            >确定</Button
          >
        </div>
      </Modal>
      <Modal v-model="peopleForm.show" :title="'严重精神障碍患者' + title" width="900">
        <Form
          ref="formPerson"
          :model="peopleForm"
          :rules="ruleValidate"
          :label-width="120"
          :disabled="title === '详情'"
        >
          <Row>
            <Col span="23">
              <Row style="margin-top: 15px">
                <Col span="12">
                  <p style="height: 40px">
                    <FormItem label="姓名" prop="name">
                      <Input
                        :disabled="onlyShow"
                        v-model="peopleForm.name"
                        placeholder="请输入姓名"
                        :maxlength="16"
                      ></Input>
                    </FormItem>
                  </p>
                </Col>
                <Col span="12">
                  <p style="height: 40px">
                    <FormItem label="性别" prop="sex">
                      <Select v-model="peopleForm.sex" placeholder="请选择性别">
                        <Option value="1">男</Option>
                        <Option value="2">女</Option>
                      </Select>
                    </FormItem>
                  </p>
                </Col>
              </Row>
              <Row style="margin-top: 15px">
                <Col span="12">
                  <p style="height: 40px">
                    <FormItem
                      :rules="[
                        { required: true, message: '必填', trigger: 'blur' },
                        { validator: checkCardNo, trigger: 'blur' },
                      ]"
                      label="身份证号"
                      prop="cardNo"
                    >
                      <Input
                        v-model="peopleForm.cardNo"
                        placeholder="请输入身份证号"
                        :maxlength="64"
                      ></Input>
                    </FormItem>
                  </p>
                </Col>
                <Col span="12">
                  <p style="height: 40px">
                    <FormItem label="民族" prop="folk">
                      <Select
                        :disabled="onlyShow"
                        v-model="peopleForm.folk"
                        placeholder="请选择民族"
                      >
                        <Option
                          v-for="(item, index) in mzList"
                          :key="index"
                          :value="item.mzcode"
                          >{{ item.mzname }}</Option
                        >
                      </Select>
                    </FormItem>
                  </p>
                </Col>
              </Row>
              <Row style="margin-top: 15px">
                <Col span="12">
                  <p style="height: 40px">
                    <FormItem
                      :rules="[
                        { required: true, message: '必填', trigger: 'blur' },
                        { validator: checkNum, trigger: 'blur' },
                      ]"
                      label="本人联系方式"
                      prop="phone"
                    >
                      <Input
                        :disabled="onlyShow"
                        v-model="peopleForm.phone"
                        placeholder="请输入联系方式"
                        :maxlength="16"
                      ></Input>
                    </FormItem>
                  </p>
                </Col>
              </Row>
            </Col>
          </Row>
          <!-- <Row style="margin-top: 15px">
            <Col span="23">
              <p style="height: 40px">
                <FormItem label="地区" required>
                  <Select :disabled="onlyShow" placeholder="请选择地区" v-model="peopleForm.region" @on-change="changeAreaType(peopleForm.region)">
                    <Option v-for="(item, index) in areaDict" :key="index" :value="item.value">{{ item.label }}</Option>
                  </Select>
                </FormItem>
              </p>
            </Col>
          </Row> -->
          <Row style="margin-top: 15px">
            <Col span="6">
              <p style="height: 40px">
                <FormItem label="现住址" prop="cityId">
                  <Select
                    :disabled="
                      onlyShow ||
                      ['2', '3', '4', '5'].includes(currentUserLevel)
                    "
                    :value="peopleForm.cityId"
                    clearable
                    placeholder="请选择市"
                    @on-change="changeCityForm"
                    @on-clear="(e) => changeCityForm(e, 'clear')"
                  >
                    <Option
                      v-for="(item, index) in cityListForm"
                      :key="index"
                      :value="item.parent_id"
                      >{{ item.name }}</Option
                    >
                  </Select>
                </FormItem>
              </p>
            </Col>
            <Col span="6">
              <p style="height: 40px">
                <FormItem label="" :label-width="20" prop="areaId">
                  <Select
                    :disabled="
                      onlyShow || ['3', '4', '5'].includes(currentUserLevel)
                    "
                    :value="peopleForm.areaId"
                    clearable
                    placeholder="请选择区"
                    @on-change="changeAreaForm"
                    @on-clear="(e) => changeAreaForm(e, 'clear')"
                  >
                    <Option
                      v-for="(item, index) in areaListForm"
                      :key="index"
                      :value="item.parent_id"
                      >{{ item.name }}</Option
                    >
                  </Select>
                </FormItem>
              </p>
            </Col>
            <Col span="6">
              <p style="height: 40px">
                <FormItem label="" :label-width="20" prop="streetId">
                  <Select
                    :disabled="
                      onlyShow || ['4', '5'].includes(currentUserLevel)
                    "
                    :value="peopleForm.streetId"
                    clearable
                    placeholder="请选择街道"
                    @on-change="changeStreetForm"
                    @on-clear="(e) => changeStreetForm(e, 'clear')"
                  >
                    <Option
                      v-for="(item, index) in streetListForm"
                      :key="index"
                      :value="item.parent_id"
                      >{{ item.name }}</Option
                    >
                  </Select>
                </FormItem>
              </p>
            </Col>
            <Col span="5">
              <p style="height: 40px">
                <FormItem :label-width="20" label="" prop="communityId">
                  <Select
                    :disabled="onlyShow || currentUserLevel === '5'"
                    :value="peopleForm.communityId"
                    clearable
                    placeholder="请选择社区"
                    @on-change="changeCommunityForm"
                    @on-clear="(e) => changeCommunityForm(e, 'clear')"
                  >
                    <Option
                      v-for="(item, index) in communityListForm"
                      :key="index"
                      :value="item.parent_id"
                      >{{ item.name }}</Option
                    >
                  </Select>
                </FormItem>
              </p>
            </Col>
          </Row>
          <Row style="margin-top: 15px">
            <Col span="23">
              <p style="height: 40px">
                <FormItem label="详细地址" prop="address">
                  <Input
                    :disabled="onlyShow"
                    v-model="peopleForm.address"
                    placeholder="请输入详细地址"
                    :maxlength="300"
                  ></Input>
                </FormItem>
              </p>
            </Col>
          </Row>
          <Row style="margin-top: 15px">
            <Col span="23">
              <p style="height: 40px">
                <FormItem label="户籍地址" prop="registeredResidence">
                  <Input
                    :disabled="onlyShow"
                    v-model="peopleForm.registeredResidence"
                    placeholder="请输入户籍地址"
                    :maxlength="300"
                  ></Input>
                </FormItem>
              </p>
            </Col>
          </Row>
          <Row style="margin-top: 15px">
            <Col span="6">
              <p style="height: 40px">
                <FormItem label="是否涉及矛盾纠纷" prop="">
                  <i-switch
                    v-model="peopleForm.involvingConflictsDisputes"
                    false-value="2"
                    size="large"
                    true-value="1"
                  >
                    <span slot="open">有</span>
                    <span slot="close">无</span>
                  </i-switch>
                </FormItem>
              </p>
            </Col>
            <Col span="8" v-if="peopleForm.involvingConflictsDisputes === '1'">
              <p style="height: 40px">
                <FormItem prop="">
                  <template slot="label">
                    <span style="">矛盾风险等级</span>
                    <Poptip trigger="hover" placement="bottom">
                      <template slot="content">
                        <div v-if="peopleForm.riskLevel === '1'">
                          <p class="risk-tishi mt30 p20">
                            一级是指在二级矛盾风险基础上，排查对象存在婚姻家庭不幸、有重大疾病、有暴力倾向、有弃世厌世倾向、扬言报复社会等情形。
                          </p>
                        </div>
                        <div v-else-if="peopleForm.riskLevel === '2'">
                          <p class="risk-tishi mt30 p20">
                            二级是指重点人群涉及的重点信访事项、重点涉法涉诉类矛盾。
                          </p>
                        </div>
                        <div v-else-if="peopleForm.riskLevel === '3'">
                          <p class="risk-tishi mt30 p20">
                            三级是指重点人群涉及的一般矛盾纠纷和非重点人群涉及的重点信访事项、重点涉法涉诉类矛盾。
                          </p>
                        </div>
                        <div v-else></div>
                      </template>
                      <span style=""
                        ><Icon type="md-help-circle" style="margin-top: -2px"
                      /></span>
                    </Poptip>
                  </template>
                  <Select v-model="peopleForm.riskLevel">
                    <Option value="1">一级</Option>
                    <Option value="2">二级</Option>
                    <Option value="3">三级</Option>
                  </Select>
                </FormItem>
              </p>
            </Col>
            <Col span="7">
              <p style="height: 40px">
                <FormItem label="危险性评估等级" prop="hazardAssessmentLevel">
                  <Select v-model="peopleForm.hazardAssessmentLevel">
                    <Option value="3">3</Option>
                    <Option value="4">4</Option>
                    <Option value="5">5</Option>
                  </Select>
                </FormItem>
              </p>
            </Col>
          </Row>
          <Row style="margin-top: 15px">
            <Col span="23">
              <p style="height: 40px">
                <FormItem label="高度关注情形">
                  <Select
                    multiple
                    v-model="peopleForm.keyPersonHighlyConcernedRel"
                    placeholder="请选择高度关注情形"
                  >
                    <Option
                      v-for="(item, index) in situationList"
                      :key="index"
                      :value="item.highlyConcernedSituation"
                      >{{ item.highlyConcernedSituation }}</Option
                    >
                  </Select>
                </FormItem>
              </p>
            </Col>
          </Row>
          <Row style="margin-top: 15px">
            <Col span="8">
              <p style="height: 40px">
                <FormItem label="监管人姓名" prop="relatedPersonName">
                  <Input
                    v-model="peopleForm.relatedPersonName"
                    placeholder="请输入姓名"
                    :maxlength="32"
                  ></Input>
                </FormItem>
              </p>
            </Col>
            <Col span="15">
              <p style="height: 40px">
                <FormItem label="与本人关系" prop="relatedPersonRelation">
                  <Select
                    v-model="peopleForm.relatedPersonRelation"
                    placeholder="请选择与本人关系"
                  >
                    <Option
                      v-for="(item, index) in dicList"
                      :key="index"
                      :value="item.id"
                      >{{ item.label }}</Option
                    >
                  </Select>
                </FormItem>
              </p>
            </Col>
          </Row>
          <Row style="margin-top: 15px">
            <Col span="23">
              <Col span="12">
                <p style="height: 40px">
                  <FormItem
                    label="监管人单位或住址"
                    prop="relatedPersonAddress"
                  >
                    <Input
                      v-model="peopleForm.relatedPersonAddress"
                      placeholder="请输入单位或住址"
                      :maxlength="128"
                    ></Input>
                  </FormItem>
                </p>
              </Col>
              <Col span="12">
                <p style="height: 40px">
                  <FormItem label="监管人联系方式" prop="relatedPersonPhone">
                    <Input
                      v-model="peopleForm.relatedPersonPhone"
                      placeholder="请输入联系方式"
                      :maxlength="32"
                    ></Input>
                  </FormItem>
                </p>
              </Col>
            </Col>
          </Row>
          <Row style="margin-top: 15px">
            <Col span="23">
              <Col span="12">
                <p style="height: 40px">
                  <FormItem label="列控单位" prop="controlCompanySupervisor">
                    <Input
                      v-model="peopleForm.controlCompanySupervisor"
                      placeholder="请输入列控单位"
                      :maxlength="128"
                    ></Input>
                  </FormItem>
                </p>
              </Col>
              <Col span="12">
                <p style="height: 40px">
                  <FormItem
                    label="责任人"
                    prop="controlCompanySupervisorPerson"
                  >
                    <Input
                      v-model="peopleForm.controlCompanySupervisorPerson"
                      placeholder="请输入责任人"
                      :maxlength="128"
                    ></Input>
                  </FormItem>
                </p>
              </Col>
            </Col>
          </Row>
          <Row style="margin-top: 15px">
            <Col span="23">
              <p>
                <FormItem label="备注信息">
                  <Input
                    :disabled="onlyShow"
                    v-model="peopleForm.remarks"
                    type="textarea"
                    :rows="4"
                    placeholder="请输入备注信息"
                    :maxlength="300"
                  />
                </FormItem>
              </p>
            </Col>
          </Row>
        </Form>
        <div slot="footer">
          <div v-if="peopleForm.formtype !== 'detail'">
            <Button
              :loading="loading"
              size="large"
              type="text"
              @click="closeModal"
              >取消</Button
            >
            <Button
              :disabled="peopleForm.confirmButton"
              :loading="loading"
              size="large"
              type="primary"
              @click="createPeopleConfirm"
              >确定</Button
            >
          </div>
        </div>
      </Modal>
      <Modal v-model="isShowMDDetail" title="矛盾列表" width="1200">
        <Table border :columns="mdColumns" :data="mdDataList">
          <template slot-scope="{ row, index }" slot="status">
            <div v-if="row.status == '1'">已办结</div>
            <div v-else-if="row.status == '2'">处理中</div>
          </template>
          <template slot-scope="{ row, index }" slot="event_source">
            <div v-if="row.event_source == '1'">pc端</div>
            <div v-else-if="row.event_source == '2'">app端</div>
            <div v-else-if="row.event_source == '3'">第三方对接</div>
          </template>
          <template slot-scope="{ row, index }" slot="is_early_warning">
            <div class="flex-div">
              <div class="circle-div3" v-if="row.is_early_warning == '1'"></div>
              <div class="circle-div2" v-if="row.is_early_warning == '3'"></div>
              <div class="circle-div1" v-if="row.is_early_warning == '4'"></div>
            </div>
          </template>
          <template slot-scope="{ row, index }" slot="risk_level">
            <div class="flex-div">
              <div v-if="row.risk_level == '一般矛盾纠纷'">
                <img
                  class="level-option-img"
                  src="@/assets/images/warning4.png"
                  alt=""
                />
                <span style="padding-left: 10px">一般矛盾纠纷</span>
              </div>
              <div v-if="row.risk_level == '复杂矛盾纠纷'">
                <img
                  class="level-option-img"
                  src="@/assets/images/warning5.png"
                  alt=""
                />
                <span style="padding-left: 10px">复杂矛盾纠纷</span>
              </div>
              <div v-if="row.risk_level == '重大矛盾纠纷'">
                <img
                  class="level-option-img"
                  src="@/assets/images/warning6.png"
                  alt=""
                />
                <span style="padding-left: 10px">重大矛盾纠纷</span>
              </div>
            </div>
          </template>
          <template slot-scope="{ row, index }" slot="is_point_event">
            <div v-if="row.is_point_event == '1'">是</div>
            <div v-else-if="row.is_point_event == '2'">否</div>
          </template>
          <template slot-scope="{ row, index }" slot="occurrence_address">
            <span
              >{{ row.cityId }}{{ row.areaId }}{{ row.streetId
              }}{{ row.communityId }}</span
            >
          </template>
          <template slot-scope="{ row, index }" slot="action">
            <div class="flex-div">
              <Button
                type="primary"
                class="mr5"
                @click="getInfo(row, 'contradiction')"
                >详情</Button
              >
            </div>
          </template>
        </Table>
        <Page
          class="page_style"
          :total="mdparams.totalRecord"
          :current="mdparams.pageNo"
          :page-size="mdparams.pageSize"
          @on-change="changePageNoMD"
          show-total
          show-sizer
          @on-page-size-change="sizeMD"
        />
        <div slot="footer">
          <Button type="text" size="large" @click="isShowMDDetail = false"
            >关闭</Button
          >
        </div>
      </Modal>
      <Modal v-model="isShowMDDetail2" title="矛盾详情" width="1200">
        <md-detail v-if="isShowMDDetail2" :mdParam="mdParam" />
        <div slot="footer">
          <Button type="text" size="large" @click="isShowMDDetail2 = false"
            >关闭</Button
          >
        </div>
      </Modal>
      <Modal v-model="peopleLog.show" title="走访日志信息列表" width="1200">
        <Button
          type="primary"
          @click="createPeopleLog"
          style="margin-bottom: 10px"
          >新增走访日志</Button
        >
        <Table
          border
          :columns="peopleLog.dataColumns"
          :data="peopleLog.dataList"
        >
          <template slot-scope="{ row, index }" slot="is_pitfall">
            <span v-if="row.is_pitfall === '1'">是</span>
            <span v-if="row.is_pitfall === '2'">否</span>
          </template>
          <template slot-scope="{ row, index }" slot="is_follow">
            <span v-if="row.is_follow === '1'">是</span>
            <span v-if="row.is_follow === '2'">否</span>
          </template>
          <template slot-scope="{ row, index }" slot="abnormal">
            <span v-if="row.abnormal === '1'">是</span>
            <span v-if="row.abnormal === '2'">否</span>
          </template>
          <template slot-scope="{ row, index }" slot="risk_level">
            <span v-if="row.risk_level === '1'">无风险</span>
            <span v-if="row.risk_level === '2'">低风险</span>
            <span v-if="row.risk_level === '3'">高风险</span>
          </template>
          <template slot-scope="{ row, index }" slot="action">
            <Button
              type="success"
              size="small"
              style="margin-right: 5px"
              @click="updatePeopleLog(row)"
              >编辑</Button
            >
            <Button
              type="primary"
              size="small"
              style="margin-right: 5px"
              @click="detailPeopleLog(row)"
              >详情</Button
            >
            <Button
              type="error"
              size="small"
              style="margin-right: 5px"
              @click="removePeopleLog(row)"
              >删除</Button
            >
          </template>
        </Table>
        <div slot="footer">
          <Button type="text" size="large" @click="peopleLog.show = false"
            >取消</Button
          >
          <Button type="primary" size="large" @click="peopleLog.show = false"
            >确定</Button
          >
        </div>
      </Modal>
      <Modal
        v-model="peopleLog.detailShow"
        title="走访日志信息详情"
        width="1200"
      >
        <Form ref="formEmployee" :label-width="100">
          <div class="title-style">身份信息</div>
          <Row style="margin-top: 30px">
            <Col span="8" style="margin-left: -4%">
              <FormItem label="姓名">
                <Input disabled v-model="peopleLog.info.user_name"></Input>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="身份证号">
                <Input disabled v-model="peopleLog.info.cardno"></Input>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="联系方式">
                <Input disabled v-model="peopleLog.info.tel"></Input>
              </FormItem>
            </Col>
          </Row>
          <div class="title-style">居住信息</div>
          <Row style="margin-top: 30px">
            <Col span="8" style="margin-left: -4%">
              <FormItem label="市（州）">
                <Input disabled v-model="peopleLog.info.cityName"></Input>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="县（市、区）">
                <Input disabled v-model="peopleLog.info.areaName"></Input>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="街道（乡镇）">
                <Input disabled v-model="peopleLog.info.streetName"></Input>
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8" style="margin-left: -4%">
              <FormItem label="社区（村）">
                <Input disabled v-model="peopleLog.info.communityName"></Input>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="网格">
                <Input disabled v-model="peopleLog.info.gardenName"></Input>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="楼">
                <Input disabled v-model="peopleLog.info.buildName"></Input>
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8" style="margin-left: -4%">
              <FormItem label="单元">
                <Input disabled v-model="peopleLog.info.unitName"></Input>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="层">
                <Input disabled v-model="peopleLog.info.floorName"></Input>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="户">
                <Input disabled v-model="peopleLog.info.doorplateName"></Input>
              </FormItem>
            </Col>
          </Row>
          <div class="title-style">走访信息</div>
          <Row>
            <Col span="8" style="margin-left: -4%">
              <FormItem label="日期">
                <DatePicker
                  disabled
                  type="date"
                  v-model="peopleLog.info.visit_date1"
                  style="width: 100%"
                ></DatePicker>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="走访人">
                <Input
                  disabled
                  v-model="peopleLog.info.community_user_name"
                ></Input>
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="24" style="margin-left: -4%">
              <FormItem label="标签">
                <Tag
                  v-for="(item, index) in peopleLog.info.label_name_list"
                  :key="index"
                  color="error"
                  >{{ item }}</Tag
                >
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8" style="margin-left: -4%">
              <FormItem label="重点关注">
                <Select
                  v-model="peopleLog.info.is_follow"
                  placeholder="请选择是否重点人员"
                >
                  <Option value="1">是</Option>
                  <Option value="2">否</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="是否存在隐患">
                <Select
                  v-model="peopleLog.info.is_pitfall"
                  placeholder="是否存在隐患"
                >
                  <Option value="1">是</Option>
                  <Option value="2">否</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="是否异常人员">
                <Select
                  v-model="peopleLog.info.abnormal"
                  placeholder="是否异常人员"
                >
                  <Option value="1">是</Option>
                  <Option value="2">否</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="8" style="margin-left: -4%">
              <FormItem label="矛盾风险等级">
                <Select
                  v-model="peopleLog.info.risk_level"
                  placeholder="矛盾风险等级"
                >
                  <Option value="1">无风险</Option>
                  <Option value="2">低风险</Option>
                  <Option value="3">高风险</Option>
                </Select>
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="24" style="margin-left: -4%">
              <FormItem label="走访内容">
                <Input
                  :rows="6"
                  type="textarea"
                  v-model="peopleLog.info.visit_content"
                ></Input>
              </FormItem>
            </Col>
          </Row>
        </Form>
        <div slot="footer">
          <Button type="text" size="large" @click="peopleLog.detailShow = false"
            >取消</Button
          >
          <Button
            :disabled="peopleLog.confirmButton"
            type="primary"
            size="large"
            @click="peopleLogConfirm"
            >确定</Button
          >
        </div>
      </Modal>
      <Modal v-model="importShow" title="数据导入" width="300">
        <Row type="flex" justify="center" align="middle">
          <Col span="10">
            <div style="text-align: center;">
            <Upload
              :show-upload-list="false"
              :before-upload="handleBeforeUpload"
              :format="['xls','xlsx']"
              accept=".xls,.xlsx"
              :max-size="4096">
              <Button icon="ios-cloud-upload-outline" type="primary" :loading="impBtnDisabled">导入</Button>
            </Upload>
            </div>
          </Col>
          <Col span="12">
            <div style="text-align: center;">
            <Button type="primary" @click="tplDownload" style="margin-right: 10px;">下载模板</Button>
            </div>
          </Col>
        </Row>
        <div slot="footer">
          <Button size="large" type="text" @click="importShow = false">关闭</Button>
        </div>
      </Modal>
    </div>
    <family-manage :peopleInfo="peopleInfo" ref="family"></family-manage>
    <rating-history-list :peopleInfo="peopleInfo" ref="ratingHistoryListRef"></rating-history-list>
    <zf-log ref="zflog" />
  </div>
</template>
<script>
import {
  findKeyPersonList,
  deleteKeyPersonById,
  insertKeyPersonById,
  updateKeyPersonById,
  // createPeopleInfo,
  createPeopleZFLog,
  // findLabelList,
  findMZList,
  // findPeopleInfoList,
  findPeopleZFLogList,
  getPeopleInfoByCardno,
  updatePeopleZFLog,
  selectGardenList,
  selectBuildingList,
  selectUnitList,
  selectFloorList,
  selectDoorplateList,
  // updateIsSpecial,
  deletePeopleZFLog,
  getLoginUserAreaInfo,
  doStatusAllCount,
  getVisitButtonPower,
  importExcel
} from '@/api/peopleInfo'
import {
  findEventPageList,
  getCardNoById,
  selectCityList,
  selectDictList
} from '@/api/contradiction.js'
import { date0str1 } from '@/api/eventlist'
import ceShiImg from '@/assets/contradictionImgs/test1.png'
import mdDetail from './components/mdDetail.vue'
import familyManage from './components/familyManage.vue'
import zfLog from './components/zfLog.vue'
import { getDictList } from '@/api/common'
import axios from 'axios'
import ratingHistoryList from '../key-person/key-person-rating/ratingHistoryList.vue'
export default {
  name: 'index',
  components: {
    mdDetail,
    zfLog,
    familyManage,
    ratingHistoryList
  },
  data () {
    return {
      dicList: [],
      cityType: false,
      title: '',
      cityList: [],
      areaList: [],
      areaDict: [],
      currentUserLevel: '', // 当前用户层级，用于控制下拉框禁用状态
      streetList: [],
      communityList: [],
      cityListForm: [],
      areaListForm: [],
      streetListForm: [],
      communityListForm: [],
      ratingLevelDict: [],
      col26List: [
        { id: 1, name: '多次犯罪记录和严重犯罪行为犯罪史' },
        { id: 2, name: '服刑期间有违规违纪行为' },
        {
          id: 3,
          name: '心理和行为评估发现存在反社会人格障碍、心理扭曲、情绪不稳定和暴力倾向'
        },
        { id: 4, name: '教育程度低，缺乏必要的职业技能和就业能力' },
        { id: 5, name: '缺乏家庭关爱、亲人疏远，或者在社会上受到歧视、排斥' },
        {
          id: 6,
          name: '经济困难、生活无以为继，又无法通过合法途径获得足够的经济资源'
        },
        {
          id: 7,
          name: '继续与有犯罪前科或不良行为的人频繁交往，仍然保持不良生活方式，如赌博、酗酒、吸毒等'
        },
        {
          id: 8,
          name: '表现出对社会不满、怨恨情绪，对法律和社会秩序缺乏尊重和认同，有报复社会的想法或言论'
        }
      ],
      situationList: [
        { highlyConcernedSituation: '婚姻家庭不幸' },
        { highlyConcernedSituation: '有重大疾病' },
        { highlyConcernedSituation: '有暴力倾向' },
        { highlyConcernedSituation: '有弃世厌世倾向' },
        { highlyConcernedSituation: '扬言报复社会' }
      ],
      ruleValidate: {
        name: [{ required: true, message: '必填', trigger: 'blur' }],
        sex: [{ required: true, message: '必填', trigger: 'change' }],
        // cardNo: [
        //   { required: true, message: '必填', trigger: 'blur' }
        // ],
        folk: [{ required: true, message: '必填', trigger: 'change' }],
        // phone: [
        //   { required: true, message: '必填', trigger: 'blur' }
        // ],
        cityId: [{ required: true, message: '必填', trigger: 'change' }],
        areaId: [{ required: true, message: '必填', trigger: 'change' }],
        streetId: [{ required: true, message: '必填', trigger: 'change' }],
        communityId: [{ required: true, message: '必填', trigger: 'change' }],
        address: [{ required: true, message: '必填', trigger: 'blur' }],
        registeredResidence: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        involvingConflictsDisputes: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        riskLevel: [{ required: true, message: '必填', trigger: 'blur' }],
        relatedPersonName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        relatedPersonRelation: [
          { required: true, message: '必选', trigger: 'change' }
        ],
        relatedPersonAddress: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        relatedPersonPhone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        controlCompanySupervisor: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        controlCompanySupervisorPerson: [
          { required: true, message: '必填', trigger: 'blur' }
        ]
      },
      ceShiImg,
      url: ceShiImg,
      changChunTableColumns: [
        // 市 区  街道 社区 姓名  身份证号 联系方式 矛盾风险等级 高度关注情形
        { type: 'index', title: '序号', align: 'center', width: '100' },
        { title: '市（州）', key: 'cityName', align: 'center', width: '100' },
        {
          title: '县（市、区）',
          key: 'areaName',
          align: 'center',
          width: '120'
        },
        {
          title: '街道（乡镇）',
          key: 'streetName',
          align: 'center',
          width: '120'
        },
        {
          title: '社区（村）',
          key: 'communityName',
          align: 'center',
          width: '120'
        },
        { title: '姓名', key: 'name', align: 'center', width: '100' },
        { title: '身份证号 ', key: 'cardNo', align: 'center', width: '280' },
        { title: '联系方式', key: 'phone', align: 'center', width: '180' },
        // { title: '是否涉矛盾纠纷', slot: 'involvingConflictsDisputes', align: 'center', width: '100' },
        {
          title: '危险性评估等级',
          key: 'hazardAssessmentLevel',
          align: 'center',
          width: '90'
        },
        {
          title: '高度关注情形',
          slot: 'keyPersonHighlyConcernedRel',
          align: 'center',
          width: '250'
        },
        {
          title: '风险等级',
          key: 'ratingTypeName',
          align: 'center',
          width: '90'
        },
        {
          title: '分数',
          key: 'rating',
          align: 'center',
          width: '90'
        },
        {
          title: '评分时间',
          key: 'ratingTime',
          align: 'center',
          width: '150'
        },
        {
          title: '评分开始日期',
          key: 'planStartData',
          align: 'center',
          width: '120'
        },
        {
          title: '评分截止日期',
          key: 'planEndData',
          align: 'center',
          width: '120'
        },
        {
          title: '评分临期日期',
          key: 'overdueDate',
          align: 'center',
          width: '120'
        },
        { title: '剩余办理天数', key: 'remainDays', align: 'center', width: 120 },
        { title: '是否临期', slot: 'isOverdue', minWidth: 100, align: 'center' },
        { title: '评分状态', slot: 'doStatus', minWidth: 100, align: 'center', fixed: 'right' },
        {
          title: '操作',
          slot: 'action',
          fixed: 'right',
          align: 'center',
          width: '360'
        }
      ],
      tableColumns: [
        // 市 区  街道 社区 姓名  身份证号 联系方式 矛盾风险等级 高度关注情形
        { type: 'index', title: '序号', align: 'center', width: '100' },
        { title: '市（州）', key: 'cityName', align: 'center', width: '100' },
        {
          title: '县（市、区）',
          key: 'areaName',
          align: 'center',
          width: '120'
        },
        {
          title: '街道（乡镇）',
          key: 'streetName',
          align: 'center',
          width: '120'
        },
        {
          title: '社区（村）',
          key: 'communityName',
          align: 'center',
          width: '120'
        },
        { title: '姓名', key: 'name', align: 'center', width: '100' },
        { title: '身份证号 ', key: 'cardNo', align: 'center', width: '280' },
        { title: '联系方式', key: 'phone', align: 'center', width: '180' },
        // { title: '是否涉矛盾纠纷', slot: 'involvingConflictsDisputes', align: 'center', width: '100' },
        {
          title: '危险性评估等级',
          key: 'hazardAssessmentLevel',
          align: 'center',
          width: '90'
        },
        {
          title: '高度关注情形',
          slot: 'keyPersonHighlyConcernedRel',
          align: 'center',
          width: '250'
        },
        {
          title: '操作',
          slot: 'action',
          fixed: 'right',
          align: 'center',
          width: '340'
        }
      ],
      tableData: [],
      tableLoading: false,
      params: {
        sysType: '3',
        pageNo: 1,
        pageSize: 10,
        totalRecord: 0
      },
      mdparams: {
        pageNo: 1,
        pageSize: 10,
        totalRecord: 0
      },
      controlData: {
        cardnoInput: '',
        show: false
      },
      peopleForm: {
        cityId: '',
        areaId: '',
        streetId: '',
        communityId: '',
        key_focus_personnel_type_json: {},
        show: false,
        confirmButton: false
      },
      labelList: [],
      mzList: [],
      peopleLog: {
        dataColumns: [
          { type: 'index', title: '序号', align: 'center', width: '80' },
          { title: '姓名', key: 'user_name', align: 'center', width: '80' },
          { title: '身份证号 ', key: 'grid_user_cardno', align: 'center' },
          { title: '联系方式', key: 'tel', align: 'center' },
          { title: '是否重点关注', slot: 'is_follow', align: 'center' },
          { title: '是否存在隐患', slot: 'is_pitfall', align: 'center' },
          { title: '是否异常人员', slot: 'abnormal', align: 'center' },
          { title: '矛盾风险等级', slot: 'risk_level', align: 'center' },
          { title: '走访日期', key: 'visit_date', align: 'center' },
          {
            title: '操作',
            slot: 'action',
            fixed: 'right',
            align: 'center',
            width: '180'
          }
        ],
        dataList: [],
        show: false,
        detailShow: false,
        info: {},
        confirmButton: false,
        tableLoading: false,
        operate_type: ''
      },
      isShowMDDetail: false,
      isShowMDDetail2: false,
      loading: false,
      severUserInfo: {},
      mdColumns: [
        { type: 'index', title: '序号', align: 'center', width: '80px' },
        { title: '矛盾状态', slot: 'status', align: 'center', width: '100px' },
        {
          title: '矛盾来源',
          slot: 'event_source',
          align: 'center',
          width: '100px'
        },
        {
          title: '纠纷编号',
          key: 'event_code',
          align: 'center',
          width: '160px'
        },
        {
          title: '超时提示',
          slot: 'is_early_warning',
          align: 'center',
          width: '90px'
        },
        {
          title: '矛盾风险等级',
          slot: 'risk_level',
          align: 'center',
          width: '140px'
        },
        {
          title: '重点矛盾',
          slot: 'is_point_event',
          align: 'center',
          width: '90px'
        },
        {
          title: '纠纷大类',
          key: 'event_category_id',
          align: 'center',
          width: '90px'
        },
        {
          title: '纠纷小类',
          key: 'event_type_id',
          align: 'center',
          width: '200px'
        },
        {
          title: '纠纷发生时间',
          key: 'occurrence_time',
          align: 'center',
          width: '150px'
        },
        {
          title: '纠纷描述',
          key: 'dispute_description',
          align: 'center',
          width: '200px'
        },
        {
          title: '纠纷发生地',
          slot: 'occurrence_address',
          align: 'center',
          width: '140px'
        },
        { title: '详细地址', key: 'address', align: 'center', width: '140px' },
        {
          title: '上报人',
          key: 'reporting_name',
          align: 'center',
          width: '90px'
        },
        {
          title: '上报单位',
          key: 'reporting_unit',
          align: 'center',
          width: '100px'
        },
        {
          title: '操作',
          slot: 'action',
          fixed: 'right',
          align: 'center',
          width: '120px'
        }
      ],
      mdDataList: [],
      mdParam: {},
      gardenList: [],
      buildingList: [],
      unitList: [],
      floorList: [],
      doorplateList: [],
      selectKeyList: ['building', 'unit', 'floor', 'doorplate'],
      onlyShow: false,
      peopleInfo: {},
      cardnoWJM: '',
      zfListId: '',
      todoCount: '',
      doneCount: '',
      visitButtonPower: {},
      importShow: false,
      impBtnDisabled: false
    }
  },
  methods: {
    fetchVisitButtonPower () {
      const payload = {}
      return getVisitButtonPower(payload).then((ret) => {
        if (ret && ret.data && ret.data.errcode === 0) {
          this.visitButtonPower = ret.data.data || {}
        } else {
          this.visitButtonPower = {}
        }
      }).catch(() => { this.visitButtonPower = {} })
    },
    canShowVisit (row) {
      const isAdmin = (this.severUserInfo.loginName === 'admin')
      const power = this.visitButtonPower || {}

      const type = String(row.sysType || '')
      if (isAdmin) return true
      if (type === '2') return !!power['rucs_rating']
      if (type === '3') return !!power['psmd_rating']
      if (type === '6') return !!power['km_rating']
      return false
    },
    canShowRating (row) {
      const isAdmin = (this.severUserInfo.loginName === 'admin')
      const power = this.visitButtonPower || {}

      const type = String(row.sysType || '')
      if (isAdmin) return true
      if (type === '2') return !!power['rucs_rating'] || !!power['rucs_view_rating']
      if (type === '3') return !!power['psmd_rating'] || !!power['psmd_view_rating']
      if (type === '6') return !!power['km_rating'] || !!power['km_view_rating']
      return false
    },
    canRatingColumn () {
      const isAdmin = (this.severUserInfo.loginName === 'admin')
      const power = this.visitButtonPower || {}

      const type = '3'
      if (isAdmin) return true
      if (type === '2') return !!power['rucs_rating'] || !!power['rucs_view_rating']
      if (type === '3') return !!power['psmd_rating'] || !!power['psmd_view_rating']
      if (type === '6') return !!power['km_rating'] || !!power['km_view_rating']
      return false
    },
    getArea () {
      selectDictList({ type: 'jl_key_person_region' }).then((res) => {
        if (res.data.errcode === 0) {
          this.areaDict = res.data.data
          return
        }
        this.$Message.error(res.errmsg)
      })
      selectDictList({ type: 'rating_level' }).then((res) => {
        if (res.data.errcode === 0) {
          this.ratingLevelDict = res.data.data
          return
        }
        this.$Message.error(res.errmsg)
      })
    },
    checkNum (rule, value, callback) {
      if (!value) {
        callback(new Error('必填'))
      } else if (
        !/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(
          value
        )
      ) {
        callback(new Error('格式不正确'))
      } else {
        callback()
      }
    },
    checkCardNo (rule, value, callback) {
      if (!value) {
        callback(new Error('必填'))
      } else if (
        !/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(
          value
        )
      ) {
        callback(new Error('格式不正确'))
      } else {
        callback()
      }
    },
    async handleDownload () {
      try {
        const response = await axios.post(
          '/api/ac/jilinsscgsdp/murderManagementService/findKeyPersonListExport',
          { ...this.searchInfo, sysType: '3' },
          {
            responseType: 'blob'
          }
        )
        const url = window.URL.createObjectURL(new Blob([response.data]))
        // 创建隐藏的a标签并设置属性
        const link = document.createElement('a')
        link.href = url
        link.download = '严重精神障碍患者导出.xlsx' // 自定义下载文件名和扩展名
        link.style.display = 'none'
        document.body.appendChild(link)
        // 触发点击下载
        link.click()
        // 清理
        document.body.removeChild(link)
        window.URL.revokeObjectURL(url)
      } catch (error) {
        console.error('下载失败:', error)
        // 可以在这里添加错误提示
      }
    },
    getHighlyConcernedRelStr (arr) {
      if (!arr || arr.length === 0) {
        return ''
      }
      let result = ''
      arr.forEach((item) => {
        result += item.highlyConcernedSituation + ','
      })
      // 去掉最后一位
      result = result.slice(0, result.length - 1)
      return result
    },
    // 请选择市的 change 事件
    async changeCityForm (e, flag) {
      if (e) {
        this.peopleForm.cityId = e
      } else if (flag && flag === 'clear') {
        this.peopleForm.cityId = ''
      }
      if (!this.peopleForm.cityId) {
        this.areaListForm = []
        this.streetListForm = []
        this.communityListForm = []
        this.peopleForm.areaId = ''
        this.peopleForm.streetId = ''
        this.peopleForm.communityId = ''
        return Promise.resolve()
      }
      const res = await selectCityList({ parent_id: this.peopleForm.cityId })
      this.areaListForm = res.data.data
      // 清空下面的数组
      this.streetListForm = []
      this.communityListForm = []
      this.peopleForm.areaId = ''
      this.peopleForm.streetId = ''
      this.peopleForm.communityId = ''
    },
    // 请选择区的 change 事件
    async changeAreaForm (e, flag) {
      if (e) {
        this.peopleForm.areaId = e
      } else if (flag && flag === 'clear') {
        this.peopleForm.areaId = ''
      }
      if (!this.peopleForm.areaId) {
        this.streetListForm = []
        this.communityListForm = []
        this.peopleForm.streetId = ''
        this.peopleForm.communityId = ''
        return Promise.resolve()
      }
      const res = await selectCityList({ parent_id: this.peopleForm.areaId })
      this.streetListForm = res.data.data
      this.communityListForm = []
      this.peopleForm.streetId = ''
      this.peopleForm.communityId = ''
    },
    // 请选择街道的 change 事件
    async changeStreetForm (e, flag) {
      if (e) {
        this.peopleForm.streetId = e
      } else if (flag && flag === 'clear') {
        this.peopleForm.streetId = ''
      }
      if (!this.peopleForm.streetId) {
        this.communityListForm = []
        this.peopleForm.communityId = ''
        return Promise.resolve()
      }
      const res = await selectCityList({ parent_id: this.peopleForm.streetId })
      this.communityListForm = res.data.data
      this.peopleForm.communityId = ''
    },
    // 请选择社区的 change 事件
    changeCommunityForm (e, flag) {
      if (e) {
        this.peopleForm.communityId = e
      } else if (flag && flag === 'clear') {
        this.peopleForm.communityId = ''
      }
      return Promise.resolve()
    },
    changeAreaType (e) {
      if (e !== '1') {
        this.peopleForm.cityId = ''
        this.peopleForm.areaId = ''
        this.peopleForm.streetId = ''
        this.peopleForm.communityId = ''
      }
    },
    changeCity () {
      if (!this.params.cityId) {
        this.areaList = []
        this.streetList = []
        this.communityList = []
        this.params.areaId = ''
        this.params.streetId = ''
        this.params.communityId = ''
        return
      }
      selectCityList({ parent_id: this.params.cityId }).then((res) => {
        this.areaList = res.data.data
      })
      // 清空下面的数组
      this.streetList = []
      this.communityList = []
    },
    changeArea () {
      if (!this.params.areaId) {
        this.streetList = []
        this.communityList = []
        this.params.streetId = ''
        this.params.communityId = ''
        return
      }
      selectCityList({ parent_id: this.params.areaId }).then((res) => {
        this.streetList = res.data.data
      })
      this.communityList = []
    },
    showRatingList (row) {
      this.$router.push({
        name: 'keyPersonRatingDetails',
        params: {
          id: row.id,
          ratingDictType: '3',
          historyId: row.historyId,
          summaryId: row.summaryId,
          isHide: true
        }
      })
    },
    showRatingHistoryList (data) {
      this.peopleInfo = data
      this.$nextTick(() => {
        this.$refs.ratingHistoryListRef.init()
      })
    },
    changeStreet () {
      if (!this.params.streetId) {
        this.communityList = []
        this.params.communityId = ''
        return
      }
      selectCityList({ parent_id: this.params.streetId }).then((res) => {
        this.communityList = res.data.data
      })
    },
    async showDetail (data) {
      this.title = '详情'
      let keyPersonArr = []
      for (let i = 0; i < data.keyPersonHighlyConcernedRel.length; i++) {
        keyPersonArr.push(
          data.keyPersonHighlyConcernedRel[i].highlyConcernedSituation
        )
      }
      this.peopleForm = { ...data, show: true, formtype: 'detail', keyPersonHighlyConcernedRel: keyPersonArr }
      this.peopleForm.cityId = data.cityId
      await this.changeCityForm()
      this.peopleForm.areaId = data.areaId
      await this.changeAreaForm()
      this.peopleForm.streetId = data.streetId
      await this.changeStreetForm()
      this.peopleForm.communityId = data.communityId
    },
    closeModal () {
      this.peopleForm.show = false
    },
    showFamily (data) {
      this.peopleInfo = data
      this.$nextTick(() => {
        this.$refs.family.init()
      })
    },
    clearSelect (index) {
      for (let i = 3; i >= index; i--) {
        delete this.peopleForm[`${this.selectKeyList[i]}_id`]
        this.$set(this, `${this.selectKeyList[i]}List`, [])
      }
    },
    getDoorplateList (mark) {
      let id = mark === 'edit' ? this.peopleForm.floor_id : mark
      if (mark !== 'edit') {
        this.clearSelect(3)
      }
      selectDoorplateList({ floor_id: id }).then((res) => {
        if (res.data.errcode === 0) {
          this.doorplateList = res.data.data
          return
        }
        this.$Message.error(res.data.errmsg)
      })
    },
    getFloorList (mark) {
      let id = mark === 'edit' ? this.peopleForm.unit_id : mark
      if (mark !== 'edit') {
        this.clearSelect(2)
      }
      selectFloorList({ unit_id: id }).then((res) => {
        if (res.data.errcode === 0) {
          this.floorList = res.data.data
          if (mark === 'edit') {
            this.getDoorplateList(mark)
          }
          return
        }
        this.$Message.error(res.data.errmsg)
      })
    },
    getUnitList (mark) {
      let id = mark === 'edit' ? this.peopleForm.building_id : mark
      if (mark !== 'edit') {
        this.clearSelect(1)
      }
      selectUnitList({ building_id: id }).then((res) => {
        if (res.data.errcode === 0) {
          this.unitList = res.data.data
          if (mark === 'edit') {
            this.getFloorList(mark)
          }
          return
        }
        this.$Message.error(res.data.errmsg)
      })
    },
    getBuildingList (mark) {
      console.log(mark)
      let id = mark === 'edit' ? this.peopleForm.garden_id : mark
      if (mark !== 'edit') {
        this.clearSelect(0)
      }
      selectBuildingList({ garden_id: id }).then((res) => {
        if (res.data.errcode === 0) {
          this.buildingList = res.data.data
          if (mark === 'edit') {
            this.getUnitList(mark)
          }
          return
        }
        this.$Message.error(res.data.errmsg)
      })
    },
    getGardenByID (mark) {
      let id =
        mark === 'add'
          ? this.severUserInfo.company_id
          : this.peopleForm.community_id
      selectGardenList({ community_id: id }).then((res) => {
        if (res.data.errcode === 0) {
          this.gardenList = res.data.data
          if (mark === 'edit') {
            this.getBuildingList(mark)
          }
          return
        }
        this.$Message.error(res.data.errmsg)
      })
    },
    getInfo (row, level) {
      // 详情接口
      this.mdParam = {
        what: 'edit',
        id: row.id,
        level: level,
        type: this.type
      }
      this.isShowMDDetail2 = true
    },
    getlist (id) {
      getCardNoById({ id }).then((ret) => {
        if (ret.data.errcode === 0) {
          findEventPageList({
            event_cardno: ret.data.data.cardno
          }).then((res) => {
            if (res.data.errcode === 0) {
              this.mdDataList = res.data.data.results
              this.mdparams.totalRecord = res.data.data.totalRecord
              return
            }
            this.$Message.error(res.data.errmsg)
          })
        }
      })
    },
    showMDDetail (data) {
      this.isShowMDDetail = true
      this.getlist(data.id)
    },
    init () {
      if (this.params.involvingConflictsDisputes === '2') {
        delete this.params.riskLevel
      }
      this.params.isChangChun = this.cityType
      findKeyPersonList(this.params).then((ret) => {
        if (ret.data.errcode === 0) {
          this.params.totalRecord = ret.data.data.totalRecord
          this.tableData = ret.data.data.results
          this.tableLoading = false
        } else {
          this.$Notice.error({ title: '查询失败！', desc: ret.data.errmsg })
        }
      })
      doStatusAllCount(this.params).then(res => {
        if (res.data.errcode === 0) {
          this.todoCount = res.data.data.todoCount
          this.doneCount = res.data.data.doneCount
          return
        }
        this.$Message.error(res.data.errmsg)
      })
    },
    size (pageSize) {
      this.params.pageSize = pageSize
      this.changePageNo(1)
    },
    changePageNo (pageNo) {
      this.params.pageNo = pageNo
      this.init(this.params)
    },
    changePageNoMD (pageNo) {
      this.mdparams.pageNo = pageNo
      this.getList(this.mdparams)
    },
    sizeMD (pageSize) {
      this.mdparams.pageSize = pageSize
      this.changePageNoMD(1)
    },
    searchData () {
      this.params.distCard = ''
      this.params.pageNo = 1
      this.init()
    },
    getDistCard () {
      this.params.distCard = '1'
      this.params.pageNo = 1
      this.init()
    },
    searchPeople () {
      this.$refs.formPerson.resetFields()
      this.title = '新增'
      this.peopleForm = {
        ...this.peopleForm,
        confirmButton: false,
        show: true,
        involvingConflictsDisputes: '2',
        criminalTendency: '2'
        // region: '1'
      }
      // 重置当前用户层级
      this.currentUserLevel = ''

      // 调用 getLoginUserAreaInfo 接口获取当前登录人的层级和区域码信息
      getLoginUserAreaInfo({ area_id: this.$store.state.user.otherUserInfo.area_id }).then(async (res) => {
        if (res.data.errcode === 0) {
          const userInfo = res.data.data
          console.log('当前登录人信息:', userInfo)

          // 根据当前登录人的层级设置对应的区域码
          if (userInfo.type === '1') {
            // 层级1（省）无需任何操作
            console.log('当前用户为省级，无需设置默认区域')
          } else {
            // 解析 parentIds 字段，获取各级区域码
            const parentIdsArray = userInfo.parentIds.split(',')
            console.log('parentIds 解析结果:', parentIdsArray)

            // 设置当前用户层级，用于控制下拉框禁用状态
            this.currentUserLevel = userInfo.type

            if (userInfo.type === '2') {
              // 层级2（市），设置市
              this.peopleForm.cityId = userInfo.code
              await this.changeCityForm(this.peopleForm.cityId)
            } else if (userInfo.type === '3') {
              // 层级3（区），设置市和区
              // parentIds: "0,220000000000,220100000000" -> 省码在索引1，市码在索引2
              this.peopleForm.cityId = parentIdsArray[2] || userInfo.parentId
              await this.changeCityForm(this.peopleForm.cityId)
              this.peopleForm.areaId = userInfo.code
              await this.changeAreaForm(this.peopleForm.areaId)
            } else if (userInfo.type === '4') {
              // 层级4（街道），设置市、区、街道
              // parentIds: "0,220000000000,220100000000,220102000000" -> 省码在索引1，市码在索引2，区码在索引3
              this.peopleForm.cityId = parentIdsArray[2] || userInfo.parentId
              await this.changeCityForm(this.peopleForm.cityId)
              this.peopleForm.areaId = parentIdsArray[3] || userInfo.code
              await this.changeAreaForm(this.peopleForm.areaId)
              this.peopleForm.streetId = userInfo.code
              await this.changeStreetForm(this.peopleForm.streetId)
            } else if (userInfo.type === '5') {
              // 层级5（社区），设置市、区、街道、社区
              // parentIds: "0,220000000000,220100000000,220102000000,220102001000" -> 省码在索引1，市码在索引2，区码在索引3，街道码在索引4
              this.peopleForm.cityId = parentIdsArray[2] || userInfo.parentId
              await this.changeCityForm(this.peopleForm.cityId)
              this.peopleForm.areaId = parentIdsArray[3] || userInfo.code
              await this.changeAreaForm(this.peopleForm.areaId)
              this.peopleForm.streetId = parentIdsArray[4] || userInfo.code
              await this.changeStreetForm(this.peopleForm.streetId)
              this.peopleForm.communityId = userInfo.code
              await this.changeCommunityForm(this.peopleForm.communityId)
            }
          }
        } else {
          this.$Notice.error({
            title: '获取用户信息失败！',
            desc: res.data.errmsg
          })
        }
      })
        .catch((error) => {
          console.error('获取用户信息失败:', error)
          this.$Notice.error({ title: '获取用户信息失败！', desc: '网络错误' })
        })
    },
    getGenderByID (idNumber) {
      if (!idNumber || idNumber.length !== 18) {
        throw new Error('无效身份证号码')
      }
      const sexCode = idNumber.charAt(16)
      // 1:男，2:女
      const gender = parseInt(sexCode, 10) % 2 === 0 ? '2' : '1'
      return gender
    },
    searchConfirm () {
      this.peopleForm = {
        key_focus_personnel_type_json: {}
      }
      let data = {
        cardno: this.controlData.cardnoInput
      }
      // 如果新增就不调查询逻辑
      getPeopleInfoByCardno(data).then((ret) => {
        if (ret.data.errcode === 0) {
          if (ret.data.data === null) {
            this.$Notice.success({
              title: '查询结果！',
              desc: '未查询到人员信息！'
            })
            this.peopleForm.cardno = this.controlData.cardnoInput
            this.peopleForm.sex = this.getGenderByID(
              this.controlData.cardnoInput
            )
            delete this.controlData.cardnoInput
            this.controlData.show = false
            this.getGardenByID('add')
          } else {
            ret.data.data.cardno = this.controlData.cardnoInput
            let data = ret.data.data
            if (data.label_id) {
              data.label_id_list = JSON.parse(data.label_id)
            }
            this.peopleForm = data
            this.controlData.show = false
            this.getGardenByID('edit')
            console.log('his.peopleForm', this.peopleForm)
          }
          this.peopleForm.show = true
          this.onlyShow = false
          this.peopleForm.confirmButton = false
        } else {
          this.$Notice.error({ title: '查询失败！', desc: ret.data.errmsg })
        }
      })
    },
    createPeopleConfirm () {
      this.$refs['formPerson'].validate((valid) => {
        if (valid) {
          this.loading = true
          delete this.peopleForm.label_id
          if (this.peopleForm.id) {
            let arr = []
            if (
              this.peopleForm.keyPersonHighlyConcernedRel &&
              this.peopleForm.keyPersonHighlyConcernedRel.length > 0
            ) {
              arr = this.peopleForm.keyPersonHighlyConcernedRel.map((item) => {
                return { highlyConcernedSituation: item }
              })
            }
            if (this.peopleForm.involvingConflictsDisputes === '2') {
              delete this.peopleForm.riskLevel
            }
            updateKeyPersonById({
              ...this.peopleForm,
              keyPersonHighlyConcernedRel: arr,
              sysType: '3'
            }).then((ret) => {
              if (ret.data.errcode === 0) {
                this.$Notice.success({
                  title: '保存成功！',
                  desc: ret.data.errmsg
                })
                this.init()
                this.peopleForm.show = false
                this.controlData.show = false
                this.$refs['formPerson'].resetFields()
                this.loading = false
              } else {
                this.$refs['formPerson'].resetFields()
                this.$Notice.error({
                  title: '保存失败！',
                  desc: ret.data.errmsg
                })
                this.loading = false
              }
            })
          } else {
            let arr = []
            if (
              this.peopleForm.keyPersonHighlyConcernedRel &&
              this.peopleForm.keyPersonHighlyConcernedRel.length > 0
            ) {
              arr = this.peopleForm.keyPersonHighlyConcernedRel.map((item) => {
                return { highlyConcernedSituation: item }
              })
            }
            if (this.peopleForm.involvingConflictsDisputes === '2') {
              delete this.peopleForm.riskLevel
            }
            insertKeyPersonById({
              ...this.peopleForm,
              keyPersonHighlyConcernedRel: arr,
              sysType: '3'
            }).then((ret) => {
              if (ret.data.errcode === 0) {
                this.$Notice.success({
                  title: '保存成功！',
                  desc: ret.data.errmsg
                })
                this.init()
                this.peopleForm.show = false
                this.controlData.show = false
                this.$refs['formPerson'].resetFields()
                this.loading = false
              } else {
                this.loading = false
                this.$refs['formPerson'].resetFields()
                this.$Notice.error({
                  title: '保存失败！',
                  desc: ret.data.errmsg
                })
              }
            })
          }
          setTimeout(() => {
            this.loading = false
          }, 2000)
        } else {
          // 校验失败
        }
      })
    },
    findLabelList () {
      // 暂时不调接口
      this.labelList = [
        {
          id: '“三失一偏”',
          name: '“三失一偏”'
        },
        {
          id: '刑满释放',
          name: '刑满释放'
        },
        {
          id: '严重精神障碍',
          name: '严重精神障碍'
        },
        {
          id: '涉一级二级三级矛盾',
          name: '涉一级二级三级矛盾'
        },
        {
          id: '涉重点信访事项',
          name: '涉重点信访事项'
        },
        {
          id: '涉重点涉法涉诉',
          name: '涉重点涉法涉诉'
        }
      ]
      // findLabelList().then(ret => {
      //   if (ret.data.errcode === 0) {
      //     this.labelList = ret.data.data
      //   } else {
      //     this.$Notice.error({ title: '查询失败！', desc: ret.data.errmsg })
      //   }
      // })
    },
    findMZList () {
      findMZList().then((ret) => {
        if (ret.data.errcode === 0) {
          this.mzList = ret.data.data
        } else {
          this.$Notice.error({ title: '查询失败！', desc: ret.data.errmsg })
        }
      })
    },
    revert () {
      this.params.name = ''
      this.params.cardNo = ''
      this.params.cityId = ''
      this.params.areaId = ''
      this.params.streetId = ''
      this.params.communityId = ''
      this.params.riskLevel = ''
      this.params.criminalTendency = ''
      this.params.criminalTendencySituation = ''
      this.params.involvingConflictsDisputes = ''
      this.params.hazardAssessmentLevel = ''
      this.params.distCard = ''
      this.params.pageNo = 1
      this.params.pageSize = 10
      this.params.doStatus = null
      this.params.ratingLevel = null
      this.params.isOverdue = null
      this.searchData()
    },
    async updatePeopleInfo (e) {
      this.title = '编辑'
      let keyPersonArr = []
      for (let i = 0; i < e.keyPersonHighlyConcernedRel.length; i++) {
        keyPersonArr.push(
          e.keyPersonHighlyConcernedRel[i].highlyConcernedSituation
        )
      }
      this.peopleForm = { ...e, show: true, formtype: 'update', keyPersonHighlyConcernedRel: keyPersonArr }
      this.peopleForm.cityId = e.cityId
      await this.changeCityForm()
      this.peopleForm.areaId = e.areaId
      await this.changeAreaForm()
      this.peopleForm.streetId = e.streetId
      await this.changeStreetForm()
      this.peopleForm.communityId = e.communityId

      // 重置当前用户层级
      this.currentUserLevel = ''

      // 调用 getLoginUserAreaInfo 接口获取当前登录人的层级和区域码信息
      getLoginUserAreaInfo({ area_id: this.$store.state.user.otherUserInfo.area_id })
        .then((res) => {
          if (res.data.errcode === 0) {
            const userInfo = res.data.data
            console.log('当前登录人信息:', userInfo)
            this.currentUserLevel = userInfo.type
          } else {
            this.$Notice.error({
              title: '获取用户信息失败！',
              desc: res.data.errmsg
            })
          }
        })
        .catch((error) => {
          console.error('获取用户信息失败:', error)
          this.$Notice.error({ title: '获取用户信息失败！', desc: '网络错误' })
        })
    },
    deletePeopleInfo (e) {
      this.$Modal.confirm({
        title: '提示',
        content: '确认删除此重点人员？',
        onOk: () => {
          deleteKeyPersonById({ id: e.id }).then((res) => {
            if (res.data.errcode === 0) {
              this.$Notice.success({
                title: '删除成功！',
                desc: res.data.errmsg
              })
              this.init()
            } else {
              this.$Notice.error({
                title: '删除失败！',
                desc: res.data.errmsg
              })
            }
          })
        },
        onCancel: () => {
          this.$Modal.remove()
        }
      })
    },
    getZFLogList () {
      this.peopleLog.tableLoading = true
      findPeopleZFLogList({ id: this.zfListId }).then((ret) => {
        if (ret.data.errcode === 0) {
          this.peopleLog.tableLoading = false
          this.peopleLog.dataList = ret.data.data
          this.peopleLog.show = true
          // this.peopleLog.info.cardno = e.cardno
        } else {
          this.$Notice.error({ title: '查询失败！', desc: ret.data.errmsg })
        }
      })
    },
    findPeopleZFLogList (e) {
      this.$refs.zflog.show(e)
      // getCardNoById({ id: e.id }).then((res) => {
      //   if (res.data.errcode === 0) {
      //     this.cardnoWJM = res.data.data.cardno
      //     this.zfListId = e.id
      //     this.getZFLogList()
      //   } else {
      //     this.$Notice.error({ title: '查询失败！', desc: res.data.errmsg })
      //   }
      // })
    },
    createPeopleLog () {
      let data = {
        cardno: this.cardnoWJM
      }
      getPeopleInfoByCardno(data).then((ret) => {
        if (ret.data.errcode === 0) {
          this.peopleLog.info = ret.data.data
          this.peopleLog.info.cardno = this.cardnoWJM
          this.peopleLog.info.visit_date1 = new Date()
          this.peopleLog.info.user_id = this.severUserInfo.id
          this.peopleLog.info.community_user_name = this.severUserInfo.name
          // if (this.peopleLog.info.label_name) {
          //   this.peopleLog.info.label_name_list = JSON.parse(this.peopleLog.info.label_name)
          // }
          this.peopleLog.operate_type = 'create'
          this.peopleLog.detailShow = true
          this.peopleLog.confirmButton = false
        } else {
          this.$Notice.error({ title: '查询失败！', desc: ret.data.errmsg })
        }
      })
    },
    updatePeopleLog (e) {
      let data = JSON.parse(JSON.stringify(e))
      data.grid_user_cardno = this.cardnoWJM
      data.cardno = this.cardnoWJM
      console.log(data, '3333333')
      this.peopleLog.operate_type = 'update'
      this.peopleLog.info = data
      this.peopleLog.info.visit_date1 = e.visit_date
      // if (this.peopleLog.info.label_name) {
      //   this.peopleLog.info.label_name_list = JSON.parse(this.peopleLog.info.label_name)
      // }
      this.peopleLog.detailShow = true
      this.peopleLog.confirmButton = false
    },
    peopleLogConfirm () {
      let data = {
        cardno: this.peopleLog.info.cardno,
        city_id: this.peopleLog.info.city_id,
        street_id: this.peopleLog.info.street_id,
        community_id: this.peopleLog.info.community_id,
        is_pitfall: this.peopleLog.info.is_pitfall,
        abnormal: this.peopleLog.info.abnormal,
        risk_level: this.peopleLog.info.risk_level,
        is_follow: this.peopleLog.info.is_follow,
        visit_content: this.peopleLog.info.visit_content,
        attachment: this.peopleLog.info.attachment,
        visit_date: date0str1(this.peopleLog.info.visit_date1)
      }
      if (this.peopleLog.operate_type === 'create') {
        createPeopleZFLog(data).then((ret) => {
          if (ret.data.errcode === 0) {
            this.getZFLogList()
            this.peopleLog.detailShow = false
            this.$Notice.success({
              title: '保存成功！',
              desc: ret.data.errmsg
            })
          } else {
            this.$Notice.error({ title: '查询失败！', desc: ret.data.errmsg })
          }
        })
      }
      if (this.peopleLog.operate_type === 'update') {
        data.id = this.peopleLog.info.id
        updatePeopleZFLog(data).then((ret) => {
          if (ret.data.errcode === 0) {
            this.getZFLogList(data)
            this.peopleLog.detailShow = false
            this.$Notice.success({
              title: '保存成功！',
              desc: ret.data.errmsg
            })
          } else {
            this.$Notice.error({ title: '查询失败！', desc: ret.data.errmsg })
          }
        })
      }
    },
    detailPeopleLog (e) {
      let data = JSON.parse(JSON.stringify(e))
      data.grid_user_cardno = this.cardnoWJM
      data.cardno = this.cardnoWJM
      this.peopleLog.info = data
      this.peopleLog.info.visit_date1 = e.visit_date
      // if (this.peopleLog.info.label_name) {
      //   this.peopleLog.info.label_name_list = JSON.parse(this.peopleLog.info.label_name)
      // }
      this.peopleLog.detailShow = true
      this.peopleLog.confirmButton = true
    },
    removePeopleLog (e) {
      this.$Modal.confirm({
        title: '是否确认删除？',
        loading: true,
        onOk: () => {
          deletePeopleZFLog({ id: e.id }).then((ret) => {
            if (ret.data.errcode === 0) {
              this.$Notice.success({ title: '删除成功！' })
              this.getZFLogList()
            } else {
              this.$Notice.error({ title: '删除失败！' })
            }
          })
          this.$Modal.remove()
        }
      })
    },
    async tplDownload () {
      try {
        const response = await axios.post(
          '/api/ac/jilinsscgsdp/keyPersonRatingHistoryService/templateDownload',
          { ...this.searchInfo, sysType: '3' },
          {
            responseType: 'blob'
          }
        )
        const url = window.URL.createObjectURL(new Blob([response.data]))
        // 创建隐藏的a标签并设置属性
        const link = document.createElement('a')
        link.href = url
        link.download = '重点人群导入模板.xlsx' // 自定义下载文件名和扩展名
        link.style.display = 'none'
        document.body.appendChild(link)
        // 触发点击下载
        link.click()
        // 清理
        document.body.removeChild(link)
        window.URL.revokeObjectURL(url)
      } catch (error) {
        console.error('下载失败:', error)
        // 可以在这里添加错误提示
      }
    },
    handleBeforeUpload (file) {
      console.log('fileupload....')
      const fileExt = file.name.split('.').pop().toLocaleLowerCase()
      if (fileExt === 'xlsx' || fileExt === 'xls') {
        this.readFile(file)
      } else {
        this.$Notice.warning({
          title: '文件类型错误',
          desc: '文件：' + file.name + '不是EXCEL文件，请选择后缀为.xlsx或者.xls的EXCEL文件。'
        })
      }
      return false
    },
    // 读取文件
    async readFile (file) {
      this.impBtnDisabled = true
      const formdata = new FormData()
      formdata.append('file', file)
      formdata.append('fileName', file.name)
      formdata.append('sysType', 3)
      formdata.append('cityId', this.peopleForm.cityId)
      const ret = await importExcel(formdata)

      if (ret && ret.data) {
        this.importShow = false
        this.impBtnDisabled = false
        let mobj = ret.data.data
        let msg = '添加' + mobj.insert + '条, 更新' + mobj.update + '条'
        if (mobj.error !== 0) {
          msg += ', 缺少关键信息未能导入' + mobj.error + '条'
        }
        if (mobj.errInfo && mobj.errInfo !== '') {
          msg += ', 以下人员位置信息未找到未能导入' + mobj.errInfo
        }
        if (ret.data.errmsg !== 'success') {
          msg += ret.data.errmsg
        }
        if (mobj.insert + mobj.update > 0) {
          this.searchData()
        }
        this.$Notice.success({
          title: '导入完成！',
          desc: msg
        })
      } else {
        this.impBtnDisabled = false
        this.$Notice.warning({
          title: '未导入数据！',
          desc: ret.data.errmsg
        })
      }
    },
    showImport () {
      const info = this.$store.state.user.otherUserInfo || {}
      const areaId = info.area_id || ''
      if (areaId.startsWith('2201')) {
        return true
      } else {
        return false
      }
    }
  },
  mounted () {
    // 只有长春市才显示评分相关功能和后端走新的横行权限
    this.severUserInfo = this.$store.state.user.otherUserInfo
    if (this.severUserInfo.parent_ids.includes('220100000000') || this.severUserInfo.loginName === 'admin') {
      this.cityType = true
    } else if (this.severUserInfo.company_id === '220100000000' || this.severUserInfo.loginName === 'admin') {
      this.cityType = true
    } else if (this.severUserInfo.area_id === '220100000000' || this.severUserInfo.loginName === 'admin') {
      this.cityType = true
    }
    if (this.cityType) {
      this.situationList.push({ highlyConcernedSituation: '重新犯罪' })
      this.situationList.push({ highlyConcernedSituation: '黑恶' })
      this.situationList.push({ highlyConcernedSituation: '恶性犯罪' })
      this.situationList.push({ highlyConcernedSituation: '邪教' })
      this.situationList.push({ highlyConcernedSituation: '三无人员' })
      this.situationList.push({ highlyConcernedSituation: '其他' })
    }
    // 接收来自图表点击的风险等级参数
    const riskLevel = this.$route.query.riskLevel
    if (riskLevel) {
      // 设置风险等级筛选条件
      this.params.ratingLevel = riskLevel
    }
    // 接收来自评分预期预警的评分状态参数
    const doStatus = this.$route.query.doStatus
    if (doStatus) {
      // 设置评分状态筛选条件
      this.params.doStatus = doStatus
    }
    // 接收临期状态参数
    const isOverdue = this.$route.query.isOverdue
    if (isOverdue) {
      this.params.isOverdue = isOverdue
    }
    this.fetchVisitButtonPower()
    this.init()
    this.findMZList()
    this.findLabelList()
    this.getArea()
    selectCityList({}).then((res) => {
      this.cityList = res.data.data
      this.cityListForm = JSON.parse(JSON.stringify(res.data.data))
    })
    getDictList({ type: 'domestic_relation' }).then((ret) => {
      if (ret.data.errcode === 0) {
        this.dicList = ret.data.data.results
        console.log(this.dicList, '字典')
      } else {
        this.$Notice.error({ title: '获取字典列表失败', desc: '' })
      }
    })
  },
  filters: {
    disposeLabel: function (value) {
      if (!value) return ''
      // value = JSON.parse(value)
      // value = value.join(',')
      // return value
      return ''
    }
  }
}
</script>
<style scoped>
.contradiction-div {
  padding: 10px;
}
.contradiction-div .search-div {
  width: 100%;
  padding: 15px 15px 15px 15px;
  border: 1px solid skyblue;
  background-color: azure;
  margin-bottom: 15px;
}
.mb10 {
  margin-bottom: 10px;
}
.mt8 {
  margin-top: 8px;
}
.mr15 {
  margin-right: 15px;
}
.mr5 {
  margin-right: 5px;
}
.page_style {
  margin-top: 10px;
  text-align: right;
}
.flex-div {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
.circle-div1 {
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: red;
}
.circle-div2 {
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: orange;
}
.circle-div3 {
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: green;
}
.show-more {
  margin-top: 5px;
  cursor: pointer;
}
.contradiction-div >>> .ivu-form .ivu-form-item-label {
  text-align: center;
}
.title-style {
  padding: 8px 12px;
  background-color: #ecf8ff;
  border-radius: 4px;
  border-left: 5px solid #50bfff;
  margin: 15px 0;
  font-size: 16px;
  width: 100%;
}
</style>
