<template>
  <div class="app-container">
    <div ref="sousuH">
      <!-- 搜索工作栏 -->
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="68px"
      >
        <el-form-item label="任务名称" prop="taskName">
          <el-input
            v-model="queryParams.taskName"
            placeholder="请输入任务名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="任务类型" prop="taskType">
          <el-select
            v-model="queryParams.taskType"
            placeholder="请选择任务类型"
            clearable
            size="small"
          >
            <el-option
              v-for="dict in this.filteredDataType"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="任务状态" prop="taskStatus">
          <el-select
            v-model="queryParams.taskStatus"
            placeholder="请选择任务状态"
            clearable
            size="small"
            @change="taskStatusChange"
          >
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.TASK_STATUS)"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="任务积分" prop="taskScore">
          <el-input onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace( /[^\d]/g,''))"
            oninput="value=value.replace(/[^\d.]/g,'')" type="text" v-model="queryParams.taskScore" placeholder="请输入任务积分"
            clearable @keyup.enter.native="handleQuery" />
        </el-form-item> -->
        <!-- <el-form-item label="检查频次" prop="inspectFrequency">
          <el-select v-model="queryParams.inspectFrequency" placeholder="请选择检查频次" clearable size="small">
            <el-option v-for="dict in this.getDictDatas(DICT_TYPE.CHECK_FRE)" :key="dict.value" :label="dict.label"
              :value="dict.value" />
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="状态" prop="status">
          <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
            <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="dict.value" :label="dict.label"
              :value="dict.value" />
          </el-select>
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <!-- 操作工具栏 -->
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['backend:task-info:create']"
            >新增</el-button
          >
        </el-col>
        <!-- <el-col :span="1.5">
          <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
            :loading="exportLoading" v-hasPermi="['backend:task-info:export']">导出</el-button>
        </el-col> -->
        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
      </el-row>
    </div>
    <el-tabs
      type="border-card"
      v-model.trim="selectedTab"
      @tab-click="clickTab"
    >
      <el-tab-pane label="草稿箱" name="type0">
        <!-- 列表 -->
        <el-table
          v-loading="loading"
          :data="list"
          :height="list.length ? tableHeight : 'auto'"
        >
          <el-table-column label="ID" align="center" prop="id" />
          <el-table-column label="任务名称" align="center">
            <template v-slot="scope">
              {{
                scope.row.taskInfoDO != null
                  ? scope.row.taskInfoDO.taskName
                  : ""
              }}</template
            >
          </el-table-column>
          <el-table-column label="任务类型" align="center">
            <template v-slot="scope">
              <dict-tag
                :type="DICT_TYPE.TASK_TYPE"
                :value="
                  scope.row.taskInfoDO == null
                    ? 0
                    : scope.row.taskInfoDO.taskType
                "
              />
            </template>
          </el-table-column>
          <el-table-column label="任务内容" align="center">
            <template slot-scope="scope">
              <div
                v-html="
                  scope.row.taskInfoDO ? scope.row.taskInfoDO.taskContent : ''
                "
              ></div>
            </template>
          </el-table-column>
          <el-table-column label="接收者" align="center" prop="receiverName" />
          <el-table-column label="发布者" align="center" prop="senderName" />
          <el-table-column label="单位" align="center" prop="orgName" />
          <!-- <el-table-column label="任务状态" align="center" prop="taskInfoDO.taskStatus">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.TASK_STATUS" :value="scope.row.taskInfoDO.taskStatus" />
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="任务积分" align="center" prop="taskScore" /> -->
          <!-- <el-table-column label="检查频次" align="center" prop="inspectFrequency">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.CHECK_FRE" :value="scope.row.inspectFrequency" />
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="状态" align="center" prop="status">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
            </template>
          </el-table-column> -->
          <el-table-column
            label="操作"
            align="center"
            class-name="small-padding fixed-width"
            fixed="right"
            width="180"
          >
            <template v-slot="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['backend:task-info:update']"
                >修改</el-button
              >
              <el-dropdown
                @command="
                  (command) => handleCommand(command, scope.$index, scope.row)
                "
              >
                <el-button size="mini" type="text" icon="el-icon-d-arrow-right"
                  >更多</el-button
                >
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item
                    command="handleDelete"
                    size="mini"
                    type="text"
                    icon="el-icon-delete"
                    v-hasPermi="['backend:task-info:delete']"
                    >删除</el-dropdown-item
                  >
                  <el-dropdown-item
                    command="handleSelectedOrg"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >已分配单位列表</el-dropdown-item
                  >
                  <el-dropdown-item
                    command="handleOrg"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >分配单位</el-dropdown-item
                  >
                  <el-dropdown-item
                    command="handleSelectedInsp"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >已分配检查项列表</el-dropdown-item
                  >
                  <el-dropdown-item
                    command="handleInsp"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >分配检查项</el-dropdown-item
                  >
                  <el-dropdown-item
                    command="handPublish"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >发布</el-dropdown-item
                  >
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="已发布/待完成 " name="type1">
        <!-- 列表 -->
        <el-table
          v-loading="loading"
          :data="list"
          :height="list.length ? tableHeight : 'auto'"
        >
          <el-table-column label="ID" align="center" prop="id" />
          <el-table-column label="任务名称" align="center">
            <template v-slot="scope">
              {{
                scope.row.taskInfoDO != null
                  ? scope.row.taskInfoDO.taskName
                  : ""
              }}
            </template>
          </el-table-column>
          <el-table-column label="任务类型" align="center">
            <template v-slot="scope">
              <dict-tag
                :type="DICT_TYPE.TASK_TYPE"
                :value="
                  scope.row.taskInfoDO ? scope.row.taskInfoDO.taskType : ''
                "
              />
            </template>
          </el-table-column>
          <el-table-column label="任务内容" align="center">
            <template slot-scope="scope">
              <div
                v-html="
                  scope.row.taskInfoDO ? scope.row.taskInfoDO.taskContent : ''
                "
              ></div>
            </template>
          </el-table-column>
          <el-table-column label="接收者" align="center" prop="receiverName" />
          <el-table-column label="发布者" align="center" prop="senderName" />
          <el-table-column label="单位" align="center" prop="orgName" />
          <!-- <el-table-column label="任务状态" align="center" prop="taskStatus">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.TASK_STATUS" :value="scope.row.taskStatus" />
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="任务积分" align="center" prop="taskScore" /> -->
          <!-- <el-table-column label="检查频次" align="center" prop="inspectFrequency">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.CHECK_FRE" :value="scope.row.inspectFrequency" />
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="状态" align="center" prop="status">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
            </template>
          </el-table-column> -->
          <el-table-column
            label="操作"
            align="center"
            class-name="small-padding fixed-width"
            fixed="right"
            width="180"
          >
            <template v-slot="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-view"
                @click="handleSee(scope.row)"
                >查看</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['backend:task-info:update']"
                >修改</el-button
              >
              <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                                                                                    v-hasPermi="['backend:task-info:delete']">删除</el-button> -->
              <el-dropdown
                @command="
                  (command) => handleCommand(command, scope.$index, scope.row)
                "
              >
                <el-button size="mini" type="text" icon="el-icon-d-arrow-right"
                  >更多</el-button
                >
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item
                    command="handleDelete"
                    size="mini"
                    type="text"
                    icon="el-icon-delete"
                    v-hasPermi="['backend:task-info:delete']"
                    >删除</el-dropdown-item
                  >
                  <el-dropdown-item
                    command="handleSelectedOrg"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >已分配单位列表</el-dropdown-item
                  >
                  <!-- <el-dropdown-item command="handleOrg" size="mini" type="text"
                    icon="el-icon-circle-check">分配单位</el-dropdown-item> -->
                  <el-dropdown-item
                    command="handleSelectedInsp"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >已分配检查项列表</el-dropdown-item
                  >
                  <!-- <el-dropdown-item command="handleInsp" size="mini" type="text"
                    icon="el-icon-circle-check">分配检查项</el-dropdown-item> -->
                  <!-- <el-dropdown-item command="handPublish" size="mini" type="text"
                    icon="el-icon-circle-check">发布</el-dropdown-item> -->
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="已完成/待审核" name="type2">
        <!-- 列表 -->
        <el-table
          v-loading="loading"
          :data="list"
          :height="list.length ? tableHeight : 'auto'"
        >
          <el-table-column label="ID" align="center" prop="id" />
          <el-table-column label="任务名称" align="center">
            <template v-slot="scope">
              {{
                scope.row.taskInfoDO != null
                  ? scope.row.taskInfoDO.taskName
                  : ""
              }}
            </template>
          </el-table-column>
          <el-table-column label="任务类型" align="center">
            <template v-slot="scope">
              <dict-tag
                :type="DICT_TYPE.TASK_TYPE"
                :value="
                  scope.row.taskInfoDO == null
                    ? 0
                    : scope.row.taskInfoDO.taskType
                "
              />
            </template>
          </el-table-column>
          <el-table-column label="任务内容" align="center">
            <template slot-scope="scope">
              <div
                v-html="
                  scope.row.taskInfoDO ? scope.row.taskInfoDO.taskContent : ''
                "
              ></div>
            </template>
          </el-table-column>
          <el-table-column label="接收者" align="center" prop="receiverName" />
          <el-table-column label="发布者" align="center" prop="senderName" />
          <el-table-column label="单位" align="center" prop="orgName" />
          <!-- <el-table-column label="任务状态" align="center" prop="taskStatus">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.TASK_STATUS" :value="scope.row.taskStatus" />
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="任务积分" align="center" prop="taskScore" /> -->
          <!-- <el-table-column label="检查频次" align="center" prop="inspectFrequency">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.CHECK_FRE" :value="scope.row.inspectFrequency" />
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="状态" align="center" prop="status">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
            </template>
          </el-table-column> -->
          <el-table-column
            label="操作"
            align="center"
            class-name="small-padding fixed-width"
            fixed="right"
            width="180"
          >
            <template v-slot="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-view"
                @click="handleSee(scope.row)"
                >查看</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['backend:task-info:update']"
                >修改</el-button
              >
              <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                                                                                    v-hasPermi="['backend:task-info:delete']">删除</el-button> -->
              <el-dropdown
                @command="
                  (command) => handleCommand(command, scope.$index, scope.row)
                "
              >
                <el-button size="mini" type="text" icon="el-icon-d-arrow-right"
                  >更多</el-button
                >
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item
                    command="handleDelete"
                    size="mini"
                    type="text"
                    icon="el-icon-delete"
                    v-hasPermi="['backend:task-info:delete']"
                    >删除</el-dropdown-item
                  >
                  <el-dropdown-item
                    command="handleSelectedOrg"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >已分配单位列表</el-dropdown-item
                  >
                  <!-- <el-dropdown-item command="handleOrg" size="mini" type="text"
                    icon="el-icon-circle-check">分配单位</el-dropdown-item> -->
                  <el-dropdown-item
                    command="handleSelectedInsp"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >已分配检查项列表</el-dropdown-item
                  >
                  <!-- <el-dropdown-item command="handleInsp" size="mini" type="text"
                    icon="el-icon-circle-check">分配检查项</el-dropdown-item> -->
                  <!-- <el-dropdown-item command="handPublish" size="mini" type="text"
                    icon="el-icon-circle-check">发布</el-dropdown-item> -->
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="已归档" name="type3">
        <!-- 列表 -->
        <el-table
          v-loading="loading"
          :data="list"
          :height="list.length ? tableHeight : 'auto'"
        >
          <el-table-column label="ID" align="center" prop="id" />
          <el-table-column label="任务名称" align="center">
            <template v-slot="scope">
              {{
                scope.row.taskInfoDO != null
                  ? scope.row.taskInfoDO.taskName
                  : ""
              }}
            </template>
          </el-table-column>
          <el-table-column label="任务类型" align="center">
            <template v-slot="scope">
              <dict-tag
                :type="DICT_TYPE.TASK_TYPE"
                :value="
                  scope.row.taskInfoDO == null
                    ? 0
                    : scope.row.taskInfoDO.taskType
                "
              />
            </template>
          </el-table-column>
          <el-table-column label="任务内容" align="center">
            <template slot-scope="scope">
              <div
                v-html="
                  scope.row.taskInfoDO ? scope.row.taskInfoDO.taskContent : ''
                "
              ></div>
            </template>
          </el-table-column>
          <el-table-column label="接收者" align="center" prop="receiverName" />
          <el-table-column label="发布者" align="center" prop="senderName" />
          <el-table-column label="单位" align="center" prop="orgName" />
          <!-- <el-table-column label="任务状态" align="center" prop="taskStatus">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.TASK_STATUS" :value="scope.row.taskStatus" />
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="任务积分" align="center" prop="taskScore" /> -->
          <!-- <el-table-column label="检查频次" align="center" prop="inspectFrequency">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.CHECK_FRE" :value="scope.row.inspectFrequency" />
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="状态" align="center" prop="status">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
            </template>
          </el-table-column> -->
          <el-table-column
            label="操作"
            align="center"
            class-name="small-padding fixed-width"
            fixed="right"
            width="180"
          >
            <template v-slot="scope">
              <!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                v-hasPermi="['backend:task-info:update']">修改</el-button> -->
              <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                                                                     v-hasPermi="['backend:task-info:delete']">删除</el-button> -->
              <el-button
                size="mini"
                type="text"
                icon="el-icon-view"
                @click="handleSee(scope.row)"
                >查看</el-button
              >
              <el-dropdown
                @command="
                  (command) => handleCommand(command, scope.$index, scope.row)
                "
              >
                <el-button size="mini" type="text">更多</el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item
                    command="handleDelete"
                    size="mini"
                    type="text"
                    icon="el-icon-delete"
                    v-hasPermi="['backend:task-info:delete']"
                    >删除</el-dropdown-item
                  >
                  <el-dropdown-item
                    command="handleSelectedOrg"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >已分配单位列表</el-dropdown-item
                  >
                  <!-- <el-dropdown-item command="handleOrg" size="mini" type="text"
                    icon="el-icon-circle-check">分配单位</el-dropdown-item> -->
                  <el-dropdown-item
                    command="handleSelectedInsp"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >已分配检查项列表</el-dropdown-item
                  >
                  <!-- <el-dropdown-item command="handleInsp" size="mini" type="text"
                    icon="el-icon-circle-check">分配检查项</el-dropdown-item> -->
                  <!-- <el-dropdown-item command="handPublish" size="mini" type="text"
                    icon="el-icon-circle-check">发布</el-dropdown-item> -->
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="周期性任务" name="type4">
        <!-- 列表 -->
        <el-table
          v-loading="loading"
          :data="list"
          :height="list.length ? tableHeight : 'auto'"
        >
          <el-table-column label="ID" align="center" prop="id" />
          <el-table-column label="任务名称" align="center" prop="taskName" />
          <el-table-column label="任务类型" align="center" prop="taskType">
            <template v-slot="scope">
              <dict-tag
                :type="DICT_TYPE.TASK_TYPE"
                :value="scope.row.taskType"
              />
            </template>
          </el-table-column>
          <el-table-column label="任务内容" align="center">
            <template slot-scope="scope">
              <div v-html="scope.row.taskContent"></div>
            </template>
          </el-table-column>
          <el-table-column label="执行状态" align="center" prop="cycleStatus">
            <template v-slot="scope">
              <dict-tag
                :type="DICT_TYPE.INFRA_JOB_STATUS"
                :value="scope.row.cycleStatus"
              />
            </template>
          </el-table-column>
          <!-- <el-table-column label="任务积分" align="center" prop="taskScore" /> -->
          <!-- <el-table-column label="检查频次" align="center" prop="inspectFrequency">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.CHECK_FRE" :value="scope.row.inspectFrequency" />
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="状态" align="center" prop="status">
            <template v-slot="scope">
              <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
            </template>
          </el-table-column> -->
          <el-table-column
            label="操作"
            align="center"
            class-name="small-padding fixed-width"
            fixed="right"
            width="180"
          >
            <template v-slot="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['backend:task-info:update']"
                >修改</el-button
              >
              <!--暂停  -->
              <svg-icon
                v-if="
                  (scope.row.iscycle && scope.row.cycleStatus == 1) ||
                  (scope.row.iscycle && scope.row.cycleStatus == 2)
                "
                icon-class="restore"
                style="font-size: 24px; cursor: pointer"
                @click="handleStopOrRest(scope.row, 0)"
              />
              <el-button
                v-if="scope.row.iscycle && scope.row.cycleStatus == 1"
                size="mini"
                type="text"
                icon="restore"
                @click="handleStopOrRest(scope.row, 2)"
                >暂停
              </el-button>
              <!-- 继续 -->
              <svg-icon
                v-if="scope.row.iscycle && scope.row.cycleStatus == 0"
                icon-class="stop"
                style="font-size: 24px; cursor: pointer"
                @click="handleStopOrRest(scope.row, 1)"
              />
              <el-button
                v-if="scope.row.iscycle && scope.row.cycleStatus == 2"
                size="mini"
                type="text"
                style="margin-left: 0px"
                @click="handleStopOrRest(scope.row, 1)"
              >
                开始</el-button
              >
              <el-dropdown
                @command="
                  (command) => handleCommand(command, scope.$index, scope.row)
                "
              >
                <el-button size="mini" type="text" icon="el-icon-d-arrow-right"
                  >更多</el-button
                >
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item
                    command="handleDelete"
                    size="mini"
                    type="text"
                    icon="el-icon-delete"
                    v-hasPermi="['backend:task-info:delete']"
                    >删除</el-dropdown-item
                  >
                  <!-- <el-dropdown-item command="handleSelectedOrg" size="mini" type="text"
                    icon="el-icon-circle-check">已分配单位列表</el-dropdown-item>
                  <el-dropdown-item command="handleOrg" size="mini" type="text"
                    icon="el-icon-circle-check">分配单位</el-dropdown-item> -->
                  <el-dropdown-item
                    command="handleSelectedInsp"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >已分配检查项列表</el-dropdown-item
                  >
                  <el-dropdown-item
                    command="handleInsp"
                    size="mini"
                    type="text"
                    icon="el-icon-circle-check"
                    >分配检查项</el-dropdown-item
                  >
                  <!-- <el-dropdown-item command="handPublishCycleTask" size="mini" type="text"
                    icon="el-icon-circle-check">发布</el-dropdown-item> -->
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
    <!-- 分页组件 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 对话框(添加 / 修改) -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="800px"
      v-dialogDrag
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="任务名称" prop="taskName">
          <el-input v-model="form.taskName" placeholder="请输入任务名称" />
        </el-form-item>
        <el-form-item label="任务类型" prop="taskType">
          <el-select
            v-model="form.taskType"
            placeholder="请选择任务类型"
            style="width: 100%"
          >
            <el-option
              v-for="dict in this.filteredData"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="单位类别"
          prop="orgTypes"
          v-if="form.taskType == 3 || form.taskType == 8"
        >
          <el-select
            v-model="form.orgTypes"
            multiple
            placeholder="请选择单位类别"
            style="width: 100%"
          >
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.BACKEND_ORG_TYPE)"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="任务内容">
          <editor v-model="form.taskContent" :min-height="192" />
        </el-form-item>
        <!-- <el-form-item label="任务状态" prop="taskStatus">
          <el-select
            v-model="form.taskStatus"
            placeholder="请选择任务状态"
            style="width: 100%"
          >
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.TASK_STATUS)"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            />
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="任务积分" prop="taskScore">
          <el-input v-model="form.taskScore" placeholder="请输入任务积分" />
        </el-form-item> -->
        <el-form-item
          label="任务周期"
          prop="inspectFrequency"
          v-if="form.taskType == 3 || form.taskType == 8"
        >
          <el-select
            v-model="form.inspectFrequency"
            placeholder="请选择任务周期"
            style="width: 100%"
          >
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.CHECK_FRE)"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>

        <el-form-item label="持续时间" prop="time" v-if="form.time">
          <el-date-picker
            clearable
            v-model="form.time"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :default-time="['00:00:00', '23:59:59']"
            placeholder="请选择任务持续时间"
          />
        </el-form-item>
        <!-- <el-form-item label="状态" prop="status">
          <el-radio-group v-model="form.status" style="width: 100%">
            <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="dict.value"
              :label="parseInt(dict.value)">{{ dict.label }}</el-radio>
          </el-radio-group>
        </el-form-item> -->
        <!-- <el-form-item label="单位类别">
           <el-select v-model="form.orgTypes" multiple placeholder="请选择单位类别" style="width: 100%;">
            <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMPANY_inspectitem_kind)" :key="dict.value" :label="dict.label"
              :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="检查项类别">
          <el-select v-model="form.inspType" multiple placeholder="请选择单位类别" style="width: 100%;">
            <el-option v-for="dict in this.getDictDatas(DICT_TYPE.DICT_INSPECT_TYPE)" :key="dict.value"
              :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="单位">
          <el-input clear @focus="handleFocus" @clear="handleClear" placeholder="请选择单位" v-model="orgList" clearable>
            <template slot="append">
              <i title="选择" @click="handleChoice" style="cursor:pointer;" class="el-icon-plus"></i>
            </template>
          </el-input>
        </el-form-item>
        <el-form-item label="检查项">
          <el-input clear @focus="handleFocusinsp" @clear="handleClearinsp" placeholder="请选择单位" v-model="inspList"
            clearable>
            <template slot="append">
              <i title="选择" @click="handleChoiceinsp" style="cursor:pointer;" class="el-icon-plus"></i>
            </template>
          </el-input>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 分配分管单位 -->
    <el-dialog
      title="分配分管单位"
      :visible.sync="openOrg"
      width="85vw"
      append-to-body
      v-if="openOrg"
    >
      <choiceSelect
        ref="choiceSelect"
        :userId="form.id"
        :type="'tackinfo'"
      ></choiceSelect>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitOrg">确 定</el-button>
        <el-button @click="cancelOrg">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 分配检查项 -->
    <el-dialog
      title="分配检查项"
      :visible.sync="openinsp"
      width="85vw"
      append-to-body
      v-if="openinsp"
    >
      <choiceTreeSelect
        ref="choiceTreeSelect"
        :userId="form.id"
      ></choiceTreeSelect>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitinsp">确 定</el-button>
        <el-button @click="cancelinsp">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 已选择分管单位 -->
    <el-dialog
      title="已选择分管单位"
      :visible.sync="openSelectedOrg"
      width="85vw"
      append-to-body
      v-if="openSelectedOrg"
    >
      <handleSelectedOrg
        ref="handleSelectedOrg"
        :userId="form.id"
        :type="'tackinfo'"
      ></handleSelectedOrg>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="openSelectedOrg = false"
          >关 闭</el-button
        >
      </div>
    </el-dialog>
    <!-- 已选择检查项 -->
    <el-dialog
      title="已选择检查项"
      :visible.sync="openSelectedInsp"
      width="85vw"
      append-to-body
      v-if="openSelectedInsp"
    >
      <handleSelectedInsp
        ref="handleSelectedInsp"
        :userId="form.id"
        :type="'tackinfo'"
      ></handleSelectedInsp>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="openSelectedInsp = false"
          >关 闭</el-button
        >
      </div>
    </el-dialog>
    <el-dialog
      title="详细信息查看"
      :visible.sync="openSeedialog"
      width="85vw"
      class="detail"
    >
      <el-form
        ref="form"
        :model="deatilData"
        label-width="auto"
        label-position="left"
      >
        <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="任务名称:">
              <div>
                {{
                  deatilData.taskInfoDO ? deatilData.taskInfoDO.taskName : ""
                }}
              </div>
            </el-form-item></el-col
          >
          <el-col :span="14">
            <el-form-item label="任务类型:">
              <dict-tag
                :type="DICT_TYPE.TASK_STATUS"
                :value="
                  deatilData.taskInfoDO ? deatilData.taskInfoDO.taskType : ''
                "
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="任务内容:">
              <div>
                {{
                  deatilData.taskInfoDO ? deatilData.taskInfoDO.taskContent : ""
                }}
              </div>
            </el-form-item></el-col
          >
          <el-col :span="14">
            <el-form-item label="接收者:">
              <div>{{ deatilData.receiverName }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="发布者:">
              <div>{{ deatilData.senderName }}</div>
            </el-form-item></el-col
          >
          <el-col :span="14">
            <el-form-item label="单位:">
              <div>{{ deatilData.orgName }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="接收时间:">
              <div>{{ parseTime(deatilData.receiveTime) }}</div>
            </el-form-item></el-col
          >
          <el-col :span="10">
            <el-form-item label="完成时间:">
              <div>{{ parseTime(deatilData.finishTime) }}</div>
            </el-form-item></el-col
          >
        </el-row>
        <el-row :gutter="20">
          <el-col :span="10" v-if="this.deatilData.taskInfoDO">
            <el-form-item label="附件:" v-if="this.deatilData.taskInfoDO.attId">
              <div @click="fujian" style="color: #204f7f">点击下载</div>
            </el-form-item></el-col
          >
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="openSeedialog = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  createTaskInfo,
  updateTaskInfo,
  deleteTaskInfo,
  getTaskInfo,
  getTaskInfoPage,
  exportTaskInfoExcel,
  createTaskInfoBroad,
  createCycleTaskInfoBroad,
  TaskInfoSetuporg,
  TaskInfoSetupinspect,
  setcycletaskstatus,
  getcycletask,
  TaskBroadPage,
  getNoPeriodicityPage,
} from "@/api/backend/taskInfo";
import { deleteTaskBroad } from "@/api/backend/taskBroad";
import Editor from "@/components/Editor";
import choiceSelect from "@/components/choiceSelect";
import choiceTreeSelect from "@/components/choiceTreeSelect";
import { getInspectItemPage } from "@/api/backend/inspectItem";
import { getTaskBroadPage } from "@/api/backend/taskBroad";
import { getTableHeight } from "@/utils/ruoyi.js";
import handleSelectedInsp from "@/components/handleSelectedInsp";
import handleSelectedOrg from "@/components/handleSelectedOrg";
import { DICT_TYPE, getDictDatas } from "@/utils/dict";
export default {
  name: "TaskInfo",
  components: {
    Editor,
    choiceSelect,
    choiceTreeSelect,
    handleSelectedOrg,
    handleSelectedInsp,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 任务信息管理列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        taskName: null,
        taskType: null,
        taskContent: null,
        taskStatus: null,
        taskScore: null,
        inspectFrequency: null,
        status: null,
      },
      // 表单参数
      form: {
        status: 0,
        time: "",
        orgTypes: [],
        startTime: null,
      },
      defaultProps: {},
      // 表单校验
      rules: {
        taskName: [
          { required: true, message: "会议名称不能为空", trigger: "blur" },
        ],
        // taskStatus: [
        //   { required: true, message: "状态不能为空", trigger: "blur" },
        // ],
        orgTypes: [
          { required: true, message: "单位类别不能为空", trigger: "blur" },
        ],
        taskScore: [
          {
            message: "只能是数字",
            trigger: "change",
            pattern: /^(([1-9]\d{0,3})|0)?$/,
          },
        ],
        taskType: [
          { required: true, message: "请选择任务类型", trigger: "blur" },
        ],
      },
      selectedTab: "type0",
      // =======单位信息==========================
      // 是否显示弹出层（分管单位）
      openOrg: false,
      // 最终选择的单位信息列表
      alreadySelectedOrgList: [],
      orgList: "",
      // ========================================
      // 是否显示弹出层（分管单位）
      openinsp: false,
      // 遮罩层
      // orgloading: true,
      // 最终选择的单位信息列表
      alreadySelectedinspList: [],
      inspList: "",
      tableHeight: "",

      // 已选择单位
      openSelectedOrg: false,
      // 已选择检查项
      openSelectedInsp: false,
      taskStatus: "",
      filteredData: [],
      filteredDataType: [],
      openSeedialog: false,
      deatilData: {},
    };
  },
  created() {},
  mounted() {
    this.filteredData = this.getDictDatas(DICT_TYPE.TASK_TYPE).filter(
      ({ label }) => label === "周期性检查" || label === "临时性任务"
    );
    this.filteredDataType = this.getDictDatas(DICT_TYPE.TASK_TYPE).filter(
      ({ label }) =>
        label === "周期性检查" ||
        label === "临时性任务" ||
        label == "隐患复查" ||
        label == "消防巡查"
    );
    //挂载window.onresize事件(动态设置table高度)
    window.addEventListener("resize", () => {
      this.$nextTick(() => {
        if (this.$refs["sousuH"]) {
          this.tableHeight = getTableHeight(
            this.$refs["sousuH"].clientHeight + 270
          );
        }
      });
    });
  },
  created() {
    this.queryParams.taskStatus = "0";
    this.taskStatus = "0";
    this.getList();
    this.$nextTick(() => {
      this.tableHeight = getTableHeight(
        this.$refs["sousuH"].clientHeight + 270
      );
    });
  },
  methods: {
    fujian() {
      const link = document.createElement("a");
      link.href = this.deatilData.taskInfoDO
        ? this.deatilData.taskInfoDO.attId
        : "";
      link.setAttribute("download", "exp_data.xlsx");
      document.body.appendChild(link);
      link.click();
    },
    /** 查看按钮操作 */
    handleSee(row) {
      this.reset();
      this.deatilData = row;
      console.log(this.deatilData, " this.deatilData ");
      const id = row.id;
      this.openSeedialog = true;
    },
    clickTab(e) {
      console.log(e._props.name, "e._props.name;e._props.name;");
      const name = e._props.name;
      this.queryParams.iscycle = "";
      this.list = [];
      switch (name) {
        case "type1":
          this.queryParams.taskStatus = "1";
          this.taskStatus = "1";
          this.getList();
          break;
        case "type2":
          this.queryParams.taskStatus = "2";
          this.taskStatus = "2";
          this.getList();
          break;
        case "type3":
          this.queryParams.taskStatus = "3";
          this.taskStatus = "3";
          this.getList();
          break;
        case "type0":
          this.queryParams.taskStatus = "0";
          this.taskStatus = "0";
          this.getList();
          break;
        case "type4":
          this.queryParams.taskStatus = "9"; //=====周期性任务未明确传什么taskStatus===========================
          this.queryParams.iscycle = "1";
          this.getList();
          break;
        default:
          break;
      }
    },
    taskStatusChange(e) {
      console.log("e :>> ", e);
      const type = e;
      this.taskStatus = type;

      this.queryParams.taskStatus = type;
      console.log('type', type)
      switch (type) {
        case "1":
          this.selectedTab = "type1";
          this.getList();
          break;
        case "2":
          this.selectedTab = "type2";
          this.getList();
          break;
        case "3":
          this.selectedTab = "type3";
          this.getList();
          break;
        case "0":
          this.selectedTab = "type0";
          this.getList();
          break;
        case "9":
          this.selectedTab = "type4";
          this.getList();
          break;
        default:
          break;
      }
    },
    // 更多操作
    handleCommand(command, index, row) {
      // getTaskInfo(row.id).then((response) => {
      //   // this.form = response.data;
      //   console.log('resoponse', response)
      // });
      switch (command) {
        case "handleUpdate":
          this.handleUpdate(row); //修改客户信息
          break;
        case "handleDelete":
          this.handleDelete(row); //红号变更
          break;
        case "handleInsp":
          this.handleInsp(row);
          break;
        case "handleOrg":
          this.handleOrg(row);
          break;
        case "handleSelectedOrg":
          this.handleSelectedOrg(row);
          break;
        case "handleSelectedInsp":
          this.handleSelectedInsp(row);
          break;
        case "handPublish":
          this.handPublish(row);
          break;
        // case "handPublishCycleTask":
        //   this.handPublishCycleTask(row);
        //   break;
        default:
          break;
      }
    },
    /** 查询列表 */
    getList() {
      this.queryParams.taskStatus = this.taskStatus;
      if (this.selectedTab == "type0") {
        this.queryParams.creator = this.$store.state.user.id;
      } else {
        this.queryParams.creator = undefined;
      }
      if (this.selectedTab == "type4") {
        // 执行查询
        this.queryParams.taskStatus = "9";
        this.queryParams.iscycle = "1";
        console.log(this.queryParams, "query");
        getTaskInfoPage(this.queryParams).then((response) => {
          this.list = response.data!=null?response.data.list:[];
          this.total = response.data.total;
          this.loading = false;
        });
      } else {
        console.log('this.queryParams', this.queryParams)
        // 执行查询
        getNoPeriodicityPage(JSON.stringify(this.queryParams)).then((response) => {
          this.list = response.data!=null?response.data.list:[];
          console.log(response.data.list, "query1");
          this.total = response.data.total;
          this.loading = false;
        });
      }
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        taskName: undefined,
        taskType: undefined,
        taskContent: undefined,
        taskStatus: undefined,
        taskScore: undefined,
        inspectFrequency: undefined,
        status: 0,
        orgTypes: [],
        inspType: undefined,
        orgIds: [],
        inspectIds: [],
      };
      this.orgList = "";
      this.inspList = "";
      this.alreadySelectedOrgList = [];
      this.alreadySelectedinspList = [];
      this.form.taskStatus = this.taskStatus;
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
      // getTaskInfoPage({ taskType: this.queryParams.taskType, taskStatus: this.queryParams?this.queryParams.taskStatus:0, taskName: this.queryParams?this.queryParams.taskName, pageNo: 1, pageSize: 10 }).then(res => {
      //   this.list = res.data.list;
      //   this.total = res.data.total;
      // })
    },
    /** 重置按钮操作 */
    resetQuery() {
      console.log(1111);
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加任务信息管理";
    },
    // 暂停
    handleStopOrRest(row, cycleStatus) {
      const id = row.id;
      setcycletaskstatus({
        cycleStatus: cycleStatus,
        taskId: id,
      }).then((response) => {
        if (response.data) {
          this.$modal.msgSuccess("成功");
          this.getList();
        }
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id =row.taskId?row.taskId:row.id;
      getTaskInfo(id).then((response) => {
        this.form = response.data != null ? response.data : {};
        this.open = true;
        this.title = "修改任务信息管理";
        const arr = [];
        if (this.form.startTime != null) {
          arr.push(this.form.startTime, this.form.endTime);
          this.$set(this.form, "time", arr);
        }

        // this.togetOneInspgList(this.form.id)
        // this.getTaskBroadPageList(this.form.id)
      });
      getcycletask(id).then((response) => {
        response.data.orgType.map((i) => this.form.orgTypes.push(i.org_type));
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (this.form.time) {
          //开始时间，结束时间
          this.form.startTime = this.form.time[0];
          this.form.endTime = this.form.time[1];
          delete this.form.time;
          handleDelete;
        }
        if (valid) {
          if (this.form.id !== undefined) {
            updateTaskInfo(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            createTaskInfo(this.form)
              .then((response) => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              })
              .catch((err) => {});
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
      console.log("row", this.selectedTab);
      const tab = this.selectedTab;
      let name =
        row.taskInfoDO != null
          ? row.taskInfoDO.taskName
          :( row.taskName
          ? row.taskName
          : "");
      this.$modal
        .confirm('是否确认删除名称为"' + name + '"的数据项?')
        .then(function () {
          if (tab == "type4") {
            return deleteTaskInfo({ id: id });
          } else {
            return deleteTaskBroad(id);
          }
        })
        .then(() => {
          this.$modal.msgSuccess("删除成功");
          this.getList();
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = { ...this.queryParams };
      params.pageNo = undefined;
      params.pageSize = undefined;
      // 执行导出
      this.$modal
        .confirm("是否确认导出?")
        .then(() => {
          this.exportLoading = true;
          return exportTaskInfoExcel(params);
        })
        .then((response) => {
          this.$download.excel(response.data, "任务分配列表.xls");
          this.exportLoading = false;
        })
        .catch(() => {});
    },

    // ========单位信息==============================================================
    getTaskBroadPageList(taskId) {
      var Params = {
        pageNo: 1,
        pageSize: 10,
        taskId: taskId,
      };
      getTaskBroadPage(Params).then((response) => {
        this.alreadySelectedOrgList = response.data[0]
          ? response.data[0].sendUser
            ? response.data[0].sendUser
            : []
          : [];
        var orgList = []; // 添加时确认形成input默认内容
        this.alreadySelectedOrgList.map((i) => {
          orgList.push(i.orgName);
        });
        this.orgList = orgList.toString();
      });
    },
    // ========检查项==============================================================
    togetOneInspgList(taskId) {
      var Params = {
        pageNo: 1,
        pageSize: 10,
        taskId: taskId,
      };
      getInspectItemPage(Params).then((response) => {
        this.alreadySelectedinspList = response.data ? response.data.list : [];
        var orgList = []; // 添加时确认形成input默认内容
        this.alreadySelectedinspList.map((i) => {
          orgList.push(i.orgName);
        });
        this.inspList = orgList.toString();
      });
    },
    /**
     * 选单位
     */
    // ==========表单添加时选单位================================================
    handleClear() {},
    handleFocus() {
      this.handleChoice();
    },
    handleChoice() {
      // 打开弹窗
      this.openOrg = true;
    },
    // ============操作区修改单位=====================================================
    // 单位信息表单重置
    Orgreset() {
      this.alreadySelectedOrgList = [];
    },
    // 打开单位信息v弹窗
    handleOrg(row) {
      if (row.id) {
        this.form.id = row.id;
      }
      this.Orgreset();
      // 打开弹窗
      this.openOrg = true;
    },
    // /============单位弹窗功能====================================================
    /** 单位信息确认按钮 */
    submitOrg() {
      this.alreadySelectedOrgList = this.$refs["choiceSelect"].confirmMSg();
      // this.orgTypes = this.$refs["choiceSelect"].confirmoOrgTypeMSg()
      // 关闭弹窗
      this.openOrg = false;
      this.submitFormOrg(
        this.$refs["choiceSelect"].confirmMSg(),
        this.$refs["choiceSelect"].confirmoOrgTypeMSg()
      );
    },
    // =======取消按钮=与=信息保存=========================================================
    // 取消按钮（分管单位）
    cancelOrg() {
      this.openOrg = false;
    },
    // ========用于form表单已存在alreadySelectedOrgList单位信息时保存============================
    submitFormOrg(alreadySelectedOrgList, orgTypes) {
      var orgIds = [];
      alreadySelectedOrgList.map((i) => {
        orgIds.push(i.dwid);
      });
      this.form.orgTypes = orgTypes;
      this.form.orgIds = orgIds;
      this.form.taskId = this.form.id;
      console.log("this.form :>> ", this.form);
      // =====================
      TaskInfoSetuporg(this.form).then((response) => {
        // this.$modal.msgSuccess("分配角色成功");
      });
    },
    /**
     * 结束
     */

    /**
     * 选检查项
     */
    // =========表单添加时 选检查项=================================================
    handleClearinsp() {
      this.form.inspectIds = [];
    },
    handleFocusinsp() {
      this.handleChoiceinsp();
    },
    handleChoiceinsp() {
      // 打开弹窗
      this.openinsp = true;
    },
    // ============操作区修改=====================================================
    // 检查项信息表单重置
    inspreset() {
      this.alreadySelectedinspList = [];
    },
    // 打开检查项信息v弹窗
    handleInsp(row) {
      this.inspreset();
      if (row.id) {
        this.form.id = row.id;
      }
      // 打开弹窗
      this.openinsp = true;
    },
    // ============检查项信息确认按钮=====================================================
    /** 检查项信息确认按钮 */
    submitinsp() {
        this.alreadySelectedinspList =
          this.$refs["choiceTreeSelect"].confirmMSg();
        // 关闭弹窗
        this.openinsp = false;
        this.submitFormInsp(
          this.$refs["choiceTreeSelect"].confirmMSg(),
          this.$refs["choiceTreeSelect"].confirmoOrgTypeMSg()
        );
    },
    submitFormInsp(alreadySelectedinspList, inspectIds) {
      var orgIds = [];
      alreadySelectedinspList.map((i) => {
        orgIds.push(i.id);
      });
      this.form.inspectTypes = inspectIds;
      this.form.inspectIds = orgIds;

      this.form.taskId = this.form.id;
      console.log("this.form :>> ", this.form);
      // =====================
      TaskInfoSetupinspect(this.form).then((response) => {
        this.$modal.msgSuccess('分配成功')
      }).catch((err)=>{
        this.$modal.msgError('请确认勾选内容是否移动到右侧区域中')
      });
    },
    // 取消按钮（分管单位）
    cancelinsp() {
      this.openinsp = false;
    },
    // ==========检查项结束=============================================================
    // ===============已分配单位列表========================
    handleSelectedOrg(row) {
      if (row.id) {
        this.form.id = row.id;
      }
      // 打开弹窗
      this.openSelectedOrg = true;
    },

    // ===============已分检查项========================
    handleSelectedInsp(row) {
      if (row.id) {
        this.form.id = row.id;
      }
      // 打开弹窗
      this.openSelectedInsp = true;
    },
    // -==========发布======================
    handPublish(row) {
      if (row.id) {
        createTaskInfoBroad({ taskId: row.id }).then((response) => {
          this.getList();
        });
      }
    },
    // -==========发布周期任务==================
    handPublishCycleTask(row) {
      if (row.id) {
        createCycleTaskInfoBroad({ taskId: row.id }).then((response) => {
          this.getList();
        });
      }
    },
  },
};
</script>
