<template>
  <div class="container">
    <header class="mb-20">
      <el-form :label-width="114">
        <el-row>
          <el-col :span="6">
            <el-form-item label="任务名称">
              <el-input
                  placeholder="请输入任务名称"
                  v-model="query.taskName"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="督察类型">
              <el-select v-model="query.taskType" clearable>
                <el-option
                    v-for="(item,key) in supervisionDict"
                    :key="key"
                    :label="item.dictLabel"
                    :value="item.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="flex between">
        <el-button type="primary" @click="handleShowAdd">
          <template #icon>
            <icon name="el-icon-Plus"/>
          </template>
          发布任务
        </el-button
        >
        <div>
          <el-button type="primary" @click="getList">
            <template #icon>
              <icon name="el-icon-Search"/>
            </template>
            查询
          </el-button
          >
          <el-button @click="reset">重置</el-button>
        </div>
      </div>
    </header>
    <div class="table-container">
      <el-table :data="list" v-loading="loading">
        <el-table-column label="任务名称" prop="taskName" show-overflow-tooltip/>

        <el-table-column
            label="参与人员"
            prop="persons"
            show-overflow-tooltip
        />
        <el-table-column
            label="任务类型"
            prop="taskType"
            width="120"
            align="center"
        >
          <template #default="{row}">
            {{ getTaskType(row.taskType) }}
          </template>
        </el-table-column>
        <el-table-column
            label="任务内容"
            prop="taskContent"
            show-overflow-tooltip
        />
        <el-table-column label="督察时间" prop="updateTime" width="280">
          <template #default="{ row }">
            <span>{{ row.beginTime }}</span>
            <span>-</span>
            <span>{{ row.endTime }}</span>
          </template>
        </el-table-column>
        <el-table-column label="任务状态" width="100" align="center">
          <template #default="{ row }">
            <span v-if="row.taskStatus === 'todo'">执行中</span>
            <span v-if="row.taskStatus === 'done'">已完成</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" min-width="120px">
          <template #default="{ row }">
            <el-button
                type="primary"
                link
                @click="handleShowDetail(row)"
            >查看详情
            </el-button
            >
            <el-button
                v-if="row.taskType === 'inspection'"
                type="primary"
                link
                @click="handleProblemsShow(row)"
            >督察详情
            </el-button
            >
            <el-button
                v-if="row.taskType === 'testing_alcohol'"
                type="primary"
                link
                @click="handleTestingDetailShow(row)"
            >检测情况
            </el-button>
            <el-button
                v-if="row.taskType === 'selfexamination'"
                type="primary"
                link
                @click="handleSelfProblemShow(row)"
            >
              自查情况
            </el-button>
            <el-button v-if="row.taskType === 'risk_personal'"
                       type="primary" link @click="showSupervise(row)"
            >督察情况
            </el-button>
            <el-button type="primary" link @click="editTable(row)">
                编辑
            </el-button>
            <el-button
                type="danger"
                link
                @click="delTaskManagementFun(row)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="flex end mt-8">
      <el-pagination
          @size-change="getList"
          @current-change="getList"
          :page-sizes="[10, 20, 50]"
          v-model:page-size="query.size"
          v-model:current-page="query.current"
          layout="total, sizes, prev, pager, next"
          :total="total"
      >
      </el-pagination>
    </div>
  </div>
  <!--任务发布-->
  <el-dialog title="发布任务" @close="addColse" v-model="show" width="80vw" top="5vh"
             style="margin-bottom: 0"
  >
    <el-scrollbar max-height="76vh"  v-loading="editLoading">
      <el-form
          :label-width="120"
          ref="formRef"
          :model="form"
          style="min-height: 66vh"
      >
        <el-form-item
            label="任务名称"
            :rules="{
                        required: true,
                        message: '请输入任务名称',
                        trigger: ['blur'],
                    }"
            prop="taskName"
        >
          <el-input
              v-model="form.taskName"
              placeholder="请输入任务名称"
          />
        </el-form-item>
        <el-form-item label="督察类型"
                      :rules="{
                        required: true,
                        message: '请选择',
                    }"
                      prop="supervisionType"
        >
          <el-radio-group v-model="form.supervisionType" clearable style="width: 300px">
            <el-radio v-for="item in dict.supervisionType"
                      :key="item.id"
                      :label="item.dictLabel"
                      :value="item.dictValue"
            ></el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item v-if="form.supervisionType === '专项督察'" label="专项督察"
                      :rules="{
                        required: true,
                        message: '请选择',
                    }"
                      prop="specialType"
        >
          <el-radio-group v-model="form.specialType" clearable style="width: 300px">
            <el-radio v-for="(item,key) in specialType"
                      :key="key"
                      :label="item.dictLabel"
                      :value="item.dictValue"
            ></el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item label="督察时间" prop="times"
                      :rules="{
                        required: true,
                        message: '请选择',
                    }"
        >
          <div style="width: 800px">
            <el-date-picker
                @change="changEndDateTime"
                v-model="form.times"
                type="datetimerange"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                value-format="YYYY-MM-DD HH:mm:ss"
                :unlink-panels="true"
            />
          </div>
        </el-form-item>

        <!--专项督察展示-->
        <div class="content-main" v-if="form.supervisionType !== '日常督察'">
          <div id="jjdc" v-if="form.specialType === '六项规定督察'">
            <hr style="color: #abaaaa;opacity: 0.2"/>
            <el-form-item label="督察人员" v-if="form.specialType === '六项规定督察'"
                :rules="{
                        required: true,
                        message: '请选择',
                    }"
                prop="persons"
            >
              <police-picker v-model="form.persons"  :dataDepartId = 'userStore.user.departId'/>
            </el-form-item>
            <el-form-item label="督察要求" :rules="{
                        required: true,
                        message: '请选择',
                    }"
                   prop="superviseRequire">
              <div style="width: 100%">
                <quill-editor
                    ref="quillRef"
                    v-model="form.superviseRequire"
                    style="
                                  min-height: 100px;
                                  max-height: 200px;
                                  overflow: auto;
                              "
                />
              </div>
            </el-form-item>
            <el-form-item label="抽检对象">
              <el-radio-group v-model="form.samplingTarget">
                <el-radio value="Excel导入人员" label="Excel导入人员"></el-radio>
                <el-radio value="自定义人员" label="自定义人员"></el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item prop="userList" v-if="form.samplingTarget === 'Excel导入人员'">
              <el-row style="width: 100%">
                <el-upload
                    style="width: 100%"
                    drag
                    :action="`${BASE_PATH}/task/management/import`"
                    :headers="{ Authorization: getToken() }"
                    :multiple="false"
                    :auto-upload="true"
                    :show-file-list="false"
                    v-model:file-list="fileListData"
                    :on-success="managementSuccess"
                    :on-progress="managementProgress"
                    accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                >
                  <template v-if="fileListData.length === 0">
                    <el-icon class="el-icon--upload">
                      <upload-filled/>
                    </el-icon>
                    <div class="el-upload__text">
                      <p>点击或拖拽文件到此区域上传</p>
                    </div>
                  </template>
                  <template v-else>
                    <el-icon class="el-icon--upload"
                    ><Select/></el-icon>
                    <div class="el-upload__text">
                      已选择文件：{{
                        fileListData[fileListData.length - 1].name
                      }}
                    </div>
                  </template>
                </el-upload>
                <div class="mt-20">
                  <span>文件模板</span>
                  <a
                      class="link"
                      :href="`${BASE_PATH}/templates/测酒任务被测人员模板.xlsx`"
                      target="__blank"
                  >测酒任务被测人员模板.xlsx 下载</a
                  >
                </div>
              </el-row>
              <div class="flex gap wrap pepole-container mt-20">
                <el-tag v-for="item in form.userList" :key="item">
                  {{ item.name }}-{{ item.empNo }}
                </el-tag>
              </div>
            </el-form-item>
            <el-form-item prop="userList" v-if=" form.samplingTarget === '自定义人员'">
              <el-row :gutter="10" style="width: 100%;margin-bottom: 10px">
                <el-col :span="3">
                  <el-input v-model="samplingQuery.samplingName" placeholder="抽检名称"></el-input>
                </el-col>
                <el-col :span="7">
                  <el-row>
                    <el-col :span="11">
                      <el-input-number placeholder="最小年龄" v-model="samplingQuery.ageMin"
                                       :controls="false"></el-input-number>
                    </el-col>
                    <el-col :span="11">
                      <el-input-number placeholder="最大年龄" v-model="samplingQuery.ageMax"
                                       :controls="false"></el-input-number>
                    </el-col>
                  </el-row>
                </el-col>
                <el-col :span="3">
                  <el-select placeholder="请选择督察类型" v-model="samplingQuery.inspectorType">
                    <el-option v-for="(item,index) in dict.inspectorType"
                               :label="item.dictLabel" :value="item.dictValue" :key="index"
                    ></el-option>
                  </el-select>
                </el-col>
                <el-col :span="3">
                  <el-select placeholder="请选择性别" v-model="samplingQuery.gender">
                    <el-option label="男" value="1"></el-option>
                    <el-option label="女" value="2"></el-option>
                  </el-select>
                </el-col>
                <el-col :span="3">
                  <el-select clearable placeholder="请选择人员属性">
                    <el-option v-for="(item,keys) in dict.personType"
                               :value="item.dictValue"
                               :label="item.dictLabel"
                               :key="keys"
                    ></el-option>
                  </el-select>
                </el-col>
                <el-col :span="4">
                  <el-button type="primary">查询</el-button>
                </el-col>
              </el-row>
              <div v-loading="samplingloading">
                <el-table
                    :data="samplingList"
                    ref="tableRef"
                    style="width: 100%"
                    @selection-change="handleSelectionChange"
                >
                  <el-table-column type="selection" width="55"/>
                  <el-table-column prop="samplingName" label="抽检名称" width="120"></el-table-column>
                  <el-table-column prop="inspectorType" label="督察类型" width="120"></el-table-column>
                  <el-table-column show-overflow-tooltip prop="samplingInspection" label="抽检规则"
                                   min-width="300"></el-table-column>
                  <el-table-column label="操作" fixed="right" min-width="180">
                    <template #default="{ row }">
                      <div class="flex v-center">
                        <el-button type="primary" link @click="handleSamplingDetail(row)">查看详情</el-button>

                      </div>
                    </template>
                  </el-table-column>
                </el-table>
                <div class="flex end mt-8">
                  <el-pagination
                      @size-change="getSamplingList"
                      @current-change="getSamplingList"
                      :page-sizes="[10, 20, 50]"
                      v-model:page-size="samplingQuery.size"
                      v-model:current-page="samplingQuery.current"
                      layout="total, sizes, prev, pager, next"
                      :total="samplingTotal"
                  />
                </div>
              </div>
            </el-form-item>
          </div>
          <div id="sdzc" v-if="form.specialType === '所队自查'">
            <hr style="color: #abaaaa;opacity: 0.2"/>
            <el-form-item label="自选单位">
              <el-tree-select  v-model="form.selfOrgs" multiple show-checkbox :data="dictData"
                              :props="{label: 'shortName', value: 'id'}" node-key="id"
                              :default-expanded-keys="['12630']" clearable filterable check-strictly/>

            </el-form-item>

            <div class="flex v-center" style="height:30px;margin-bottom: 10px">
              <h5>任务要求</h5>
            </div>
            <!--                    任务要求-->
            <el-form-item
                prop="taskContentHtml"
                :rules="{
                                required: true,
                                message: '请输入任务要求'
                            }"
                label-position="top"
            >
              <div style="width: 100%">

                <quill-editor
                    ref="quillRef"
                    v-model="form.taskContentHtml"
                    style="
                                  min-height: 200px;
                                  max-height: 360px;
                                  overflow: auto;
                              "
                />

              </div>
            </el-form-item>
            <div class="flex between" style="width: 100%;height:30px;line-height: 30px; align-items: center">
              <h5>自查内容</h5>
              <div>
                <el-button type="primary" @click="addSelfArray">添加自查内容</el-button>
              </div>
            </div>
            <div class="card_content">
              <div class="zcCard"
                   v-for="(item,index) in form.selfContents"
              >
                <div style="display: flex;justify-content: space-between;margin-bottom: 5px">
                  <div>自查内容{{ index + 1 }}</div>
                  <div>
                    <el-button type="danger" link @click="delCardFun(index)">删除</el-button>
                  </div>
                </div>
                <div class="card_title">
                  <el-input v-model="item.title" placeholder="请输入自查项目"></el-input>
                </div>
                <div class="card_main">
                  <el-input v-model="item.content" type="textarea" :rows="5"></el-input>
                </div>
              </div>
            </div>
          </div>
          <div id="zdrygk" v-if="form.specialType === '重点人员管控'">
            <el-form-item label="督察要求" :rules="{
                        required: true,
                        message: '请选择',
                    }"
                          prop="superviseRequire">
              <div style="width: 100%">
                <quill-editor
                    ref="quillRef"
                    v-model="form.superviseRequire"
                    style="
                                  min-height: 100px;
                                  max-height: 200px;
                                  overflow: auto;
                              "
                />
              </div>
            </el-form-item>
            <el-form-item label="管控对象导入">
              <div>
                <a
                    class="link"
                    :href="`${BASE_PATH}/templates/重点人员管控导入模板.xlsx`"
                    target="__blank"
                >重点人员管控模板下载</a
                >
              </div>
              <div style="width: 100%" v-show="!uploadShow">
                <el-upload
                    style="width: 100%"
                    drag
                    v-loading="fileDataLoading"
                    :action="`${BASE_PATH}/task/management/importSupRiskPersonal`"
                    :headers="{ Authorization: getToken() }"
                    :multiple="false"
                    :auto-upload="true"
                    :show-file-list="false"
                    v-model:file-list="fileData"
                    :on-progress="SupRiskProgress"
                    :on-success="SupRiskSuccess"
                    accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                >
                  <template v-if="fileData.length === 0">
                    <el-icon class="el-icon--upload">
                      <upload-filled/>
                    </el-icon>
                    <div class="el-upload__text">
                      <p>点击或拖拽文件到此区域上传</p>
                    </div>
                  </template>
                  <template v-else>
                    <el-icon class="el-icon--upload"
                    ><Select/></el-icon>
                    <div class="el-upload__text">
                      已选择文件：{{
                        fileData[fileData.length - 1].name
                      }}
                    </div>
                  </template>
                </el-upload>
              </div>
              <div v-show="uploadShow"
                   style="width: 100%;margin: 5px 0;display: flex;justify-content: space-between;background-color: #F8F9FE">
                <div>
                  {{ fileData[fileData.length - 1]?.name }}
                </div>
                <div>
                  <el-button type="primary" link @click="showUploadFun">重新上传</el-button>
                </div>
              </div>
              <div style="width: 100%" v-if="showRiskDataTable">
                <el-row style="width: 100%" :gutter="20">
                  <el-col :span="4">
                    <el-select placeholder="管控级别" v-model="riskDataQuery.controlLevel">
                      <el-option v-for="(item,index) in dict.controlLevel"
                                 :key="index"
                                 :label="item.dictLabel"
                                 :value="item.dictValue"
                      ></el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="4">
                    <el-input v-model="riskDataQuery.keyword" placeholder="姓名或手机号或身份证"></el-input>
                  </el-col>
                  <el-col :span="4">
                    <el-select v-model="riskDataQuery.personalType" placeholder="人员类别">
                      <el-option v-for="(item,index) in dict.controlType"
                                 :key="index"
                                 :label="item.dictLabel"
                                 :value="item.dictValue"
                      ></el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="4">
                    <el-input v-model="riskDataQuery.responsibleName" placeholder="责任民警"></el-input>
                  </el-col>
                  <el-col :span="4">
                    <el-input v-model="riskDataQuery.controlName" placeholder="包保督察人员"></el-input>
                  </el-col>
                  <el-col :span="4">
                    <el-button type="primary" @click="getRiskDataTableSubmit">查询</el-button>
                  </el-col>

                </el-row>
                <el-table
                    ref="singleTableRef"
                    :data="riskDataTable"
                    highlight-current-row
                    style="width: 100%;margin-top: 10px"
                >
                  <el-table-column type="index" width="50" label="序号"/>
                  <el-table-column property="name" label="项目" width="60"/>
                  <el-table-column property="gender" label="性别" width="60"/>
                  <el-table-column property="idCode" label="身份证号" width="100"/>
                  <el-table-column property="mobile" label="联系方式" width="100"/>
                  <el-table-column property="personalType" label="人员类别" width="80"/>
                  <el-table-column property="controlLevel" label="管控级别" width="80"/>
                  <el-table-column property="controlTimeInterval" label="管控间隔" width="60"/>
                  <el-table-column property="responsibleDepartName" label="责任单位" width="70"/>
                  <el-table-column property="responsibleName" label="责任民警" width="60"/>
                  <el-table-column property="controlEmpNo" label="包保督察人员警号" width="120"/>
                  <el-table-column property="controlName" label="包保督察人员姓名" width="120"/>
                  <el-table-column fixed="right" label="操作" min-width="120">
                    <template #default="{row}">
                      <el-button link type="danger" size="small" @click="delriskData(row)">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
                <div class="flex end mt-8">
                  <el-pagination
                      @size-change="getRiskDataTableList"
                      @current-change="getRiskDataTableList"
                      :page-sizes="[10]"
                      v-model:page-size="riskDataQuery.size"
                      v-model:current-page="riskDataQuery.current"
                      layout="total, sizes, prev, pager, next"
                      :total="riskDataTotal"
                  />
                </div>
              </div>

            </el-form-item>
          </div>
        </div>

        <!--日常督察-->
        <div id="rcdc" v-if="form.supervisionType ==='日常督察'">
          <hr style="color: #abaaaa;opacity: 0.2"/>
          <el-form-item
              v-if="form.supervisionType === '日常督察'"
              label="督察人员"
              :rules="{
                        required: true,
                        message: '请选择',
                    }"
              prop="persons"
          >
            <police-picker v-model="form.persons"/>
          </el-form-item>
          <div class="flex v-center" style="height:30px;margin-bottom: 10px">
            <h5>任务内容</h5>
          </div>
          <el-form-item
              prop="taskContentHtml"
              :rules="{
                        required: true,
                        message: '请输入任务内容'
                    }"
              label-position="top"
          >
            <div style="width: 100%">
              <quill-editor
                  ref="quillRef"
                  v-model="form.taskContentHtml"
                  style="
                                min-height: 200px;
                                max-height: 360px;
                                overflow: auto;
                            "
              />
            </div>
          </el-form-item>
          <div class="flex v-center" style="height:30px;margin-bottom: 10px">
            <h5>任务附件</h5>
          </div>
          <file-upload
              style="width: 100%"
              :uploadDrag="true"
              v-model:files="form.fileList"></file-upload>
        </div>
      </el-form>
    </el-scrollbar>
    <footer class="flex end mt-20">
      <el-button type="primary" @click="submit" size="large"
      >发布
      </el-button>
    </footer>
  </el-dialog>
  <!--任务发布详情-->
  <el-dialog v-model="detailShow" title="发布任务详情" width="1076px"
             top="5vh"
             style="margin-bottom: 0">
    <el-scrollbar max-height="76vh" v-loading="detailLoading">
      <el-form
          :label-width="150"
          ref="formRef"
          :model="form"
          style="min-height: 66vh"
      >
        <el-form-item
            label="任务名称"

        >
          {{ activeRow.taskName }}
        </el-form-item>
        <el-form-item label="督察类型"

        >
          {{
            getDictLable(
                dict.supervisionType,
                activeRow.supervisionType
            )
          }}
        </el-form-item>

        <el-form-item v-if="activeRow.supervisionType === '专项督察'" label="专项督察"

        >
          {{ activeRow.specialType }}

        </el-form-item>

        <el-form-item label="督察时间"
        >
          <div style="width: 800px" v-if="activeRow.times">
            {{ `${timeFormat(activeRow.times[0])} - ${timeFormat(activeRow.times[1])}` }}
          </div>
          <div v-else>
          </div>
        </el-form-item>

        <!--专项督察展示-->
        <div class="content-main" v-if="activeRow.supervisionType !== '日常督察'">
          <div id="jjdc" v-if="activeRow.specialType === '六项规定督察'">
            <hr style="color: #abaaaa;opacity: 0.2"/>
            <el-form-item label="督察人员"
            >
              <!--              <police-picker v-model="activeRow.persons" />-->
              <div class="flex gap wrap pepole-container mt-20">
                <el-tag v-for="item in activeRow.persons" :key="item">{{ item.name }}-{{ item.empNo }}</el-tag>
              </div>
            </el-form-item>
            <el-form-item label="督察要求">
              <div style="width: 100%" v-html="activeRow.superviseRequire">
              </div>
            </el-form-item>
            <el-form-item label="抽检对象">
              {{ activeRow.samplingTarget }}
            </el-form-item>
            <el-form-item prop="userList" v-if="activeRow.samplingTarget === 'Excel导入人员'">
              <div class="flex gap wrap pepole-container mt-20">
                <el-tag v-for="item in activeRow.userList" :key="item"
                >{{ item.name }}-{{ item.empNo }}
                </el-tag
                >
              </div>
            </el-form-item>
            <el-form-item prop="userList" v-if=" activeRow.samplingTarget === '自定义人员'">
              <div v-loading="samplingloading">
                <el-table
                    :data="samplingList"
                    ref="tableRef"
                    style="width: 100%"
                    @selection-change="handleSelectionChange"
                >
                  <el-table-column prop="samplingName" label="抽检名称" width="120"></el-table-column>
                  <el-table-column prop="inspectorType" label="督察类型" width="120"></el-table-column>
                  <el-table-column show-overflow-tooltip prop="samplingInspection" label="抽检规则"
                                   min-width="300"></el-table-column>
                  <el-table-column label="操作" fixed="right" min-width="180">
                    <template #default="{ row }">
                      <div class="flex v-center">
                        <el-button type="primary" link @click="handleSamplingDetail(row)">查看详情</el-button>
                      </div>
                    </template>
                  </el-table-column>
                </el-table>
                <div class="flex end mt-8">
                  <el-pagination
                      @size-change="getSamplingList"
                      @current-change="getSamplingList"
                      :page-sizes="[10, 20, 50]"
                      v-model:page-size="samplingQuery.size"
                      v-model:current-page="samplingQuery.current"
                      layout="total, sizes, prev, pager, next"
                      :total="samplingTotal"
                  />
                </div>
              </div>
            </el-form-item>
          </div>
          <div id="sdzc" v-if="activeRow.specialType === '所队自查'">
            <hr style="color: #abaaaa;opacity: 0.2"/>
            <el-form-item label="自选单位">
              <div class="flex gap wrap pepole-container mt-7">
                <el-tag v-for="item in slofOrgList" :key="item"
                >{{ item.shortName }}
                </el-tag
                >
              </div>
            </el-form-item>

            <div class="flex v-center" style="height:30px;margin-bottom: 10px">
              <h5>任务要求</h5>
            </div>
            <!--                    任务要求-->
            <el-form-item
                label-position="top"
            >
              <div style="width: 100%">
                <div v-html="activeRow.taskContentHtml"></div>

              </div>
            </el-form-item>
            <div class="flex between" style="width: 100%;height:30px;line-height: 30px; align-items: center">
              <h5>自查内容</h5>
              <div>
                <!--                <el-button type="primary" @click="addSelfArray">添加自查内容</el-button>-->
              </div>
            </div>
            <div class="card_content">
              <div class="zcCard"
                   v-for="(item,index) in activeRow.selfContents"
              >
                <div style="display: flex;justify-content: space-between;margin-bottom: 5px">
                  <div>自查内容{{ index + 1 }}</div>
                  <!--                  <div ><el-button type="danger" link   @click="delCardFun(index)" >删除</el-button></div>-->
                </div>
                <div class="card_title">
                  {{ item.title }}
                </div>
                <div class="card_main">
                  {{ item.content }}
                </div>
              </div>
            </div>
          </div>
          <div id="zdrygk" v-if="activeRow.specialType === '重点人员管控'">
            <el-form-item label="督察要求"
                          prop="superviseRequire">
              <div style="width: 100%" v-html="activeRow.superviseRequire">
              </div>
            </el-form-item>
            <el-form-item label="管控对象">
              <div style="width: 100%">
                <el-row style="width: 100%" :gutter="20">
                  <el-col :span="4">
                    <el-select placeholder="管控级别" v-model="riskDataQuery.controlLevel">
                      <el-option v-for="(item,index) in dict.controlLevel"
                                 :key="index"
                                 :label="item.dictLabel"
                                 :value="item.dictValue"
                      ></el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="4">
                    <el-input v-model="riskDataQuery.keyword" placeholder="姓名或手机号或身份证"></el-input>
                  </el-col>
                  <el-col :span="4">
                    <el-select v-model="riskDataQuery.personalType" placeholder="人员类别">
                      <el-option v-for="(item,index) in dict.controlType"
                                 :key="index"
                                 :label="item.dictLabel"
                                 :value="item.dictValue"
                      ></el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="4">
                    <el-input v-model="riskDataQuery.responsibleName" placeholder="责任民警"></el-input>
                  </el-col>
                  <el-col :span="4">
                    <el-input v-model="riskDataQuery.controlName" placeholder="包保督察人员"></el-input>
                  </el-col>
                  <el-col :span="4">
                    <el-button type="primary" @click="getRiskDataTableSubmit">查询</el-button>
                  </el-col>

                </el-row>
                <el-table
                    ref="singleTableRef"
                    :data="riskDataTable"
                    highlight-current-row
                    style="width: 100%;margin-top: 10px"
                >
                  <el-table-column type="index" width="50" label="序号"/>
                  <el-table-column property="name" label="项目" width="60"/>
                  <el-table-column property="gender" label="性别" width="60"/>
                  <el-table-column property="idCode" label="身份证号" width="100"/>
                  <el-table-column property="mobile" label="联系方式" width="100"/>
                  <el-table-column property="personalType" label="人员类别" width="80"/>
                  <el-table-column property="controlLevel" label="管控级别" width="80"/>
                  <el-table-column property="controlTimeInterval" label="管控间隔" width="60"/>
                  <el-table-column property="responsibleDepartName" label="责任单位" width="70"/>
                  <el-table-column property="responsibleName" label="责任民警" width="60"/>
                  <el-table-column property="controlEmpNo" label="包保督察人员警号" width="70"/>
                  <el-table-column property="controlName" label="包保督察人员姓名" width="70"/>

                </el-table>
                <div class="flex end mt-8">
                  <el-pagination
                      @size-change="getRiskDataTableList"
                      @current-change="getRiskDataTableList"
                      :page-sizes="[10]"
                      v-model:page-size="riskDataQuery.size"
                      v-model:current-page="riskDataQuery.current"
                      layout="total, sizes, prev, pager, next"
                      :total="riskDataTotal"
                  />
                </div>
              </div>
            </el-form-item>
          </div>
        </div>

        <!--日常督察-->
        <div id="rcdc" v-if="activeRow.supervisionType ==='日常督察'">
          <hr style="color: #abaaaa;opacity: 0.2"/>
          <el-form-item
              label="督察人员"
              :rules="{
                        required: true,
                        message: '请选择',
                    }"
              prop="persons"
          >
            <!--            <police-picker v-model="activeRow.persons" />-->
            <div class="flex gap wrap pepole-container mt-7">
              <el-tag v-for="item in activeRow.persons" :key="item"
              >{{ item.name }}-{{ item.empNo }}
              </el-tag
              >
            </div>
          </el-form-item>
          <div class="flex v-center" style="height:30px;margin-bottom: 10px">
            <h5>任务内容</h5>
          </div>
          <el-form-item
              prop="taskContentHtml"
              :rules="{
                        required: true,
                        message: '请输入任务内容'
                    }"
              label-position="top"
          >
            <div style="width: 100%">
              <div v-html="activeRow.taskContentHtml"></div>
            </div>
          </el-form-item>
          <div class="flex v-center" style="height:30px;margin-bottom: 10px">
            <h5>任务附件</h5>
          </div>
          <file-list v-model:files="activeRow.files" :removeEnable="false" />
        </div>
      </el-form>
    </el-scrollbar>
  </el-dialog>
  <!--  人员抽检详情-->
  <el-dialog v-model="samplingDetailShow" title="人员抽检详情" width="900px">
    <el-form ref="editForm">
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="抽检名称">
            {{ editData.samplingName }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="督察类型">
            {{
              getDictLable(
                  dict.inspectorType,
                  editData.inspectorType
              )
            }}
          </el-form-item>
        </el-col>
      </el-row>
      <hr style="color: #abaaaa;opacity: 0.2"/>
      <div>
        <!--          基础信息-->
        <div class="flex v-center" style="height:20px;">
          <h4>抽检规则</h4>
        </div>
        <div class="flex v-center" style="height:30px;">
          <h5>基础信息</h5>
        </div>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="年龄范围">
              <span v-if="editData.ageMin">  {{ editData.ageMin }} 至   {{ editData.ageMax }}</span>

            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别">
              {{ editData.gender === '1' ? '男' : '女' }}

            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="人员属性">
                <span v-for="(type,key) in editData.personnelTypeArray" :key="key" style="margin-left: 10px">

                    {{
                    getDictLable(
                        dict.personType,
                        type
                    )
                  }}
                </span>

            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否存在违反六项规定情节">
              {{ editData.drinkAlcohol === '1' ? '是' : '否' }}
            </el-form-item>
          </el-col>
        </el-row>
        <hr style="color: #abaaaa;opacity: 0.2"/>
        <!--          人员比率-->
        <div class="flex v-center" style="height:30px;">
          <h5>人员比率</h5>
        </div>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="抽检人数">
              {{ editData.samplingNum }} 人
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="领导人数">
              {{ editData.leadersNumber }}人
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="民警比率">
              {{ editData.policeRatio }}%
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="辅警比率">
              {{ editData.assistRatio }}%
            </el-form-item>
          </el-col>
        </el-row>
        <!--          抽检规则-->
        <div class="flex v-center" style="height:30px;">
          <h5>抽检规则</h5>
        </div>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="时间范围">
              <span v-if="editData.samplingTime">{{
                  `${timeFormat(editData.samplingTime[0])} 至 ${timeFormat(editData.samplingTime[1])}`
                }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="被抽检次数">
              {{ editData.samplingNumber }}次
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="距最后一次检测时间">
              {{ editData.distanceDay }}天
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否值班人员">
              {{ editData.beDuty === '1' ? '是' : '否' }}
            </el-form-item>
          </el-col>
        </el-row>
        <hr style="color: #abaaaa;opacity: 0.2"/>
        <!--          被抽检对象-->
        <div class="flex between" style="height:30px; align-items: center">
          <div>
            <h5>被抽检对象</h5>
          </div>
        </div>
        <el-card shadow="never" style="background-color: #F9FAFF">
          <el-row :gutter="20" style="margin-bottom: 10px;align-items: center"
                  v-for="(item,key) in editData.samplingObjectList" :key="key">
            <el-col :span="14">
              <el-form-item label="抽检单位">
                {{ item.departName }}
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="人数">
                {{ item.value }}
              </el-form-item>
            </el-col>
            <el-col :span="4">

            </el-col>
          </el-row>
        </el-card>
        <!--          抽检对象名单-->
        <hr style="color: #abaaaa;opacity: 0.2"/>
        <div class="flex between" style="height:30px; align-items: center">
          <div>
            <h5>抽检对象名单<span></span></h5>
          </div>
          <div>
            <!--              <el-button @click="getSamplingPolices">重新生成抽检对象</el-button>-->
          </div>
        </div>
        <el-card shadow="never" style="background-color: #F9FAFF;min-height: 50px" v-loading="policeLoading">
          <div class="flex   flex-wrap" style="width: 100%">
            <el-tag
                :disable-transitions="false"
                style="padding: 5px 10px;margin-right: 10px;margin-bottom: 5px"
                v-for="(polices,index) in editData.samplingPolices"
                :key="polices.empNo"
            >
              <span>{{ polices.name }}</span> {{ polices.empNo }}
            </el-tag>
          </div>
          <div style="display: flex;justify-content: flex-end">
            <el-button type="primary" @click="handleExport">导出Excel表</el-button>
          </div>
        </el-card>
      </div>
    </el-form>
  </el-dialog>
  <!--  日常督察详情-->
  <el-dialog title="问题清单" v-model="problemsShow" width="60vw"
             style="margin-bottom: 0"
  >
    <header class="mb-20">
      <el-form :label-width="94">
        <el-row>
          <el-col :span="6">
            <el-form-item label="具体情况">
              <el-input
                  v-model="problemQuery.detail"
                  clearable
                  placeholder="请输入具体情况"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <div class="flex end">
          <el-button type="primary" @click="getProblems">
            <template #icon>
              <icon name="el-icon-Search"/>
            </template>
            查询
          </el-button
          >
          <el-button @click="problemReset">重置</el-button>
        </div>
      </el-form>
    </header>
    <div style="min-height: 400px">
      <div class="table-container">
        <el-table v-loading="problemsLoading" :data="problems" :max-height="640" min-height="300">
          <el-table-column
              label="是否发现督察问题"
              prop="hasProblem"
              width="80"
              align="center"
          >
            <template #default="{ row }">
              <span v-if="row.hasProblem">是</span>
              <span v-else>否</span>
            </template>
          </el-table-column>
          <el-table-column
              label="单位"
              prop="departName"
              width="80"
              show-overflow-tooltip
          />
          <el-table-column
            prop="createName"
            label="录入人"
            width="80"
          />
          <el-table-column label="下发状态" >
            <template #default="{row}">
              <el-tag type="info" v-if=" row.hasProblem && row.distributionState == '0' ">未下发</el-tag>
              <el-tag type="primary" v-if="row.hasProblem && row.distributionState == '1' ">已分发</el-tag>
              <el-tag type="primary" v-if="row.hasProblem && row.distributionState == '2' ">已处置</el-tag>
            </template>
          </el-table-column>
          <el-table-column
              label="问题类型"
              prop="problemType"
              width="140"
              show-overflow-tooltip
          />
          <el-table-column label="具体情况" prop="thingDesc"/>
          <el-table-column
              label="创建时间"
              prop="createTime"
              width="160"
          />
          <el-table-column label="操作" width="100">
            <template #default="{ row }">
              <el-button
                  type="primary"
                  link
                  @click="showDeatil(row)"
              >详情
              </el-button>
              <el-button
                  type="primary"
                  link
                  v-if="row.hasProblem && row.distributionState  == '0'"
                  @click="issueMatterFun(row,'inspection')"
              >
                下发
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="flex end mt-8">
        <el-pagination
            @size-change="getProblems"
            @current-change="getProblems"
            :page-sizes="[10, 20, 50]"
            v-model:page-size="problemQuery.size"
            v-model:current-page="problemQuery.current"
            layout="total, sizes, prev, pager, next"
            :total="problemTotal"
        >
        </el-pagination>
      </div>
    </div>
  </el-dialog>
  <!--  所队自查详情-->
  <el-dialog title="自查详情" v-model="selfProblemsShow" width="60vw"
             style="margin-bottom: 0"
  >
    <header class="mb-20">
      <el-form :label-width="94">
        <el-row>
          <el-col :span="6">
            <el-form-item label="具体情况">
              <el-input
                  v-model="selfPeopleQuery.detail"
                  clearable
                  placeholder="请输入具体情况"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <div class="flex end">
          <el-button type="primary" @click="getSelfexaminationProblemFun">
            <template #icon>
              <icon name="el-icon-Search"/>
            </template>
            查询
          </el-button
          >
          <el-button @click="problemReset">重置</el-button>
        </div>
      </el-form>
    </header>
    <div style="min-height: 400px">
      <div class="table-container">
        <el-table v-loading="problemLoading" :data="selfProblemList" :max-height="640" min-height="300">
          <el-table-column
              label="是否发现督察问题"
              prop="hasProblem"
              width="120"
              align="center"
          >
            <template #default="{ row }">
              <span v-if="row.hasProblem">是</span>
              <span v-else>否</span>
            </template>
          </el-table-column>
          <el-table-column
              label="单位"
              prop="departName"
              width="140"
              show-overflow-tooltip
          />
          <el-table-column
              prop="createName"
              label="问题录入人"
              width="80"
          />
          <el-table-column
              label="问题类型"
              prop="problemType"
              width="140"
              show-overflow-tooltip
          />

          <el-table-column label="具体情况" prop="thingDesc"/>
          <el-table-column label="下发状态" >
            <template #default="{row}">
              <el-tag type="info" v-if=" row.hasProblem && row.distributionState == '0' ">未下发</el-tag>
              <el-tag type="primary" v-if="row.hasProblem && row.distributionState == '1' ">已分发</el-tag>
              <el-tag type="primary" v-if="row.hasProblem && row.distributionState == '2' ">已处置</el-tag>
            </template>
          </el-table-column>
          <el-table-column
              label="创建时间"
              prop="createTime"
              width="160"
          />
          <el-table-column label="操作" width="100">
            <template #default="{ row }">
              <el-button
                  type="primary"
                  link
                  @click="showDeatil(row)"
              >详情
              </el-button
              >
              <el-button
                type="primary"
                link
                v-if="row.hasProblem && row.distributionState  == '0'"
                @click="issueMatterFun(row,'selfexamination')"
              >
                下发
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="flex end mt-8">
        <el-pagination
            @size-change="getSelfexaminationProblemFun"
            @current-change="getSelfexaminationProblemFun"
            :page-sizes="[10, 20, 50]"
            v-model:page-size="selfPeopleQuery.size"
            v-model:current-page="selfPeopleQuery.current"
            layout="total, sizes, prev, pager, next"
            :total="selfProblemTotal"
        >
        </el-pagination>
      </div>
    </div>
  </el-dialog>
  <!--  六项规定督察详情-->
  <el-dialog v-model="testingDetailShow" title="检测情况" width="60vw"
             top="2vh"
             style="margin-bottom: 0"
  >
    <header class="mb-20">
      <el-form :label-width="94">
        <el-row>
          <el-col :span="6">
            <el-form-item label="姓名">
              <el-input
                  v-model="peopleQuery.name"
                  clearable
                  placeholder="请输入警员姓名"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="警号">
              <el-input
                  v-model="peopleQuery.empNo"
                  clearable
                  placeholder="请输入警号"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="检测情况">
              <el-select
                  clearable
                  v-model="peopleQuery.testingResult"
              >
                <el-option value="已检测">已检测</el-option>
                <el-option value="未检测">未检测</el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col
              :span="6"
              v-if="peopleQuery.testingResult === '已检测'"
          >
            <el-form-item label="饮酒结果">
              <el-select
                  clearable
                  v-model="peopleQuery.drinkResult"
              >
                <el-option value="饮酒">饮酒</el-option>
                <el-option value="未饮酒">未饮酒</el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="flex end">
          <el-button type="primary" @click="getTestingAlcoholPeople">
            <template #icon>
              <icon name="el-icon-Search"/>
            </template>
            查询
          </el-button
          >
          <el-button @click="peopleReset">重置</el-button>
        </div>
      </el-form>
    </header>
    <div class="table-container">
      <el-table v-loading="testingLoading" :data="peoples" :max-height="640">
        <el-table-column width="60" align="center">
          <template #default="{ row }">
            <img
                class="avatar"
                :src="`${BASE_PATH}/file/stream/${row.avatarUrl}`"
                v-if="row.avatarUrl"
            />
            <img class="avatar" src="/imgs/police.png" v-else/>
          </template>
        </el-table-column>
        <el-table-column label="姓名" prop="name" width="80"/>
        <el-table-column label="警号" prop="empNo" width="80"/>
        <el-table-column
            label="单位"
            prop="departName"
            width="140"
            show-overflow-tooltip
        />
        <el-table-column
            label="检测情况"
            prop="testingResult"
            width="90"
        />
        <el-table-column
          label="问题录入人"
          prop="createName"
          width="80"
        />
        <el-table-column
            label="测酒时间"
            prop="testingTime"
            width="160"
        />
        <el-table-column label="饮酒情况/未检测原因" show-overflow-tooltip align="center">
          <template #default="{ row }">
            <el-tag type="success" v-if="row.drinkResult === '未饮酒'">未饮酒</el-tag>
            <el-tag type="error" v-if="row.drinkResult === '饮酒'">饮酒</el-tag>
            <span v-if="row.drinkResult === '饮酒'" class="ml-10">(酒精含量：{{ row.alcoholContent }} mg/100ml)</span>
            <span>{{ row.unTestingDesc }}</span>
          </template>
        </el-table-column>
        <el-table-column label="下发状态" align="center">
          <template #default="{row}">
            <el-tag type="info" v-if=" row.drinkResult === '饮酒' && row.distributionState == '0' ">未下发</el-tag>
            <el-tag type="primary" v-if="row.drinkResult === '饮酒' && row.distributionState == '1' ">已分发</el-tag>
            <el-tag type="primary" v-if="row.drinkResult === '饮酒' && row.distributionState == '2' ">已处置</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="100">
          <template #default="{ row }">
            <el-button
                type="primary"
                link
                @click="handleShowPeople(row)"
            >详情
            </el-button>
            <el-button  v-if="row.drinkResult === '饮酒' && (!row.distributionState || row.distributionState == '0')" type="primary" link @click="issueMatterFun(row,'testing_alcohol')">下发</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="flex end mt-8">
      <el-pagination
          @size-change="getTestingAlcoholPeople"
          @current-change="getTestingAlcoholPeople"
          :page-sizes="[10, 20, 50]"
          v-model:page-size="peopleQuery.size"
          v-model:current-page="peopleQuery.current"
          layout="total, sizes, prev, pager, next"
          :total="peopleTotal"
      >
      </el-pagination>
    </div>
  </el-dialog>
  <!--六项规定督察 - 人员检测情况-->
  <el-dialog title="人员检测情况" v-model="peopleDetailShow" width="40vw">
    <div style="width: 600px; margin: auto">
      <el-row>
        <el-col :span="6">
          <img
              style="height: 100px"
              :src="`${BASE_PATH}/file/stream/${activePeople.avatarUrl}`"
              v-if="activePeople.avatarUrl"
          />
          <img style="height: 100px" src="/imgs/police.png" v-else/>
        </el-col>
        <el-col :span="18">
          <div class="row">
            <div class="col col-12">
              <label>姓名</label>
              <span>{{ activePeople.name }}</span>
            </div>
            <div class="col col-12">
              <label>警号</label>
              <span>{{ activePeople.empNo }}</span>
            </div>
            <div class="col col-24">
              <label>身份证</label>
              <span>{{ activePeople.idCode || '/' }}</span>
            </div>
            <div class="col col-24">
              <label>单位</label>
              <span>{{ activePeople.departName }}</span>
            </div>
          </div>
        </el-col>
      </el-row>
      <el-divider style="width: 90%"/>
      <div class="row">
        <div class="col col-24" v-if="activePeople.testingResult">
          <label>检测情况</label>
          <span>{{ activePeople.testingResult }}</span>
        </div>
        <div class="col col-12" v-if="activePeople.drinkResult">
          <label>饮酒结果</label>
          <span>{{ activePeople.drinkResult }}</span>
        </div>
        <div class="col col-12" v-if="activePeople.drinkResult === '饮酒'">
          <label>酒精含量</label>
          <span>{{ activePeople.alcoholContent }} mg/100ml</span>
        </div>
        <div class="col col-24" v-if="activePeople.unTestingDesc">
          <label>未检测原因</label>
          <span>{{ activePeople.unTestingDesc }}</span>
        </div>
      </div>
      <div v-if="activePeople.testingFileList.length">
        <div class="mb-8">测酒现场照片</div>
        <file-list v-model:files="activePeople.testingFileList"/>
      </div>
    </div>
    <footer class="flex end mt-20">
      <el-button size="large" @click="peopleDetailShow = false">关闭</el-button>
    </footer>
  </el-dialog>
  <!--问题详情-->
  <el-dialog title="问题详情" v-model="problemShow">
    <div>
      <div class="row">
        <div class="col col-12">
          <label>发现时间</label>
          <span>{{ activeRowData.createTime }}</span>
        </div>
        <div class="col col-12">
          <label>问题来源</label>
          <span>{{ getDictLable(dict.taskType, activeRowData.taskType) }}</span>
        </div>
        <div class="col col-12">
          <label>涉及单位</label>
          <span>{{ activeRowData.departName }}</span>
        </div>
        <div class="col col-12">
          <label>涉及人员</label>
          <span v-if="activeRowData.peoples">

            <el-tag v-for="(item,index) in JSON.parse(activeRowData.peoples)" :key="index">
              {{item.name}}
            </el-tag>
          </span>
        </div>
        <div class="col col-24">
          <label>问题类型</label>
          <span>{{ activeRowData.problemType || '/' }}</span>
        </div>
        <div class="col col-24">
          <label>问题描述</label>
          <span>{{ activeRowData.thingDesc }}</span>
        </div>
        <div class="col col-24">
          <label>分发状态</label>
          <span>{{ getDictLable(dict.distributionState, activeRowData.distributionState) }}</span>
        </div>
      </div>
      <div>
        <file-list :files="activeRowData.files? JSON.parse(activeRowData.files) : []"/>
      </div>
    </div>
  </el-dialog>
<!--  重点人员督察情况-->
  <el-dialog title="重点人员督察情况" v-model="superviseRiskShow" width="80vw" style="min-height:80vh" >
    <div v-loading="riskPersonalLoading">
      <el-form >
        <el-row :gutter="20">
          <el-col :span="6">
            <el-input v-model="riskPersonalQuery.name"  placeholder="请输入姓名或身份证、手机号" clearable />
          </el-col>
          <el-col :span="6">
            <el-select v-model="riskPersonalQuery.personalType" placeholder="请选择人员类别" clearable>
              <el-option v-for="(item,index) in dict.controlType"
                         :key="index"
                         :label="item.dictLabel"
                         :value="item.dictValue"/>
            </el-select>
          </el-col>
          <el-col :span="6">
            <el-select placeholder="管控级别" clearable v-model="riskPersonalQuery.controlLevel">
              <el-option v-for="(item,index) in dict.controlLevel"
                         :key="index"
                         :label="item.dictLabel"
                         :value="item.dictValue"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="6">
            <el-input size="default"  placeholder="管控间隔" v-model="riskPersonalQuery.controlTimeInterval" />
          </el-col>
        </el-row>
        <el-row style="margin-top:20px" :gutter="20">
          <el-col :span="6" >
            <depart-tree-select :size="'default'" placeholder="责任单位"  v-model="riskPersonalQuery.responsibleDepartId" clearable/>
          </el-col>
          <el-col :span="6">
            <el-input placeholder="责任民警" clearable v-model="riskPersonalQuery.responsibleName"></el-input>
          </el-col>
          <el-col :span="6">
            <el-select placeholder="督察状态" v-model="riskPersonalQuery.supStatus" clearable>
              <el-option label="在控" value="在控"></el-option>
              <el-option label="失控" value="失控"></el-option>
              <el-option label="无法确认" value="无法确认"></el-option>
            </el-select>
          </el-col>
        </el-row>
      </el-form>
      <div class="flex end" style="margin: 10px 0">
        <el-button type="primary" @click="getSuperviseTable" >
          <template #icon>
            <icon name="el-icon-Search"/>
          </template>
          查询
        </el-button
        >
      </div>
      <el-row>
        <el-table :data="riskDataCards" @row-click="row=>handSupRiskCard(row)">
          <el-table-column label="姓名" prop="name" width="120">
            <template #default="{row}">
              <div style="display:flex;align-items: center;justify-content: space-around">
                <el-avatar style="height: 60px;width: 60px " shape="square" :size="100" :fit="`fit`"
                           :src="row.imgBase64"/>
                <div >{{row.name}}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="性别" prop="gender" width="40"></el-table-column>
          <el-table-column label="身份证号" prop="idCode" width="120"></el-table-column>
          <el-table-column label="联系方式" prop="mobile"></el-table-column>
          <el-table-column label="人员类别" prop="personalType"></el-table-column>
          <el-table-column label="管控级别" prop="controlLevel"></el-table-column>
          <el-table-column label="管控间隔" prop="controlTimeInterval"></el-table-column>
          <el-table-column label="责任单位" prop="responsibleDepartName"></el-table-column>
          <el-table-column label="责任民警" prop="responsibleName"></el-table-column>
          <el-table-column label="督察状态" prop="supStatus">
            <template #default="{row}">
              <el-tag type="danger"  v-if="row.supStatus == '失控'">{{row.supStatus}}</el-tag>
              <el-tag type="primary"  v-if="row.supStatus == '在控'">{{row.supStatus}}</el-tag>
              <el-tag type="info"  v-if="row.supStatus == '无法确认'">{{row.supStatus}}</el-tag>
            </template>
          </el-table-column>
        </el-table>
        <div class="flex end mt-8">
          <el-pagination
              @size-change="getSuperviseTable"
              @current-change="getSuperviseTable"
              :page-sizes="[10, 20, 50]"
              v-model:page-size="riskPersonalQuery.size"
              v-model:current-page="riskPersonalQuery.current"
              layout="total, sizes, prev, pager, next"
              :total="riskPersonalTotal"
          >
          </el-pagination>
        </div>
      </el-row>
      <el-row>
        <el-table ref="taskSupDataTable" :preserve-expanded-content="preserveExpanded" :data="taskSupData" v-loading="taskLoading">
          <el-table-column type="expand">
            <template #default="props">
              <div >
                <p >督察时间: {{ props.row.supTime }}</p>
                <p>督察状态: {{ props.row.supStatus }}</p>
                <p >督察方式: {{ props.row.supType }}</p>
                <p>督察情况: {{props.row.supDesc}}</p>
                <p>录入人：{{props.row.createName}}</p>
                <p>附件：</p>
                <file-list v-model:files="props.row.fileVoList" :removeEnable="false" />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="督察时间" prop="supTime"></el-table-column>
          <el-table-column label="督察状态" prop="supStatus">
            <template #default="{row}">
              <el-tag type="danger"  v-if="row.supStatus == '失控'">{{row.supStatus}}</el-tag>
              <el-tag type="primary"  v-if="row.supStatus == '在控'">{{row.supStatus}}</el-tag>
              <el-tag type="info"  v-if="row.supStatus == '无法确认'">{{row.supStatus}}</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="督察方式" prop="supType"></el-table-column>
          <el-table-column label="督察情况" prop="supDesc"></el-table-column>
          <el-table-column label="问题录入人" prop="createName"></el-table-column>
          <el-table-column label="操作">
            <template #default="{row}">
              <el-button  v-if="row.supStatus != '在控'" @click="issueMatterFun(row,'risk_personal')" type="primary" link>下发</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="flex end mt-8">
          <el-pagination
              @size-change="getTaskSupDataFun"
              @current-change="getTaskSupDataFun"
              :page-sizes="[10, 20, 50]"
              v-model:page-size="taskSupQuery.size"
              v-model:current-page="taskSupQuery.current"
              layout="total, sizes, prev, pager, next"
              :total="taskSupTotal"
          >
          </el-pagination>
        </div>
      </el-row>
    </div>
  </el-dialog>

  <el-dialog title="任务分发" v-model="distributeShow" width="50vw" top="2vh" style="margin-bottom: 0">
    <el-form :label-width="120" ref="formRefs" :model="issueForm" v-loading="issueLoading">
      <el-form-item
          label="任务名称"
          prop="taskName"
          :rules="{
                    required: true,
                    message: '请输入任务名称',
                }"
      >
        <el-input
            v-model="issueForm.taskName"
            style="width: 280px"
            placeholder="请输入"
        />
      </el-form-item>
      <el-form-item label="指定办理单位" prop="handleDepartId">
        <div class="flex gap">
          <div style="width: 280px">
            <depart-tree-select v-model="issueForm.handleDepartId" />
          </div>
          <div class="tips mt-10">
            <p>指定具体办理单位 指将问题分派给哪个单位办理。</p>
          </div>
        </div>
      </el-form-item>
      <el-form-item
          label="业务类别"
          prop="businessTypeCode"
          :rules="{
                    required: true,
                    message: '请选择业务类别',
                    trigger: ['blur'],
                }"
      >
        <el-select v-model="issueForm.businessTypeCode" style="width: 280px">
          <el-option
              v-for="item in dict.businessType"
              :key="item.id"
              :label="item.dictLabel"
              :value="item.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item
          label="涉嫌问题"
          prop="involveProblem"
          :rules="{
                    required: true,
                    message: '请选择涉嫌问题',
                    trigger: ['blur'],
                }"
      >
        <el-select
            v-model="issueForm.involveProblem"
            multiple
            clearable
            style="width: 280px"
        >
          <el-option
              v-for="item in dict.suspectProblem"
              :key="item.id"
              :label="item.dictLabel"
              :value="item.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="涉及警种" prop="policeType">
        <el-select
            v-model="issueForm.policeType"
            clearable
            filterable
            style="width: 280px"
        >
          <el-option
              v-for="item in dict.policeType"
              :key="item.id"
              :label="item.dictLabel"
              :value="item.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item
          label="办理时限"
          prop="timeLimit"
          :rules="{
                    required: true,
                    message: '请选择办理时限',
                }"
      >
        <time-limit-select
            v-model="issueForm.timeLimit"
            v-model:maxSignDuration="issueForm.maxSignDuration"
            v-model:maxHandleDuration="issueForm.maxHandleDuration"
            v-model:maxExtensionDuration="issueForm.maxExtensionDuration"
        />
      </el-form-item>

      <el-form-item
          label="下发流程"
          prop="distributionFlow"
          :rules="{
                    required: true,
                    message: '请选择下发流程',
                }"
      >
        <el-radio-group v-model="issueForm.distributionFlow" class="block">
          <el-radio
              v-for="item in dict.distributionFlow"
              :key="item.dictCode"
              :value="item.dictValue"
          >{{ item.dictLabel
            }}</el-radio
          >
        </el-radio-group>
      </el-form-item>
      <el-form-item
          label="审核流程"
          prop="approvalFlow"
          :rules="{
                    required: true,
                    message: '请选择审核流程',
                }"
      >
        <el-radio-group v-model="issueForm.approvalFlow">
          <el-radio
              v-for="item in dict.approvalFlow"
              :key="item.dictCode"
              :value="item.dictValue"
          >{{ item.dictLabel
            }}{{ item.remark ? `(${item.remark})` : "" }}</el-radio
          >
        </el-radio-group>
        <div class="tips mt-10">
          <p>
            三级审核　在问题提交办结时，需经过“所队—>二级机构—>市局”三级审核，通过后方可办结；
          </p>
          <p>
            二级审核　在问题提交办结时，仅需经过“所队—>二级机构”两级审核，通过后即可办结；
          </p>
        </div>
      </el-form-item>
      <el-form-item label="附件说明" prop="thingFiles">
        <file-upload v-model:files="issueForm.thingFiles" />
      </el-form-item>
    </el-form>
    <footer class="flex end mt-20">
      <el-button
          type="primary"
          size="large"
          @click="handleSubmitTask"
          v-loading="issueLoading"
      >确认下发</el-button
      >
    </footer>
  </el-dialog>



</template>
<script setup>
import {
  listInspection,
  addInspection,
  listInspectionProblems
} from "@/api/mobileSupervision/inspection";
import {TestingAlcoholIssueMatterFun} from '@/api/mobileSupervision/testingAlcohol';
import feedback from "@/utils/feedback";
import useCatchStore from "@/stores/modules/catch";
import {selectListData} from "@/api/mobileSupervision/Sampling";
import {getDictLable, timeFormat} from "@/utils/util";
import {getDepartProfile} from "@/api/sensitivePerception/profileDepart";
import {ROOT_DEPART_ID} from '@/enums/appEnums';
import {BASE_PATH} from "@/api/request";
import {getTaskSuprt} from '@/api/mobileSupervision/supRiskPerson';
import {
  addTaskManagement,
  getTaskManagementDetail,
  getRiskPersonalPage,
  getDepartByIds,
  delTaskManagement,
  importTemperancePolice,
  importSupRiskPersonal,
  getListFun
} from "@/api/mobileSupervision/taskManagement";
import {listTestingAlcoholPeoples, TestingAlcoholDetail} from "@/api/mobileSupervision/testingAlcohol";
import {getSelfexaminationProblem} from "@/api/mobileSupervision/selfexamination";
import {getTaskProblem} from "@/api/mobileSupervision/taskProblem";
import {getToken} from "@/utils/token";
import {disabledDate} from "@/utils/util";

import useUserStore from "@/stores/modules/user";
const userStore = useUserStore();


let cardContent = ref()
const catchStore = useCatchStore();
const dict = catchStore.getDicts(["supervisionType","policeType","suspectProblem", "approvalFlow","distributionFlow","personnelTypeArray", "inspectorType", "personType","businessType", "controlLevel","distributionState", "controlType"]);

const fileListData = ref([]);
const list = ref([]);

const samplingList = ref([]);
const samplingTotal = ref(10)
const samplingloading = ref(false)
const samplingDetailShow = ref(false)
const editData = ref(false)
const policeLoading = ref(false)
const peopleDetailShow = ref(false)
const show = ref(false);
const samplingQuery = ref({
  current: 1,
  size: 10,
  departBranch: false,
  confinementTime: []
})

const supervisionDict = ref([
  {
    dictValue: 'inspection',
    dictLabel: '日常督察'
  },
  {
    dictValue: 'testing_alcohol',
    dictLabel: '六项规定督察'
  },
  {
    dictValue: 'selfexamination',
    dictLabel: '所队自查'
  },
  {
    dictValue: 'risk_personal',
    dictLabel: '重点人员管控'
  }
])

const query = ref({
  current: 1,
  size: 10,
});
const total = ref(0);

const specialType = ref([
  {
    dictLabel: '六项规定督察',
    dictValue: '六项规定督察'
  },
  {
    dictLabel: '所队自查',
    dictValue: '所队自查'
  },
  {
    dictLabel: '重点人员管控',
    dictValue: '重点人员管控'
  }
])


const dictData = ref([])
const loading = ref(false)

//督察任务列表
function getList() {
  loading.value = true
  getListFun(query.value).then((data) => {
    list.value = data.records;
    total.value = data.total;
    loading.value = false
  })
}

/**
 * 删除督察任务
 * */
async function delTaskManagementFun(row) {
  await feedback.confirm("确定要删除该数据？");
   delTaskManagement(row.id).then(res=>{
     getList()
   })

  feedback.msgSuccess("删除成功");
}


function reset() {
  query.value = {
    current: 1,
    size: 10,
  };
  getList();
}

getList();


const form = ref({
  files: [],
  supRiskDtoList: []
});
const formRef = ref(null);

const quillRef = ref()

//发布任务
async function submit() {
  await formRef.value.validate();
  if (quillRef.value) {
    form.value.taskContent = quillRef.value.getText()
  }
  if(form.value.files ){
     delete  form.value.files
  }
  await addTaskManagement(form.value)
  feedback.msgSuccess("发布成功");
  show.value = false;
  getList();
}

//关闭弹窗的回调函数（清空）
const addColse =()=>{
  form.value = {
    files: [],
    supervisionType: '日常督察',
    supRiskDtoList: []
  };
}

//任务类型转换函数
const getTaskType = (val) => {
  if (val === 'inspection') {
    return "日常督察";
  } else if (val === 'testing_alcohol') {
    return "六项规定督察";
  } else if (val === 'selfexamination') {
    return "所队自查";
  } else {
    return "重点人员督察"
  }
}

const changEndDateTime =()=>{
  if(form.value.times[1]){
    form.value.times[1]= timeFormat(new Date(form.value.times[1]))+" 23:59:59";
  }
}

function handleShowAdd() {
  show.value = true;
  form.value = {
    files: [],
    supervisionType: '日常督察',
    supRiskDtoList: [],
    times:[]
  };
  fileData.value=[]
  filterDataTable.value=[]
  riskDataTable.value=[]

}

const detailShow = ref(false);
const detailLoading = ref(false);
const activeRow = ref({
  supRiskDtoList: []
});

const editLoading = ref(false)
const editTable =async (row)=>{

  show.value = true;
  editLoading.value = true;
  try {
    const res = await getTaskManagementDetail(row.id);
    form.value = res;
    if(res.files){
      form.value.files = JSON.parse(res.files)
    }
    if (res.samplingTarget == '自定义人员' && res.samplingIds) {

      getSamplingList()
      delete samplingQuery.value.ids
    }
    if (res.selfOrgs) {
      getDepartByIdsFun(res.selfOrgs)
    } else {
      slofOrgList.value = []
    }
    showRiskDataTable.value=true
    editLoading.value = false;
  } catch (e) {
    editLoading.value = false;
  }
}
const tableRef =ref()
function setCheck() {

    if( form.value.samplingIds && form.value.samplingIds.length > 0){
      let idList = form.value.samplingIds;
      samplingList.value.forEach(item => {
        if (form.value.samplingIds && idList.indexOf(item.id) >= 0) {
          nextTick(() => {
          tableRef.value.toggleRowSelection(item, true);
          })
        }
      })
    }
}



/**
 * 显示督察任务详情
 * */
async function handleShowDetail(row) {
  detailShow.value = true;
  detailLoading.value = true;
  try {
    const res = await getTaskManagementDetail(row.id);
    activeRow.value = res;
    if(res.files){
      activeRow.value.files = JSON.parse(res.files)
    }
    if (res.samplingTarget == '自定义人员' && res.samplingIds) {
      samplingQuery.value.ids = res.samplingIds;
      getSamplingList()
      delete samplingQuery.value.ids
    }
    if (res.selfOrgs) {
      getDepartByIdsFun(res.selfOrgs)
    } else {
      slofOrgList.value = []
    }
    detailLoading.value = false;
  } catch (e) {
    detailLoading.value = false;
  }

}


const slofOrgList = ref([])

/**
 * 获取自选单位名称
 * */
function getDepartByIdsFun(data) {
  getDepartByIds({'ids': data}).then((res) => {
    slofOrgList.value = res
  })
}


//问题详情

const problemShow = ref(false);
const activeRowData = ref({})

async function showDeatil(row) {
  problemShow.value = true
  activeRowData.value = await getTaskProblem(row.id)
}

const preserveExpanded = ref(false)

//重点督察人员导入
const fileData = ref([])
const fileDataLoading = ref(false)
const showRiskDataTable = ref(false);

/*
*获取重点督察人员
* **/
async function SupRiskSuccess(val) {
  form.value.supRiskDtoList = val.data
  fileDataLoading.value = false;
  showRiskDataTable.value = true;
  showUploadFun();
}

const SupRiskProgress = () => {
  fileDataLoading.value = true;
}


const superviseRiskShow = ref(false);
const superviseRiskLoading =ref(false);
const taskSupQuery = ref({
  current: 1,
  size: 10,
})
const taskSupTotal = ref(0)
const taskSupData = ref([])
const taskLoading = ref(false)
const riskDataCards = ref(null)

const riskPersonalQuery = ref({
  current: 1,
  size: 10,
})
const riskPersonalTotal =ref(0);
const riskPersonalLoading = ref(false);

const getSuperviseTable = async ()=>{
  const res = await getRiskPersonalPage(riskPersonalQuery.value);
  const riskData = res.records;
  riskPersonalTotal.value = res.total;
  riskDataCards.value = riskData;
  if (res.records?.length > 0) {
    taskSupQuery.value.idCode = riskData[0].idCode;
    taskSupQuery.value.taskId = row.id;
    const taskSupert = await getTaskSuprt(taskSupQuery.value);
    taskSupTotal.value = taskSupert.total;
    taskSupData.value = taskSupert.records;
  }else{
    taskSupData.value = null
  }
}

const showSupervise = async (row) => {
  superviseRiskShow.value = true;
  riskPersonalLoading.value=true;
  riskPersonalQuery.value.id = row.id;
  const res = await getRiskPersonalPage(riskPersonalQuery.value);
  //获取重点人员列表
  const riskData = res.records;
  riskPersonalTotal.value = res.total;
  riskDataCards.value = riskData;
  if (res.records?.length > 0) {
    taskSupQuery.value.idCode = riskData[0].idCode;
    taskSupQuery.value.taskId = row.id;
    const taskSupert = await getTaskSuprt(taskSupQuery.value);
    taskSupTotal.value = taskSupert.total;
    taskSupData.value = taskSupert.records;
  }else{
    taskSupData.value = null;
  }
  riskPersonalLoading.value=false;
}
/**
 * 获取重点人员督察记录列表
 * */
const getTaskSupDataFun = async () => {
  taskLoading.value = true;
  try {
    const taskSupert = await getTaskSuprt(taskSupQuery.value);
    taskSupTotal.value = taskSupert.total;
    taskSupData.value = taskSupert.records;
    taskLoading.value = false;
  } catch (e) {
    taskLoading.value = false;
  }
}
/**
 * 点击重点人员
 * */
const handSupRiskCard = async (row)=>{
  taskLoading.value = true;
  try {
    taskSupQuery.value.idCode = row.idCode;
    const taskSupert = await getTaskSuprt(taskSupQuery.value);
    taskSupTotal.value = taskSupert.total;
    taskSupData.value = taskSupert.records;
    taskLoading.value = false;
  } catch (e) {
    taskLoading.value = false;
  }
}
/**
 * 重点督察人员前端列表
 * */
const getRiskDataTableSubmit = () => {
  filterDataTable.value = (form.value.supRiskDtoList && form.value.supRiskDtoList.length > 0) ? form.value.supRiskDtoList : activeRow.value.supRiskDtoList
  //管控级别
  if (riskDataQuery.value.controlLevel) {
    filterDataTable.value = filterDataTable.value.filter(s => s.controlLevel.includes(riskDataQuery.value.controlLevel));
  }
  if (riskDataQuery.value.keyword) {
    filterDataTable.value = filterDataTable.value.filter(s => s.name.includes(riskDataQuery.value.keyword) || s.idCode.includes(riskDataQuery.value.keyword) || s.mobile.includes(riskDataQuery.value.keyword));
  }
  if (riskDataQuery.value.personalType) {
    filterDataTable.value = filterDataTable.value.filter(s => s.personalType.includes(riskDataQuery.value.personalType));
  }
  if (riskDataQuery.value.responsibleName) {
    filterDataTable.value = filterDataTable.value.filter(s => s.responsibleName.includes(riskDataQuery.value.responsibleName));
  }
  if (riskDataQuery.value.controlName) {
    filterDataTable.value = filterDataTable.value.filter(s => s.controlName.includes(riskDataQuery.value.controlName));
  }

  nextTick(()=>{
    riskDataTotal.value = filterDataTable.value.length;
    riskDataTable.value = filterDataTable.value.slice(startValue.value, endValue.value);
  })
}
/**
 * 删除重点督察人员数据
 * */
const delriskData = async (row) => {
  await feedback.confirm(`确认删除数据 ？`)
  nextTick(() => {
    form.value.supRiskDtoList = form.value.supRiskDtoList.filter(s => s.idCode !== row.idCode);
  })
}

//检测情况（六项规定督察）---------
const testingDetailShow = ref(false);
const testingLoading = ref(false);
const peopleQuery = ref({
  size: 10,
  current: 1,
})

/**
 * 数据导出
 * */
const handleExport = async () => {
  let data = Object.assign({}, editData.value)
  delete data.samplingPolices
  delete data.startTime
  delete data.endTime
  if (!data.samplingTime) {
    delete data.samplingTime
  }
  if (data.samplingObjectList) {
    data.orgStr =
        data.samplingObjectList.map(s => s.deptId).join(",")
    delete data.samplingObjectList
  } else {

  }
  window.open(`${BASE_PATH}/sampling/export/samplingPoling?` + new URLSearchParams(data).toString())
}

// 获取六项规定督察详情
async function handleTestingDetailShow(row) {
  testingDetailShow.value = true;
  activeRow.value = await TestingAlcoholDetail(row.id)
  await getTestingAlcoholPeople()
}

// 获取酒精检测人员
async function getTestingAlcoholPeople() {
  testingLoading.value = true;
  try {
    const data = await listTestingAlcoholPeoples(activeRow.value.id, peopleQuery.value)
    peoples.value = data.records;
    peopleTotal.value = data.total;
  } catch (e) {
    testingLoading.value = false;
  }
  testingLoading.value = false;
}

// 重置酒精检测人员
function peopleReset() {
  peopleQuery.value = {
    size: 10,
    current: 1,
  };
  getTestingAlcoholPeople()
}

// 获取酒精检测人员详情
function handleShowPeople(row) {
  activePeople.value = row;
  peopleDetailShow.value = true;
}


//-----获取所队自查-督察问题-----
const selfProblemList = ref([]);
const problemLoading = ref(false);
const selfProblemsShow = ref(false);
const selfPeopleQuery = ref({})
const selfProblemTotal = ref(0);
//打开所队自查详情界面
const handleSelfProblemShow = (row) => {
  selfProblemsShow.value = true;
  selfPeopleQuery.value.id = row.id;
  getSelfexaminationProblemFun();
}

//获取所队自查-问题内容
async function getSelfexaminationProblemFun() {
  problemLoading.value = true;
  try {
    const res = await getSelfexaminationProblem(selfPeopleQuery.value.id, selfPeopleQuery.value);
    selfProblemList.value = res.records;
    selfProblemTotal.value = res.total;
  } catch (e) {
    problemLoading.value = false;
  }
  problemLoading.value = false;
}


const problemsShow = ref(false);
const problems = ref([]);
const problemQuery = ref({
  size: 10,
  current: 1,
});
const problemTotal = ref(0);
const activePeople = ref()
const peoples = ref()
const peopleTotal = ref(0);
const problemsLoading = ref(false)

// ---- 打开督察详情界面（日常督察）
async function handleProblemsShow(row) {
  activeRow.value = row;
  problemsLoading.value = true
  problemsShow.value = true;
  try {
    problemQuery.value.id = activeRow.value.id;
    const res = await listInspectionProblems(problemQuery.value.id,problemQuery.value);
    problems.value = res.records;
    problemTotal.value = res.total;
  } catch (e) {
    problemsLoading.value = false;
  }
  problemsLoading.value = false;
}

// ---- 获取督察详情界面（日常督察）
function getProblems() {
  listInspectionProblems(activeRow.value.id).then((data) => {
    problems.value = data.records;
    problemTotal.value=data.total;
  });
}

function problemReset() {
  problemQuery.value = {
    size: 10,
    current: 1,
  };
}

/**
 * 查询抽检人员
 * */
function getSamplingList() {
  samplingloading.value = true
  selectListData(samplingQuery.value).then((res) => {
    samplingList.value = res.records;
    setCheck();
    samplingTotal.value = res.total;
    samplingloading.value = false
  })
}

/**
 * 数据处理（抽检规则-抽检对象）
 * */
function handleSamplingDetail(row) {
  editData.value = null
  editData.value = row
  editData.value.samplingObjectList.forEach(async (x) => {
    x.departName = await getDepartShortNameFun(x.deptId)
  })
  samplingDetailShow.value = true
}

/**
 * 获取被选择的数据
 * */
function handleSelectionChange(val) {
  let arr = []
  form.value.samplingIds = [];
  val.forEach((s) => {
    s.samplingPolices.map((val) => {
      arr.push({
        empNo: val.empNo,
        departId: val.deptId,
        name: val.name
      })
    })
    form.value.samplingIds.push(s.id)
  })
  form.value.userList = arr;
}


//获取单位为简称
const getDepartShortNameFun = async (val) => {
  const res = await getDepartProfile(val)
  if (res) {
    return res.departInfo?.shortName;
  }
}

/**
 * 删除自查内容
 * */
const delCardFun = (index) => {
  if (form.value.selfContents) {
    form.value.selfContents.splice(index, 1)
  }
}
/**
 * 添加自查内容
 * */
const addSelfArray = () => {
  if (form.value.selfContents) {
    form.value.selfContents.push(
        {
          title: null,
          content: null
        }
    )
  } else {
    form.value.selfContents = [
      {
        title: null,
        content: null
      }
    ]
  }
}


const temperancLoading = ref(false);
//上传成功
const managementSuccess = async (val) => {
  form.value.userList = val.data;
  temperancLoading.value = false;
}
//上传开始回调
const managementProgress = async (val) => {
  temperancLoading.value = true;
}

//getDeparts
const departs = catchStore.getDepartsAll();

//任务分发
const distributeShow = ref(false)
const issueForm = ref({})
const issueLoading = ref(false)
const formRefs =ref();
//六项规定督察下发问题
const issueMatterFun =async (row,key)=>{
  switch (key){
    case "selfexamination":
      issueForm.value.taskId = selfPeopleQuery.value.id;
      issueForm.value.problemVo = row
      break;
    case "inspection":
      issueForm.value.taskId = problemQuery.value.id;
      issueForm.value.problemVo = await getTaskProblem(row.id)
      // issueForm.value.problemVo = row
      break;
    case "testing_alcohol":
      issueForm.value.taskId = row.taskId;
      issueForm.value.empNo =row.empNo;
      break;
    case "risk_personal":
      issueForm.value.taskId = riskPersonalQuery.value.id;
      issueForm.value.supRecordId =row.id
      break;
  }

  issueForm.value.tableKey = key
  console.log('actrow',row)
  distributeShow.value=true;
}
//下发问题
const handleSubmitTask =async ()=>{
  await formRefs.value.validate();
  issueLoading.value = true
  console.log('activeRow----------',activeRow.value)

  try {
    await  TestingAlcoholIssueMatterFun(issueForm.value)
  } catch(e) {
    issueLoading.value = false
    return
  }
  issueLoading.value = false
  feedback.msgSuccess("下发成功");
  distributeShow.value = false;
  switch (issueForm.value.tableKey){
    case "selfexamination":
      getSelfexaminationProblemFun();
      break;
    case "inspection":
      getProblems();
      break;
    case "testing_alcohol":
      getTestingAlcoholPeople();
      break;
    case "risk_personal":
      getTaskSupDataFun();
      break;
  }

}


function getData() {
  if (departs.length && departs[0].id === ROOT_DEPART_ID) {
    dictData.value = departs[0].children
  } else {
    dictData.value = departs
  }
}


onMounted(() => {
  getData()
})

const riskDataTable = ref([]);
const riskDataQuery = ref({})
const riskDataTotal = ref(0);
const filterDataTable = ref([])
const uploadShow = ref(false)


const showUploadFun = () => {
  uploadShow.value = !uploadShow.value
}

const startValue = ref(0);
const endValue = ref(11);
/**
 * 获取表单数据
 * */
const getRiskDataTableList = (val) => {
  endValue.value = (10 * val) + 1;
  startValue.value = (10 * (val - 1));
  if (riskDataTotal.value < (10 * val)) {
    endValue.value = riskDataTotal.value;
  }
  riskDataTable.value = filterDataTable.value.slice(startValue.value, endValue.value);
}
/**
 * 获取重点督察人员表单
 * */
watch(() => form.value.supRiskDtoList, (newVal) => {
  if (form.value.supRiskDtoList && form.value.supRiskDtoList.length > 0) {
    getRiskDataTableSubmit();
  }
  if(!activeRow.value.supRiskDtoList ||  activeRow.value.supRiskDtoList.length == 0){
    riskDataTotal.value = 0;
    riskDataTable.value =[];
  }
}, {immediate: true, deep: true})

/**
 * 获取重点督察人员表单
 * */
watch(() => activeRow.value.supRiskDtoList, (newVal) => {
  if (activeRow.value.supRiskDtoList && activeRow.value.supRiskDtoList.length > 0) {
    getRiskDataTableSubmit();
  }
}, {immediate: true, deep: true})


watch(departs, () => {
  getData()
})


watch(() => form.value.specialType, (newVal) => {
  console.log('newVal',newVal)
  if (newVal === '六项规定督察') {
    form.value.samplingTarget = '自定义人员'
  }
}, {immediate: true})

watch(() => form.value.samplingTarget, (newVal) => {
  if (newVal === '自定义人员') {

    getSamplingList()
  }
}, {immediate: true})

watch(() => form.value.supervisionType, (newVal) => {
  if (newVal === '日常督察') {
    form.value.taskContentHtml = '<p>任务要求</p>'
  } else {
    delete form.value.taskContentHtml
  }
}, {immediate: true})


</script>
<style lang="scss" scoped>
h5 {
  margin-bottom: 10px;
}

.pepole-container > * {
  margin-bottom: 8px;
}

.card_content {
  height: 100px;
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: row;
  flex-wrap: wrap;
  margin-top: 10px;
}

.zcCard {
  width: 47%;
  padding: 15px 10px;
  margin-bottom: 10px;
  margin-left: 5px;
  background-color: #f1f6ff
}

.card_title {
  margin-bottom: 10px
}

.superviseRiskCards {
  width: 100%;
  height: 70vh;
  display: flex;
  justify-content: space-around;
}

.risk_left {
  width: 30%;
  height: 70vh;
  overflow-x: visible;
  overflow-y: auto;
  margin-right:10px;
}

.risk_right {
  width: 70%;
  height: 70vh;
  overflow: auto;
}

.user_card {
  width: 99%;
  display: flex;
  justify-content: space-around;
  border: 1px solid #ECEEFB;
  border-radius: 10px;
  margin-top: 5px;
  margin-bottom: 10px;
  overflow: hidden;

}
.user_card_change{
  background-color: #eaeaf1;

}

.user_card_img {
  width: 40%;

}

.user_card_info {
  width: 60%;
  color: #afaeae;
  padding: 10px;
  .user_card_info_text {
    color: #0d0e1b;
  }
}
</style>
