<template>
  <div id="handle_merge">
    <el-form
      ref="disposeForm"
      :model="disposeForm"
      label-position="right"
      label-width="100px"
      :rules="!disabled ? rules : {}"
      size="mini"
    >
      <el-collapse v-model="activeName" :class="!isLcjd ? 'NBjd' : ''">
        <el-collapse-item title="认证处置" name="2" class="wrap">
          <div v-if="bhjl[0]">
            <div v-for="item in bhjl" :key="item.id">
              <div class="Bhclass">
                <div style="width:75%">
                  <el-row>
                    <el-col>
                      <el-form-item label="驳回说明:">
                        <el-input v-model="item.clyj" disabled />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="8">
                      <el-form-item label="驳回人员:">
                        <el-input v-model="item.clry" disabled />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="驳回时间:">
                        <el-input v-model="item.createTime" disabled />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="驳回到:">
                        <el-input v-model="item.bbhLcjd" disabled />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </div>
                <div style="width:25%;" class="Bhclass">
                  <img src="@/assets/images/Bh.png" alt="" style="width:30%">
                </div>
                <!-- </el-row> -->
              </div>
              <hr>
            </div>
          </div>
          <div v-if="zpjl[0]">
            <div v-for="item in zpjl" :key="item.id">
              <div class="Bhclass">
                <!-- <el-row> -->
                <div style="width:75%">
                  <el-row>
                    <el-col>
                      <el-form-item label="转派说明:">
                        <el-input v-model="item.zpyj" disabled type="textarea" />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="8">
                      <el-form-item label="转派人员:">
                        <el-input v-model="item.zpry" disabled />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="转派时间:">
                        <el-input v-model="item.createTime" disabled />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </div>
                <div style="width:25%;" class="Bhclass">
                  <img src="@/assets/images/Zp.png" alt="" style="width:30%">
                </div>
                <!-- </el-row> -->
              </div>
              <hr>
            </div>
          </div>
          <el-row>
            <el-col :span="24">
              <el-row>
                <el-col v-if="disposeForm.lczt !== 53 && disposeForm.lczt !== 70 && data.isLeak == 1" :span="12">
                  <el-form-item label="漏点状态:" prop="isRealLeak">
                    <el-input v-if="disabled" v-model="disposeForm.isRealLeakName" :disabled="disabled" size="small" />
                    <el-select v-else v-model="disposeForm.isRealLeak" size="small" clearable>
                      <el-option key="1" label="真实漏点" value="1" />
                      <el-option key="2" label="非漏点" value="2" />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col v-if="disposeForm.lczt !== 53 && disposeForm.lczt !== 70 && data.isLeak == 1" :span="12">
                  <el-form-item label="预估漏损水量:" prop="predictLeakWater">
                    <el-input
                      v-if="disabled"
                      v-model="disposeForm.predictLeakWater"
                      :disabled="disabled"
                      type="number"
                      size="small"
                    />
                    <el-input v-else v-model="disposeForm.predictLeakWater" type="number" size="small" />
                  </el-form-item>
                </el-col>
                <el-col v-if="disposeForm.lczt !== 53 && disposeForm.lczt !== 70" :span="24">
                  <el-form-item label="认证说明:" prop="rzyj">
                    <el-input
                      v-model="disposeForm.rzyj"
                      :placeholder="disabled ? '未输入认证说明' : '请输入认证说明'"
                      :disabled="disabled"
                      type="textarea"
                      size="small"
                      :rows="disabled ? 1 : 3"
                    />
                  </el-form-item>
                </el-col>
                <el-col v-if="disposeForm.lczt === 53" :span="24">
                  <el-form-item label="驳回原因:" prop="bhyy">
                    <el-input
                      v-model="disposeForm.bhyy"
                      :placeholder="disabled ? '未输入驳回原因' : '请输入驳回原因'"
                      :disabled="disabled"
                      type="textarea"
                      :rows="disabled ? 1 : 3"
                    />
                  </el-form-item>
                </el-col>
                <el-col v-if="disposeForm.lczt === 70" :span="24">
                  <el-form-item label="转派原因:" prop="zpyj">
                    <el-input
                      v-model="disposeForm.zpyj"
                      :placeholder="disabled ? '未输入转派原因' : '请输入转派原因'"
                      :disabled="disabled"
                      type="textarea"
                      :rows="disabled ? 1 : 3"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col v-if="!lcjdParams.stopFlag && isJgcz && disposeForm.rzslry.length > 1 && !disabled" :span="6">
                  <el-form-item label="汇集人员:" prop="slry">
                    <el-select v-model="clhjr" placeholder="请选择处理汇集人" filterable :disabled="disabled">
                      <el-option
                        v-for="item in clhjrList"
                        :key="item.id"
                        :label="item.personName"
                        :value="item.personId"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
          <el-row>
            <el-col v-if="disposeForm.lczt === 51 || disposeForm.lczt === 52 || disposeForm.lczt === 54" :span="24">
              <el-row>
                <el-col v-if="download" :span="24">
                  <el-form-item label="附件上传:">
                    <el-upload
                      class="upload-demo"
                      action="https://jsonplaceholder.typicode.com/posts/"
                      :on-preview="handlePreview"
                      :on-remove="handleRemove"
                      :before-remove="beforeRemove"
                      :on-change="beforeAvatarUpload"
                      :on-success="handleAvatarSuccess"
                      accept=".docx,.doc,.xls,.xlsx.JPG,JPEG,PNG,GIF,.jpg,.jpeg,.png,.gif,.JPG,.JPEG,.PBG,.GIF,.amr"
                      :file-list="fileList"
                      :auto-upload="false"
                      multiple
                      :limit="3"
                      :on-exceed="handleExceed"
                      style="width: 90%;"
                      size="small"
                    >
                      <el-button size="small" type="primary" style="margin-top: 3px; left:0px; float:left; ">点击上传
                      </el-button>
                      <div slot="tip" class="el-upload__tip">⚠️注意:最多上传3个文件,且大小不能超过10MB!</div>
                    </el-upload>
                  </el-form-item>
                </el-col>
                <el-col v-if="!download" :span="24">
                  <el-form-item label="附件下载:">
                    <div v-if="ImgUrlList[0] || fileListF[0]" style="display: flex;">
                      <el-row type="flex" style="padding-right:10px; " :gutter="20">
                        <el-image
                          v-for="item in ImgUrlList"
                          :key="item"
                          :lazy="true"
                          style="padding-left:10px;margin-right:5px;  width: 100px ;"
                          :src="item"
                          :preview-src-list="ImgUrlList"
                        />
                      </el-row>

                      <el-row type="flex" style="padding-left:30px; margin: 0;margin-left:5px">
                        <el-upload
                          ref="upload"
                          disabled
                          class="upload-demo"
                          :limit="3"
                          action="https://jsonplaceholder.typicode.com/posts/"
                          :file-list="fileListF"
                          :on-preview="handleClick"
                        />
                      </el-row>
                    </div>
                    <div v-else>
                      <div class="colflexS">
                        <img src="@/assets/icon/null.png" alt="" style="height:30px">
                        <div>无上传文件</div>
                      </div>
                    </div>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
          <el-row type="flex">
            <el-col v-if="!disabled" :span="6">
              <el-form-item label="流程状态:" prop="lczt">
                <el-select v-model="disposeForm.lczt" :disabled="disabled" placeholder="请选择流程状态" @change="gddjZtChange">
                  <el-option
                    v-for="item in flows"
                    :key="item.id"
                    :disabled="disabled"
                    :label="item.cname"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="!lcjdParams.stopFlag && !disabled" :span="6">
              <el-form-item label="受理时限:">
                <el-date-picker
                  v-model="disposeForm.shsx"
                  disabled
                  placeholder="自动生成配置时限"
                  type="datetime"
                  style="width: 100%"
                  :picker-options="pickerOptions"
                  value-format="yyyy-MM-dd HH:mm:ss"
                />
              </el-form-item>
            </el-col>
            <el-col v-if="!lcjdParams.stopFlag && !disabled" :span="6">
              <el-form-item :label="Name + '部门:'" prop="rzbm">
                <el-select
                  v-model="disposeForm.rzbm"
                  placeholder="请选择部门"
                  :disabled="disabled"
                  :collapse-tags="isDisable"
                  :multiple="isJgcz"
                  @change="Bmchange"
                >
                  <el-option
                    v-for="item in acceptanceDepartments"
                    :key="item.departId"
                    :label="item.departName"
                    :value="item.departId"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="!lcjdParams.stopFlag && !disabled" :span="6">
              <el-form-item :label="Name + '人员:'" prop="rzslry">
                <el-select
                  v-model="disposeForm.rzslry"
                  placeholder="请选择人员"
                  filterable
                  :multiple="isJgcz"
                  :collapse-tags="isDisable"
                  :disabled="disabled"
                  @change="slryChange"
                >
                  <el-option v-for="item in receiver" :key="item.id" :label="item.personName" :value="item.personId" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="disposeForm.lczt === 70" :span="6">
              <el-form-item label="转派部门:" prop="slbm">
                <el-select
                  v-model="disposeForm.slbm"
                  placeholder="请选择转派部门"
                  filterable
                  :disabled="disabled"
                  @change="Bmchange_zp"
                >
                  <el-option
                    v-for="item in acceptanceDepartments_zp"
                    :key="item.departId"
                    :label="item.departName"
                    :value="item.departId"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="disposeForm.lczt === 70" :span="6">
              <el-form-item label="转派人员:" prop="slry">
                <el-select v-model="disposeForm.slry" placeholder="请选择转派人员" filterable :disabled="disabled">
                  <el-option
                    v-for="item in receiver_zp"
                    :key="item.id"
                    :label="item.personName"
                    :value="item.personId"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-if="disabled" type="flex">
            <el-col :span="8">
              <el-form-item label="认证部门:">
                <el-input v-model="disposeForm.rzbmName" disabled placeholder="未选择认证部门" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="认证人员:">
                <el-input v-model="disposeForm.rzryName" disabled placeholder="未选择认证人员" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="认证时间:">
                <!-- <el-input v-model="disposeForm.rzsj" type="text" disabled placeholder="未选择认证时间" /> -->
                <el-input v-model="disposeForm.rzsj" placeholder="未选择认证时间" style="width: 100%" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <!-- <el-row v-if="disabled" type="flex">
            <el-col :span="8">
              <el-form-item label="审核部门:">
                <el-input v-model="data.jgAuditList[0].deptName" disabled placeholder="未选择审核部门" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="审核人员:">
                <el-input v-model="data.jgAuditList[0].auditUserName" disabled placeholder="未选择审核人员" />
              </el-form-item>
            </el-col>
          </el-row> -->
        </el-collapse-item>
      </el-collapse>
      <QwxFlow
        v-if="lcjdParams.zrjrFlag"
        :prop-workflow-qwx="workflowQwx"
        :acceptance-departments="acceptanceDepartments"
        :receivers="receivers"
        :is-lcjd="isLcjd"
        @propSetQwxData="propSetQwxData"
      />
    </el-form>
  </div>
</template>

<script>
import QwxFlow from '../../components/qwxFlow'
import { parseTime } from '@/utils/index'
import { IP } from '@/utils/request'
import { editHandle, getPersonnel, getSelectBygdlx, getUserByDepts, getById, getRejectList, getRedeploy } from '@/api/work'
import { imageByName } from '@/api/ftp'
import { client, _throttle } from '@/utils/index'

export default {
  components: { QwxFlow },
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    data: {
      type: Object,
      required: true
    },
    // 部门
    acceptanceDepartment: {
      type: Array,
      required: true
    },
    download: {
      type: Boolean,
      default: false
    },
    activeNames: {
      type: String,
      default: '2'
    }
  },
  data() {
    return {
      activeName: this.activeNames,
      isJgcz: false,
      isJgsh: false,
      JgshData: {},
      BmSplist1Sure: false,
      BmSplist2Sure: false,
      BmSplist3Sure: false,
      BmSplist4Sure: false,
      isLcjd: true,
      jgshCcjb: '',
      BmSplist1: [],
      RySplist1: [],
      BmSplist2: [],
      RySplist2: [],
      BmSplist3: [],
      RySplist3: [],
      BmSplist4: [],
      RySplist4: [],
      dialogFormVisible: false,
      fileListImg: [],
      ImgUrlList: [],
      srcListsrc: [],
      fileListF: [],
      rules: {
        rzbm: [{ required: true, message: ' ', trigger: 'change' }],
        slry: [{ required: true, message: ' ', trigger: 'change' }],
        slbm: [{ required: true, message: ' ', trigger: 'change' }],
        rzslry: [{ required: true, message: ' ', trigger: 'change' }],
        lczt: [{ required: true, message: ' ', trigger: 'change' }],
        bhyy: [{ required: true, message: ' ', trigger: 'blur' }],
        rzyj: [{ required: true, message: ' ', trigger: 'blur' }],
        zpyj: [{ required: true, message: ' ', trigger: 'blur' }],
        // predictLeakWater: [{ required: true, message: ' ', trigger: 'blur' }],
        // 抢维修
        orderSource: [
          { required: true, message: ' ', trigger: 'change' }
        ],
        typeId: [
          { required: true, message: ' ', trigger: 'change' }
        ],
        respUser: [
          { required: true, message: ' ', trigger: 'change' }
        ],
        qwxTime: [
          { required: true, message: ' ', trigger: 'change' }
        ]
      },
      rulesR: {
        czbm: [{ required: true, message: ' ', trigger: 'change' }],
        czbm2: [{ required: true, message: ' ', trigger: 'change' }],
        czbm3: [{ required: true, message: ' ', trigger: 'change' }],
        czbm4: [{ required: true, message: ' ', trigger: 'change' }],
        jgczry: [{ required: true, message: ' ', trigger: 'change' }],
        jgczry2: [{ required: true, message: ' ', trigger: 'change' }],
        jgczry3: [{ required: true, message: ' ', trigger: 'change' }],
        jgczry4: [{ required: true, message: ' ', trigger: 'change' }]
      },
      pickerOptions: {
        disabledDate(time) {
          const dateTime = new Date()
          const startDateTime = dateTime.setDate(dateTime.getDate() - 1)
          const endDateTime = dateTime.setDate(dateTime.getDate() + 7)
          return (
            time.getTime() < new Date(startDateTime).getTime() ||
            time.getTime() > new Date(endDateTime).getTime()
          )
        },
        selectableRange: parseTime(new Date(), '{hh}:{ii}:{ss}') + '- 23:59:00'
      },
      auditForm: {
        czbm: '',
        czbm2: '',
        czbm3: '',
        czbm4: '',
        jgczry: '',
        jgczry2: '',
        jgczry3: '',
        jgczry4: ''
      },
      disposeForm: {
        rzsj: '',
        gdlx: '',
        rzyj: '',
        rzbm: '',
        slry: '',
        lczt: '',
        shsx: '',
        bhyy: '',
        lcid: '',
        rzbmName: '',
        rzryName: '',
        rzslry: '',
        rzslryOld: '', // 初始的受理人员
        slbm: '', // 部门
        // 抢维修
        qwxTime: undefined, // 抢维修时间
        startTime: '', // 开始时间
        endTime: '', // 结束时间
        orderSource: '', // 工单来源 字典编码表,0计划、1自建、2热线
        typeId: '', // 维修类型,关联表TF_YWPN_REPAIRTYPE_D的关键值,查询维修类型
        respUser: '', // 维修人ID,主要负责人,查询维修人员接口
        // isLeak: '',
        /**
         * @isRealLeak 是否为真实漏点
         */
        isRealLeak: '', // 是否为真实漏点
        /**
         * @predictLeakWater 预估漏损水量
         */
        predictLeakWater: undefined // 预估漏损水量
      },
      acceptanceDepartments: [],
      acceptanceDepartments_zp: [], // 转派部门列表
      allLcjd: '',
      menuId: '',
      tableData: [],
      isDisable: true,
      files: [],
      indexNum: 0,
      // 人员
      receiver: [],
      receiver_zp: [], // 转派时的人员
      receivers_zp: [], // 转派时保存的所有人员
      receivers: [],
      flows: [
        {
          cname: '本环节',
          id: 51
        },
        {
          cname: '下一环节',
          id: 52
        },
        {
          cname: '驳回',
          id: 53
        },
        {
          cname: '转派',
          id: 70
        }
      ],
      editData: {},
      dialogVisible: false,
      rejectedList: [],
      sendRecordList: [],
      Name: '审核',
      bhjl: [],
      zpjl: [],
      difference: false,
      fileList: [],
      clhjr: '',
      clhjrList: [],
      lcjdParams: {
        stopFlag: false, // 是否为最后一个节点
        zrjrFlag: false, // 转出外部流程(抢维修)
        lastLcjd: '', // 最后一个流程节点
        transferOutType: '', // 抢维修类型
        currentFlow: '2' // 当前步骤:2
      },
      workflowQwx: {
        // 抢维修
        slbm: '', // 部门编码
        slbmName: '', // 部门名称
        qwxTime: undefined, // 抢维修时间
        startTime: '', // 开始时间
        endTime: '', // 结束时间
        orderSource: '1', // 工单来源 字典编码表,0计划、1自建、2热线
        typeId: '', // 维修类型,关联表TF_YWPN_REPAIRTYPE_D的关键值,查询维修类型
        respUser: '', // 维修人ID,主要负责人,查询维修人员接口
        phone: '' // 受理人电话
      }
    }
  },
  computed: {
    // getFlows() {
    //   return this.disposeForm.lczt
    // }
  },
  watch: {
    // getFlows(val) {
    //   if (val === 70) {
    //     this.disposeForm.slry = ''
    //     getPersonnel({ ids: 2002, departmentId: this.data.slbm }).then(res => {
    //       this.receiver = res.result.filter(v => {
    //         return v.id !== this.data.slry
    //       })
    //     })
    //   } else {
    //     // this.getReceiver()
    //   }
    // }
  },
  created() {
    const that = this
    const data = JSON.parse(JSON.stringify(this.data))
    this.difference = JSON.stringify(this.data) !== '{}'
    if (this.difference) {
      if (this.data.lcjdName !== '认证处置' || this.disabled) {
        this.isLcjd = false
      }
    }
    const datas = {
      gdbh: this.data.gdbh
    }
    getRejectList(datas).then((res) => {
      const list = res.result.records
      if (list.length !== 0) {
        this.rejectedList = list.map((val, index) => {
          return { ...val, index: index + 1 }
        })
      }
      this.bhjl = []
      for (const i in this.rejectedList) {
        if (this.rejectedList[i].lcjd == '认证处置') {
          this.bhjl.push(this.rejectedList[i])
        }
      }
    })
    getRedeploy(datas).then(res => {
      const list = res.result.records
      if (list.length !== 0) {
        this.sendRecordList = list.map((val, index) => {
          return { ...val, index: index + 1 }
        })
      }
      this.zpjl = []
      for (const i in this.sendRecordList) {
        if (this.sendRecordList[i].lcjd == '认证处置') {
          this.zpjl.push(this.sendRecordList[i])
        }
      }
    })
    console.log(this.zpjl, '认证处置')
    console.log(data)
    Object.keys(this.disposeForm).forEach(key => {
      if (key == 'shsx') {
        // 受理时限 => 受节点影响自动判断
        const allLcjdAry = this.data['allLcjd'].split(',')
        if (allLcjdAry.indexOf('3') > 0) {
          this.disposeForm[key] = this.data['shsx']
        } else if (allLcjdAry.indexOf('4') > 0) {
          this.disposeForm[key] = this.data['zjsx']
        } else if (allLcjdAry.indexOf('5') > 0) {
          this.disposeForm[key] = this.data['czsx']
        }
      } else if (key == 'predictLeakWater' || key == 'isRealLeak' || key == 'isRealLeakName') {
        // 漏点处理
        if (key == 'predictLeakWater') {
          this.disposeForm[key] = data.leakInfo?.estimatedWaterLoss
        }
        if (key == 'isRealLeak') {
          this.disposeForm[key] = data.leakInfo?.isReal
          this.disposeForm['isRealLeakName'] = data.leakInfo?.isReal == '1' ? '真实漏点' : '非漏点'
        }
      } else {
        this.disposeForm[key] = data[key]
      }
    })
    if (!this.disposeForm.lczt) {
      this.disposeForm.lczt = 52
    }
    const _allLcjd = this.data.allLcjd

    this.allLcjd = _allLcjd.split(',')
    this.getallLcjd()
    getById({ id: data.lcid, node: 6 }).then(res => {
      console.log('123123123213213', this.allLcjd)
      const result = res.result
      // let node = ''
      if (this.disabled) {
        this.srcListsrc = []
        const arr = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', '.tiff']
        var token = that.$store.state.user.token
        if (!this.arrayIsNull(this.data.gddjFiles)) {
          console.log('文件:', JSON.stringify(this.data.gddjFiles))

          for (const i in this.data.gddjFiles) {
            var fileModel = this.data.gddjFiles[i]
            const esuffixt = fileModel.fileFormat
            const es = fileModel.filePath
            // if(esuffixt == '.amr'){
            //   const audioPath = `${IP}/base/file/loadAudio?remotePath=${es}&access_token=${token}`
            //   this.audioFileList.push(audioPath)
            // }else

            // esuffixt === '.jpeg' || esuffixt === '.png' || esuffixt === '.jpg'
            if (arr.includes(esuffixt)) {
              const imagePath = `${IP}/base/file/loadImg?remotePath=${es}&access_token=${token}`
              this.ImgUrlList.push(imagePath)
            } else {
              this.fileListF.push({
                url: es,
                name: fileModel.fileName,
                urlName: fileModel.filePath,
                id: fileModel.id,
                fileFormat: fileModel.fileFormat
              })
            }
          }
        }
      }
      const deWeightThree1 = () => {
        const map = new Map()
        for (const item of result.gdpersonList) {
          if (!map.has(item.departId)) {
            map.set(item.departId, item)
          }
        }
        return [...map.values()]
      }
      // if (result.gdpersonList.length > 0) { // 如果该工单细分下分配了处理人员,则部门下拉列表则使用处理人员的部门,如果没有分配处理人员,则使用该工单类型所属的部门
      //   this.acceptanceDepartments = deWeightThree1()// deWeightThree1()// result.gddepartmentList
      //   // this.acceptanceDepartments_zp = deWeightThree1()
      // } else {
      //   this.acceptanceDepartments = result.gddepartmentList// deWeightThree1()// result.gddepartmentList
      //   // this.acceptanceDepartments_zp = result.gddepartmentList
      // }
      // this.acceptanceDepartments = result.gddepartmentList
      // this.acceptanceDepartments_zp = result.gddepartmentList
      // this.Bmchange_zp()
      // for (const i in this.allLcjd) {
      //   if (this.allLcjd[i] == 2) {
      //     if (this.allLcjd[Number(i) + 1]) {
      //       node = this.allLcjd[Number(i) + 1]
      //     }
      //   }
      // }

      this.acceptanceDepartments = result.gddepartmentList

      if (result.gdpersonList[0]) {
        var arr = []
        for (const i in result.gdpersonList) {
          if (Number(result.gdpersonList[i].node) == Number(this.allLcjd)) {
            arr.push(result.gdpersonList[i])
          }
        }
        this.receivers = arr
      }
      this.isDisable = true
      switch (this.allLcjd) {
        case '2':
          this.Name = '处置'
          break
        case '3':
          this.Name = '审核'
          break
        case '4':
          this.Name = '质检'
          break
        case '5':
          this.Name = '处置'
          break
        case '6':
          this.Name = '审核'
          break
        default:
          this.Name = '处置'
      }
      if (this.allLcjd == 5) {
        // 下一阶段为结果处置
        this.isJgcz = true
        const departArr = []
        for (const i in result.gdpersonList) {
          if (result.gdpersonList[i].node == 5) {
            departArr.push({
              departId: result.gdpersonList[i].departId,
              departName: result.gdpersonList[i].departName
            })
          }
        }
        const deWeightThree = () => {
          const map = new Map()
          for (const item of departArr) {
            if (!map.has(item.departId)) {
              map.set(item.departId, item)
            }
          }
          return [...map.values()]
        }
        const newDepartArr = deWeightThree()
        // 当结果处置配置了处理人员时
        if (newDepartArr[0]) {
          this.acceptanceDepartments = newDepartArr
        }
        // else {
        //   this.acceptanceDepartments = this.acceptanceDepartment
        //   for (const i in this.acceptanceDepartments) {
        //     this.acceptanceDepartments[i].departId = this.acceptanceDepartments[i].id
        //     this.acceptanceDepartments[i].departName = this.acceptanceDepartments[i].name
        //   }
        // }
        console.log(newDepartArr, 'newDepartArr')
        if (!this.arrayIsNull(this.data.resultList)) {
          let departmentArr = []
          const UsermentArr = []
          for (const i in this.data.resultList) {
            departmentArr.push(this.data.resultList[i].departId)
            UsermentArr.push(this.data.resultList[i].personId)
          }
          const deWeightThree = () => {
            const map = new Map()
            for (const item of departmentArr) {
              if (!map.has(item.departId)) {
                map.set(item.departId, item)
              }
            }
            return [...map.values()]
          }
          departmentArr = deWeightThree()
          this.disposeForm.rzbm = departmentArr
          this.Bmchange()
          // this.Bmchange_zp()
          this.disposeForm.rzslry = UsermentArr
          this.slryChange()
          this.clhjr = this.data.slryName
          this.isDisable = false
        } else {
          this.disposeForm.rzbm = data.rzbm ? [data.rzbm] : []
          this.Bmchange()
          // this.Bmchange_zp()
          this.disposeForm.rzslry = data.rzslry ? [data.rzslry] : []
          this.slryChange()
          this.clhjr = data.rzslry
        }
      } else {
        this.isJgcz = false
        // if (this.disabled) {
        //   this.disposeForm.rzbm = data.rzbmName
        //   this.disposeForm.rzslry = data.rzslryName
        //   this.clhjr = data.rzslryName
        // } else {
        this.disposeForm.rzbm = data.rzbm ? data.rzbm : ''
        this.Bmchange()
        // this.Bmchange_zp()
        this.disposeForm.rzslry = data.rzslry ? data.rzslry : ''
        // }
      }
      // 下一阶段为结果审核
      if (this.allLcjd == 6) {
        this.isJgsh = true
        const departArr = []
        for (const i in result.gdpersonList) {
          if (result.gdpersonList[i].childNode == 1 && result.gdpersonList[i].node == 6) {
            departArr.push({
              departId: result.gdpersonList[i].departId,
              departName: result.gdpersonList[i].departName
            })
          }
        }
        const deWeightThree = () => {
          const map = new Map()
          for (const item of departArr) {
            if (!map.has(item.departId)) {
              map.set(item.departId, item)
            }
          }
          return [...map.values()]
        }
        const newDepartArr = deWeightThree()
        // 当结果审核配置了处理人员时
        if (newDepartArr[0]) {
          this.acceptanceDepartments = newDepartArr
        }
        // else {
        //   this.acceptanceDepartments = this.acceptanceDepartment
        //   for (const i in this.acceptanceDepartments) {
        //     this.acceptanceDepartments[i].departId = this.acceptanceDepartments[i].id
        //     this.acceptanceDepartments[i].departName = this.acceptanceDepartments[i].name
        //   }
        // }
        // 审批等级中人员部门名单
        this.BmSplist1 = []
        this.RySplist1 = []
        this.BmSplist2 = []
        this.RySplist2 = []
        this.BmSplist3 = []
        this.RySplist3 = []
        this.BmSplist4 = []
        this.RySplist4 = []
        for (const i in result.gdpersonList) {
          if (result.gdpersonList[i].childNode == 1 && result.gdpersonList[i].node == 6) {
            this.BmSplist1.push({
              id: result.gdpersonList[i].departId,
              name: result.gdpersonList[i].departName
            })
            const deWeightThree = () => {
              const map = new Map()
              for (const item of this.BmSplist1) {
                if (!map.has(item.id)) {
                  map.set(item.id, item)
                }
              }
              return [...map.values()]
            }
            this.BmSplist1 = deWeightThree()
            this.RySplist1.push(result.gdpersonList[i])
          }
        }
        for (const i in result.gdpersonList) {
          if (result.gdpersonList[i].childNode == 2 && result.gdpersonList[i].node == 6) {
            this.BmSplist2.push({
              id: result.gdpersonList[i].departId,
              name: result.gdpersonList[i].departName
            })
            const deWeightThree = () => {
              const map = new Map()
              for (const item of this.BmSplist2) {
                if (!map.has(item.id)) {
                  map.set(item.id, item)
                }
              }
              return [...map.values()]
            }
            this.BmSplist2 = deWeightThree()
            this.RySplist2.push(result.gdpersonList[i])
          }
        }
        for (const i in result.gdpersonList) {
          if (result.gdpersonList[i].childNode == 3 && result.gdpersonList[i].node == 6) {
            this.BmSplist3.push({
              id: result.gdpersonList[i].departId,
              name: result.gdpersonList[i].departName
            })
            const deWeightThree = () => {
              const map = new Map()
              for (const item of this.BmSplist3) {
                if (!map.has(item.id)) {
                  map.set(item.id, item)
                }
              }
              return [...map.values()]
            }
            this.BmSplist3 = deWeightThree()
            this.RySplist3.push(result.gdpersonList[i])
          }
        }
        for (const i in result.gdpersonList) {
          if (result.gdpersonList[i].childNode == 4 && result.gdpersonList[i].node == 6) {
            this.BmSplist4.push({
              id: result.gdpersonList[i].departId,
              name: result.gdpersonList[i].departName
            })
            const deWeightThree = () => {
              const map = new Map()
              for (const item of this.BmSplist4) {
                if (!map.has(item.id)) {
                  map.set(item.id, item)
                }
              }
              return [...map.values()]
            }
            this.BmSplist4 = deWeightThree()
            this.RySplist4.push(result.gdpersonList[i])
          }
        }
        if (!this.BmSplist1[0]) {
          this.BmSplist1 = this.acceptanceDepartments
          this.BmSplist1Sure = true
        }
        if (!this.BmSplist2[0]) {
          this.BmSplist2 = this.acceptanceDepartments
          this.BmSplist2Sure = true
        }
        if (!this.BmSplist3[0]) {
          this.BmSplist3 = this.acceptanceDepartments
          this.BmSplist3Sure = true
        }
        if (!this.BmSplist4[0]) {
          this.BmSplist4 = this.acceptanceDepartments
          this.BmSplist4Sure = true
        }
        // 审批链审批等级
        this.jgshCcjb = res.result.jgshCcjb
      } else {
        this.isJgsh = false
      }
    })
    getSelectBygdlx({ id: data.gdlx, xf1id: data.gdxf1, xf2id: data.gdxf2, node: 2 }).then(res => {
      const result = res.result
      const deWeightThree1 = () => {
        const map = new Map()
        for (const item of result.gdpersonList) {
          if (!map.has(item.departId)) {
            map.set(item.departId, item)
          }
        }
        return [...map.values()]
      }
      if (result.gdpersonList.length > 0) { // 如果该工单细分下分配了处理人员,则部门下拉列表则使用处理人员的部门,如果没有分配处理人员,则使用该工单类型所属的部门
        this.acceptanceDepartments_zp = deWeightThree1()// deWeightThree1()// result.gddepartmentList
      } else {
        this.acceptanceDepartments_zp = result.gddepartmentList// deWeightThree1()// result.gddepartmentList
      }
      if (result.gdpersonList[0]) {
        const UserData = []
        for (const i in result.gdpersonList) {
          if (result.gdpersonList[i].node == 2) { // node ==2为认证处置
            // result.gdpersonList.splice(i, 1)
            // delete result.gdpersonList[i]
            UserData.push(result.gdpersonList[i])
            // console.log(result.gdpersonList[i])
          }
          // var arr = [1, 2, 3, 5, 6, 7]
          // arr.splice(0, 3)
          // console.log(arr)
          // console.log(result.gdpersonList[i].node)
        }
        console.log(result.gdpersonList, 2, 'result.gdpersonListresult.gdpersonListresult.gdpersonListresult.gdpersonListresult.gdpersonList')
        this.receivers_zp = UserData.filter(v => {
          return v.personId !== this.data.slry
        })
        this.disposeForm.slry = ''
      }
      this.Bmchange_zp()
    })
    this.disposeForm.rzslryOld = data.rzslry || ''
    // }

    if (this.disposeForm.lczt !== 52) {
      this.disposeForm.lczt = 51
    }
    // this.getReceiver()

    if (data.files !== null) {
      this.fileList = data.files.map((v) => {
        return {
          id: v.id,
          name: v.fileName,
          url: v.filePath,
          createTime: v.createTime,
          createUserName: v.createUserName
        }
      })
      this.tableData = this.fileList
    }
    // 获取最后的流程编码
    this.lcjdParams.lastLcjd = this.removeLcjd(_allLcjd)
    this.lcjdParams.transferOutType = this.data.gdflowconfig.transferOutType
    this.setFlows()
    this.judgeZrjrFlag()

    // 赋值抢维修
    this.workflowQwx.slbm = data.slbm
    this.workflowQwx.slbmName = data.slbmName
    console.log(this.disposeForm.rzbm, 'wwwwwwwwwwwwwwwwwwwwwwwwwwwwwww')
  },
  methods: {
    getReceiver() {
      switch (this.allLcjd) {
        case '3':
          this.menuId = 2003
          break
        case '4':
          this.menuId = 2004
          break
        case '5':
          this.menuId = 2005
          break
        case '6':
          this.menuId = 4097
          break
        default:
          break
      }
      if (!this.strIsNull(this.menuId)) {
        if (this.disposeForm.rzbm) {
          getPersonnel({ ids: this.menuId, departmentId: this.disposeForm.rzbm }).then(res => {
            this.receiver = res.result
          })
        }
      }
    },
    Bmchange() {
      if (this.isJgcz) {
        if (!this.arrayIsNull(this.receivers)) {
          const arr = []
          for (const i in this.receivers) {
            for (const j in this.disposeForm.rzbm) {
              if (this.receivers[i].departId === this.disposeForm.rzbm[j]) {
                arr.push(this.receivers[i])
              }
            }
          }
          this.receiver = arr
        } else {
          const data = this.disposeForm.rzbm.join(',')
          this.getUserByDept(data)
        }
      } else {
        if (!this.arrayIsNull(this.receivers)) {
          const arr = []
          for (const i in this.receivers) {
            if (this.receivers[i].departId === this.disposeForm.rzbm) {
              arr.push(this.receivers[i])
            }
          }
          this.receiver = arr
        } else {
          this.getUserByDept(this.disposeForm.rzbm)
        }
      }
    },
    Bmchange_zp() {
      this.disposeForm.slry = ''
      // const data = this.disposeForm.slbm
      // this.getUserByDept_zp(data)
      if (this.isJgcz) {
        if (!this.arrayIsNull(this.receivers_zp)) {
          const arr = []
          for (const i in this.receivers_zp) {
            for (const j in this.disposeForm.slbm) {
              if (this.receivers_zp[i].departId === this.disposeForm.slbm[j]) {
                arr.push(this.receivers_zp[i])
              }
            }
          }
          this.receiver_zp = arr.filter(item => {
            return item.personId != this.data.slry
          })
        } else {
          const data = this.acceptanceDepartments_zp.map(item => {
            return item.departId
          }).join()
          this.getUserByDept_zp(data)
        }
      } else {
        if (!this.arrayIsNull(this.receivers_zp)) {
          const arr = []
          for (const i in this.receivers_zp) {
            if (this.receivers_zp[i].departId === this.disposeForm.slbm) {
              arr.push(this.receivers_zp[i])
            }
          }
          this.receiver_zp = arr.filter(item => {
            return item.personId != this.data.slry
          })
        } else {
          this.disposeForm.slbm = ''
          const data = this.acceptanceDepartments_zp.map(item => {
            return item.departId
          }).join()
          this.getUserByDept_zp(data)
        }
      }
    },
    BmSplist1Change() {
      if (this.BmSplist1Sure) {
        this.getUserByDeptSplist(this.auditForm.czbm, '1')
        // this.RySplist1 = arr
      } else {
        return
      }
    },
    BmSplist2Change() {
      if (this.BmSplist2Sure) {
        this.getUserByDeptSplist(this.auditForm.czbm2, '2')
        // this.RySplist2 = arr
      } else {
        return
      }
    },
    BmSplist3Change() {
      if (this.BmSplist3Sure) {
        this.getUserByDeptSplist(this.auditForm.czbm3, '3')
        // this.RySplist3 = arr
      } else {
        return
      }
    },
    BmSplist4Change() {
      if (this.BmSplist4Sure) {
        this.getUserByDeptSplist(this.auditForm.czbm4, '4')
        // this.RySplist4 = arr
      } else {
        return
      }
    },
    getUserByDeptSplist(data, name) {
      const datas = {
        depts: data
      }
      getUserByDepts(datas).then(res => {
        var arr = []
        for (const i in res.result) {
          const name = res.result[i].name
          for (const j in res.result[i].users) {
            res.result[i].users[j].personId = res.result[i].users[j].id
            res.result[i].users[j].personName = res.result[i].users[j].realName
            res.result[i].users[j].departId = res.result[i].users[j].departmentId
            res.result[i].users[j].departName = name
          }
        }
        for (const i in res.result) {
          for (const j in res.result[i].users) {
            arr.push(res.result[i].users[j])
          }
        }
        switch (name) {
          case '1':
            this.RySplist1 = arr
            break
          case '2':
            this.RySplist2 = arr
            break
          case '3':
            this.RySplist3 = arr
            break
          case '4':
            this.RySplist4 = arr
            break
        }
        console.log(this.RySplist1, this.RySplist2, this.RySplist3, this.RySplist4)
        // return arr
      })
    },
    getUserByDept(datas) {
      const data = {
        depts: datas
      }
      getUserByDepts(data).then(res => {
        var arr = []
        for (const i in res.result) {
          var name = res.result[i].name
          for (const j in res.result[i].users) {
            res.result[i].users[j].personId = res.result[i].users[j].id
            res.result[i].users[j].personName = res.result[i].users[j].realName
            res.result[i].users[j].departId = res.result[i].users[j].departmentId
            res.result[i].users[j].departName = name
          }
        }
        for (const i in res.result) {
          for (const j in res.result[i].users) {
            arr.push(res.result[i].users[j])
          }
        }
        this.receiver = arr
      })
    },
    getUserByDept_zp(datas) {
      const data = {
        depts: datas
      }
      getUserByDepts(data).then(res => {
        var arr = []
        for (const i in res.result) {
          var name = res.result[i].name
          for (const j in res.result[i].users) {
            res.result[i].users[j].personId = res.result[i].users[j].id
            res.result[i].users[j].personName = res.result[i].users[j].realName
            res.result[i].users[j].departId = res.result[i].users[j].departmentId
            res.result[i].users[j].departName = name
          }
        }
        for (const i in res.result) {
          for (const j in res.result[i].users) {
            arr.push(res.result[i].users[j])
          }
        }
        this.receiver_zp = arr.filter(v => {
          return v.personId !== this.data.slry
        })
        this.receivers_zp = arr
      })
    },
    slryChange() {
      if (this.isJgcz) {
        var arr = []
        console.log(this.disposeForm.rzslry, this.receiver, '12333333333333333333333')
        for (const i in this.disposeForm.rzslry) {
          for (const j in this.receiver) {
            if (this.receiver[j].personId === this.disposeForm.rzslry[i]) {
              arr.push(this.receiver[j])
            }
          }
        }
        this.clhjrList = arr
        this.clhjr = this.disposeForm.rzslry[0]
      }
    },
    getallLcjd() {
      for (let index = 0; index < this.allLcjd.length; index++) {
        if (this.allLcjd[index] > 2) {
          this.allLcjd = this.allLcjd[index]
          return
        }
      }
    },
    handleClick(row) {
      window.open(
        `${IP}/base/file/downloadFile?fileName=${row.name}&remotePath=${row.urlName}&access_token=${this.$store.state.user.token}`
      )
    },
    JgshMothed(data) {
      this.JgshData = data
      this.dialogFormVisible = true
      this.auditForm.czbm = this.disposeForm.rzbm
      this.BmSplist1Change()
    },
    // 提交
    submitForm: _throttle(function() {
      this.$refs.disposeForm.validate((valid) => {
        if (valid) {
          const _this = this
          const rzFileid = []
          let data = {}
          _this.fileList.forEach((v) => {
            if (!_this.strIsNull(v.id)) {
              rzFileid.push(v.id)
            }
          })

          switch (_this.disposeForm.lczt) {
            // 下个环节
            case 52:
              data = {
                id: _this.data.id,
                rzyj: _this.disposeForm.rzyj,
                rzbm: _this.disposeForm.rzbm,
                gdlx: _this.data.gdlx,
                rzslry: _this.disposeForm.rzslry || '',
                lczt: _this.disposeForm.lczt,
                processDeposit: _this.data.processDeposit,
                lcid: _this.disposeForm.lcid,
                rzFileid: rzFileid.toString()
              }
              if (_this.lcjdParams.zrjrFlag) {
                data.startTime = _this.workflowQwx.startTime
                data.endTime = _this.workflowQwx.endTime
                data.orderSource = _this.workflowQwx.orderSource
                data.typeId = _this.workflowQwx.typeId
                data.respUser = _this.workflowQwx.respUser
                data.phone = _this.workflowQwx.phone
              } else {
                data.startTime = ''
                data.endTime = ''
                data.orderSource = ''
                data.typeId = ''
                data.respUser = ''
                data.phone = ''
              }
              // eslint-disable-next-line no-case-declarations
              const resultdispList = []
              if (this.disposeForm.lczt === 52) {
                if (this.isJgcz) {
                  if (!this.clhjr) {
                    this.$message.error('请选择处置汇集人')
                    return
                  }
                  for (const i in this.receiver) {
                    for (const j in this.disposeForm.rzslry) {
                      if (this.receiver[i].personId === this.disposeForm.rzslry[j]) {
                        resultdispList.push({
                          departId: this.receiver[i].departId,
                          departName: this.receiver[i].departName,
                          personId: this.receiver[i].personId,
                          personName: this.receiver[i].personName,
                          isCollect: 0
                        })
                      }
                    }
                  }
                  for (const i in resultdispList) {
                    if (resultdispList[i].personId === this.clhjr) {
                      resultdispList[i].isCollect = 1
                      _this.disposeForm.rzslry = resultdispList[i].personId
                      // 重置审核人员
                      _this.disposeForm.rzbm = resultdispList[i].departId
                      //
                    }
                    data['resultdispList[' + i + '].departId'] = resultdispList[i].departId
                    data['resultdispList[' + i + '].departName'] = resultdispList[i].departName
                    data['resultdispList[' + i + '].personId'] = resultdispList[i].personId
                    data['resultdispList[' + i + '].personName'] = resultdispList[i].personName
                    data['resultdispList[' + i + '].isCollect'] = resultdispList[i].isCollect
                    // data.resultdispList = resultdispList
                  }
                  // this.checkForm.rzslry = this.checkForm.shbm = ''
                }
              }

              switch (_this.allLcjd) {
                case '4':
                  data.shslry = _this.disposeForm.rzslry || ''
                  break
                case '5':
                  data.zjczry = _this.disposeForm.rzslry || ''
                  break
                case '6':
                  data.jgczry = _this.disposeForm.rzslry || ''
                  break
                default:
                  break
              }
              break
            // 驳回
            case 53:
              data = {
                id: _this.data.id,
                gdlx: _this.data.gdlx,
                gdbh: _this.data.gdbh,
                bhyy: _this.disposeForm.bhyy,
                lcjd: _this.data.lcjd,
                lcid: _this.disposeForm.lcid,
                lczt: _this.disposeForm.lczt,
                processDeposit: _this.data.processDeposit
              }
              break
            // 转派
            case 70:
              data = {
                gdbh: _this.data.gdbh,
                gdlx: _this.data.gdlx,
                slry: _this.disposeForm.slry,
                lcjd: _this.data.lcjd,
                id: _this.data.id,
                lcid: _this.disposeForm.lcid,
                lczt: _this.disposeForm.lczt, // 流程状态
                zpyj: _this.disposeForm.zpyj, // 转派原因
                processDeposit: _this.data.processDeposit
              }
              break
            // 51  本环节
            default:
              data = {
                id: _this.data.id,
                gdlx: _this.data.gdlx,
                lcid: _this.disposeForm.lcid,
                rzyj: _this.disposeForm.rzyj,
                lczt: _this.disposeForm.lczt,
                processDeposit: _this.data.processDeposit,
                rzFileid: rzFileid.toString(),
                isLeak: _this.data.isLeak
              }
              break
          }

          if (_this.disposeForm.lczt !== 53 && _this.disposeForm.lczt !== 70 && _this.data.isLeak == 1) {
            const leakInfo = {
              // 漏点
              'leakInfo.isReal': _this.disposeForm.isRealLeak,
              'leakInfo.estimatedWaterLoss': _this.disposeForm.predictLeakWater
            }
            if (_this.disposeForm.isRealLeak == '1') {
              // 漏点
              data.isLeak = '1'
            } else if (_this.disposeForm.isRealLeak == '2') {
              // 非漏点
              data.isLeak = '0'
            }
            Object.assign(data, leakInfo)
          }

          if (this.isJgsh && this.disposeForm.lczt == 52) {
            // this.JgshMothed(data)
            data['audit.auditUser'] = _this.disposeForm.rzslry
          }
          const datas = new FormData()
          Object.keys(data).forEach((key) => {
            datas.append(key, data[key])
          })
          if (this.files.length > 0) {
            for (let i = 0; i < this.files.length; i++) {
              console.log('附件:' + i)
              const _file = _this.files[i]
              if (!_this.strIsNull(_file) && _this.strIsNull(_file.id)) {
                datas.append('fileList', _this.files[i])
              }
            }
          }

          // console.log("认证处置:"+ JSON.stringify(_this.disposeForm))
          // return false
          //  else {
          editHandle(datas).then((res) => {
            if (res.code === 1) {
              _this.$message.success('处理成功')
              this.dialogFormVisible = false
              _this.$emit('remind', '成功')
            }
          })
          // }
          return true
        } else {
          return false
        }
      })
    }, 5000),

    /* --------------------- 附件上传 ----------------*/
    handleRemove(file, fileList) {
      console.log('文件列表移除文件时的钩子', file, fileList)
      const files = fileList.map((v) => {
        return v.raw
      })
      this.files = files
      this.fileList = fileList
    },
    handlePreview(file) {
      console.log('点击文件列表中已上传的文件时的钩子', file)
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件,本次选择了 ${files.length
        } 个文件,共选择了 ${files.length + fileList.length} 个文件`
      )
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}?`)
    },
    onBeforeUpload(file) {
      // const isIMAGE = file.type === 'image/jpeg' || file.type === 'image/png';
      const isLt1M = file.size / 1024 / 1024 < 10

      // if (!isIMAGE) {
      // 	this.$message.error('上传文件只能是图片格式!');
      // }
      if (!isLt1M) {
        this.$message.error('上传文件大小不能超过 10MB!')
      }
      // return isIMAGE && isLt1M;
      return isLt1M
    },
    // 上传之前的钩子函数
    beforeAvatarUpload(response, file, fileList) {
      console.log(response, file)
      var isTrue = this.onBeforeUpload(response.raw)
      if (isTrue) {
        this.fileMap(file)
      } else {
        file.pop()
      }
    },
    fileMap(file) {
      if (file.length !== 0) {
        const files = file.map((v) => {
          return v.raw
        })
        this.files = files
      }
    },
    handleAvatarSuccess(res, file, fileList) {
      console.log('文件上传成功时的钩子', res, file, fileList)
    },

    /**
     * @description 流程状态 值 改变事件
     */
    gddjZtChange() {
      this.judgeZrjrFlag()
    },
    saveAuditChain() {
      this.$refs.auditForm.validate((valid) => {
        if (valid) {
          const data = {
            auditList: [
              {
                auditLevel: 0,
                // auditPlanId: planId,
                // auditType: '12',
                auditUser: this.auditForm.jgczry
              },
              {
                auditLevel: 1,
                // auditPlanId: planId,
                // auditType: '12',
                auditUser: this.auditForm.jgczry2
              },
              {
                auditLevel: 2,
                // auditPlanId: planId,
                // auditType: '12',
                auditUser: this.auditForm.jgczry3
              },
              {
                auditLevel: 3,
                // auditPlanId: planId,
                // auditType: '12',
                auditUser: this.auditForm.jgczry4
              }
            ]
          }

          // 判断审批人员是否相同
          const auditUserAry = []
          if (!this.strIsNull(this.auditForm.jgczry)) {
            auditUserAry.push(this.auditForm.jgczry)
          }
          if (!this.strIsNull(this.auditForm.jgczry2)) {
            auditUserAry.push(this.auditForm.jgczry2)
          }
          if (!this.strIsNull(this.auditForm.jgczry3)) {
            auditUserAry.push(this.auditForm.jgczry3)
          }
          if (!this.strIsNull(this.auditForm.jgczry4)) {
            auditUserAry.push(this.auditForm.jgczry4)
          }

          if (new Set(auditUserAry).size !== auditUserAry.length) {
            this.$message.error('多级审核时,每级审核人员不能重复!')
            return false
          }

          data.auditList = data.auditList.slice(0, this.jgshCcjb)
          console.log('新增审批链' + JSON.stringify(data))
          const auditList = data.auditList
          // return false;
          // this.JgshData.auditList = auditUserAry
          for (const i in auditList) {
            console.log(auditList[i], 'auditUserAry[i].auditLevel')
            this.JgshData['auditList[' + i + '].auditLevel'] = auditList[i].auditLevel
            this.JgshData['auditList[' + i + '].auditUser'] = auditList[i].auditUser
          }
          const formData = new FormData()
          Object.keys(this.JgshData).forEach((key) => {
            formData.append(key, this.JgshData[key])
          })
          if (this.files.length > 0) {
            for (let i = 0; i < this.files.length; i++) {
              console.log('附件:' + i)
              const _file = this.files[i]
              if (!this.strIsNull(_file) && this.strIsNull(_file.id)) {
                formData.append('fileList', this.files[i])
              }
            }
          }
          editHandle(formData).then((res) => {
            if (res.code === 1) {
              this.$message.success('处理成功')
              this.dialogFormVisible = false
              this.$emit('remind', '成功')
            }
          })
        } else {
          this.$message.warning('请完善工单信息!')
          return false
        }
      })

      // if (!this.difference) {
      //   this.newAddUser(formData)
      // } else {
      //   this.editSubmit(formData)
      // }
    },
    /**
     * @description 判断当前流程是否为最后一个节点,是否增加流程处置下拉
     */
    setFlows() {
      if (this.lcjdParams.lastLcjd === this.lcjdParams.currentFlow &&
        this.strIsNull(this.lcjdParams.transferOutType)
      ) {
        // this.flows =  this.flows.filter(function(flow){
        //   return flow.id !== 52
        // })
        // this.flows.push({ cname:'终止',id:54 })
        this.flows = this.flows.map(function(flow) {
          if (flow.id === 52) { flow.cname = '终止' }
          return flow
        })
      }
    },

    /**
     * @description 是否属于终止节点
     */
    existStop() {
      const lczt = this.disposeForm.lczt
      this.lcjdParams.stopFlag = false
      if (lczt === 51 || lczt === 53 || lczt === 70) {
        this.lcjdParams.stopFlag = true
      } else if (this.lcjdParams.zrjrFlag === true && lczt === 52) {
        this.lcjdParams.stopFlag = true
      } else if (this.lcjdParams.lastLcjd === this.lcjdParams.currentFlow &&
        lczt === 52 &&
        this.lcjdParams.zrjrFlag === false) {
        this.lcjdParams.stopFlag = true
      }

      console.log('测试:' + this.lcjdParams.stopFlag)
    },

    /**
     * @description 判断是否暂时外部流程(抢维修)
     */
    judgeZrjrFlag() {
      this.lcjdParams.zrjrFlag = false
      // 判断是否应该显示抢维修流程
      if (this.activeNames == this.lcjdParams.lastLcjd &&
        this.disabled === false &&
        this.disposeForm.lczt === 52) {
        if (!this.strIsNull(this.lcjdParams.transferOutType)) {
          this.lcjdParams.zrjrFlag = true
        }
      }
      this.existStop()
    },

    /**
     * @description 获取当前流程的最后一个节点
     */
    removeLcjd(lcjdStr) {
      let lastLcjd = '' // 最后一个流程节点

      var lcjdAry = lcjdStr.split(',')
      // 去除最后节点 6 和 7
      var newLcjd = lcjdAry.filter(function(value, index) {
        return value != '7'
      })

      // 返回最后一个节点
      if (newLcjd.length > 0) {
        lastLcjd = newLcjd.pop()
      }
      console.log('新数组:' + lastLcjd)

      return lastLcjd
    },

    /**
     * @description 判断数组是否为空
     */
    arrayIsNull(aryList) {
      return (typeof (aryList) === 'undefined' || aryList == null || aryList.length == 0)
    },

    /**
     * @description 判断字符串是否为空
     */
    strIsNull(strVal) {
      strVal = strVal || ''
      return (typeof (strVal) === 'undefined' || strVal == null || strVal == '')
    },

    /**
     * @description 抢维修子组件赋值
     */
    propSetQwxData(data) {
      // data就是子组件传过来的值
      console.log('子组件参数变化: ', JSON.stringify(data))
      this.workflowQwx = data

      // 给表单赋值
      this.disposeForm.qwxTime = this.workflowQwx.qwxTime
      this.disposeForm.startTime = this.workflowQwx.startTime
      this.disposeForm.endTime = this.workflowQwx.endTime
      this.disposeForm.orderSource = this.workflowQwx.orderSource
      this.disposeForm.typeId = this.workflowQwx.typeId
      this.disposeForm.respUser = this.workflowQwx.respUser
    },
    // 折叠面板
    closeTab(val) {
      this.activeName = val
    }
  }

}
</script>

<style lang="scss" scoped>
#handle_merge {
  .wrap {
    border: 1px solid rgba(57, 153, 243, 0.15);

    >>>.el-collapse-item__header {
      background: rgba(57, 153, 243, 0.15);
      font-size: 15px;
      height: 40px;
      line-height: 40px;
      color: rgb(28, 105, 229);
      padding-left: 15px;
      // text-indent: 15px;
      font-weight: 600;
      // .el-collapse-item__arrow{
      //   margin:0 9px 12px auto;
      // }
    }
  }

  .NBjd {
    >>>.el-collapse-item__header {
      background: rgb(240, 240, 240);
      color: black;
    }
  }

  .dialog_style {
    width: 100%;
    overflow-y: auto;

    /deep/ .el-table {
      text-align: center;
      vertical-align: middle;
    }
  }

  /deep/ .el-form-item {
    margin-bottom: 5px;
  }

  /deep/ .el-collapse-item__wrap {
    margin-top: 10px;
  }
}

.is-disabled>>>.el-input__inner {
  background: white;
  border: none;
  font-size: 14px;
  color: black;
  cursor: default;
  padding: 0;
}

.is-disabled>>>.el-textarea__inner {
  background: white;
  border: none;
  font-size: 14px;
  color: black;
  cursor: default;
  padding: 0;
}

/deep/ .el-upload {
  justify-content: flex-start;
}
</style>

<style lang="scss">
.Bhclass {
  display: flex;
  justify-content: center;
  align-items: center;
  // img{
  //   height: 200%;
  // }
}

.colflexS {
  display: flex;
  align-items: center;
  // justify-content: center;
}
</style>