<template>
  <div>
    <div class="app-container">
      <el-page-header :content="$parent.OUTSOURCED_ID ? '编辑' : '新增'" @back="back"/>
      <div class="level-title mt-20">
        <h1>工程信息：</h1>
      </div>
      <el-form ref="form" :model="form" :rules="rules" label-width="180px">
        <div>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="DEPARTMENT_ID" label="股份主管部门:">
                <SelectTree
                  ref="MANAGERTree"
                  :clearable="false"
                  :options="treeDataInspectDept"
                  :props="defaultProps"
                  v-model="form.MANAGER_DEPARTMENT_ID"
                  placeholder="请选择股份主管部门"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="DEPARTMENT_ID" label="股份监管部门:">
                <SelectTree
                  ref="deptTree"
                  :clearable="false"
                  :options="treeDataInspectDept"
                  :props="defaultProps"
                  v-model="form.DEPARTMENT_ID"
                  placeholder="请选择股份监管部门"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="辖区单位">
                <Treeselect
                  v-if="updateValue"
                  :multiple="true"
                  :flat="true"
                  :default-expand-level="0"
                  :options="treeDataAllDept"
                  :props="defaultProps"
                  :normalizer="normalizer"
                  v-model="form.JURISDICTION_UNIT"
                  placeholder="请选择部门"
                  no-options-text="暂无数据"
                  no-children-text="暂无数据"
                  style="width: 100%;"
                  @select="handleSelect"
                  @deselect="handleRemove"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="重点工程名称:" prop="OUTSOURCED_NAME">
                <el-input v-model="form.OUTSOURCED_NAME" placeholder="这里输入重点工程名称..." />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="计划工期起止时间：" prop="STARTTIME">
                <el-date-picker
                  v-model="form.STARTTIME_TIMES"
                  style="width: 100%;"
                  type="daterange"
                  unlink-panels
                  value-format="yyyy-MM-dd"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="合同号：" prop="CONTRACT_NUM">
                <el-input v-model="form.CONTRACT_NUM" placeholder="这里输入合同号" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="施工相关方:" prop="UNITS_ID">
                <el-select v-model="form.UNITS_ID" filterable placeholder="请选择施工相关方" style="width: 100%;" @change="getUnitUser">
                  <el-option
                    v-for="item in unitsList"
                    :key="item.UNITS_ID"
                    :label="item.UNITS_NAME"
                    :value="item.UNITS_ID" />
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="相关方单位工程负责人:" prop="UNITS_PIC">
                <!--                <el-input v-model="form.UNITS_PIC" placeholder="这里输入相关方单位本工程负责人" />-->
                <el-select v-model="form.UNITS_PIC" placeholder="请选择监理单位" style="width: 100%;" @change="selectUnitsUser($event)">
                  <el-option v-for="item in unitsUserList" :key="item.PERSONNELMANAGEMENT_ID" :label="item.NAME" :value="item.PERSONNELMANAGEMENT_ID" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="相关方单位负责人手机：" prop="UNITS_PHONE">
                <el-input v-model="form.UNITS_PHONE" disabled placeholder="这里输入相关方单位本工程负责人手机" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>

            <el-col :span="8">
              <el-form-item label="监理单位名称：" prop="MANAGE_NAME">
                <el-select v-model="form.MANAGE_NAME" multiple placeholder="请选择监理单位" style="width: 100%;" @change="selectDeptOption">
                  <el-option v-for="item in mangeList" :key="item.CORPINFO_ID" :label="item.CORP_NAME" :value="item.CORPINFO_ID" />
                </el-select>
              </el-form-item>
            </el-col>
            <!--          <el-row>-->
            <!--            <el-col :span="8">-->
            <!--              <el-form-item label="相关方单位资质（附件）" prop="UNITS_APTITUDEPATH">-->
            <!--                <div class="uo-flex">-->
            <!--                  <el-input v-model="form.UNITS_APTITUDE" :disabled="true" title="请上传附件" />-->
            <!--                  <el-upload :before-upload="beforeFileUpload" accept=".pdf" class="avatar-uploader" action="#">-->
            <!--                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>-->
            <!--                  </el-upload>-->
            <!--                </div>-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->
            <!--            <el-col :span="8">-->

            <!--              <el-form-item label="监理单位资质（附件）" prop="MANAGE_APTITUDEPATH">-->
            <!--                <div class="uo-flex">-->
            <!--                  <el-input v-model="form.MANAGE_APTITUDE" :disabled="true" title="请上传附件" />-->
            <!--                  <el-upload :before-upload="beforeFileUpload2" accept=".pdf" class="avatar-uploader" action="#">-->
            <!--                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>-->
            <!--                  </el-upload>-->
            <!--                </div>-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->
            <!--            <el-col :span="8">-->

            <!--              <el-form-item label="安全技术措施（附件）" prop="MEASURESPATH">-->
            <!--                <div class="uo-flex">-->
            <!--                  <el-input v-model="form.MEASURES" :disabled="true" title="请上传附件" />-->
            <!--                  <el-upload :before-upload="beforeFileUpload1" accept=".pdf" class="avatar-uploader" action="#">-->
            <!--                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>-->
            <!--                  </el-upload>-->
            <!--                </div>-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->
            <!--          </el-row>-->

            <el-col :span="8">
              <el-form-item label="监理单位工程负责人：">
                <el-input v-model="form.MANAGE_PIC" placeholder="这里输入监理单位工程负责人姓名" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="监理单位负责人手机：" prop="MANAGE_PHONE">
                <el-input v-model="form.MANAGE_PHONE" placeholder="这里输入监理单位工程负责人手机" />
              </el-form-item>
            </el-col>
            <!--<el-col :span="8">
                <el-form-item label="申请人：" prop="APPLICANT">
                  <el-input v-model="form.APPLICANT" placeholder="这里输入申请人" />
                </el-form-item>
              </el-col>-->

            <!--            <el-col :span="8">-->
            <!--              <el-form-item label="备注：" prop="REMARKS">-->
            <!--                <el-input v-model="form.REMARKS" placeholder="这里输入备注" />-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->
            <!--            <el-col :span="8">-->
            <!--              <el-form-item label="相关方组织设计（附件）" prop="DESIGEPATH">-->
            <!--                <div class="uo-flex">-->
            <!--                  <el-input v-model="form.DESIGE" :disabled="true" title="请上传附件" />-->
            <!--                  <el-upload :before-upload="beforeFileUpload3" accept=".pdf" class="avatar-uploader" action="#">-->
            <!--                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>-->
            <!--                  </el-upload>-->
            <!--                </div>-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->
            <!--          </el-row>-->
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="集团单位：" prop="GROUP_UNIT">
                <!--                <el-date-picker v-model="form.STARTTIME" style="width: 100%;" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" placeholder="选择开始日期" clearable class="filter-item"/>-->
                <el-select v-model="form.GROUP_UNIT" multiple placeholder="请选择集团单位" style="width: 100%;">
                  <el-option v-for="item in groupCorpList" :key="item.CORPINFO_ID" :label="item.CORP_NAME" :value="item.CORPINFO_ID" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="状态：" prop="STATE">
                <el-select v-model="form.STATE" disabled style="width: 100%;">
                  <el-option v-for="item in stateList" :key="item.ID" :label="item.NAME" :value="item.ID" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="是否发送短信：">
                <el-select v-model="form.IS_SMS" style="width: 100%;">
                  <el-option v-for="item in smsList" :key="item.ID" :label="item.NAME" :value="item.ID" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="安全管理协议（附件）" prop="AQGLXY" class="is-required">
                <div class="uo-flex">
                  <el-upload
                    ref="uploadfile9"
                    :file-list="file9"
                    :on-change="beforeFileUpload9"
                    :on-exceed="handleUpload9Exceed"
                    :before-remove="beforeBeforeRemove9"
                    :on-remove="beforeRemove9"
                    :auto-upload="false"
                    :limit="9"
                    accept=".pdf,.jpg,.jpeg,.png"
                    class="avatar-uploader"
                    action="#">
                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>
                    <div slot="tip" class="el-upload__tip">只能上传pdf,jpg,jpeg,png类型文件，且最多上传9个附件</div>
                  </el-upload>
                </div>
              </el-form-item>
            </el-col>
            <!--            <el-col :span="8">-->

            <!--              <el-form-item label="附件" prop="ATTACHMENTSPATH">-->
            <!--                <div class="uo-flex">-->
            <!--                  <el-input v-model="form.ATTACHMENTS" :disabled="true" title="请上传附件" />-->
            <!--                  <el-upload :before-upload="beforeFileUpload4" accept=".pdf" class="avatar-uploader" action="#">-->
            <!--                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>-->
            <!--                  </el-upload>-->
            <!--                </div>-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->

          </el-row>

        </div>

        <!--        <div class="level-line" />-->
        <!--        <div class="level-title">-->
        <!--          <h1>安全培训：</h1>-->
        <!--        </div>-->

        <!--        <div>-->
        <!--          <el-row>-->
        <!--            <el-col :span="8">-->
        <!--              <el-form-item label="培训管理单位:" prop="TRAINING_NAME">-->
        <!--                <el-input v-model="form.TRAINING_NAME" placeholder="这里输入培训管理单位" />-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--            <el-col :span="8">-->
        <!--              <el-form-item label="培训时间：" prop="TRAINING_TIME">-->
        <!--                &lt;!&ndash;                <el-date-picker v-model="form.TRAINING_TIME" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" placeholder="选择培训日期" clearable class="filter-item"/>&ndash;&gt;-->
        <!--                <el-date-picker-->
        <!--                  v-model="form.TRAINING_TIME"-->
        <!--                  style="width: 100%;"-->
        <!--                  type="daterange"-->
        <!--                  unlink-panels-->
        <!--                  value-format="yyyy-MM-dd"-->
        <!--                  range-separator="至"-->
        <!--                  start-placeholder="开始日期"-->
        <!--                  end-placeholder="结束日期"-->
        <!--                  format="yyyy-MM-dd"-->
        <!--                  class="filter-item" />-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--            <el-col :span="8">-->
        <!--              <el-form-item label="培训管理负责人:" prop="TRAINING_PIC">-->
        <!--                <el-input v-model="form.TRAINING_PIC" placeholder="这里输入培训管理负责人" />-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--          </el-row>-->
        <!--          <el-row>-->
        <!--            <el-col :span="8">-->

        <!--              <el-form-item label="安全培训记录（附件）" prop="RECORDSPATH">-->
        <!--                <div class="uo-flex">-->
        <!--                  <el-input v-model="form.RECORDS" :disabled="true" title="请上传附件" />-->
        <!--                  <el-upload :before-upload="beforeFileUpload5" accept=".pdf" class="avatar-uploader" action="#">-->
        <!--                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>-->
        <!--                  </el-upload>-->
        <!--                </div>-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--            <el-col :span="8">-->

        <!--              <el-form-item label="培训签名表（附件）" prop="SHEETPATH">-->
        <!--                <div class="uo-flex">-->
        <!--                  <el-input v-model="form.SHEET" :disabled="true" title="请上传附件" />-->
        <!--                  <el-upload :before-upload="beforeFileUpload6" accept=".pdf" class="avatar-uploader" action="#">-->
        <!--                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>-->
        <!--                  </el-upload>-->
        <!--                </div>-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--          -->
        <!--          </el-row>-->
        <!--          <el-row>-->
        <!--            <el-col :span="8">-->

        <!--              <el-form-item label="重点工程考试题（附件）" prop="EXAMINATIONPATH">-->
        <!--                <div class="uo-flex">-->
        <!--                  <el-input v-model="form.EXAMINATION" :disabled="true" title="请上传附件" />-->
        <!--                  <el-upload :before-upload="beforeFileUpload7" accept=".pdf" class="avatar-uploader" action="#">-->
        <!--                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>-->
        <!--                  </el-upload>-->
        <!--                </div>-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--            <el-col :span="8">-->

        <!--              <el-form-item label="其他附件" prop="OATTACHMENTSPATH">-->
        <!--                <div class="uo-flex">-->
        <!--                  <el-input v-model="form.OATTACHMENTS" :disabled="true" title="请上传附件" />-->
        <!--                  <el-upload :before-upload="beforeFileUpload8" accept=".pdf" class="avatar-uploader" action="#">-->
        <!--                    <el-button type="primary" icon="el-icon-upload" style="margin-left:10px; " plain>上传附件</el-button>-->
        <!--                  </el-upload>-->
        <!--                </div>-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--          </el-row>-->
        <!--          <el-row/>-->
        <!--        </div>-->

        <div class="level-line" />
        <div class="level-title">
          <h1>处罚相关：</h1>
        </div>
        <el-divider content-position="left">处罚人员 <el-button type="primary" size="mini" @click="addInspector">添加</el-button></el-divider>
        <el-form-item v-for="(item,index) in inspectorList" :key="index + (Math.random() + '').replace('.', '')" :label="(index+1)+'.'" class="is-required">
          <div class="uo-flex">
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="处罚人员部门" prop="INSPECTION_DEPARTMENT_ID" label-width="100px">
                  <SelectTree
                    :ref="'deptTree_INSPECTION'+index"
                    :clearable="false"
                    :options="treeDeptOptions"
                    :props="defaultProps"
                    v-model="item.INSPECTION_DEPARTMENT_ID"
                    placeholder="请选择处罚人员部门"
                    style="width: 300px"
                    @change="updateInspecteDept(item.INSPECTION_DEPARTMENT_ID,index)"/>
                </el-form-item>
              </el-col>
              <el-col :span="11">
                <el-form-item label="处罚人员" prop="INSPECTION_USER_ID" label-width="100px">
                  <el-select
                    v-model="item.INSPECTION_USER_ID"
                    clearable
                    placeholder="请选择处罚人员"
                  >
                    <el-option
                      v-for="data in INSPECTOR_List[index]"
                      :key="data.USER_ID"
                      :label="data.NAME"
                      :value="data.USER_ID"
                      @click.native="changeHiddenUserList(item, data, index)" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="1">
                <el-button plain size="mini" type="danger" icon="el-icon-delete" title="移除" @click="delInspectorRow(item,index)"/>
              </el-col>
            </el-row>
          </div>
        </el-form-item>
        <!--        <div>-->
        <!--          <el-form-item v-for="(item,index) in inspectorList" :key="index + (Math.random() + '').replace('.', '')" :label="(index+1)+'.'">-->
        <!--            <div class="uo-flex">-->
        <!--              <el-row :gutter="20">-->
        <!--                <el-col :span="12">-->
        <!--                  <el-form-item label="处罚人部门" prop="INSPECTION_DEPARTMENT_ID" label-width="80px">-->
        <!--                    <SelectTree-->
        <!--                      ref="'deptTree_INSPECTION'+index"-->
        <!--                      :clearable="false"-->
        <!--                      :options="treeDeptOptions"-->
        <!--                      :props="defaultProps"-->
        <!--                      v-model="item.INSPECTION_DEPARTMENT_ID"-->
        <!--                      placeholder="请选择处罚人部门"-->
        <!--                      style="width: 300px"-->
        <!--                      @change="selectUserOptionByDept(item.INSPECTION_DEPARTMENT_ID,index)"/>-->
        <!--                  </el-form-item>-->
        <!--                </el-col>-->
        <!--                <el-col :span="11">-->
        <!--                  <el-form-item label="处罚人" prop="INSPECTION_USER_ID" label-width="80px">-->
        <!--                    <el-select v-model="selectUsers" multiple placeholder="请选择处罚人">-->
        <!--                      <el-option-->
        <!--                        v-for="data in punishThePersonOptions"-->
        <!--                        :key="data.USER_ID"-->
        <!--                        :label="data.NAME"-->
        <!--                        :value="data.USER_ID"-->
        <!--                        @click.native="addUserList(item, data)" />-->
        <!--                    </el-select>-->
        <!--                  </el-form-item>-->
        <!--                </el-col>-->
        <!--              </el-row>-->
        <!--            </div>-->
        <!--            <el-col :span="21">-->
        <!--              <el-form-item label="已选用户" prop="INSPECTION_USER_ID" label-width="80px"/>-->
        <!--              <el-col v-for="(user,index) in chooseUserList" :key="index" style="width: 150px;">-->
        <!--                <el-input v-model="user.NAME" disabled/>-->
        <!--                <el-button @click="delUserList(user,index)">删除</el-button>-->
        <!--              </el-col>-->
        <!--            </el-col>-->
        <!--          </el-form-item>-->
        <!--        </div>-->
        <div style="height: 200px"/>
      </el-form>
      <!--        <div class="ui-height" />-->
      <div class="ui-foot">
        <el-button icon="el-icon-check" type="primary" @click="confirm">保 存</el-button>
        <el-button icon="el-icon-arrow-left" @click="back">返 回</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import { upload } from '@/utils/upload'
import { requestFN } from '@/utils/request'
import waves from '@/directive/waves' // waves directive
import SelectTree from '@/components/SelectTree'
// eslint-disable-next-line no-unused-vars
import formatDate from '@/utils/dateformat'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'

export default {
  components: { Treeselect, Pagination, SelectTree },
  directives: { waves },
  data() {
    return {
      updateValue: true,
      selectUsers: [], // 防止报错，参数无用
      chooseUserList: [],
      punishThePerson: [],
      punishThePersonOptions: [],
      treeDeptOptions: [],
      inspectorList: [{ INSPECTION_DEPARTMENT_ID: '', INSPECTION_USER_ID: '', USER_SIDE: '' }], // 检查人员
      INSPECTOR_List: [],
      listLoading: true,
      add: false,
      del: false,
      edit: false,
      listQuery: {
        page: 1,
        limit: 20
      },
      total: 0,
      KEYWORDS: '',
      CONTRACTTIME: [], // 区间条件
      CONTRACT_STIME: '',
      CONTRACT_ETIME: '',
      TRAINING_TIME: [], // 区间条件
      TRAINING_STIME: '',
      TRAINING_ETIME: '',
      DEPARTMENT_ID: '',
      treeDataInspectDept: [],
      treeDataAllDept: [],
      defaultProps: {
        value: 'id',
        children: 'nodes',
        label: 'name'
      },
      userList: [],
      corpList: [],
      groupCorpList: [],
      mangeList: [],
      unitsList: [],
      STATE: '',
      varList: [],
      pd: [],
      file9: [],
      form: {
        DEPARTMENT_ID: '', // 发包部门
        CONTRACT_PIC: '', // 发包部门负责人
        OUTSOURCED_NAME: '', // 重点工程名称
        STARTTIME: '', // 计划工期开始时间
        ENDTIME: '', // 计划工期结束时间
        CONTRACTTIME: [], // 区间条件
        TRAINING_TIME: [], // 区间条件
        CONTRACT_STIME: '', // 合同起止时间
        CONTRACT_ETIME: '', // 合同起止时间
        UNITS_ID: '', // 相关方单位名称
        CONTRACT_NUM: '', // 合同号
        UNITS_APTITUDE: '', // 相关方单位资质
        UNITS_APTITUDEPATH: '',
        UNITS_PIC: '', // 相关方单位本项目负责人
        UNITS_PHONE: '', // 相关方单位本项目负责人手机
        MANAGE_NAME: '', // 监理单位名称
        MANAGE_APTITUDE: '', // 监理单位资质
        MANAGE_APTITUDEPATH: '',
        MANAGE_PIC: '', // 监理单位本项目负责人姓名
        DESIGE: '', // 相关方组织设计
        DESIGEPATH: '', // 相关方组织设计
        MANAGE_PHONE: '', // 监理单位本项目负责人手机
        MEASURES: '', // 安全技术措施
        MEASURESPATH: '', // 安全技术措施
        ATTACHMENTS: '', // 附件
        ATTACHMENTSPATH: '', // 附件
        REMARKS: '', // 备注
        TRAINING_NAME: '', // 培训管理单位
        TRAINING_PIC: '', // 培训管理负责人
        TRAINING_STIME: '', // 培训时间
        TRAINING_ETIME: '', // 培训时间
        RECORDS: '', // 安全培训记录
        RECORDSPATH: '', // 安全培训记录
        SHEET: '', // 培训签名表
        AQGLXY: '', // 安全管理协议
        SHEETPATH: '', // 培训签名表
        EXAMINATION: '', // 重点工程考试题
        EXAMINATIONPATH: '', // 重点工程考试题
        OATTACHMENTS: '', // 其他附件
        OATTACHMENTSPATH: '', // 其他附件
        file: '', // 相关附件
        APPLICANT: '', // 申请人
        PUNISH_THE_PERSON: '', // 处罚人
        INVOLVING_CORPS: [], // 辖区单位
        JURISDICTION_UNIT: [], // 辖区单位 实际使用
        STATE: '', // 状态
        GROUP_UNIT: [], // 集团单位
        MANAGER_DEPARTMENT_ID: '', // 股份主管部门
        IS_SMS: '1' // 是否发送短信
      },
      multipleSelectionAll: [], // 所有选中的数据包含跨页数据
      multipleSelection: [], // 当前页选中的数据
      dialogFormEdit: false,
      dialogType: 'add',
      rules: {
        DEPARTMENT_ID: [{ required: true, message: '股份监管部门不能为空', trigger: 'blur' }],
        CONTRACT_PIC: [{ required: true, message: '股份监管部门负责人不能为空', trigger: 'blur' }],
        OUTSOURCED_NAME: [{ required: true, message: '重点工程名称不能为空', trigger: 'blur' }],
        UNITS_ID: [{ required: true, message: '施工相关方名称 不能为空', trigger: 'blur' }],
        UNITS_PIC: [{ required: true, message: '相关方单位工程负责人不能为空', trigger: 'blur' }],
        MANAGE_PIC: [{ required: true, message: '监理单位工程负责人不能为空', trigger: 'blur' }],
        UNITS_PHONE: [
          { required: true, message: '相关方单位工程负责人手机不能为空', trigger: 'change' },
          { min: 11, max: 11, message: '请输入11位手机号码', trigger: 'blur' },
          {
            pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
            message: '请输入正确的手机号码'
          }
        ],
        MANAGE_PHONE: [
          // { required: true, message: '监理单位本项目负责人手机不能为空', trigger: 'change' },
          { min: 11, max: 11, message: '请输入11位手机号码', trigger: 'blur' },
          {
            pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
            message: '请输入正确的手机号码'
          }
        ],
        STATE: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
      },
      smsList: [
        { ID: '0', NAME: '是' },
        { ID: '1', NAME: '否' }
      ],
      stateList: [
        // { ID: '0', NAME: '未申请' },
        // { ID: '1', NAME: '申请中' },
        // { ID: '2', NAME: '已完成' }
        { ID: '0', NAME: '未开工' },
        { ID: '1', NAME: '进行中' },
        { ID: '2', NAME: '已结束' },
        { ID: '-1', NAME: '开工申请中' },
        { ID: '-2', NAME: '结束申请中' }
      ],
      unitsUserList: [],
      normalizer(node) {
        return {
          id: node.id,
          label: node.name,
          children: node.nodes,
          isDisabled: node.pId === '0'
        }
      }
    }
  },
  watch: {
    CONTRACTTIME: function(newData, oldData) {
      if (!newData) {
        this.CONTRACTTIME = ['', '']
        this.getQuery()
      }
    },
    'form.DEPARTMENT_ID': {
      handler(newVal, oldVal) {
        if (this.dialogType == 'add' || (oldVal != null && oldVal != '')) { // 编辑初始化时，不监听
          this.form.CONTRACT_PIC = ''
          this.userList = []
        }
        if (newVal != null && newVal != '') {
          this.getInspectorList(newVal)
        }
      },
      immediate: false

    },
    //'form.ENDTIME': {
    //  handler: function() {
    //    // eslint-disable-next-line no-unused-vars
    //    var time = formatDate(new Date(), 'YYYY-MM-DD')
    //    if (this.form.ENDTIME > time) {
    //      this.form.STATE = '1'
    //    } else {
    //      this.form.STATE = '2'
    //    }
    //  }
    //},
    TRAINING_TIME: function(newData, oldData) {
      if (!newData) {
        this.TRAINING_TIME = ['', '']
        this.getQuery()
      }
    }
  },
  async created() {
    this.getUnitsList()
    this.getCorpList()
    this.getmangeList()
    this.selectDeptOption()
    await this.getDict()
    await this.getistTreeCorpDept()
    if (this.$parent.OUTSOURCED_ID) {
      this.dialogType = 'edit'
      this.form.OUTSOURCED_ID = this.$parent.OUTSOURCED_ID
      this.getData()
    } else {
      this.form.STATE = '0'
    }
  },
  methods: {
    handleTreeSelected(checkedIds, checkedData) {
      this.DEPTIDS = checkedIds.join(',')
    },
    getRowKey(row) {
      return row.OUTSOURCED_ID
    },
    // 获取人员列表
    getInspectorList(DEPARTMENT_ID) {
      if (DEPARTMENT_ID) {
        requestFN(
          '/user/listAllManageAndCorp',
          {
            DEPARTMENT_ID: DEPARTMENT_ID,
            NOMAIN: '1'
          }
        ).then((data) => {
          this.userList = data.userList
        }).catch((e) => {
        })
      }
    },
    // 返回列表
    back() {
      this.$parent.activeName = 'List'
      this.$parent.OUTSOURCED_ID = ''
    },
    getUnitsList() {
      requestFN(
        '/units/listAll'
      ).then((data) => {
        this.unitsList = data.varList
      }).catch((e) => {
      })
    },
    getmangeList() {
      requestFN(
        '/corpinfo/listAll',
        {}
      ).then((data) => {
        this.mangeList = data.varList
        for (let i = 0; i < data.varList.length; i++) {
          const corpId = data.varList[i].CORPINFO_ID
          if (corpId === '1e6dbbe16004402f8d2c0e52afd9a676' ||
            corpId === '3a854eefa7894e06aaa1a2611bca80f6' ||
            corpId === '020578a4c1f04bc692ee25145c2efbe5' || corpId === '90966974de3c4b83aca6f8fd6432d5c2') {
            this.groupCorpList.push(data.varList[i])
          }
        }
      }).catch((e) => {
      })
    },
    getCorpList() {
      requestFN(
        '/corpinfo/listAll',
        {}
      ).then((data) => {
        this.corpList = data.varList
        if (!this.$parent.OUTSOURCED_ID) {
          this.form.MANAGE_NAME = ['133a982a3e93464a9b1de25fe6dd4948']
        }
        // for (let i = 0; i < data.varList.length; i++) {
        //   const corpId = data.varList[i].CORPINFO_ID
        //   if (corpId === '1e6dbbe16004402f8d2c0e52afd9a676' ||
        //     corpId === '3a854eefa7894e06aaa1a2611bca80f6' || corpId === '020578a4c1f04bc692ee25145c2efbe5' || corpId === '') {
        //     this.groupCorpList.push(data.varList[i])
        //   }
        // }
      }).catch((e) => {
      })
    },
    // 修改
    handleEdit(ID) {
      this.getDict()
      this.dialogType = 'edit'
      requestFN(
        '/outsourced/goEdit',
        {
          OUTSOURCED_ID: ID
        }
      ).then((data) => {
        this.form = Object.assign({}, data.pd) // copy obj
      }).catch((e) => {
        this.listLoading = false
      })
      this.dialogFormEdit = true
    },

    // 编辑初始化
    getData() {
      requestFN(
        '/outsourced/goEdit',
        {
          OUTSOURCED_ID: this.form.OUTSOURCED_ID
        }
      ).then(async(data) => {
        var pd = data.pd
        if (pd.JURISDICTION_UNIT) {
          pd.JURISDICTION_UNIT = pd.JURISDICTION_UNIT.split(',')
        }
        if (pd.MANAGE_NAME) {
          pd.MANAGE_NAME = pd.MANAGE_NAME.split(',')
        }
        if (pd.GROUP_UNIT) {
          pd.GROUP_UNIT = pd.GROUP_UNIT.split(',')
        }
        pd.STARTTIME_TIMES = []
        if (pd.STARTTIME && pd.ENDTIME) {
          pd.STARTTIME_TIMES.push(pd.STARTTIME)
          pd.STARTTIME_TIMES.push(pd.ENDTIME)
        }
        this.form = Object.assign({}, pd) // copy obj
        this.getUnitUser(this.form.UNITS_ID, true)
        const node = {}
        node.id = this.form.DEPARTMENT_ID
        this.$refs.deptTree.clearHandle()
        this.$nextTick(() => { // 此处使用这个可以等节点渲染后再获取节点
          this.$refs.deptTree.handleNodeClick(node)
        })
        const nodeMANAGER = {}
        nodeMANAGER.id = this.form.MANAGER_DEPARTMENT_ID
        this.$refs.MANAGERTree.clearHandle()
        this.$nextTick(() => { // 此处使用这个可以等节点渲染后再获取节点
          this.$refs.MANAGERTree.handleNodeClick(nodeMANAGER)
        })
        this.$set(this.form, 'CONTRACTTIME', Object.assign([], [this.form.CONTRACT_STIME, this.form.CONTRACT_ETIME]))
        this.$set(this.form, 'TRAINING_TIME', Object.assign([], [this.form.TRAINING_STIME, this.form.TRAINING_ETIME]))
        const punishThePerson = data.punishThePerson
        for (let i = 0; i < data.file9.length; i++) {
          data.file9[i].name = data.file9[i].FILE_NAME
        }
        this.file9 = data.file9
        await this.selectDeptOption()
        if (punishThePerson) {
          this.inspectorList = []
          let i = 0
          punishThePerson.forEach(item => {
            this.selectUserOptionByDept(item.DEPARTMENT_ID, i)
            i++
            var name = {
              INSPECTION_DEPARTMENT_ID: item.DEPARTMENT_ID,
              INSPECTION_USER_ID: item.USER_ID,
              USER_SIDE: ''
            }
            this.inspectorList.push(name)
          })
        }
        // this.chooseUserList = JSON.parse(data.pd.PUNISH_THE_PERSON)
      }).catch((e) => {

      })
    },

    // 保存
    confirm() {
      for (let i = 0; i < this.inspectorList.length; i++) {
        if (this.inspectorList[i].INSPECTION_USER_ID == '') {
          this.$message.warning('第' + (i + 1) + '行必须添加处罚人')
          return
        }
      }
      if (this.form.CONTRACTTIME && this.form.CONTRACTTIME.length > 0) {
        this.form.CONTRACT_STIME = this.form.CONTRACTTIME[0]
        this.form.CONTRACT_ETIME = this.form.CONTRACTTIME[1]
      }
      if (this.form.TRAINING_TIME && this.form.TRAINING_TIME.length > 0) {
        this.form.TRAINING_STIME = this.form.TRAINING_TIME[0]
        this.form.TRAINING_ETIME = this.form.TRAINING_TIME[1]
      }
      if (this.file9.length == 0) {
        this.$message({
          message: '请上传安全管理协议（附件）',
          type: 'error'
        })
        return false
      }
      if (this.form.STARTTIME_TIMES && this.form.STARTTIME_TIMES.length > 0) {
        this.form.STARTTIME = this.form.STARTTIME_TIMES[0]
        this.form.ENDTIME = this.form.STARTTIME_TIMES[1]
      }
      this.$refs.form.validate(valid => {
        if (valid) {
          if (this.form.JURISDICTION_UNIT) {
            this.form.JURISDICTION_UNIT = this.form.JURISDICTION_UNIT.toString().split(',')
          }
          if (this.form.MANAGE_NAME) {
            this.form.MANAGE_NAME = this.form.MANAGE_NAME.toString().split(',')
          }
          if (this.form.GROUP_UNIT) {
            this.form.GROUP_UNIT = this.form.GROUP_UNIT.toString().split(',')
          }
          this.listLoading = true
          const formData = new FormData()
          Object.keys(this.form).map(key => {
            formData.append(key, this.form[key])
          })
          // let PUNISH_THE_PERSONStr = ''
          //
          // for (const i in this.chooseUserList) {
          //
          //   PUNISH_THE_PERSONStr = PUNISH_THE_PERSONStr + ',' + this.chooseUserList[i].USER_ID
          // }
          var PUNISH_THE_PERSON = ''
          this.inspectorList.forEach(item => {
            PUNISH_THE_PERSON = item.INSPECTION_USER_ID + ',' + PUNISH_THE_PERSON
          })
          if (PUNISH_THE_PERSON.length > 0) {
            PUNISH_THE_PERSON = PUNISH_THE_PERSON.substr(0, PUNISH_THE_PERSON.length - 1)
          }

          formData.set('PUNISH_THE_PERSON', PUNISH_THE_PERSON)
          // this.$refs.uploadfile9.submit()
          for (let i = 0; i < this.file9.length; i++) {
            if (!this.file9[i].FILEPATH) {
              formData.append('file9', this.file9[i])
            }
          }
          formData.set('PUNISH_THE_PERSON', PUNISH_THE_PERSON)
          upload(
            '/outsourced/' + this.dialogType,
            formData
          ).then((data) => {
            this.$parent.activeName = 'List'
            this.$parent.OUTSOURCED_ID = ''
          }).catch((e) => {
            console.log(e)
            if (this.form.JURISDICTION_UNIT) {
              this.form.JURISDICTION_UNIT = this.form.JURISDICTION_UNIT.split(',')
            }
            if (this.form.MANAGE_NAME) {
              this.form.MANAGE_NAME = this.form.MANAGE_NAME.split(',')
            }
            if (this.form.GROUP_UNIT) {
              this.form.GROUP_UNIT = this.form.GROUP_UNIT.toString().split(',')
            }
            this.listLoading = false
          })
        } else {
          return false
        }
      })
    },
    beforeFileUpload(file) {
      const suffix = file.name.substring(file.name.lastIndexOf('.'), file.name.length)
      if (suffix === '.pdf') {
        this.form.file = file
        this.form.UNITS_APTITUDE = file.name
        this.$forceUpdate()
        return false
      } else {
        this.$message.warning('请上传pdf文件')
      }
      return false
    },
    beforeFileUpload1(file1) {
      const suffix = file1.name.substring(file1.name.lastIndexOf('.'), file1.name.length)
      if (suffix === '.pdf') {
        this.form.file1 = file1
        this.form.MEASURES = file1.name
        this.$forceUpdate()
        return false
      } else {
        this.$message.warning('请上传pdf文件')
      }
      return false
    },
    beforeFileUpload2(file2) {
      const suffix = file2.name.substring(file2.name.lastIndexOf('.'), file2.name.length)
      if (suffix === '.pdf') {
        this.form.file2 = file2
        this.form.MANAGE_APTITUDE = file2.name
        this.$forceUpdate()
        return false
      } else {
        this.$message.warning('请上传pdf文件')
      }
      return false
    },
    beforeFileUpload3(file3) {
      const suffix = file3.name.substring(file3.name.lastIndexOf('.'), file3.name.length)
      if (suffix === '.pdf') {
        this.form.file3 = file3
        this.form.DESIGE = file3.name
        this.$forceUpdate()
        return false
      } else {
        this.$message.warning('请上传pdf文件')
      }
      return false
    },
    beforeFileUpload4(file4) {
      const suffix = file4.name.substring(file4.name.lastIndexOf('.'), file4.name.length)
      if (suffix === '.pdf') {
        this.form.file4 = file4
        this.form.ATTACHMENTS = file4.name
        this.$forceUpdate()
        return false
      } else {
        this.$message.warning('请上传pdf文件')
      }
      return false
    },
    beforeFileUpload5(file5) {
      const suffix = file5.name.substring(file5.name.lastIndexOf('.'), file5.name.length)
      if (suffix === '.pdf') {
        this.form.file5 = file5
        this.form.RECORDS = file5.name
        this.$forceUpdate()
        return false
      } else {
        this.$message.warning('请上传pdf文件')
      }
      return false
    },
    beforeFileUpload6(file6) {
      const suffix = file6.name.substring(file6.name.lastIndexOf('.'), file6.name.length)
      if (suffix === '.pdf') {
        this.form.file6 = file6
        this.form.SHEET = file6.name
        this.$forceUpdate()
        return false
      } else {
        this.$message.warning('请上传pdf文件')
      }
      return false
    },
    beforeFileUpload7(file7) {
      const suffix = file7.name.substring(file7.name.lastIndexOf('.'), file7.name.length)
      if (suffix === '.pdf') {
        this.form.file7 = file7
        this.form.EXAMINATION = file7.name
        this.$forceUpdate()
        return false
      } else {
        this.$message.warning('请上传pdf文件')
      }
      return false
    },
    beforeFileUpload8(file8) {
      const suffix = file8.name.substring(file8.name.lastIndexOf('.'), file8.name.length)
      if (suffix === '.pdf') {
        this.form.file8 = file8
        this.form.OATTACHMENTS = file8.name
        this.$forceUpdate()
        return false
      } else {
        this.$message.warning('请上传pdf文件')
      }
      return false
    },
    beforeFileUpload9(file9) {
      const suffix = file9.name.substring(file9.name.lastIndexOf('.'), file9.name.length)
      if (suffix === '.pdf' || suffix === '.jpg' || suffix === '.jpeg' || suffix === '.png') {
        this.file9.push(file9.raw)
        return false
      } else {
        this.$message.warning('请上传pdf,pdf,jpg,jpeg,png文件')
      }
      return false
    },
    handleUpload9Exceed(files, fileList) {
      this.$message.warning(`当前限制选择 9 个文件.`)
    },
    beforeBeforeRemove9(file) {
      if (file.IMGFILES_ID) {
        return new Promise((resolve, reject) => {
          this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            requestFN(
              '/imgfiles/delete',
              {
                IMGFILES_ID: file.IMGFILES_ID,
                FOREIGN_KEY: file.FOREIGN_KEY,
                TYPE: 300
              }
            ).then(() => {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              resolve(true)
            }).catch((e) => {
              reject(false)
            })
          })
        })
      }
      return true
    },
    beforeRemove9(files, fileList) {
      this.file9 = fileList
    },
    handleDelete(id) {
      this.$confirm('确定要删除吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.listLoading = true
        requestFN(
          '/outsourced/delete',
          {
            OUTSOURCED_ID: id
          }
        ).then(() => {
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.listLoading = false
          this.varList = []
          this.listQuery.page = 1
          this.getList()
        }).catch((e) => {
          this.listLoading = false
        })
      }).catch(() => {
      })
    },

    batchDel() {
      const _selectData = this.$refs.multipleTable.selection
      if (_selectData == null || _selectData.length == 0) {
        this.$message({
          message: '请选中要删除的项...',
          type: 'error'
        })
        return false
      }
      const ids = _selectData.map((item, index) => {
        return item.OUTSOURCED_ID
      }).join(',')

      this.$confirm('确定要删除选中的数据吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.listLoading = true
        requestFN(
          '/outsourced/deleteAll',
          {
            DATA_IDS: ids
          }
        ).then(() => {
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.listLoading = false
          this.varList = []
          this.listQuery.page = 1
          this.$refs.multipleTable.clearSelection()
          this.getList()
        }).catch((e) => {
          this.listLoading = false
        })
      }).catch(() => {
      })
    },
    // 判断按钮权限，用于是否显示按钮
    hasButton: function() {
      var keys = 'outsourced:add,outsourced:del,outsourced:edit,toExcel'
      requestFN(
        '/head/hasButton',
        {
          keys: keys
        }
      ).then((data) => {
        this.add = data.outsourcedfhadminadd		// 新增权限
        this.del = data.outsourcedfhadmindel		// 删除权限
        this.edit = data.outsourcedfhadminedit	// 修改权限
      }).catch((e) => {
        this.listLoading = false
      })
    },
    // 获取数据字典数据
    getDict: function() {
      return new Promise((resolve) => {
        requestFN(
          '/corpDepartment/listTreeManageAndCorp1',
          {}
        ).then((data) => {
          this.treeDataInspectDept = this.listTransTree(JSON.parse(data.zTreeNodes), 'id', 'pId', 'nodes')
          resolve()
        }).catch((e) => {
        })
      })
    },
    getistTreeCorpDept() {
      return new Promise((resolve) => {
        requestFN(
          '/corpDepartment/listTreeCorpDept',
          {}
        ).then((data) => {
          this.treeDataAllDept = this.listTransTree(JSON.parse(data.zTreeNodes), 'id', 'pId', 'nodes')
          resolve()
        }).catch((e) => {
        })
      })
    },
    resetForm() {
      this.form = {
        DEPARTMENT_ID: '', // 发包部门
        CONTRACT_PIC: '', // 发包部门负责人
        OUTSOURCED_NAME: '', // 重点工程名称
        STARTTIME: '', // 计划工期开始时间
        ENDTIME: '', // 计划工期结束时间
        CONTRACT_STIME: '', // 合同起止时间
        CONTRACT_ETIME: '', // 合同起止时间
        UNITS_ID: '', // 相关方单位名称
        CONTRACT_NUM: '', // 合同号
        UNITS_APTITUDE: '', // 相关方单位资质
        UNITS_PIC: '', // 相关方单位本项目负责人
        UNITS_PHONE: '', // 相关方单位本项目负责人手机
        MANAGE_NAME: '', // 监理单位名称
        MANAGE_APTITUDE: '', // 监理单位资质
        MANAGE_PIC: '', // 监理单位本项目负责人姓名
        DESIGE: '', // 相关方组织设计
        MANAGE_PHONE: '', // 监理单位本项目负责人手机
        MEASURES: '', // 安全技术措施
        ATTACHMENTS: '', // 附件
        REMARKS: '', // 备注
        TRAINING_NAME: '', // 培训管理单位
        TRAINING_PIC: '', // 培训管理负责人
        TRAINING_STIME: '', // 培训时间
        TRAINING_ETIME: '', // 培训时间
        RECORDS: '', // 安全培训记录
        SHEET: '', // 培训签名表
        EXAMINATION: '', // 重点工程考试题
        OATTACHMENTS: '', // 其他附件
        APPLICANT: '', // 申请人
        STATE: '', // 状态
        GROUP_UNIT: [], // 集团单位
        MANAGER_DEPARTMENT_ID: '' // 股份主管部门
      }
    },
    selectDeptOption() {
      // 合并
      // var arr = [...this.form.INVOLVING_CORPS, ...this.form.MANAGE_NAME]
      // // 去重
      // var dataSet = [...new Set(arr)]
      // // 转数组
      // var dataArray = Array.from(dataSet)
      // var dataJson = JSON.stringify(dataArray)
      return new Promise((resolve) => {
        requestFN(
          '/corpDepartment/listTreeManageAndCorpForPcPunishThePerson',
        ).then((data) => {
          this.treeDeptOptions = this.listTransTree(JSON.parse(data.zTreeNodes), 'id', 'pId', 'nodes')
          resolve()
        }).catch((e) => {
        })
      })
    },
    removeDeptOption() {
      this.inspectorList = [{ INSPECTION_DEPARTMENT_ID: '', INSPECTION_USER_ID: '', USER_SIDE: '' }] // 检查人员
    },
    selectUserOptionByDept(id, i) {
      return new Promise((resolve) => {
        requestFN(
          '/corpDepartment/selectUserByDepartmentId',
          {
            DEPARTMENT_ID: id
          }
        ).then((data) => {
          this.INSPECTOR_List[i] = data.usersList
          this.$forceUpdate()
          // this.punishThePersonOptions = data.usersList
          // resolve()
        }).catch((e) => {
        })
      })
    },
    addUserList(item, data) {
      var con = this.chooseUserList.findIndex(i => i.USER_ID === data.USER_ID)
      if (con < 0) {
        this.chooseUserList.push(data)
      }
      this.selectUsers = ''
    },
    delUserList(user, index) {
      this.chooseUserList.splice(this.chooseUserList.findIndex(i => i.USER_ID === user.USER_ID), 1)
    },
    addInspector() {
      this.inspectorList.push({ INSPECTION_DEPARTMENT_ID: '', INSPECTION_USER_ID: '', USER_SIDE: '' })
      this.INSPECTOR_List.push([])
    },
    updateInspecteDept(DEPARTMENT_ID, i) {
      this.inspectorList[i].INSPECTION_USER_ID = ''
      this.inspectorList[i].USER_SIDE = ''
      this.selectUserOptionByDept(DEPARTMENT_ID, i)
    },
    changeHiddenUserList(item, data, index) {
      var count = 0
      this.inspectorList.forEach(selct => {
        if (selct.INSPECTION_USER_ID === data.USER_ID) {
          count++
        }
      })
      if (count > 1) {
        this.inspectorList[index].INSPECTION_USER_ID = ''
        this.$message.warning('请勿重复选择处罚人员')
      }
      item.USER_SIDE = data.USER_SIDE
    },
    // 删除检查人员
    delInspectorRow(row, index) {
      if (this.inspectorList.length === 1) {
        this.$message.warning('必须添加处罚人')
        return
      }
      if (this.validStr(row.INSPECTION_DEPARTMENT_ID) || this.validStr(row.INSPECTION_USER_ID)) {
        this.$confirm('确定要移除第' + (index + 1) + '个检查人员吗?', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          if (this.form.OUTSOURCED_ID) {
            var data = { OUTSOURCED_ID: this.form.OUTSOURCED_ID, CREATOR: row.INSPECTION_USER_ID }
            requestFN(
              '/keyprojectpunish/findByOperator',
              data
            ).then((data) => {
              if (data.data.length > 0) {
                this.$message({
                  message: '此用户对项目进行了罚款操作，不可删除',
                  type: 'error'
                })
              } else {
                this.$set(this.inspectorList, this.inspectorList.splice(index, 1))
                this.INSPECTOR_List.splice(index, 1)
              }
            }).catch((e) => {
            })
          } else {
            this.$set(this.inspectorList, this.inspectorList.splice(index, 1))
            this.INSPECTOR_List.splice(index, 1)
          }
        }).catch(() => {
        })
      } else {
        this.inspectorList.splice(index, 1)
        this.INSPECTOR_List.splice(index, 1)
      }
    },
    getUnitUser(event, clear) {
      if (!clear) {
        this.form.UNITS_PIC = ''
        this.form.UNITS_PHONE = ''
      }
      requestFN(
        '/personnelmanagement/listAll',
        {
          UNITS_ID: event
        }
      ).then((data) => {
        // this.form.UNITS_PIC = ''
        // this.form.UNITS_PHONE = ''
        this.unitsUserList = data.varList
        // this.punishThePersonOptions = data.usersList
        // resolve()
      }).catch((e) => {
      })
    },
    selectUnitsUser(event) {
      this.unitsUserList.find((item) => {
        if (item.PERSONNELMANAGEMENT_ID === event) {
          this.form.UNITS_PHONE = item.PHONENUM
        }
      })
    },
    // 将树节点的子节点全部添加到数组中
    pullSelectedNodes(selectedItems) {
      if (selectedItems.nodes && selectedItems.nodes.length > 0) {
        for (let i = 0; i < selectedItems.nodes.length; i++) {
          if (!this.form.JURISDICTION_UNIT.includes(selectedItems.nodes[i].id)) {
            this.form.JURISDICTION_UNIT.push(selectedItems.nodes[i].id)
          }
          this.pullSelectedNodes(selectedItems.nodes[i])
        }
      }
    },
    // 选择项时触发的事件
    handleSelect(selectedItems) {
      // 选择父节点时同时勾选全部子节点
      if (!this.form.JURISDICTION_UNIT.includes(selectedItems.id)) {
        this.form.JURISDICTION_UNIT.push(selectedItems.id)
      }
      this.pullSelectedNodes(selectedItems)
      this.onClick()
    },
    // 将选中项的子节点全部移除
    removeSelectedNodes(selectedItems) {
      if (selectedItems.nodes && selectedItems.nodes.length > 0) {
        for (let i = 0; i < selectedItems.nodes.length; i++) {
          if (this.form.JURISDICTION_UNIT.includes(selectedItems.nodes[i].id)) {
            this.form.JURISDICTION_UNIT.splice(this.form.JURISDICTION_UNIT.indexOf(selectedItems.nodes[i].id), 1)
          }
          this.removeSelectedNodes(selectedItems.nodes[i])
        }
      }
    },
    // 移除选中项时触发的事件
    handleRemove(selectedItems) {
      // 移除选中项时同时移除全部子节点
      if (this.form.JURISDICTION_UNIT.includes(selectedItems.id)) {
        this.form.JURISDICTION_UNIT.splice(this.form.JURISDICTION_UNIT.indexOf(selectedItems.id), 1)
      }
      this.removeSelectedNodes(selectedItems)
      this.onClick()
    },
    onClick() {
      this.updateValue = false
      this.$nextTick(() => {
        this.updateValue = true
      })
    }
  }
}

</script>
<style lang="sass" scoped>
.uo-flex
  display: flex
  .avatar-uploader
    ul
      margin: 0
      li
        padding: 0
  .el-dialog__body
    padding: 0
  .map-flex
    display: flex
    width: 500px
    align-items: center

  .ud-flex
    display: flex
  .form-group
    display: flex
    align-items: center
    .form-label
      padding: 0px 15px
      font-size: 14px
      width: 240px
      font-weight: 400
      text-align: right
      margin-bottom: 18px
      .star
        color: red
        padding-right: 4px
    .input-block
      display: flex

  .disContent
    display: flex
    align-items: center
    flex-wrap: wrap
    .img-div
      position: relative
      margin: 0 10px 0px 0
      width: 108px
      height: 108px
      border-radius: 4px
      overflow: hidden
      &>img
        width: 100%
        height: 100%

  .disContent-hide
    position: absolute
    width: 100%
    height: 100%
    border-radius: 4px
    background-color: rgba(48, 48, 48, 0.59)
    display: none
    top: 0
    left: 0
    line-height: 32px

    .Delete
      position: absolute
      bottom: 14px
      right: 10px
      font-size: 16px
      color: white
      cursor: pointer
    .yuLan
      position: absolute
      bottom: 23px
      right: 50px
      font-size: 16px
      color: white
      cursor: pointer
      .yuLanImg
        position: absolute
        bottom: 0
        right: 0
        width: 100%
        height: 100%
        opacity: 0

  .img-div:hover .disContent-hide
    display: block

    .pitchCss
      border: 1px solid #202e78
      transition: all linear 0.1s
      width: 116px
      height: 116px

</style>
