<template>
  <div class="bigBox" :style="{ height: bigHeight }">
    <MOSTY.FromPage :title="props.title" @closeDialog="CloseEvent">
      <template #content>
        <MOSTY.Assort :title="'基本信息'" />
        <div class="box_cont">
          <div class="fromBox">
            <div class="box_gbig">
              <div class="box_left">
                <el-form class="mosty-from-wrap" ref="ruleFormRef" label-width="141px" :model="data.fromObj"
                  :inline="true" :disabled="!props.saveBtnShow" :rules="rules">
                  <el-form-item label="申请部门:" prop="askdeptname">
                    <el-input v-model="data.fromObj.askdeptname" disabled clearable style="width: 250px" />
                  </el-form-item>
                  <el-form-item label="申请人:" prop="askpeoplename">
                    <el-input v-model="data.fromObj.askpeoplename" clearable disabled style="width: 250px" />
                  </el-form-item>
                  <el-form-item label="业务责任部门:" prop="businessdeptid">
                    <el-cascader style="width: 250px" :show-all-levels="false" placeholder='请选择业务责任部门'
                      :options="putUnderDeptData" v-model="data.fromObj.businessdeptid" @change="handleSelectStatus"
                      :props="cascaderProps" clearable />
                  </el-form-item>
                  <el-form-item label="作业类型:" prop="zylb">
                    <el-select v-model="data.fromObj.zylb" style="width: 698px" clearable>
                      <el-option v-for="item in props.zdlist.D_BZ_WXZYLXNEW" :key="item" :label="item.label"
                        :value="item.value" @click.native='getlable(item)' />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="有限空间类别:" prop="yxkjlb" v-if="data.fromObj.zylb == '5'">
                    <el-select v-model="data.fromObj.yxkjlb" style="width: 698px" clearable>
                      <el-option v-for="item in D_BZ_YXKJLB" :key="item" :label="item.label" :value="item.value" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="有限空间危害因素:" prop="yxkjwhys" v-if="data.fromObj.zylb == '5'">
                    <el-input v-model="data.fromObj.yxkjwhys" clearable style="width: 698px" />
                  </el-form-item>
                  <el-form-item label="有限空间事故类别:" prop="yxkjsglb" v-if="data.fromObj.zylb == '5'">
                    <el-select v-model="data.fromObj.yxkjsglb" style="width: 698px" clearable>
                      <el-option v-for="item in D_BZ_YXKJSGLB" :key="item" :label="item.label" :value="item.value" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="蒸熏杀虫作业方式:" prop="xzsczyfs" v-if="data.fromObj.zylb == '6'">
                    <el-select v-model="data.fromObj.xzsczyfs" style="width: 698px" clearable>
                      <el-option v-for="item in D_BZ_XCZYFS" :key="item" :label="item.label" :value="item.value" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="蒸熏杀虫作业周期:" prop="xzsczyzq" v-if="data.fromObj.zylb == '6'">
                    <el-select v-model="data.fromObj.xzsczyzq" style="width: 698px" clearable>
                      <el-option v-for="item in D_BZ_XSCZYZQ" :key="item" :label="item.label" :value="item.value" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="危险级别:" prop="dangerLevel">
                    <MOSTY.DictRidioAndSelect :dictData="dangerLevelOpt" style="width: 250px"
                      v-model="data.fromObj.dangerLevel" selectType="select"
                      :disabledItem="isdisabledjb ? ['0', '1'] : []" />
                  </el-form-item>
                  <el-form-item label="场所名称:" prop="siteid">
                    <el-input v-if="!props.saveBtnShow" v-model="data.fromObj.sitename" placeholder="请选择场所名称：" readonly
                      style="width: 250px" />
                    <MOSTY.Select v-else v-model="data.fromObj.siteid" :options="csmclist" style="width: 250px"
                      @change="cahngecsmc" clearable placeholder="请选择场所名称：">
                      <!-- <el-option v-for="item in csmclist" :key="item" :label="item.placename" :value="item.id" /> -->
                    </MOSTY.Select>
                  </el-form-item>
                  <el-form-item :label="data.fromObj.publicarea == '1' ? '所属场区:' : '所属建筑物:'">
                    <el-select v-model="data.fromObj.buildingname" @change="cahngejzwmc" clearable style="width: 250px"
                      placeholder="请选择">
                      <el-option v-for="item in jzwlist" :key="item.id" :label="item.buildingname" :value="item.id" />
                    </el-select>
                  </el-form-item>
                  <el-form-item v-if="data.fromObj.publicarea != '1'" label="所属楼层:">
                    <el-select v-model="data.fromObj.floorname" @change="cahngelcmc" clearable style="width: 250px"
                      placeholder="请选择">
                      <el-option v-for="item in lclist" :key="item.id" :label="item.floorname" :value="item.id" />
                    </el-select>
                  </el-form-item>
                  <el-form-item :label="data.fromObj.publicarea == '1' ? '场区部位:' : '所属部位:'">
                    <el-select v-model="data.fromObj.partname" @change="cahngebw" clearable style="width: 250px"
                      placeholder="请选择">
                      <el-option v-for="item in bwlist" :key="item.id"
                        :label="item.partname ? item.partname : item.qtmc" :value="item.id" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="作业开始时间:" prop="jobstarttime">
                    <el-date-picker v-model="data.fromObj.jobstarttime" style="width: 250px" type="datetime"
                      value-format="YYYY-MM-DD HH:mm:ss" />
                  </el-form-item>
                  <el-form-item label="作业结束时间:" prop="jobendtime">
                    <el-date-picker v-model="data.fromObj.jobendtime" style="width: 250px" type="datetime"
                      value-format="YYYY-MM-DD HH:mm:ss" />
                  </el-form-item>
                  <el-form-item label="现场监护人:" prop="sitemanagerid">
                    <!-- <el-input v-model="data.fromObj.sitemanagername" clearable style="width: 250px" /> -->
                    <inputUser v-model:ids="data.fromObj.sitemanagerid" Single
                      :isNewChooseDeptWx="getItem('deptId').orgLevel === '21' ? false : true"
                      v-model:cName="data.fromObj.sitemanagername" width="250"
                      :deptId="getItem('deptId').orgLevel === '21' ? userOrgId : userDeptId"></inputUser>
                  </el-form-item>
                  <el-form-item label="作业责任人:" prop="safetywardname">
                    <!-- <el-input v-model="data.fromObj.safetywardname" readonly clearable style="width: 250px">
                      <template #append>
                        <el-button class='cursor' @click="ChooesDdlds('01')">选择</el-button>
                      </template>
                    </el-input> -->
                    <inputUser v-model:ids="data.fromObj.safetywardid" Single
                      v-model:cName="data.fromObj.safetywardname" width="250" :isNewChooseDeptWx="true"
                      :deptId="userDeptId">
                    </inputUser>
                  </el-form-item>
                  <el-form-item label="实施作业方:" prop="zydx">
                    <el-radio-group v-model="data.fromObj.zydx" style="width: 250px">
                      <el-radio label="01">部门(内部)</el-radio>
                      <el-radio label="02">相关方(外部)</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="作业部门:" prop="deptname" v-if="data.fromObj.zydx == '01'">
                    <el-input v-model="data.fromObj.deptname" placeholder="请选择作业部门" clearable readonly
                      style="width: 250px">
                      <template #append>
                        <el-button class='cursor' @click="showDept = true">选择</el-button></template>
                    </el-input>
                  </el-form-item>
                  <el-form-item label="选择相关方:" prop="xgfmc" v-if="data.fromObj.zydx == '02'">
                    <el-select v-model="data.fromObj.xgfmc" style="width: 250px" @change="changexgf" clearable>
                      <el-option v-for="item in xgflist" :key="item.id" :label="item.label" :value="item" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="相关方责任人:" prop="xgfzrr" v-if="data.fromObj.zydx == '02'">
                    <el-select v-model="data.fromObj.xgfzrr" style="width: 250px" @change="changexgfzrr" clearable
                      :disabled="isXgfrr">
                      <el-option v-for="item in xgfrrlist" :key="item.id" :label="item.label" :value="item" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="相关方监护人:" prop="xgfjhr" v-if="data.fromObj.zydx == '02'">
                    <el-select v-model="data.fromObj.xgfjhr" style="width: 250px" @change="changexgfjhr" clearable
                      :disabled="isXgfrr">
                      <el-option v-for="item in xgfrrlist" :key="item.id" :label="item.label" :value="item" />
                    </el-select>
                  </el-form-item>
                  <!-- <el-form-item label="应急预案类型:">
                    <el-select v-model="data.fromObj.emergencyid" style="width: 250px" @change="cahngeyj" clearable>
                      <el-option v-for="item in yjlist" :key="item.id" :label="item.planname" :value="item.id" />
                    </el-select>
                  </el-form-item> -->
                  <el-form-item label="作业地点:">
                    <el-input v-model="data.fromObj.jobplace" clearable style="width: 698px" />
                  </el-form-item>
                  <el-form-item label="作业内容:">
                    <el-input v-model="data.fromObj.jobcontent" clearable style="width: 698px" />
                  </el-form-item>
                  <!-- <el-form-item label="安全措施:">
                    <el-input v-model="data.fromObj.securitymeasures" type="textarea" :row="4" clearable
                      style="width: 698px" />
                  </el-form-item> -->
                  <el-form-item label="备注:">
                    <el-input v-model="data.fromObj.bz" clearable style="width: 698px" />
                  </el-form-item>
                  <el-form-item label="施工方案:" v-if="data.fromObj.dangerLevel === '2'" prop="file">
                    <MOSTY.Upload :widthNumber="698" :limit="5" :nopicer="true" :isImg="false" :ShowfileList="true"
                     :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx','wps']" v-model="data.fromObj.file" :showinput="true" :delrow="delrow" :disabled="!props.saveBtnShow">
                    </MOSTY.Upload>
                  </el-form-item>
                  <el-form-item label="施工方案:" v-else>
                    <MOSTY.Upload :widthNumber="698" :limit="5" :nopicer="true" :isImg="false" :ShowfileList="true"
                     :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx','wps']" v-model="data.fromObj.file" :showinput="true" :delrow="delrow" :disabled="!props.saveBtnShow">
                    </MOSTY.Upload>
                  </el-form-item>
                </el-form>
                <el-divider></el-divider>
                <el-form ref="ruleFormRef2" class="mosty-from-wrap" label-width="11.8em" :model="data.fromObj"
                  :inline="false" :rules="rules">
                  <!-- 相关方归口部门负责人上传资料(危险作业资料) -->
                  <!-- <el-form-item
                    v-if="['02', '03', '04', '05', '06', '11'].includes(data.fromObj.state) && data.fromObj.zydx == '02'"
                    label="危险作业资料:" prop="xgffile">
                    <MOSTY.Upload :width="'698px'" :widthNumber="698" :limit="30" :nopicer="true" :isImg="false"
                      :ShowfileList="true" :disabled="data.fromObj.state != '02'" v-model="data.fromObj.xgffile"
                      :showinput="false">
                    </MOSTY.Upload>
                  </el-form-item> -->
                  <el-form-item label="审核说明:"
                    v-if="['07', '08', '09', '10', '11', '12', '13', '14', '15'].includes(data.fromObj.state)"
                    prop="content">
                    <el-input v-model="data.fromObj.content"
                      :disabled="!(['07', '08', '09', '10', '11', '12', '13', '14', '15'].includes(data.fromObj.state)) && !props.examineshow"
                      clearable style="width: 698px" maxlength="200" />
                  </el-form-item>
                  <!-- <el-form-item v-if="isShowSFFHZYTJ" label="是否符合作业条件" prop="sffh">
                    <el-radio-group v-model="data.fromObj.sffh" :disabled="data.fromObj.state != '04'"
                      style="width:698px">
                      <el-radio label="1">是</el-radio>
                      <el-radio label="0">否</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="现场照片:" v-if="isShowSFFHZYTJ" prop="sceneImg">
                    <MOSTY.Upload :width="'698px'" :limit="3" :nopicer="false" :isImg="true" :ShowfileList="false"
                      v-model="data.fromObj.sceneImg" :disabled="data.fromObj.state != '04'" :nameshow='true'
                      :gsgfList="['jpeg', 'jpg', 'png']">
                    </MOSTY.Upload>
                  </el-form-item>
                  <el-form-item label="过程监护和监管内容:" v-if="isShowGuoCJHHNR" prop="processDesc">
                    <el-input v-model="data.fromObj.processDesc" :disabled="data.fromObj.state != '05'" clearable
                      style="width: 698px" maxlength="200" />
                  </el-form-item>
                  <el-form-item label="过程监护和监管图片:" v-if="isShowGuoCJHHNR" prop="processImg">
                    <MOSTY.Upload :width="'698px'" :limit="3" :nopicer="false" :isImg="true" :ShowfileList="false"
                      :disabled="data.fromObj.state != '05'" v-model="data.fromObj.processImg" :nameshow='true'
                      :gsgfList="['jpeg', 'jpg', 'png']">
                    </MOSTY.Upload>
                  </el-form-item>
                  <el-form-item v-if="isShowShiGfafj" label="施工方案附件:" prop="file">
                    <MOSTY.Upload :width="'698px'" :widthNumber="698" :limit="3" :nopicer="true" :isImg="false"
                      :disabled="data.fromObj.state != '06'" :ShowfileList="true" v-model="data.fromObj.file"
                      :showinput="false">
                    </MOSTY.Upload>
                  </el-form-item>
                  <el-form-item v-if="isShowShiGfafj" label="归口管理部门上传资料:" prop="otherFile">
                    <MOSTY.Upload :width="'698px'" :widthNumber="698" :limit="3" :nopicer="true" :isImg="false"
                      :disabled="data.fromObj.state != '06'" :ShowfileList="true" v-model="data.fromObj.otherFile"
                      :showinput="false">
                    </MOSTY.Upload>
                  </el-form-item> -->
                  <el-form-item label="作业过程资料:" v-if="['05', '16'].includes(data.fromObj.state)">
                    <MOSTY.Upload :widthNumber="698" :limit="100" :nopicer="true" :isImg="false" :ShowfileList="true"
                    :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx','wps']"  v-model="data.fromObj.workMaterial" :showinput="true" :disabled="data.fromObj.state != '05'">
                    </MOSTY.Upload>
                  </el-form-item>
                </el-form>
              </div>
              <div class="box_right" v-if="!props.saveBtnShow">
                <el-timeline>
                  <el-timeline-item v-for="(activity, index) in data.fromObj.timeLineArr" :key="index"
                    :icon="activity.icon" :type="activity.type" :color="activity.color" :size="activity.size"
                    :hollow="activity.hollow">
                    <div class="time-line-container">
                      <div class="time-line-date">
                        {{ activity.czsj }}
                      </div>
                      <div class="time-line-status-text"
                        :class="{ 'time-line-0': activity.czzt == 0, 'time-line-1': activity.czzt == 1, 'time-line-2': activity.czzt == 2 }">
                        {{ activity.czsm }}
                      </div>
                      <div>
                        {{ activity.deptname + '-' + activity.username }}
                      </div>
                    </div>
                  </el-timeline-item>
                </el-timeline>
              </div>

            </div>
          </div>
        </div>
        <MOSTY.Assort :title="'施工人员信息列表'" />
        <div v-if='props.saveBtnShow && !examineshow'>
          <el-button class="addbtn" type="primary" @click="ChooesDdlds('02')">
            <el-icon>
              <CirclePlus />
            </el-icon>
            <span>新增</span>
          </el-button>
          <!-- <el-button class="addbtn" type="primary" @click="addShowinput">
            <el-icon>
              <CirclePlus />
            </el-icon>
            <span>新增</span>
          </el-button> -->
          <el-button class="addbtn" type="primary" @click="submittab">
            <el-icon>
              <Select />
            </el-icon>
            <span>保存</span>
          </el-button>
          <el-button class="addbtn" type="primary" @click="deletetab">
            <el-icon>
              <DeleteFilled />
            </el-icon>
            <span>删除</span>
          </el-button>
        </div>
        <div class="tabbox">
          <el-table :data="data.fromObj.tbBuildpeopleList" border stripe style="width: 100%" :height="tableHeight"
            :key="keyCount" @row-click="handlecheckChange">
            <el-table-column prop="peoplename" align="center" label="人员姓名">
              <template #default="{ row }">
                <input v-if="row.input == true" type="text" v-model="row.peoplename" />
                <span v-else>{{ row.peoplename }}</span>
              </template>
            </el-table-column>
            <!-- <el-table-column prop="goodscompany" align="center" label="人员证件类型">
              <template #default="{ row }">
                <MOSTY.DictTree v-if="row.input == true" type="array" v-model="row.peoplepapers"
                  :zdlist="credentialsList" style="width: 100%;margin-bottom: 13px;" />
                <dict-tag v-else :options="credentialsOpts" :value="row.peoplepapers" :tag="true" />
              </template>
            </el-table-column> -->
            <el-table-column prop="papersnumber" align="center" label="证件号码">
              <template #default="{ row }">
                <!-- <IdentityCard style="width: 100%" v-if="row.input == true" v-model="row.papersnumber" prop="identity"
                  :isRequired="true" @validateStatus="changeValidate" :label="false" placeholder="请输入证件号码">
                </IdentityCard> -->
                <input v-if="row.input == true" type="text" v-model="row.papersnumber" placeholder="请输入证件号码" />
                <span v-else>{{ row.papersnumber }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="bz" align="center" label="备注">
              <template #default="{ row }">
                <input v-if="row.input == true" type="text" v-model="row.bz" />
                <span v-else>{{ row.bz }}</span>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <MOSTY.Assort :title="'危险作业风险及安全管控措施'" />
        <div v-if='props.saveBtnShow && !examineshow'>
          <el-button @click="addkzcs('01')">选择</el-button>
        </div>
        <div class="tabbox">
          <MOSTY.Table :table-columns="tableColumns" :tableData="tableData" :isSelect="false" :isSort="false"
            :tableHeight="'200px'">
            <template #yhLv="{ row }">
              <dict-tag :options="D_DBZ_YHDJ" :value="row.yhLv" :tag="false"></dict-tag>
            </template>
            <template #yhFlag="{ row }">
              <dict-tag :options="NYHBZ" :value="row.yhFlag" :tag="false"></dict-tag>
            </template>
            <template #yhLx="{ row }">
              <span class="dix-cell">
                <dict-tag :options="D_BZ_SYPCCJ" :value="row.yhLx" toArr :tag="false" />
              </span>
            </template>
            <template #isPic="{ row }">
              <dict-tag :options="NSFBXSCTP" :value="row.isPic" :tag="false"></dict-tag>
            </template>
            <template #actions="{ row }">
              <el-popconfirm v-if="props.saveBtnShow && !examineshow" confirm-button-text="是" cancel-button-text="否"
                icon-color="red" title="确定要删除?" @confirm="handleDelete(row)">
                <template #reference>
                  <span class="operdel" size="small">
                    <el-icon>
                      <Delete />
                    </el-icon>
                    删除</span>
                </template>
              </el-popconfirm>
              <span v-else>--</span>
            </template>
          </MOSTY.Table>
        </div>
      </template>
      <template #footer>
        <el-button style="margin-left: 10px" type="primary" @click="handleSave(ruleFormRef)"
          v-if="props.saveBtnShow && !examineshow && !data.fromObj.id" :loading="saveloading">
          <el-icon>
            <Search />
          </el-icon>
          <span>保存</span>
        </el-button>
        <el-button style="margin-left: 10px" type="primary" @click="handleSave(ruleFormRef)"
          v-if="props.saveBtnShow && !examineshow && data.fromObj.id" :loading="saveloading">
          <el-icon>
            <Search />
          </el-icon>
          <span>保存</span>
        </el-button>
        <el-button type="primary" @click="examineok" v-if="examineshow" :loading="saveloading">
          <el-icon>
            <CirclePlus />
          </el-icon>
          <span>{{ ['03', '07', '08', '09', '10', '11', '12', '13', '14', '15'].includes(data.fromObj.state) ? '同意' :
            '提交'
            }}</span>
        </el-button>
        <el-button
          v-if="examineshow && ['03', '07', '08', '09', '10', '11', '12', '13', '14', '15'].includes(data.fromObj.state)"
          :loading="saveloading" type="primary" @click="examinefalse">
          <el-icon>
            <CirclePlus />
          </el-icon>
          <span>不同意</span>
        </el-button>
        <el-button type="primary" @click="CloseEvent">
          <el-icon>
            <DocumentDelete />
          </el-icon>
          <span>关闭</span>
        </el-button>
      </template>
    </MOSTY.FromPage>
    <!-- 选择人员 -->
    <MOSTY.xgfandzzjgry v-model="chooseUserVisibles" :Single="singleShow" :stlyrylx='stlyrylx' :relatedid="null"
      @choosedUsers="getSonValues" @changerylx='changerylx' />
    <!-- 选择部门 -->
    <Departbm :showDdld="showDept" :Single="true" :formInfo="data.fromObj.formInfo" @closezzjg="showDept = false"
      @listdata="getDeptData" :orgLevels="deptId.orgLevel">
    </Departbm>
    <ChooseUser v-model="chooseUserVisible" :Single="singleShow" :leaderid="leaderid" @choosedUsers="getSonValue"
      :deptId="data.deptId">
    </ChooseUser>
    <!-- 控制措施 -->
    <Kzcstab v-if="kzcsshow" v-model="kzcsshow" :defaultData="defaultData" :Single="false" :info='InnerForm'
      @confirm="getkzcsData" />
  </div>
</template>

<script setup>
import Departbm from "@/components/MyComponents/ChooseDept/Departbm.vue";
import { getImgUrl } from "@/utils/tools.js"
import { ref, onMounted, defineProps, defineEmits, reactive, watchEffect, computed, getCurrentInstance, watch } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import Kzcstab from "@/views/fxgk/aqfxfjgk/component/kzcstab.vue";
import { getItem } from "@/utils/storage";
import * as MOSTY from "@/components/MyComponents/index";
import { getApi, postApi } from "@/api/tobAcco_api.js";
import IdentityCard from '@/components/From/IdentityCard/index'
import ChooseUser from "@/components/MyComponents/ChooseUser/Leader.vue";
import inputUser from "@/views/fxgk/jcss/components/MostCom/inputUser.vue";
// const showDepts = ref(false)
const isaddtr = ref(true)
const { proxy } = getCurrentInstance();
const { NSFBXSCTP, D_BZ_SYPCCJ, NYHBZ, D_DBZ_YHDJ, D_BZ_CYZJ, D_BZ_XCZYFS, D_BZ_XSCZYZQ, D_BZ_YXKJLB, D_BZ_YXKJSGLB, D_BZ_WXZYJB } =
  proxy.$dict("NSFBXSCTP", "D_BZ_SYPCCJ", "NYHBZ", "D_DBZ_YHDJ", "D_BZ_CYZJ", "D_BZ_XCZYFS", "D_BZ_XSCZYZQ",
    "D_BZ_YXKJLB", "D_BZ_YXKJSGLB", "D_BZ_WXZYJB");
const bigHeight = ref()
const tableHeight = ref()
const keyCount = ref(0)
/** 选人dept参数 31 30*/
const userDeptId = getItem("deptId").ssbmid
const userOrgId = getItem("deptId").ssdwid
const rules = reactive({
  askdeptname: [{ required: true, message: "申请部门不能为空", trigger: "blur" }],
  askpeoplename: [{ required: true, message: "申请人不能为空", trigger: "blur" }],
  businessdeptid: [{ required: true, message: "业务归口部门不能为空", trigger: "blur" }],
  siteid: [{ required: true, message: "场所名称不能为空", trigger: "blur" }],
  sitemanagerid: [{ required: true, message: "现场监护人不能为空", trigger: "blur" }],
  jobstarttime: [{ required: true, message: "作业开始时间", trigger: "blur" }],
  jobendtime: [{ required: true, message: "作业结束时间", trigger: "blur" }],
  safetywardname: [{ required: true, message: "作业责任人为空", trigger: "blur" }],
  zylb: [{ required: true, message: "作业类型不能为空", trigger: "blur" }],
  yxkjlb: [{ required: true, message: "有限空间类别不能为空", trigger: "blur" }],
  yxkjwhys: [{ required: true, message: "有限空间危害因素不能为空", trigger: "blur" }],
  yxkjsglb: [{ required: true, message: "有限空间事故类别不能为空", trigger: "blur" }],
  xzsczyfs: [{ required: true, message: "蒸熏杀虫作业方式不能为空", trigger: "blur" }],
  xzsczyzq: [{ required: true, message: "蒸熏杀虫作业周期不能为空", trigger: "blur" }],
  xgfmc: [{ required: true, message: "相关方不能为空", trigger: "blur" }],
  deptname: [{ required: true, message: "作业部门不能为空", trigger: "blur" }],
  xgfzrr: [{ required: true, message: "相关方责任人不能为空", trigger: "blur" }],
  xgfjhr: [{ required: true, message: "相关方监护人不能为空", trigger: "blur" }],
  dangerLevel: [{ required: true, message: "危险级别不能为空", trigger: "blur" }],
  cgbm: [{ required: true, message: "采购部门不能为空", trigger: "blur" }],
  xgffile: [{ required: true, message: "危险作业资料不能为空", trigger: "blur" }],
  content: [{ required: true, message: "审核说明不能为空", trigger: "blur" }],
  sffh: [{ required: true, message: "请选择是否符合作业条件", trigger: "blur" }],
  sceneImg: [{ required: true, message: "现场照片不能为空", trigger: "blur" }],
  processDesc: [{ required: true, message: "过程监护和监管内容不能为空", trigger: "blur" }],
  processImg: [{ required: true, message: "过程监护和监管图片不能为空", trigger: "blur" }],
  file: [{ required: true, message: "施工方案附件不能为空", trigger: "blur" }],
  files: [{ required: true, message: "施工方案不能为空", trigger: "blur" }],
  otherFile: [{ required: true, message: "归口管理部门上传资料不能为空", trigger: "blur" }],
});
/** 证件类型下拉 */
const credentialsList = ref([])
const ryzjlxOpt = ref([])
const saveloading = ref(false)
const showDept = ref(false)
const dangerLevelOpt = computed(() => {
  if (!D_BZ_WXZYJB.value) return []
  if (!D_BZ_WXZYJB?.value?.length) return []
  if (!data.fromObj.zylb) return D_BZ_WXZYJB?.value || []
  /** 仅高风险数组 */
  let onlyHightDanger = ['1', '5', '6', '2', '7']
  // let onlySimpleDanger = ['7']
  if (onlyHightDanger.includes(data.fromObj.zylb)) {
    let opts = D_BZ_WXZYJB.value.filter(item => {
      return item.value == '2' // 0: 一般风险 1: 中度风险 2:高度风险
    })
    return opts
  } else if (onlySimpleDanger.includes(data.fromObj.zylb)) {
    let opts = D_BZ_WXZYJB.value.filter(item => {
      return item.value == '0' // 0: 一般风险 1: 中度风险 2:高度风险
    })
    return opts
  } else {
    return D_BZ_WXZYJB.value
  }
})
/** 人员证件类型回显 */
const credentialsOpts = computed(() => {
  let list = credentialsList.value
  let arr = []
  if (!list?.length) return []
  list.forEach(item => {
    let itemList = item?.itemList || []
    if (itemList.length > 0) {
      itemList.forEach(item => {
        arr.push({ label: item.zdmc, value: item.dm })
      })
    } else {
      arr.push({ label: item?.zdmc, value: item?.dm })
    }
  })
  return arr
})
/** 是否显示-是否符合作业条件 04*/
const isShowSFFHZYTJ = computed(() => {
  if (!data?.fromObj?.zydx) return
  if (data?.fromObj?.zydx == '02') return ['04', '05', '06', '11'].includes(data.fromObj.state) // 相关方
  if (data?.fromObj?.zydx == '01') {
    /** 风险等级 0: 一般风险 1: 中度风险 2:高度风险 */
    const dangerLevel = data.fromObj.dangerLevel
    if (dangerLevel == '0') return ['04', '05', '06', '11'].includes(data.fromObj.state)
    return ['04', '05', '06', '11'].includes(data.fromObj.state)
  }
})

/** 是否显示 (过程监护和内容 和 过程监护和监管图片) 05*/
const isShowGuoCJHHNR = computed(() => {
  if (data?.fromObj?.zydx == '01') return ['05', '06', '11'].includes(data.fromObj.state)
  if (data?.fromObj?.zydx == '02') return ['05', '06', '11'].includes(data.fromObj.state)
})
/** 是否显示 (施工方案附件 和 归口管理部门上传资料) 06*/
const isShowShiGfafj = computed(() => {
  if (data?.fromObj?.zydx == '01') return ['06', '11'].includes(data.fromObj.state)
  if (data?.fromObj?.zydx == '02') return ['06', '11'].includes(data.fromObj.state)
})
const props = defineProps({
  title: {
    type: String,
    default: ""
  },
  rwid: String,
  examineshow: {
    default: false,
    type: Boolean
  },
  saveBtnShow: {
    type: Boolean,
    default: true
  },
  editObj: {
    type: Object,
    default: () => { }
  },
  zdlist: {
    type: Object,
    default: () => { }
  },
  /** 任务列表跳转来的p1 */
  p1: {
    type: String,
  }
});
const deptId = getItem("deptId");
const placename = ref("");
const activeNames = ref(1);
const emits = defineEmits(["close"]);
const currentRowjc = ref(); //选中的表格数据
const CloseEvent = () => {
  if ((props.saveBtnShow && !props.examineshow) || props.examineshow) {
    proxy.$modal.confirm('离开会丢失页面中修改的内容，确认离开吗？')
      .then(() => {
        // 关闭上一次的表单校验
        ruleFormRef.value.clearValidate();
        emits("close");
      })
      .catch(() => {
        // catch error
      })
  } else {
    // 关闭上一次的表单校验
    ruleFormRef.value.clearValidate();
    emits("close");
  }

};
const delrow = ref({}); //删除文件列表
function ChooesDdld() {
  if (props.title == "危险作业申请") {
    data.fromObj.askpeoplename = localStorage.getItem("USERNAME");
    data.fromObj.askpeopleid = getItem("USERID").toString();
    data.fromObj.askdeptid = getItem("deptId").ssbmid;
    data.fromObj.askdeptname = getItem("deptId").ssbmmc;
    data.fromObj.askunitid = getItem("deptId").ssdwid;
    data.fromObj.askunitname = getItem("deptId").ssdwmc;
  }
}
const csmclist = ref([]);
const jzwlist = ref([])
const lclist = ref([])
const bwlist = ref([])
const yjlist = ref([]);
const xgflist = ref([])
const chooseUserVisible = ref(false);
const isdisabledjb = ref(false);
const getRyzjlxOpt = (arr) => {
  return arr.map(item => {
    return {
      label: item.zdmc,
      value: item.dm
    }
  })
}
const setCredentialsList = () => {
  getApi({ zdbh: 'D_TB_ZSLB' }, "/mosty-base/sysDict/getDictTree").then(res => {
    if (res?.itemList) {
      credentialsList.value = res.itemList.filter(item => {
        const excludeArr = [527700000055728, 527700000055785, 527700000055786]
        return item.id && !excludeArr.includes(item.id)
      })
      ryzjlxOpt.value = getRyzjlxOpt(credentialsList.value)
    }
  })

}
const data = reactive({
  fromObj: { zydx: "01", jobendtime: '', jobstarttime: '' }
});
watch(() => data.fromObj.jobendtime, (val) => {
  if (!val || !data.fromObj.jobstarttime) return

  if (val.endsWith("00:00:00")) return

  const start = new Date(data.fromObj.jobstarttime).getTime()
  const end = new Date(val).getTime()

  if (isNaN(start) || isNaN(end)) return

  if (end <= start) {
    ElMessage.error("作业结束时间必须大于作业开始时间")
    data.fromObj.jobendtime = ""
  }
})
// 初始化
onMounted(() => {
  activeNames.value = ["1", "2"];
  ChooesDdld();
  getcsData();
  getdeptId();
  getxgflist()
  getPutUnderDept()
  setCredentialsList()
});
const defaultData = ref([])
const tableData = ref([]);
const InnerForm = ref({
  checklibId: "300600000000",
  checklibName: "危险作业"
})
const tableColumns = reactive([
  {
    title: "排查项",
    prop: "checklibName"
  },
  {
    title: "控制措施内容",
    prop: "itemName"
  },
  {
    title: "隐患等级",
    prop: "yhLv",
    slot: true
  },
  {
    title: "隐患说明",
    prop: "yhNote",

  },
  {
    title: "标红项",
    prop: "yhFlag",
    slot: true
  },
  {
    title: "适用排查场景",
    prop: "yhLx",
    slot: true
  },
  {
    title: "是否必须上传图片",
    prop: "isPic",
    slot: true
  },

  {
    title: "操作",
    prop: "actions",
    fixed: 'right',
    slot: true
  }
])
const kzcsshow = ref(false)
function getkzcsData(val) {
  if (tableData.value.length == 0) {
    tableData.value.push(...val)
  } else {
    tableData.value.push(...val)
    let map = new Map();
    for (let item of tableData.value) {
      map.set(item.id, item);
    }
    tableData.value = [...map.values()];
  }
  data.fromObj.securitymeasures = tableData.value.map(it => { return it.id }).toString()
  console.log(data.fromObj.securitymeasures, 'data.fromObj.securitymeasures')
  kzcsshow.value = false
}
// 添加排查分类
const addkzcs = (type) => {
  defaultData.value = tableData.value ? tableData.value.map(it => { return it.id }) : []
  kzcsshow.value = true
}
// 删除
const handleDelete = (row) => {
  tableData.value.forEach((item, index) => {
    if (row.id == item.id) {
      tableData.value.splice(index, 1);
      ElMessage.success("删除成功");
    }
  });
  data.fromObj.securitymeasures = tableData.value.map(it => { return it.id }).toString()
}
const putUnderDeptData = ref([])
const cascaderProps = {
  value: 'id',
  label: 'orgname',
  children: 'children'
}
function getPutUnderDept() {
  getApi({}, '/mosty-base/deptFeign/getPutUnderDept')
    .then(res => {
      putUnderDeptData.value = res
    })
}
const handleSelectStatus = (val) => {
  const selectedId = val[val.length - 1];
  const selectedNode = findNodeById(putUnderDeptData.value, selectedId);
  if (selectedNode) {
    data.fromObj.businessdeptid = selectedNode.id
    data.fromObj.businessdeptname = selectedNode.orgname
  } else {
    data.fromObj.businessdeptid = ''
    data.fromObj.businessdeptname = ''
  }
}
// 递归在树形数据中根据id查找节点
function findNodeById(tree, id) {
  for (let node of tree) {
    if (node.id === id) {
      return node;
    }
    if (node.children && node.children.length > 0) {
      const found = findNodeById(node.children, id);
      if (found) {
        return found;
      }
    }
  }
  return null;
}
//部门选择
const getDeptData = (val) => {
  if (val) {
    data.fromObj.deptname = val.orgName
    data.fromObj.deptid = val.orgCode
  }
}
function getlable(val) {
  isdisabledjb.value = false
  switch (val.value) {
    case '1':
      isdisabledjb.value = true
      break;
    case '2':
      isdisabledjb.value = true
      break;
    case '5':
      isdisabledjb.value = true
      break;
    case '6':
      isdisabledjb.value = true
      break;
    case '7':
      isdisabledjb.value = true
      break;
  }
  // 清空风险
  data.fromObj.dangerLevel = ''
}

//根据操作人 查询 场所
function getcsData() {
  getApi({}, "/mosty-jcgl/site/getSiteListByUser").then((res) => {
    csmclist.value = Array.isArray(res) ? res : [];
    csmclist.value = csmclist.value.map(item => {
      item.value = item.id
      item.label = item.placename
      return item
    })
  });
  getApi({ orgcode: getItem("deptId").ssbmid }, "/mosty-jcgl/yabz/queryYabzBydeptcode").then((res) => {
    yjlist.value = res;
  });
}
//获取相关方
function getxgflist() {
  let orgid = getItem("deptId").ssdwid
  getApi({ orgid }, '/mosty-jcgl//relatedpartyinfo/getListByOrg').then(res => {
    if (res) {
      xgflist.value = res.map(item => {
        return { label: item.relatedname, value: item.id }
      });
    }
  })
}
const xgfrrlist = ref([])
const isXgfrr = ref(true)
function changexgf(val) {
  isXgfrr.value = true
  data.fromObj.xgfid = val.value
  data.fromObj.xgfmc = val.label
  data.fromObj.xgfzrrid = ''
  data.fromObj.xgfzrr = ''
  data.fromObj.xgfjhrid = ''
  data.fromObj.xgfjhr = ''
  xgfrrlist.value = []
  let params = {
    id: val.value,
    pageCurrent: 1,
    pageSize: 10000,
  };
  // 当前相关方人员
  getApi(params, '/mosty-jcgl/relatedpartyinfo/getRelatedUserPage')
    .then((res) => {
      if (res.records && res.records.length > 0) {
        res.records.forEach((item) => {
          xgfrrlist.value.push({
            label: item.xm,
            value: item.id,
            deptId: item.relatedid,
          })
        })
        isXgfrr.value = false
      }
    })
}
function changexgfzrr(val) {
  data.fromObj.xgfzrrid = val.value
  data.fromObj.xgfzrr = val.label
}
function changexgfjhr(val) {
  data.fromObj.xgfjhrid = val.value
  data.fromObj.xgfjhr = val.label
}
//获取场所选择
const cahngecsmc = (val) => {
  csmclist.value.forEach((item) => {
    if (item.id == val) {
      data.fromObj.siteid = item.id;
      data.fromObj.sitename = item.placename;
      data.fromObj.buildingname = ""
      data.fromObj.buildingid = ""
      data.fromObj.publicarea = ""
      data.fromObj.floorname = ""
      data.fromObj.floorid = ""
      data.fromObj.partname = ""
      data.fromObj.partid = ""
      getjzwlist(item.id)
      // placename.value = item.id
    }
  });
};
//	根据placeid，查询建筑物
function getjzwlist(placeid) {
  getApi({ placeid }, "/mosty-jcgl/building/queryBuildingByPlaceid").then(res => {
    jzwlist.value = res ? res : []
  })
}//获取建筑物名称
function cahngejzwmc(val) {
  jzwlist.value.forEach(item => {
    if (item.id == val) {
      data.fromObj.buildingid = item.id
      data.fromObj.buildingname = item.buildingname
      data.fromObj.publicarea = item.publicarea
      data.fromObj.floorname = ""
      data.fromObj.floorid = ""
      data.fromObj.partname = ""
      data.fromObj.partid = ""
      if (item.publicarea == "1") {
        getbw2data(item.id)
      } else {
        getlcdata(item.id)
      }
    }
  })
}

//根据建筑物查询楼层
function getlcdata(id) {
  getApi({ id }, "/mosty-jcgl/floor/queryFloorByBuildId").then(res => {
    lclist.value = res ? res : []
  })
}

//获取楼层名称
function cahngelcmc(val) {
  lclist.value.forEach(item => {
    if (item.id == val) {
      data.fromObj.floorid = item.id
      data.fromObj.floorname = item.floorname
      data.fromObj.partname = ""
      data.fromObj.partid = ""
      getbwdata(item.id)
    }
  })
}

// (新)根据楼层id查询部位
function getbwdata(id) {
  getApi({ id }, "/mosty-jcgl/part/getListByFloorid").then(res => {
    bwlist.value = res ? res : []
  })
}

//(新)根据建筑物id查询部位
function getbw2data(id) {
  getApi({ id }, "/mosty-jcgl/part/getListByBuildid").then(res => {
    bwlist.value = res ? res : []
  })
}
//获取当前部位
const cahngebw = val => {
  bwlist.value.forEach(item => {
    if (item.id == val) {
      data.fromObj.partid = item.id
      data.fromObj.partname = item.partname ? item.partname : item.qtmc
    }
  })
}
//获取应急预案选择
const cahngeyj = (val) => {
  yjlist.value.forEach((item) => {
    if (item.id == val) {
      data.fromObj.emergencyid = item.id
    }
  });
};
//限制选人只能为本部门的人
function getdeptId() {
  data.deptId = getItem("deptId").ssbmid;
}
//新增表格
function addShowinput() {
  let tab = {
    peoplename: "",
    // peoplepapers: "",
    papersnumber: "",
    bz: "",
    input: true
  };
  if (data.fromObj.tbBuildpeopleList.length) {
    let legths = data.fromObj.tbBuildpeopleList.length - 1;
    let datalist = data.fromObj.tbBuildpeopleList[legths];
    if (
      datalist.peoplename != "" &&
      // datalist.peoplepapers != "" &&
      datalist.papersnumber != ""
    ) {
      data.fromObj.tbBuildpeopleList.push(tab);
    } else {
      if (datalist.peoplename == "") {
        ElMessage.error("人员名称不能为空!");
      }
      // else if (datalist.peoplepapers == "") {
      //   ElMessage.error("证件类型不能为空!");
      // }
      else if (datalist.papersnumber == "") {
        ElMessage.error("证件号码不能为空!");
      }
    }
  } else {
    data.fromObj.tbBuildpeopleList.push(tab);
  }
}
//保存表格数据
function submittab() {
  // isaddtr.value = true
  isaddtr.value = data.fromObj.tbBuildpeopleList.every((el) => {
    if (!el.papersnumber) {
      ElMessage.error("证件号码不可为空!");
      return false
    } else if (!el.peoplename) {
      ElMessage.error("施工人员名称不可为空!");
      return false
    }
    // else if (!el.peoplepapers) {
    //   ElMessage.error("证件类型不可为空!");
    //   return false
    // }
    else {
      el.input = false;
      return true
    }
  });
}
function checkTable() {
  const tbBuildpeopleList = data.fromObj.tbBuildpeopleList

  if (!tbBuildpeopleList?.length) {
    ElMessage.error("请填写施工人员信息列表");
    return false
  }
  for (let index = 0; index < tbBuildpeopleList.length; index++) {
    const el = tbBuildpeopleList[index];
    if (!el.papersnumber) {
      ElMessage.error("证件号码不可为空!");
      return false
    }
    // else if (!el.peoplepapers) {
    //   ElMessage.error("证件类型不可为空!");
    //   return false
    // }
    else if (!el.peoplename) {
      ElMessage.error("施工人员名称不可为空!");
      return false
    } else {
      return true
    }
  }
  return true
}
//删除表格数据
function deletetab() {
  data.fromObj.tbBuildpeopleList.forEach((item, index) => {
    if (currentRowjc.value == item) {
      data.fromObj.tbBuildpeopleList.splice(index, 1);
    }
  });
}
//选中当前表格行
function handlecheckChange(val) {
  if (props.saveBtnShow) {
    currentRowjc.value = val;
    data.fromObj.tbBuildpeopleList.forEach((el) => {
      if (el == val) {
        el.input = true;
      }
    });
  }

}
watchEffect(() => {
  if (props.editObj) {
    data.fromObj = props.editObj;
    tableData.value = []
    tableData.value = props.editObj.controlLibs
    // data.fromObj.state = '05';//  TODO:
  } else {
    data.fromObj = { zydx: "01" };
    data.fromObj.tbBuildpeopleList = [];
  }
});

//审批（同意）
const examineok = async () => {
  if (typeof ruleFormRef2.value?.validate !== 'function') return
  ruleFormRef2.value?.validate(valid2 => {
    if (valid2) {
      ElMessageBox.confirm("送给上级审批?", "提示", {
        confirmButtonText: "确认",
        cancelButtonText: "关闭",
        type: "warning"
      }).then(() => {
        examine();
      })
    } else {
      ElMessage.error("请正确输入必填项!");
    }
  })
};
//审批（不同意）
const examinefalse = () => {
  ElMessageBox.confirm("确认不同意?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "关闭",
    type: "warning"
  }).then(() => {
    Chooesresault(data.fromObj.state);
  })
};
//审批（不同意）修改审批结果
function Chooesresault(val) {
  // data.fromObj.deptpersoresul.type = '1' // 0:通过 1不通过
  // if (val == "2") {
  //   data.fromObj.deptpersoresult = "2";
  // }
  // if (val == "3") {
  //   data.fromObj.fgldresult = "2";
  // }
  // if (val == "4") {
  //   data.fromObj.branchedleadstate = "2";
  // }
  // if (val == "5") {
  //   data.fromObj.managerresult = "2";
  // }
  examine({ type: '1' });
}
const zzlx = ref(null);
const leaderid = ref("");
const singleShow = ref(true); //单选多选
//选择审批人员（并且修改审批结果为同意)
function ChooesSpry(val) {
  zzlx.value = val;
  leaderid.value = "";
  if (val == "2") {
    leaderid.value = data.fromObj.fgldid;
    data.fromObj.fgldresult = "1";
  }
  if (val == "3") {
    leaderid.value = data.fromObj.branchedleadid;
    data.fromObj.branchedleadstate = "1";
  }
  if (val == "4") {
    leaderid.value = data.fromObj.managerid;
    data.fromObj.managerresult = "1";
  }
  singleShow.value = true;
  // 省公司就时省公司审批，市公司就时市公司审批（不一定是同一个部门）
  data.deptId = getItem("deptId").sssgsid || getItem("deptId").ssdwid;
  chooseUserVisible.value = true;
}
//完成选人
const getSonValue = (value) => {
  // if (zzlx.value == "2") {
  //   data.fromObj.fgldname = value[0].userName;
  //   data.fromObj.fgldid = value[0].id;
  //   data.fromObj.fglddeptname = value[0].deptName;
  //   data.fromObj.fglddeptid = value[0].deptId;
  // }
  // if (zzlx.value == "3") {
  //   data.fromObj.branchedleadname = value[0].userName;
  //   data.fromObj.branchedleadid = value[0].id;
  //   data.fromObj.branchedleaddeptname = value[0].deptName;
  //   data.fromObj.branchedleaddeptid = value[0].deptId;
  // }
  // if (zzlx.value == "4") {
  //   data.fromObj.managername = value[0].userName;
  //   data.fromObj.managerid = value[0].id;
  //   data.fromObj.managerdeptname = value[0].deptName;
  //   data.fromObj.managerdeptid = value[0].deptId;
  // }
  examine();
};
/**确认审核结果并且发起审核
 * @param {Object} params
 * @param {String} params.type 0通过 1不通过
 */
function examine(params) {
  data.fromObj.type = params?.type === '1' ? '1' : '0' // 0通过 1不通过
  data.fromObj.ywid = data.fromObj.id;
  data.fromObj.file = data.fromObj.file ? data.fromObj.file.toString() : "";
  data.fromObj.xgffile = data.fromObj.xgffile ? data.fromObj.xgffile.toString() : "";
  data.fromObj.sceneImg = data.fromObj.sceneImg ? data.fromObj.sceneImg.toString() : "";
  data.fromObj.processImg = data.fromObj.processImg ? data.fromObj.processImg.toString() : "";
  data.fromObj.otherFile = data.fromObj.otherFile ? data.fromObj.otherFile.toString() : "";
  saveloading.value = true
  postApi(data.fromObj, "/mosty-jcgl/dangerJob/auditNewOne").then(() => {
    ElMessage.success("修改审核状态成功");
    changestate();
  }).finally(() => {
    saveloading.value = false
  })
}
const zzlxs = ref();
const stlyrylx = ref('01')
const chooseUserVisibles = ref(false);
//获取人员类型
function changerylx(val) {
  stlyrylx.value = val
}
function ChooesDdlds(val) {
  zzlxs.value = val;
  //选择检查成员
  if (val == "01") {
    leaderid.value = "";
    singleShow.value = true;
    chooseUserVisibles.value = true;
  } else if (val == "02") {
    leaderid.value = "";
    singleShow.value = true;
    chooseUserVisibles.value = true;
  }
}
const getSonValues = (value) => {
  console.log(value, 'value')
  // 驾驶员姓名
  if (zzlxs.value == "01") {
    data.fromObj.safetywardname = value[0].userName
    data.fromObj.safetywardid = value[0].id
  } else if (zzlxs.value == "02") {
    let tab = {
      peoplename: value[0].userName || '',
      // peoplepapers: "",
      papersnumber: value[0].idEntityCard || value[0].idcard || '',
      bz: "",
      input: true
    };
    data.fromObj.tbBuildpeopleList.push(tab);
  }
};
//改变审核状态
const changestate = () => {
  let params = {
    id: props.rwid,
    sfyd: "1",
    clzt: "02"
  };
  postApi(params, "/mosty-jcgl/rw/updateRw").then(() => {
    // ElMessage.success("修改任务状态成功");
    emits("close");
  })
};
const ruleFormRef = ref();
/** 审核-表单验证 */
const ruleFormRef2 = ref();
// 保存
const handleSave = async (ruleFormRef) => {
  if (!ruleFormRef) return;
  await ruleFormRef.validate((valid) => {
    if (valid) {
      let flag = checkTable()
      if (!flag) return;
      data.fromObj.file = data.fromObj.file ? data.fromObj.file.toString() : "";
      if (data.fromObj) {
        saveloading.value = true
        if (data.fromObj.tbBuildpeopleList.length) {
          let params = {
            ...data.fromObj,
            list: data.fromObj.tbBuildpeopleList
          }
          if (props.title == "危险作业申请" && isaddtr.value) {
            params.state = '00'
            postApi(params, "/mosty-jcgl/dangerJob/addNewOne").then((res) => {
              ElMessage.success("申请成功，正在送审");
              emits("close");
            }).finally(() => {
              saveloading.value = false
            })
          } else if (props.title == "危险作业编辑" && isaddtr.value) {
            postApi(params, "/mosty-jcgl/dangerJob/editNewOne").then((res) => {
              ElMessage.success("编辑成功!");
              emits("close");
            }).finally(() => {
              saveloading.value = false
            })

          } else {
            saveloading.value = false
          }
        } else {
          ElMessage.error("请填写施工人员信息表");
          saveloading.value = false
        }
      }
    } else {
      ElMessage.error("请正确输入必填项");
      saveloading.value = false
    }
  });
};
</script>

<style lang="scss" scoped>
.box_cont {
  // height: 73vh;
  // overflow-y: auto;
  // border: 1px solid red;
}

.fromBox {
  width: 1333px;
  margin: 20px auto;
}

.box_gbig {
  width: 100%;
  display: flex;
  justify-content: center;
}

.ld_box {
  display: flex;
  margin-right: 30px;
}

.box_left {
  width: 856px;
}

.el-form {
  width: 100%;
  align-items: center;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

.el-form-item {
  display: flex;
  margin-right: 20px;
}

.addbtn {
  margin-bottom: 10px;
}

.bigBox {
  display: block !important;
  box-sizing: border-box;
}

.tabbox {
  min-height: 200px;
  overflow-y: scroll;

  .input {
    width: 100%;
    height: 100%;
  }
}

::v-deep .el-table .cell {
  padding: 0 0 !important;
}

::v-deep .el-table--border .el-table__cell .cell {
  padding-left: 0px !important;

  >input {
    width: 100%;
    height: 33px;
    margin-bottom: 14px;
  }
}

::v-deep .el-upload-list {
  width: 100%;
}

::v-deep .el-table td.el-table__cell div {
  width: 100%;
}

//时间轴
.box_right {
  width: 37%;
  margin-left: 20px;
  position: relative;

  .time-line-container {
    padding-top: 3px;
    padding-bottom: 3px;

    .time-line-date {
      color: #999;
      font-size: 13px;
    }

    .time-line-status-text {
      font-weight: bolder;
    }

    .time-line-1 {
      color: rgb(255, 132, 0);
    }

    .time-line-2 {
      color: green;
    }
  }

}

.box_right .line {
  position: absolute;
  top: 0;
  left: 201px;
  width: 1px;
  background-color: #5ecb4c;
  height: 420px;
  z-index: 10;
}

.typ {
  color: #5ecb4c;
  margin-right: 10px;
}

.timeimg {
  width: 100%;
  text-align: center;
}

.boc_tim {
  width: 60px;
  margin-left: 90px !important;
  height: 60px;
  background-color: #fff;
  z-index: 999;
}

.box_right ul li {
  color: #000;
  display: flex;
  padding: 0 20px;
  margin: 20px 0;
  z-index: 99;
  padding-left: 80px;
}

.box_right ul li div {
  margin: 0 20px;
}

.iconre {
  width: 20px;
  height: 20px;
  z-index: 99;
  margin-left: -10px;
}

.time_le span {
  display: block;
  width: 80px;
}

.box_gbig .box_right ::v-deep .el-timeline-item {
  padding: 0;
  margin: 0;
}
</style>
