<template>
  <view :class="isUps == true ? 'prevent' : ''">
    <cu-custom bgColor="bg-gradual-blueness" :isBack="true">
      <block slot="backText">返回</block>
      <block slot="content">隐患登记</block>
    </cu-custom>
    <scroll-view scroll-y="false">
      <view class="form">
        <view class="cu-form-group">
          <view class="title asterisk">检查内容</view>
          <picker
              @change="fireDeviceTypeChange"
              :value="pd.CHECK_CONTENT"
              :range="fireDeviceTypeList"
              range-key="FIRE_CHECK_STANDARD_ITEM"
          >
            <view class="picker">
              {{ pd.CHECK_CONTENT || '请选择' }}
            </view>
          </picker>
        </view>
        <view class="cu-bar bg-white margin-top">
          <view class="action" style="font-size: 28upx; font-weight: bold; color: #000;">
            隐患照片
          </view>
          <view class="action">
            {{ imgList.length }}/4
          </view>
        </view>
        <view class="cu-form-group">
          <view class="grid col-4 grid-square flex-sub">
            <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" data-type="0"
                  :data-url="imgList[index].filePath">
              <image :src="imgList[index].filePath" mode="aspectFill"></image>
              <view class="cu-tag bg-red" @tap.stop="DelImg" data-type="0" :data-index="index">
                <text class='cuIcon-close'></text>
              </view>
            </view>
            <view class="solids" @tap.stop="openAuth('CAMERA')" v-if="imgList.length<4">
              <text class='cuIcon-cameraadd'></text>
            </view>
          </view>
        </view>
        <view class="ai_btn ">
          <view class="ai_btn_con" @click="$noMultipleClicks(goIdentifyImg)">
            <image src="../../../../static/ai_img.png" style="width: 16px;height: 16px"/>
            <view class="text" style="margin-left: 5px;"> AI隐患识别与处置</view>
          </view>
        </view>
        <view class="cu-bar bg-white">
          <view class="action">
            隐患视频
          </view>
          <view class="action">
            {{ videoList.length }}/1
          </view>
        </view>
        <view class="cu-form-group">
          <view class="grid col-4 grid-square flex-sub">
            <view class="bg-img" v-for="(item,vindex) in videoList" :key="vindex" style="background-color: #000">
              <image src="/static/icon-apps/video.png" mode="aspectFill" @click="playVideo"
                     :data-src="videoList[vindex].filePath"></image>
              <view class="cu-tag bg-red" @tap.stop="DelVideo" data-type="0" :data-index="vindex">
                <text class='cuIcon-close'></text>
              </view>
            </view>
            <view class="solids" @tap.stop="openAuthVideo('CAMERA')" v-if="videoList.length == 0">
              <text class='cuIcon-cameraadd'></text>
            </view>
          </view>
        </view>
        <view class="cu-form-textarea margin-top">
          <view class="cu-form-title">隐患描述</view>
          <textarea maxlength="-1" :disabled="modalName!=null" v-model="pd.HIDDENDESCR"
                    placeholder="请对隐患进行详细描述(必填项)"></textarea>
        </view>
        <view class="cu-form-textarea margin-top">
          <view class="cu-form-title">
            隐患部位
            <!--          <button class="cu-btn bg-green sm reg-btn" @click="openHidden" >隐患字典</button>-->
          </view>
          <textarea maxlength="-1" :disabled="modalName!=null" v-model="pd.HIDDENPART"
                    placeholder="请对隐患部位进行详细描述(必填项)"></textarea>
        </view>
        <view class="cu-form-group margin-top">
          <view class="title">隐患区域</view>
          <view class="picker-tree-box">
            <view class="picker-tree" @tap="showHiddenQyZgTree">
              {{ pd.HIDDEN_DANGER_AREA_NAME ? pd.HIDDEN_DANGER_AREA_NAME : '请选择' }}
            </view>
          </view>
          <tki-tree ref="tkiTreedd"
                    :selectParent=true
                    :range="treeNode"
                    rangeKey="name"
                    @confirm="zgtreeHiddenQy"
                    @cancel="zgtreeCancel"></tki-tree>
        </view>
        <view class="cu-form-group margin-top">
          <view class="title">隐患标签</view>
          <picker @change="hiddenDangerLabelPickerChange" :value="dangerLabellindex" :range="hiddenDangerLabelList"
                  range-key="NAME">
            <view class="picker">
              {{ pd.HIDDEN_DANGER_LABEL_NAME ? pd.HIDDEN_DANGER_LABEL_NAME : '请选择' }}
            </view>
          </picker>
        </view>
        <view class="cu-form-group margin-top">
          <view class="title">隐患分级</view>
          <picker @change="hiddenDangerClassificationPickerChange" :value="hiddenClassificationlindex"
                  :range="hiddenClassificationList" range-key="NAME">
            <view class="picker">
              {{ pd.HIDDEN_CLASSIFICATION_NAME ? pd.HIDDEN_CLASSIFICATION_NAME : '请选择' }}
            </view>
          </picker>
        </view>
        <view class="cu-form-group margin-top">
          <view class="title">隐患级别</view>
          <picker @change="levelPickerChange" :value="lindex" :range="levelList" range-key="NAME">
            <view class="picker">
              {{ pd.HIDDENLEVELNAME ? pd.HIDDENLEVELNAME : '请选择' }}
            </view>
          </picker>
        </view>
        <view class="cu-form-group margin-top">
          <view class="title">隐患类型</view>
          <view class="picker-tree-box">
            <view class="picker-tree" @tap="showZgTree1">{{ pd.HIDDENTYPENAME ? pd.HIDDENTYPENAME : '请选择' }}</view>
          </view>
          <tki-tree ref="tkiTree1"
                    :selectParent="true"
                    :range="hiddenTypeList"
                    rangeKey="name"
                    @confirm="zgtreeConfirm1"
                    @cancel="zgtreeCancel1"></tki-tree>
        </view>

        <view class="cu-form-group margin-top">
          <view class="title">是否立即整改</view>
          <radio-group class="selected">
            <view class="group mr20" v-if="disabledvalue==false">
              <radio class='radio' value="1" :checked="RECTIFICATIONTYPE==1" @click="radioType(1)"></radio>
              <text>是</text>
            </view>
            <view class="group mr20" v-if="disabledvalue==true">
              <radio class='radio' disabled="true" value="1" :checked="RECTIFICATIONTYPE==1"></radio>
              <text>是</text>
            </view>
            <view class="group">
              <radio class='radio' value="2" :checked="RECTIFICATIONTYPE==2" @click="radioType(2)"></radio>
              <text>否</text>
            </view>
          </radio-group>
        </view>

        <view class="cu-form-group margin-top" v-if="RECTIFICATIONTYPE==2">
          <view class="title">整改责任部门</view>
          <view class="picker-tree-box">
            <view class="picker-tree" @tap="showZgTree">
              {{ pd.RECTIFICATIONDEPTNAME ? pd.RECTIFICATIONDEPTNAME : '请选择' }}
            </view>
          </view>
          <tki-tree ref="tkiTree"
                    :selectParent=true
                    :range="treeNode"
                    rangeKey="name"
                    @confirm="zgtreeConfirm"
                    @cancel="zgtreeCancel"></tki-tree>
        </view>
        <view class="cu-form-group margin-top" v-if="RECTIFICATIONTYPE==2">
          <view class="title">整改责任人</view>
          <view style="position: relative">
            <view class="search-input">
              <input
                  type="text"
                  style="text-align: right"
                  v-model="searchRectificationUser"
                  placeholder="请输入整改责任人"
                  @input="filterRectificationUser"
                  @click="toggleRectifyDropdown"
              >
              <view class="search-icon" @click="toggleRectifyDropdown">
                <text class="cuIcon-right"></text>
              </view>
            </view>
            <view v-show="showRectifyDropdown" class="showbg" style="position: absolute; left: 0; top: 36px;">
              <view
                  v-for="(user, index) in filteredRectificationUsers"
                  :key="index"
                  @click="selectRectificationUser(user)"
              >
                {{ user.NAME }}
              </view>
            </view>
          </view>
        </view>
        <view class="cu-form-group margin-top" v-if="RECTIFICATIONTYPE==2">
          <view class="title">整改期限</view>
          <picker mode="date" :value="pd.RECTIFICATIONDEADLINE" :start="rectifyPlanCompletionStartTime"
                  @change="changeDate">
            <view class="picker">
              {{ pd.RECTIFICATIONDEADLINE ? pd.RECTIFICATIONDEADLINE : '请选择' }}
            </view>
          </picker>
        </view>

        <view class="cu-form-textarea margin-top" v-if="RECTIFICATIONTYPE==1">
          <view class="cu-form-title">整改描述</view>
          <textarea maxlength="-1" :disabled="modalName!=null" v-model="pd.RECTIFYDESCR"
                    placeholder="请对隐患进行整改描述(必填项)"></textarea>
        </view>
        <view class="cu-bar bg-white margin-top" v-if="RECTIFICATIONTYPE==1">
          <view class="action">
            整改后图片
          </view>
          <view class="action">
            {{ imgList1.length }}/4
          </view>
        </view>
        <view class="cu-form-group" v-if="RECTIFICATIONTYPE==1">
          <view class="grid col-4 grid-square flex-sub">
            <view class="bg-img" v-for="(item,index) in imgList1" :key="index" @tap="ViewImage" data-type="1"
                  :data-url="imgList1[index].filePath">
              <image :src="imgList1[index].filePath" mode="aspectFill"></image>
              <view class="cu-tag bg-red" @tap.stop="DelImg" data-type="1" :data-index="index">
                <text class='cuIcon-close'></text>
              </view>
            </view>
            <view class="solids" @tap.stop="openAuthZg('CAMERA')" v-if="imgList1.length<4">
              <text class='cuIcon-cameraadd'></text>
            </view>
          </view>
        </view>
        <view class="cu-form-group margin-top">
          <view class="title">隐患确认人部门</view>
          <view class="picker-tree-box">
            <view class="picker-tree" @tap="showQrTree">
              {{ pd.CONFIRM_DEPT_NAME ? pd.CONFIRM_DEPT_NAME : '请选择' }}
            </view>
          </view>
          <tki-tree ref="tkiTreeQr"
                    :selectParent=true
                    :range="treeNode"
                    rangeKey="name"
                    @confirm="fnHiddenConfirmDept"
                    @cancel="zgtreeCancel"></tki-tree>
        </view>
        <view class="cu-form-group margin-top">
          <view class="title">隐患确认人</view>
          <view style="position: relative">
            <view class="search-input">
              <input
                  type="text"
                  style="text-align: right"
                  v-model="searchConfirmUser"
                  placeholder="请输入确认人"
                  @input="filterConfirmUser"
                  @click="toggleConfirmDropdown"
              >
              <view class="search-icon" @click="toggleConfirmDropdown">
                <text class="cuIcon-right"></text>
              </view>
            </view>
            <view v-show="showAnalyzeDropdown" class="showbg" style="position: absolute; left: 0; top: 36px;">
              <view
                  v-for="(user, index) in filteredConfirmUsers"
                  :key="index"
                  @click="selectConfirmUser(user)"
              >
                {{ user.NAME }}
              </view>
            </view>
          </view>
        </view>
      </view>
      <view v-if="ISLOG == '0'" class="padding flex flex-direction">
        <button
            class="cu-btn bg-blue margin-tb-sm lg"
            @click="$noMultipleClicks(goSubmit)"
        >
          提交
        </button>
      </view>
    </scroll-view>
    <view :class="['cu-modal',{'show':modalShow}]" v-if="modalShow">
      <view class="cu-dialog">
        <view class="cu-bar bg-white justify-end">
          <view class="content">播放视频</view>
          <view class="action" @tap="modalShow = false">
            <text class="cuIcon-close text-red"></text>
          </view>
        </view>
        <video :src="videoSrc" :show-fullscreen-btn="false" :autoplay="true"
               @fullscreenchange="fullScreenHandler"></video>
        <view class="cu-bar bg-white justify-end">
          <view class="action">
            <button class="cu-btn line-green text-green" @click="modalShow = false">关闭</button>
          </view>
        </view>
      </view>
    </view>
    <library-select :visible.sync="library" :value="pd.HIDDENPART" :name="RISK_UNIT_NAME" @confirm="confirm"/>

    <yk-authpup ref="authpup" type="top" @changeAuth="ChooseImage(0)" :permissionID="permissionID"></yk-authpup>
    <yk-authpup ref="authpup_video" type="top" @changeAuth="chooseVideo(0)" :permissionID="permissionID"></yk-authpup>
    <yk-authpup ref="authpup_zg" type="top" @changeAuth="ChooseImage(1)" :permissionID="permissionID"></yk-authpup>
  </view>
</template>

<script>
import {
  baseImgPath,
  basePath,
  corpinfoId,
  deptId,
  formatDate,
  loginSession,
  loginUser
} from '@/common/tool.js'
import tkiTree from '@/components/select-tree/select-tree.vue'
import LibrarySelect from '@/components/library-select/index.vue';
import ykAuthpup from "@/components/yk-authpup/yk-authpup"

export default {
  components: {
    tkiTree, LibrarySelect, ykAuthpup
  },
  data() {
    return {
      permissionID: '',
      isUps: false,
      showRectifyDropdown: false,
      filteredRectificationUsers: [],
      searchRectificationUser: '',
      showAnalyzeDropdown: false,
      filteredConfirmUsers: [],
      searchConfirmUser: '',
      msg: 'fireAdd',
      width: '',
      height: '',
      ISLOG: '',
      RISK_UNIT_NAME: '',
      index: '',
      noClick: true,
      pd: {
        LISTMANAGER_ID: '',
        RISKITEM_ID: '',
        CHECKRECORD_ID: '',
        RECORDITEM_ID: '',
        RISK_UNIT: '',
        IDENTIFICATION: '',
        RECTIFICATIONTYPE: 2,
        DISCOVERYTIME: '',
        LATITUDE: '',
        LONGITUDE: '',
        ISRELEVANT: '1',
        conUserId: '',
        CHECK_CONTENT: -1
      },
      imgList: [],
      imgList1: [],
      HIDDENDESCR: '',//隐患描述
      HIDDENPART: '',//隐患部位
      modalName: null,
      id: '',
      CHECK_CONTENT: '',
      checkId: '',
      info_index: 0,
      RECTIFYDESCR: '',//整改描述
      RECTIFICATIONTYPE: 2,//是否立即
      ISRELEVANT: '2', //是否相关方
      treeNode: [], //部门下拉数据
      RECTIFICATIONDEPT: '',//整改部门
      RECTIFICATIONDEPTNAME: '请选择',//整改部门
      CHECKDEPT: '',//验收部门
      CHECKDEPTNAME: '请选择',//验收部门
      confirmDept: '',
      hregionDeptName: '请选择',
      CONFIRM_USER: "", // 隐患确认人
      CONFIRM_DEPT: "", // 隐患确认部门
      rectificationUserList: [],
      confirmUserList: [], // 隐患确认人
      RECTIFICATIONORNAME: loginUser.NAME, // 使用当前登录用户姓名
      RECTIFICATIONOR: loginUser.USER_ID, // 使用当前登录用户ID
      uindex: -1,
      lindex: -1,
      cindex: -1,
      dangerLabellindex: -1,
      hiddenClassificationlindex: -1,
      hiddenClassificationList: [
        {NAME: "公司级", BIANMA: "0"},
        {NAME: "厂部级", BIANMA: "1"},
        {NAME: "车间级", BIANMA: "2"},
        {NAME: "班组级", BIANMA: "3"},
      ],
      hiddenDangerLabelList: [
        {NAME: "外施工", BIANMA: "1"},
        {NAME: "厂内", BIANMA: "2"},
        {NAME: "BOO、BOT项目", BIANMA: "3"},
      ],
      levelList: [],
      tindex: -1,
      hiddenTypeList: [],
      HIDDENLEVEL: '',//隐患级别
      RECTIFICATIONDEADLINE: '',//整改期限
      rectifyPlanCompletionStartTime: '',
      disabledvalue: false,
      todayDate: formatDate(new Date(), 'yyyy-MM-dd hh:mm'),
      confirUserAllList: [],
      // otherUserList: [],
      other: [],
      hiddenRegionTreeList: [],
      videoSrc: '',
      modalShow: false,
      videoList: [],
      FIRE_DEVICE_TYPE: '', //检查标准
      fireDeviceTypeList: [],
      library: false
    }
  },
  onLoad(event) {
    console.log(this.pd.HIDDEN_ID)
    this.ISLOG = event.ISLOG
    this.info_index = event.INDEX
    let now = new Date()
    var tomorrow = now.setDate(now.getDate() + 1)
    tomorrow = new Date(tomorrow)
    this.rectifyPlanCompletionStartTime = formatDate(tomorrow, 'yyyy-MM-dd')
    this.pd.HIDDEN_ID = event.HIDDEN_ID
    this.FIRE_DEVICE_TYPE = event.FIRE_DEVICE_TYPE
    this.ISLOG = event.ISLOG
    if (this.pd.HIDDEN_ID) {
      this.msg = 'fireEdit'
      this.getData()
    } else {
      this.pd.CHECK_CONTENT = event.FIRE_CHECK_STANDARD_ITEM
      this.pd.LISTMANAGER_ID = event.LISTMANAGER_ID // bus_fire_checklist 表 FIRE_CHECK_ID
      this.pd.RISKITEM_ID = event.RISKITEM_ID // bus_fire_device_prepared 表 FIRE_PREPARED_ID
      this.pd.CHECKRECORD_ID = event.CHECKRECORD_ID // bus_fire_record 表 FIRE_RECORD_ID
      this.pd.RECORDITEM_ID = event.RECORDITEM_ID // bus_fire_record_device 表 EQUIPMENT_RECORD_ID
      this.pd.RISK_UNIT = JSON.parse(decodeURIComponent(event.RISK_UNIT));
      this.pd.IDENTIFICATION = JSON.parse(decodeURIComponent(event.IDENTIFICATION));
      this.pd.DISCOVERYTIME = formatDate(new Date(), 'yyyy-MM-dd hh:mm')
      this.myOther()
    }
    this.getDept()
    this.getLevel()
    this.getConfirmUser()
    this.getFireDeviceType()
    // this.getHiddenType();
    this.getHiddenProvinceId();
    loginSession()
  },
  methods: {
    filterRectificationUser() {
      const query = this.searchRectificationUser.trim().toLowerCase();
      if (!query) {
        this.filteredRectificationUsers = this.rectificationUserList;
        this.pd.RECTIFICATIONOR = '';
        this.pd.RECTIFICATIONORNAME = '';
      } else {
        this.filteredRectificationUsers = this.rectificationUserList.filter(user =>
            user.NAME.toLowerCase().includes(query)
        );
      }
    },
    toggleRectifyDropdown() {
      if (!this.pd.RECTIFICATIONDEPT) {
        uni.showToast({
          icon: 'none',
          title: '请选择整改部门',
          duration: 1500
        });
        return;
      }
      if (!this.rectificationUserList.length) {
        uni.showToast({
          icon: 'none',
          title: '部门下无整改责任人',
          duration: 1500
        });
        this.searchRectificationUser = ""
        return;
      }
      this.showRectifyDropdown = !this.showRectifyDropdown;
      if (this.showRectifyDropdown) this.filterRectificationUser();
    },
    selectRectificationUser(user) {
      this.searchRectificationUser = user.NAME;
      this.pd.RECTIFICATIONOR = user.USER_ID;
      this.pd.RECTIFICATIONORNAME = user.NAME;
      this.showRectifyDropdown = false;
    },
    filterConfirmUser() {
      const query = this.searchConfirmUser.trim().toLowerCase();
      if (!query) {
        this.filteredConfirmUsers = this.confirmUserList;
        this.pd.CONFIRM_USER = '';
        this.pd.CONFIRM_USER_NAME = '';
      } else {
        this.filteredConfirmUsers = this.confirmUserList.filter(user =>
            user.NAME.toLowerCase().includes(query)
        );
      }
    },
    toggleConfirmDropdown() {
      if (!this.pd.CONFIRM_DEPT) {
        uni.showToast({
          icon: 'none',
          title: '请选择确认人部门',
          duration: 1500
        });
        return;
      }
      if (!this.confirmUserList.length) {
        uni.showToast({
          icon: 'none',
          title: '部门下无确认人',
          duration: 1500
        });
        this.searchConfirmUser = ""
        return;
      }
      this.showAnalyzeDropdown = !this.showAnalyzeDropdown;
      if (this.showAnalyzeDropdown) this.filterConfirmUser();
    },
    selectConfirmUser(user) {
      this.searchConfirmUser = user.NAME;
      this.pd.CONFIRM_USER = user.USER_ID;
      this.pd.CONFIRM_USER_NAME = user.NAME;
      this.showAnalyzeDropdown = false;
    },
    hiddenDangerClassificationPickerChange(e) {
      this.hiddenClassificationlindex = e.detail.value;
      this.pd.HIDDEN_CLASSIFICATION = this.hiddenClassificationList[this.hiddenClassificationlindex].BIANMA;
      this.pd.HIDDEN_CLASSIFICATION_NAME = this.hiddenClassificationList[this.hiddenClassificationlindex].NAME;
      this.$forceUpdate();//强制刷新
    },
    fullScreenHandler(e) {
      if (uni.getSystemInfoSync().platform == "ios") {
        return
      }
    },
    getData() {
      var _this = this;
      uni.showLoading({
        title: '请稍候'
      })
      uni.request({
        url: basePath + '/app/hidden/goEdit',
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          HIDDEN_ID: _this.pd.HIDDEN_ID,
        },
        success: (res) => {
          if ('success' == res.data.result) {
            uni.hideLoading()
            res.data.pd.HIDDENTYPE = res.data.pd.HIDDENTYPE ? res.data.pd.HIDDENTYPE.split(',') : []
            res.data.pd.HIDDENTYPENAME = res.data.pd.HIDDENTYPE_NAME
            res.data.pd.DISCOVERYTIME = res.data.pd.CREATTIME
            console.log(res.data)
            _this.pd = res.data.pd //参数map
            _this.ISRELEVANT = res.data.pd.ISRELEVANT
            _this.RECTIFICATIONTYPE = _this.pd.RECTIFICATIONTYPE
            _this.searchConfirmUser = _this.pd.CONFIRM_USER_NAME;
            _this.searchRectificationUser = _this.pd.RECTIFICATIONORNAME;
            if (_this.pd.HIDDEN_CLASSIFICATION == '0'){
              _this.pd.HIDDEN_CLASSIFICATION_NAME = "公司级"
            }
            if (_this.pd.HIDDEN_CLASSIFICATION == '1'){
              _this.pd.HIDDEN_CLASSIFICATION_NAME = "厂部级"
            }
            if (_this.pd.HIDDEN_CLASSIFICATION == '2'){
              _this.pd.HIDDEN_CLASSIFICATION_NAME = "车间级"
            }
            if (_this.pd.HIDDEN_CLASSIFICATION == '3'){
              _this.pd.HIDDEN_CLASSIFICATION_NAME = "班组级"
            }
            if (_this.pd.HIDDEN_DANGER_LABEL == '1'){
              _this.pd.HIDDEN_DANGER_LABEL_NAME = "外施工"
            }
            if (_this.pd.HIDDEN_DANGER_LABEL == '2'){
              _this.pd.HIDDEN_DANGER_LABEL_NAME = "厂内"
            }
            if (_this.pd.HIDDEN_DANGER_LABEL == '3'){
              _this.pd.HIDDEN_DANGER_LABEL_NAME = "BOO、BOT项目"
            }
            let files = res.data.hImgs;
            for (var i = 0; i < files.length; i++) {
              let img = {};
              img.filePath = baseImgPath + files[i].FILEPATH;
              if (files[i].FILEPATH.substring(files[i].FILEPATH.lastIndexOf("."), files[i].FILEPATH.length) != '.mp4') {
                img.id = files[i].IMGFILES_ID;
                _this.imgList.push(img);
              } else {
                img.id = files[i].IMGFILES_ID;
                _this.videoList.push(img);
              }
            }
            let files1 = res.data.rImgs;
            for (var i = 0; i < files1.length; i++) {
              let img = {};
              img.filePath = baseImgPath + files1[i].FILEPATH;
              img.id = files1[i].IMGFILES_ID;
              _this.imgList1.push(img);
            }
            _this.getUserList();

            for (var i = 0; i < res.data.hiddenVideo.length; i++) {
              let video = {}
              video.filePath = baseImgPath + res.data.hiddenVideo[i].FILEPATH
              video.id = res.data.hiddenVideo[i].IMGFILES_ID
              _this.videoList.push(video)
            }
            for (var i = 0; i < res.data.hiddenFindPeople.length; i++) {
              let o = {
                DEPARTMENT_ID: res.data.hiddenFindPeople[i].DEPARTMENT_ID,
                USER_ID: res.data.hiddenFindPeople[i].USER_ID,
                DEPARTMENT_NAME: res.data.hiddenFindPeople[i].deptName,
                USER_NAME: res.data.hiddenFindPeople[i].NAME,
                index: i - 1
              }
              _this.other.push(o)
            }
          } else if ('exception' == data.result) {
            uni.showToast({
              title: '错误',
              duration: 2000
            });
          }
        }
      })
    },
    getDept() {
      var _this = this;
      uni.request({
        url: basePath + '/app/sys/listTree',//部门下拉接口
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          CORPINFO_ID: corpinfoId
        },
        success: (res) => {
          if ("success" == res.data.result) {
            _this.treeNode = eval(res.data.zTreeNodes);
          } else {
            uni.showToast({
              title: res.data.message,
              duration: 2000
            });
          }
        }
      });
    },
    // 确定回调事件
    zgtreeConfirm(e) {
      this.isUps = false
      this.pd.RECTIFICATIONDEPT = e[0].id
      this.pd.RECTIFICATIONDEPTNAME = e[0].name
      this.pd.confirmDept = e[0].id
      this.pd.hregionDeptName = e[0].name
      this.uindex = -1
      this.pd.RECTIFICATIONOR = ''
      this.pd.RECTIFICATIONORNAME = ''
      this.pd.searchRectificationUser = '';
      this.$forceUpdate() //强制刷新
      this.getUserList()
    },
    showHiddenQyZgTree() {
      this.isUps = true
      this.$refs.tkiTreedd._show();
    },
    zgtreeHiddenQy(e) {
      this.isUps = false;
      this.pd.HIDDEN_DANGER_AREA = e[0].id;
      this.pd.HIDDEN_DANGER_AREA_NAME = e[0].name;
      this.uindex = -1;
      this.$forceUpdate();//强制刷新
      this.getUserList();
    },
    hiddenDangerLabelPickerChange(e) {
      this.dangerLabellindex = e.detail.value;
      this.pd.HIDDEN_DANGER_LABEL = this.hiddenDangerLabelList[this.dangerLabellindex].BIANMA;
      this.pd.HIDDEN_DANGER_LABEL_NAME = this.hiddenDangerLabelList[this.dangerLabellindex].NAME;
      this.$forceUpdate();//强制刷新
    },
    showQrTree() {
      this.isUps = true
      this.$refs.tkiTreeQr._show();
    },
    fnHiddenConfirmDept(e) {
      this.isUps = false;
      this.pd.CONFIRM_DEPT = e[0].id;
      this.pd.CONFIRM_DEPT_NAME = e[0].name;
      this.uindex = -1;
      this.pd.CONFIRM_USER = '';
      this.pd.CONFIRM_USER_NAME = '';
      this.searchConfirmUser = '';
      this.$forceUpdate();//强制刷新
      this.getConfirmUserList();
    },
    getConfirmUserList() {
      var _this = this;
      uni.request({
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        url: basePath + '/app/sys/listUser',
        data: {
          DEPARTMENT_ID: _this.pd.CONFIRM_DEPT,
          tm: new Date().getTime(),
          CORPINFO_ID: loginUser.CORPINFO_ID,
          USER_ID: loginUser.USER_ID,
          ISCONFIRM: 1,
        },
        success: function (res) {
          if ("success" == res.data.result) {
            _this.confirmUserList = res.data.userList;
          } else {
            uni.showToast({
              title: res.data.message,
              duration: 2000
            });
          }
        }
      })
    },

    // 取消回调事件
    zgtreeCancel(e) {
      this.isUps = false;
    },
    // 显示树形选择器
    showZgTree() {
      this.isUps = true
      this.$refs.tkiTree._show();
    },

    // 确定回调事件
    ystreeConfirm(e) {
      this.pd.CHECKDEPT = e[0].id;
      this.pd.CHECKDEPTNAME = e[0].name;
      this.$forceUpdate();//强制刷新
    },
    // 显示树形选择器
    showYsTree() {
      this.$refs.tkiTree1._show();
    },
    //获取人员列表
    getUserList() {
      //发送 post 请求
      var _this = this;
      uni.request({
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        url: basePath + '/app/sys/listUser',
        data: {
          DEPARTMENT_ID: _this.pd.RECTIFICATIONDEPT,
          NOMAIN: '1',
          tm: new Date().getTime()
        },
        success: function (res) {
          if ("success" == res.data.result) {
            _this.rectificationUserList = res.data.userList;
          } else {
            uni.showToast({
              title: res.data.message,
              duration: 2000
            });
          }
        }
      })
    },
    //获取数据字典数据
    getLevel: function () {
      var _this = this;
      uni.request({
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        url: basePath + '/dictionaries/getLevels?tm=' + new Date().getTime(),
        data: {
          DICTIONARIES_ID: '5e7cf8620ba54ad89719d0be62133c7a',
          CORPINFO_ID: loginUser.CORPINFO_ID,
          USER_ID: loginUser.USER_ID,
        },
        success: function (res) {
          _this.levelList = res.data.list;
        }
      });
      uni.request({
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        url: basePath + '/dictionaries/getLevels?tm=' + new Date().getTime(),
        data: {
          DICTIONARIES_ID: 'ec1d6dcfd0f2438a88968feea542eab0',
          CORPINFO_ID: loginUser.CORPINFO_ID,
          USER_ID: loginUser.USER_ID,
        },
        success: function (res) {
          _this.categoryList = res.data.list;
        }
      });
    },
    levelPickerChange(e) {
      console.log(e)
      if (e.detail.value == 1) {
        this.disabledvalue = true;
        this.RECTIFICATIONTYPE = 2;
      } else {
        this.disabledvalue = false;
      }
      this.lindex = e.detail.value;
      this.pd.HIDDENLEVEL = this.levelList[this.lindex].BIANMA;
      this.pd.HIDDENLEVELNAME = this.levelList[this.lindex].NAME;
      this.$forceUpdate();//强制刷新
    },
    showZgTree1() {
      this.isUps = true
      this.$refs.tkiTree1._show();
    },
    zgtreeCancel1(e) {
      this.isUps = false;
    },
    zgtreeConfirm1(e) {
      this.isUps = false;
      if (e[0]?.parents.length === 1) {
        this.pd.HIDDENTYPE = [e[0]?.parents[0]?.id || '', e[0]?.id || ''];
        this.pd.HIDDENTYPENAME = [e[0]?.parents[0]?.name || '', e[0]?.name || ''].join('/')
      } else if (e[0]?.parents.length === 2) {
        this.pd.HIDDENTYPE = [e[0]?.parents[0]?.id || '', e[0]?.parents[1]?.id || '', e[0]?.id || ''];
        this.pd.HIDDENTYPENAME = [e[0]?.parents[0]?.name || '', e[0]?.parents[1]?.name || '', e[0]?.name || ''].join('/')
      } else {
        this.pd.HIDDENTYPE = [e[0]?.id || ''];
        this.pd.HIDDENTYPENAME = [e[0]?.name || ''].join('/');
      }
    },
    changeDate(e) {
      this.pd.RECTIFICATIONDEADLINE = e.detail.value
      this.$forceUpdate();//强制刷新
    },
    // radioISRELEVANT(e) {
    //   this.pd.ISRELEVANT = e
    // },

    openAuth(permissionID) {
      this.permissionID = permissionID;
      setTimeout(() => {
        this.$refs['authpup'].open();
      }, 200)
    },

    openAuthZg(permissionID) {
      this.permissionID = permissionID;
      setTimeout(() => {
        this.$refs['authpup_zg'].open();
      }, 200)
    },

    //图片上传
    ChooseImage(e) {
      var _this = this;
      var ss = 4 - this.imgList.length;
      uni.chooseImage({
        count: ss, //默认9
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
        sourceType: ['camera', 'album'], //从相册选择
        success: (res) => {
          if (e == 0) {
            for (let i = 0; i < res.tempFilePaths.length; i++) {
              let img = {};
              img.id = '';
              img.filePath = res.tempFilePaths[i];
              this.imgList.push(img)
            }
          } else {
            for (let i = 0; i < res.tempFilePaths.length; i++) {
              let img = {};
              img.id = '';
              img.filePath = res.tempFilePaths[i];
              this.imgList1.push(img)
            }
          }
        }
      });
    },
    ViewImage(e) {
      console.info(e.currentTarget.dataset.type)
      if (e.currentTarget.dataset.type == 0) {
        let files = [];
        for (var i = 0; i < this.imgList.length; i++) {
          files.push(this.imgList[i].filePath)
        }
        uni.previewImage({
          urls: files,
          current: e.currentTarget.dataset.url
        });
      } else {
        let files = [];
        for (var i = 0; i < this.imgList1.length; i++) {
          files.push(this.imgList1[i].filePath)
        }
        uni.previewImage({
          urls: files,
          current: e.currentTarget.dataset.url
        });
      }
    },
    DelImg(e) {
      var _this = this;
      let i = e.currentTarget.dataset.index
      uni.showModal({
        title: '温馨提示',
        content: '确定要删除这张图片吗？',
        cancelColor: "#000000",
        cancelText: '取消',
        confirmText: '确定',
        success: res => {
          if (res.confirm) {
            if (e.currentTarget.dataset.type == 0) {
              if (_this.imgList[i].id) {
                uni.showLoading({
                  title: '处理中'
                })
                uni.request({
                  url: basePath + '/app/imgfiles/delete',
                  method: 'POST',
                  dataType: 'json',
                  header: {
                    'Content-type': 'application/x-www-form-urlencoded'
                  },
                  data: {
                    IMGFILES_ID: _this.imgList[i].id,
                    CORPINFO_ID: loginUser.CORPINFO_ID,
                    USER_ID: loginUser.USER_ID,
                  },
                  success: (res) => {
                    uni.hideLoading();
                    uni.showToast({
                      icon: 'none',
                      title: '删除成功',
                      duration: 1500
                    });
                    _this.imgList.splice(i, 1)
                  },
                  fail: (err) => {
                    uni.hideLoading();
                    uni.showModal({
                      content: err.errMsg,
                      showCancel: false
                    });
                  }
                })
              } else {
                this.imgList.splice(e.currentTarget.dataset.index, 1)
              }
            } else {
              if (_this.imgList1[i].id) {
                uni.showLoading({
                  title: '处理中'
                })
                uni.request({
                  url: basePath + '/app/imgfiles/delete',
                  method: 'POST',
                  dataType: 'json',
                  header: {
                    'Content-type': 'application/x-www-form-urlencoded'
                  },
                  data: {
                    IMGFILES_ID: _this.imgList1[i].id,
                    CORPINFO_ID: loginUser.CORPINFO_ID,
                    USER_ID: loginUser.USER_ID,
                  },
                  success: (res) => {
                    uni.hideLoading();
                    uni.showToast({
                      icon: 'none',
                      title: '删除成功',
                      duration: 1500
                    });
                    _this.imgList1.splice(i, 1)
                  },
                  fail: (err) => {
                    uni.hideLoading();
                    uni.showModal({
                      content: err.errMsg,
                      showCancel: false
                    });
                  }
                })
              } else {
                this.imgList1.splice(e.currentTarget.dataset.index, 1)
              }
            }
          }
        }
      })
    },
    textareaAInput(e) {
      this.pd.HIDDENDESCR = e.detail.value
    },
    textareaBInput(e) {
      this.pd.HIDDENPART = e.detail.value
    },
    textareaCInput(e) {
      this.pd.RECTIFYDESCR = e.detail.value
    },
    goIdentifyImg() {
      if (this.imgList.length === 0) {
        uni.showToast({
          icon: 'none',
          title: '请先上传图片',
          duration: 2000
        });
      } else if (this.imgList.length > 1) {
        uni.showToast({
          icon: 'none',
          title: '识别暂时只能上传一张图片',
          duration: 2000
        });
      } else {
        var _this = this;
        if (this.imgList[0].id != "") {
          uni.showToast({
            icon: 'none',
            title: '请删除图片重新上传图片后,再次进行图片识别',
            duration: 2000
          });
          return;
        }
        _this.buttonloading = true
        uni.showLoading({
          title: '识别中...'
        })
        uni.uploadFile({
          url: basePath + '/app/hidden/identifyImg',
          filePath: _this.imgList[0].filePath,
          name: 'FFILE',
          formData: {
            CORPINFO_ID: loginUser.CORPINFO_ID,
            USER_ID: loginUser.USER_ID,

          },
          success: (res) => {
            _this.buttonloading = false
            _this.aiFlag = true
            if ("success" == JSON.parse(res.data).result) {
              const aiHiddens = JSON.parse(res.data).aiHiddens;
              let hiddenDescr = ""
              let rectificationSuggestions = ""
              let legalBasis = ""
              aiHiddens.forEach((item) => {
                hiddenDescr += JSON.parse(item).hiddenDescr + ";"
                rectificationSuggestions += JSON.parse(item).rectificationSuggestions + ";"
                legalBasis += JSON.parse(item).legalBasis + ";"
              })
              _this.pd.HIDDENDESCR = hiddenDescr
              _this.pd.LEGALBASIS = legalBasis
              _this.pd.RECTIFYDESCR = rectificationSuggestions
              _this.radioType(1)
            } else {
              uni.showToast({
                icon: 'none',
                title: "未识别图片中的隐患",
                duration: 2000
              });
            }
            uni.hideLoading();
          },
          fail: (err) => {
            _this.buttonloading = false
            uni.hideLoading();
            uni.showModal({
              content: err.errMsg,
              showCancel: false
            });
          }
        })
      }
    },
    goSubmit() {
      var _this = this
      if (!_this.pd.CHECK_CONTENT || _this.pd.CHECK_CONTENT == '请选择') {
        uni.showToast({
          icon: 'none',
          title: '请选择检查内容',
          duration: 1500
        })
        return
      }
      if (_this.imgList.length <= 0) {
        uni.showToast({
          icon: 'none',
          title: '请上传隐患图片',
          duration: 1500
        })
        return
      }
      if (!_this.pd.HIDDENDESCR) {
        uni.showToast({
          icon: 'none',
          title: '请填隐患描述',
          duration: 1500
        })
        return
      }
      if (!_this.pd.HIDDENPART) {
        uni.showToast({
          icon: 'none',
          title: '请填隐患部位',
          duration: 1500
        })
        return
      }
      if (!_this.pd.HIDDEN_DANGER_AREA) {
        uni.showToast({
          icon: 'none',
          title: '请选择隐患区域',
          duration: 1500
        });
        return;
      }
      if (!_this.pd.HIDDEN_DANGER_LABEL) {
        uni.showToast({
          icon: 'none',
          title: '请选择隐患标签',
          duration: 1500
        });
        return;
      }
      if (!_this.pd.HIDDEN_CLASSIFICATION) {
        uni.showToast({
          icon: 'none',
          title: '请选择隐患分级',
          duration: 1500
        });
        return;
      }
      if (!_this.pd.HIDDENLEVEL) {
        uni.showToast({
          icon: 'none',
          title: '请选择隐患级别',
          duration: 1500
        })
        return
      }
      if (!_this.pd.HIDDENTYPE) {
        uni.showToast({
          icon: 'none',
          title: '请选择隐患类型',
          duration: 1500
        })
        return
      }
      if (_this.RECTIFICATIONTYPE == 1 && !_this.pd.RECTIFYDESCR) {
        uni.showToast({
          icon: 'none',
          title: '请填整改描述',
          duration: 1500
        })
        return
      }
      if (_this.RECTIFICATIONTYPE == 1 && _this.imgList1.length <= 0) {
        uni.showToast({
          icon: 'none',
          title: '请上传整改后图片',
          duration: 1500
        })
        return
      }
      if (!_this.pd.CONFIRM_DEPT) {
        uni.showToast({
          icon: 'none',
          title: '请选择确认部门',
          duration: 1500
        });
        return;
      }
      if (!_this.pd.CONFIRM_USER) {
        uni.showToast({
          icon: 'none',
          title: '请选择确认人',
          duration: 1500
        });
        return;
      }

      var fileList = [];
      for (var i = 0; i < _this.imgList.length; i++) {
        if (!_this.imgList[i].id) {
          var file = {};
          file.type = 3;
          file.filePath = _this.imgList[i].filePath;
          fileList.push(file);
        }
      }
      for (var i = 0; i < _this.videoList.length; i++) {
        if (!_this.videoList[i].id) {
          var file = {};
          file.type = 3;
          file.filePath = _this.videoList[i].filePath;
          fileList.push(file);
        }
      }
      if (_this.RECTIFICATIONTYPE == 1) {
        for (var i = 0; i < _this.imgList1.length; i++) {
          if (!_this.imgList1[i].id) {
            var file = {};
            file.type = 4;
            file.filePath = _this.imgList1[i].filePath;
            fileList.push(file);
          }
        }
      }
      uni.showLoading({
        title: '处理中'
      })
      new Promise((resolve, reject) => {
        _this.submit().then(() => {
          resolve()
        })
      })
          .then(() => {
            var i = 0
            _this.uploadImg(fileList, i).then(() => {
              resolve()
            })
          })
          .then(() => {
            var pages = getCurrentPages() // 获取当前页面栈
            var prePage = pages[pages.length - 2] // 上一个页面
            prePage.$vm.initflag = true // A 页面 init方法 为true
            prePage.$vm.info[this.info_index].ISNORMAL = 1
            prePage.$vm.info[this.info_index].HIDDEN_ID = _this.pd.HIDDEN_ID
            prePage.$vm.info[this.info_index].FIRE_CHECK_STANDARD_ID = _this.pd.CHECK_CONTENT_ID
            prePage.$vm.info[this.info_index].HIDDENDESCR = _this.pd.HIDDENDESCR
            uni.navigateBack({})
            uni.hideLoading()
          })
    },
    uploadImg(tempFilePaths, i) {
      return new Promise((resolve, reject) => {
        var _this = this
        if (tempFilePaths.length == 0) {
          resolve()
        }
        uni.uploadFile({
          url: basePath + '/app/imgfiles/add',
          filePath: tempFilePaths[i].filePath,
          name: 'FFILE',
          formData: {
            TYPE: tempFilePaths[i].type,
            FOREIGN_KEY: _this.pd.HIDDEN_ID,
            CORPINFO_ID: loginUser.CORPINFO_ID,
          },
          success: (res) => {
            i++
            if (tempFilePaths.length > i) {
              _this.uploadImg(tempFilePaths, i)
            } else {
              uni.hideLoading()
              resolve()
            }
          },
          fail: (err) => {
            uni.hideLoading()
            uni.showModal({
              content: err.errMsg,
              showCancel: false
            })
          }
        })
      })
    },
    submit() {
      return new Promise((resolve, reject) => {
        var _this = this
        let longitude = '';
        let latitude = '';
        // uni.getLocation({
        //   type: 'GCJ02',
        //   success: function (res1) {
        //     longitude = res1.longitude;
        //     latitude = res1.latitude;
        //     var result = gcoord.transform(
        //         [longitude, latitude],    // 经纬度坐标
        //         gcoord.GCJ02,               // 当前坐标系
        //         gcoord.BD09                // 目标坐标系
        //     );
        //     longitude = result[0];
        //     latitude =  result[1];
            uni.request({
              url: basePath + '/app/hidden/' + _this.msg,
              method: 'POST',
              dataType: 'json',
              header: {
                'Content-type': 'application/x-www-form-urlencoded'
              },
              data: {
                HIDDEN_ID: _this.pd.HIDDEN_ID,
                SOURCE: '6',
                STATE: '-2',
                HIDDENDESCR: _this.pd.HIDDENDESCR,
                HIDDENPART: _this.pd.HIDDENPART,
                // LATITUDE:latitude,
                // LONGITUDE:longitude,
                HIDDEN_CLASSIFICATION: _this.pd.HIDDEN_CLASSIFICATION ? _this.pd.HIDDEN_CLASSIFICATION : '',
                HIDDEN_DANGER_AREA: _this.pd.HIDDEN_DANGER_AREA ? _this.pd.HIDDEN_DANGER_AREA : '',
                HIDDEN_DANGER_LABEL: _this.pd.HIDDEN_DANGER_LABEL ? _this.pd.HIDDEN_DANGER_LABEL : '',
                RECTIFYDESCR: _this.pd.RECTIFYDESCR ? _this.pd.RECTIFYDESCR : '',
                RECTIFICATIONDEADLINE: _this.pd.RECTIFICATIONDEADLINE ? _this.pd.RECTIFICATIONDEADLINE : '',
                RECTIFICATIONTYPE: _this.RECTIFICATIONTYPE,
                RECTIFICATIONOR: _this.pd.RECTIFICATIONOR,
                CONFIRM_DEPT: _this.pd.CONFIRM_DEPT,
                CONFIRM_USER: _this.pd.CONFIRM_USER,
                HIDDENLEVEL: _this.pd.HIDDENLEVEL,
                HIDDENTYPE: _this.pd.HIDDENTYPE,
                RECTIFICATIONDEPT: _this.pd.RECTIFICATIONDEPT,
                CHECK_CONTENT: _this.pd.CHECK_CONTENT,
                CORPINFO_ID: corpinfoId,
                HIDDENFINDDEPT: deptId,
                CREATOR: loginUser.USER_ID,
                ISRELEVANT: _this.pd.ISRELEVANT,
                // POSITIONDESC: _this.pd.POSITIONDESC,
                LISTMANAGER_ID: _this.pd.LISTMANAGER_ID, // bus_fire_checklist 表 FIRE_CHECK_ID
                RISKITEM_ID: _this.pd.RISKITEM_ID, // bus_fire_device_prepared 表 FIRE_PREPARED_ID
                CHECKRECORD_ID: _this.pd.CHECKRECORD_ID, // bus_fire_record 表 FIRE_RECORD_ID
                RECORDITEM_ID: _this.pd.RECORDITEM_ID, // bus_fire_record_device 表 EQUIPMENT_RECORD_ID
                RISK_UNIT: _this.pd.RISK_UNIT,
                IDENTIFICATION: _this.pd.IDENTIFICATION,
                // FIRE_CHECK_STANDARD_ID: _this.pd.CHECK_CONTENT_ID, // bus_fire_check_standard 表 FIRE_CHECK_STANDARD_ID 用于存储在bus_fire_record_device 表 FIRE_CHECK_STANDARD_ID
                CLEARIMG: '1',
                HIDDENTYPE_NAME:_this.pd.HIDDENTYPENAME,
                HIDDENTYPE1:_this.pd.HIDDENTYPE[0] || '',
                HIDDENTYPE2:_this.pd.HIDDENTYPE[1] || '',
                HIDDENTYPE3:_this.pd.HIDDENTYPE[2] || '',
                DISCOVERYTIME: _this.pd.DISCOVERYTIME,
                other: JSON.stringify(_this.other),
              },
              success: (res) => {
                if ('success' == res.data.result) {
                  _this.pd.HIDDEN_ID = res.data.pd.HIDDEN_ID
                  resolve()
                } else {
                  uni.showToast({
                    icon: 'none',
                    title: res.data.msg,
                    duration: 2000
                  })
                }
              },
              fail: (err) => {
                uni.hideLoading();
                uni.showModal({
                  content: err.errMsg,
                  showCancel: false
                });
              }
            })
          // },
          // fail: function(res){
          //   uni.hideLoading();
          //   uni.showToast({
          //     title: "获取位置失败",
          //     duration: 2000
          //   });
          // }
        // })
      })
    },
    radioType(e) {
      if (!this.disabledvalue) {
        this.RECTIFICATIONTYPE = e
      } else {
        this.RECTIFICATIONTYPE = 2
      }
    },
    // showHiddenLevenTreeTree() {
    //   var _this = this
    //   uni.request({
    //     method: 'POST',
    //     dataType: 'json',
    //     header: {
    //       'Content-type': 'application/x-www-form-urlencoded'
    //     },
    //     url:
    //         basePath +
    //         '/dictionaries/listSelectTreeByTkiTree?tm=' +
    //         new Date().getTime(),
    //     data: {
    //       DICTIONARIES_ID: '5e7cf8620ba54ad89719d0be62133c7a'
    //     },
    //     success: function (res) {
    //       var data = JSON.parse(res.data.zTreeNodes)
    //       for (let i = 0; i < data.length; i++) {
    //         for (let j = 0; j < data[i].children.length; j++) {
    //           if (data[i].children[j].id == 'hiddenLevel1001') {
    //             data[i].children.splice(j, 1)
    //           }
    //         }
    //       }
    //       _this.levelList = data
    //     }
    //   })
    //   this.isUps = false
    //   this.$refs.hiddenLevenTree._show()
    //   this.$forceUpdate()
    // },
    // hiddenLevenConfirm(e) {
    //   this.isUps = false
    //   this.pd.HIDDENLEVEL = e[0].id
    //   this.pd.HIDDENLEVELNAME = e[0].name
    //   if (this.pd.HIDDENLEVEL === 'hiddenLevel0002') {
    //     this.pd.RECTIFICATIONDEPTNAME = loginUser.DEPARTMENT_NAME
    //     this.pd.RECTIFICATIONDEPT = loginUser.DEPARTMENT_ID
    //     this.pd.RECTIFICATIONORNAME = loginUser.NAME
    //     this.pd.RECTIFICATIONOR = loginUser.USER_ID
    //   }
    //
    //   this.$forceUpdate() // 强制刷新
    // },
    // hiddentrddeeCancel(e) {
    //   this.isUps = false
    // },
    /** 获取隐患所在省份的ID */
    getHiddenProvinceId() {
      var _this = this;
      uni.request({
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        url: basePath + '/dictionaries/getLevels',
        data: {
          DICTIONARIES_ID: '3babc15144444bdc8d763d0af2bdfff8',
          CORPINFO_ID:loginUser.CORPINFO_ID,
          USER_ID:loginUser.USER_ID,
        },
        success: function ({data}) {
          for (let i = 0; i < data.list.length; i++) {
            if (data.list[i].BIANMA.indexOf(loginUser.PROVINCE) > -1) {
              _this.getTrainDicList(data.list[i].DICTIONARIES_ID)
              break
            }
          }
        }
      });
    },
    getTrainDicList(parentId) {
      var _this = this
      if (_this.hiddenTypeList) {
        uni.request({
          method: 'POST',
          dataType: 'json',
          header: {
            'Content-type': 'application/x-www-form-urlencoded'
          },
          url: basePath + '/dictionaries/listAllDictToParId',
          data: {
            parentId,
            CORPINFO_ID:loginUser.CORPINFO_ID,
            USER_ID:loginUser.USER_ID,
          },
          success: function ({data}) {
            if(data.result === 'success') {
              let zTreeNodes = data.zTreeNodes
              zTreeNodes = zTreeNodes.replace(/"nodes":\[/g, '"children":[')
              _this.hiddenTypeList = JSON.parse(zTreeNodes)
            }
          }
        });
      }
    },
    // showHiddenType1TreeTree() {
    //   this.isUps = false
    //   this.$refs.hiddenType1Tree._show()
    //   // var dicID = '3babc15144444bdc8d763d0af2bdfff6'
    //   // if ('2' == type) {
    //   //   dicID = '18c0a9aea6e54feab9f4ab3f46e0bc86'
    //   // }
    //   // if ('1' == type) {
    //   //   this.$refs.hiddenType1Tree._show()
    //   // }
    //   // if ('2' == type) {
    //   //   this.$refs.hiddenType2Tree._show()
    //   // }
    // },
    // hiddenType1Confirm(e) {
    //   this.isUps=false;
    //   if(e[0]?.parents.length === 1){
    //     this.pd.HIDDENTYPE = [e[0]?.parents[0]?.id || '', e[0]?.id || ''];
    //     this.pd.HIDDENTYPENAME = [e[0]?.parents[0]?.name || '', e[0]?.name || ''].join('/')
    //   }else if(e[0]?.parents.length === 2) {
    //     this.pd.HIDDENTYPE = [e[0]?.parents[0]?.id || '', e[0]?.parents[1]?.id || '', e[0]?.id || ''];
    //     this.pd.HIDDENTYPENAME = [e[0]?.parents[0]?.name || '', e[0]?.parents[1]?.name || '', e[0]?.name || ''].join('/')
    //   }else{
    //     this.pd.HIDDENTYPE = [e[0]?.id || ''];
    //     this.pd.HIDDENTYPENAME = [e[0]?.name || ''].join('/');
    //   }
    //   this.$forceUpdate() //强制刷新
    // },
    // hiddenType1Cancel() {
    //   this.isUps = false
    // },
    // hiddenType2Confirm(e) {
    //   this.$set(this.pd, 'HIDDENTYPENAME2', e[0].name)
    //   this.$set(this.pd, 'HIDDENTYPE2', e[0].id)
    //   this.isUps = false
    // },
    // hiddenType2Cancel() {
    //   this.isUps = false
    // },
    myOther() {
      var _this = this
      let otherParams = {
        DEPARTMENT_ID: loginUser.DEPARTMENT_ID,
        USER_ID: loginUser.USER_ID,
        DEPARTMENT_NAME: loginUser.DEPARTMENT_NAME,
        USER_NAME: loginUser.NAME,
        index: -1
      }
      _this.other.push(otherParams)
      // let index = _this.other.length - 1
      // _this.otherUserList[index] = []
    },
    // addOther() {
    //   var _this = this;
    //   let o = {
    //     "DEPARTMENT_ID": '',
    //     "USER_ID": '',
    //     "DEPARTMENT_NAME": '',
    //     "USER_NAME": '',
    //     index: -1
    //   };
    //   _this.other.push(o);
    //   let index = _this.other.length - 1;
    //   _this.otherUserList[index] = [];
    // },
    // showConTree(index) {
    //   this.$refs['tkiConfirmTree' + index][0]._show()
    // },
    // contreeConfirm(e, index) {
    //   this.other[index].DEPARTMENT_ID = e[0].id
    //   this.other[index].DEPARTMENT_NAME = e[0].name
    //   this.other[index].USER_ID = ''
    //   this.other[index].USER_NAME = ''
    //   this.other[index].index = -1
    //   this.getConUserList(this.other[index].DEPARTMENT_ID, index)
    //   this.$forceUpdate() //强制刷新
    // },
    // getConUserList(DEPARTMENT_ID, i) {
    //   var _this = this
    //   uni.request({
    //     method: 'POST',
    //     dataType: 'json',
    //     header: {
    //       'Content-type': 'application/x-www-form-urlencoded'
    //     },
    //     url: basePath + '/app/sys/listUser',
    //     data: {
    //       DEPARTMENT_ID: DEPARTMENT_ID,
    //       NOMAIN: '1',
    //       LOGINUSERID: loginUser.USER_ID,
    //       NOSELF: '1',
    //       tm: new Date().getTime()
    //     },
    //     success: function (res) {
    //       if ('success' == res.data.result) {
    //         if (i > -1) {
    //           _this.otherUserList[i] = []
    //           _this.otherUserList[i] = res.data.userList
    //           _this.$forceUpdate() //强制刷新
    //         } else {
    //           _this.rectificationUserList = res.data.userList
    //         }
    //       } else {
    //         uni.showToast({
    //           title: res.data.message,
    //           duration: 2000
    //         })
    //       }
    //     }
    //   })
    // },
    // haveUser(e) {
    //   if (e == null || e.length == 0) {
    //     uni.showToast({
    //       icon: 'none',
    //       title: '请先选择有人员的部门',
    //       duration: 2000
    //     })
    //   }
    // },
    // PickerYsr(e, index) {
    //   this.other[index].index = e.detail.value
    //   this.other[index].USER_ID = this.otherUserList[index][e.detail.value]
    //       ? this.otherUserList[index][e.detail.value].USER_ID
    //       : ''
    //   this.other[index].USER_NAME = this.otherUserList[index][e.detail.value]
    //       ? this.otherUserList[index][e.detail.value].NAME
    //       : ''
    //   this.$forceUpdate() //强制刷新
    // },
    // removeOther(index) {
    //   this.other.splice(index, 1)
    //   this.otherUserList.splice(index, 1)
    // },

    // showConTreeTree() {
    //   this.isUps = false
    //   this.$refs.confirmTree._show()
    // },

    getConfirmUser(e) {
      this.isUps = false
      var _this = this
      uni.request({
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        url: basePath + '/app/user/getHiddenConfirm',
        data: {
          corpinfoId: corpinfoId,
          tm: new Date().getTime()
        },
        success: function (res) {
          if ('success' == res.data.result) {
            _this.confirUserAllList = res.data.userList
            _this.$forceUpdate() //强制刷新
          } else {
            uni.showToast({
              title: res.data.message,
              duration: 2000
            })
          }
        }
      })
    },
    // setConUser(e) {
    //   var index = e.detail.value
    //   this.pd.conUserId = this.confirUserAllList[index].USER_ID
    //   this.pd.conUserName = this.confirUserAllList[index].NAME
    //   this.$forceUpdate() //强制刷新
    // },
    // showHiddenRegionTree() {
    //   var _this = this
    //   uni.request({
    //     method: 'POST',
    //     dataType: 'json',
    //     header: {
    //       'Content-type': 'application/x-www-form-urlencoded'
    //     },
    //     url: basePath + '/app/hidden/getTreehiddenRegionListAll',
    //     data: {
    //       CORPINFO_ID: corpinfoId,
    //       tm: new Date().getTime()
    //     },
    //     success: function (res) {
    //       if ('success' == res.data.result) {
    //         var json = res.data.zTreeNodes
    //         _this.hiddenRegionTreeList = JSON.parse(json)
    //         _this.$forceUpdate() //强制刷新
    //       } else {
    //         uni.showToast({
    //           title: res.data.message,
    //           duration: 2000
    //         })
    //       }
    //     }
    //   })
    //   this.isUps = false
    //   this.$refs.hiddenRegionTree._show()
    // },
    // hiddenRegionTreeCon(e) {
    //   this.isUps = false
    //   this.pd.hregionName = e[0].name
    //   this.pd.HIDDENPART = e[0].id
    //   this.$forceUpdate() //强制刷新
    // },

    openAuthVideo(permissionID) {
      this.permissionID = permissionID;
      setTimeout(() => {
        this.$refs['authpup_video'].open();
      }, 200)
    },

    chooseVideo(e) {
      var _this = this;
      uni.chooseVideo({
        maxDuration: 60,
        count: 1, //默认9
        // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
        sourceType: ['camera', 'album'], //从相册选择
        success: (res) => {
          if (res.tempFilePath.substring(res.tempFilePath.lastIndexOf(".") + 1, res.tempFilePath.length) === 'mp4') {
            let img = {};
            img.id = '';
            img.filePath = res.tempFilePath;
            this.videoList.push(img)
          } else {
            uni.showToast({
              title: "只能上传MP4格式",
              duration: 2000
            });
          }
        }
      });
    },
    DelVideo(e) {
      uni.showModal({
        title: '',
        content: '确定要删除这个视频吗？',
        cancelColor: "#000000",
        cancelText: '取消',
        confirmText: '确定',
        success: res => {
          if (res.confirm) {
            this.videoList = []
          }
        }
      })
    },
    // showMapModal() {
    //   var _this = this
    //   uni.navigateTo({
    //     url: '/pages/map/mapPro',
    //     events: {
    //       acceptDataFromOpenedPage: function (e) {
    //         _this.pd.LONGITUDE = e.data.longitue
    //         _this.pd.LATITUDE = e.data.latitude
    //       }
    //     }
    //   })
    // },
    playVideo(e) {
      this.videoSrc = e.currentTarget.dataset.src
      this.modalShow = true
    },
    confirm(info) {
      this.pd.HIDDENPART = info.HIDDEN_PART
      this.pd.HIDDENDESCR = info.INSPECTION_BASIS
      this.pd.HIDDENLEVEL = 'hiddenLevel0001'
      this.pd.HIDDENLEVELNAME = '一般隐患'
      if (info.HIDDEN_TYPE_ONE_NAME) {
        this.pd.HIDDENTYPENAME = info.HIDDEN_TYPE_ONE_NAME
      }
      if (info.HIDDEN_TYPE_TWO_NAME) {
        this.pd.HIDDENTYPENAME = this.pd.HIDDENTYPENAME + '/' + info.HIDDEN_TYPE_TWO_NAME
      }
      if (info.HIDDEN_TYPE_THREE_NAME) {
        this.pd.HIDDENTYPENAME = this.pd.HIDDENTYPENAME + '/' + info.HIDDEN_TYPE_THREE_NAME
      }
      this.pd.HIDDENTYPE = info.HIDDENTYPE
    },
    getFireDeviceType() {
      var _this = this
      uni.showLoading({
        title: '请稍候'
      })
      uni.request({
        url: basePath + '/app/fireRecordManger/getStandardListByType',
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          FIRE_DEVICE_TYPE_LIST: _this.FIRE_DEVICE_TYPE
        },
        success: (res) => {
          if ('success' == res.data.result) {
            uni.hideLoading()
            _this.fireDeviceTypeList = res.data.varList
            this.pd.CHECK_CONTENT = '请选择'
            this.$forceUpdate()
          } else {
            uni.showToast({
              title: res.data.message,
              duration: 2000
            })
          }
        }
      })
    },
    fireDeviceTypeChange(e) {
      const value = e.detail.value || 0
      this.$set(this.pd, 'CHECK_CONTENT_INDEX', value)
      this.$set(
          this.pd,
          'CHECK_CONTENT',
          this.fireDeviceTypeList[value].FIRE_CHECK_STANDARD_ITEM
      )
      this.$set(
          this.pd,
          'CHECK_CONTENT_ID',
          this.fireDeviceTypeList[value].FIRE_CHECK_STANDARD_ID
      )
      console.log(this.pd.CHECK_CONTENT_ID)
      this.$forceUpdate()
    }
  }
}
</script>

<style>
.prevent {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  overflow: hidden;
}

.cu-form-title {
  padding: 20upx 0;
}

.cu-form-textarea {
  background-color: #ffffff;
  padding: 1upx 30upx 20upx;
  min-height: 100upx;
}

.cu-form-textarea textarea {
  height: 4.6em;
  width: 100%;
  line-height: 1.2em;
  flex: 1;
  font-size: 28upx;
  padding: 0;
}

.selected {
  display: flex;
  align-items: center;
  height: 100upx;
}

.selected .radio {
  transform: scale(0.8);
  margin-right: 10upx;
}

.group {
  display: flex;
  align-items: center;
}

.cu-form-group .title {
  font-size: 28upx;
  font-weight: bold;
  color: #000;
}

.cu-bar .action:first-child {
  font-size: 28upx;
}

.cu-form-group .picker {
  color: #808080;
}

.picker-tree {
  color: #808080;
}

.ai_btn {
  width: 100%;
  box-sizing: border-box;
  background: #FFFFFF;
  margin-bottom: 10px;
  padding: 10px;
}

.ai_btn .ai_btn_con {
  width: 45%;
  background: #dfeaff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 10px;
}

.dropdown view {
  padding: 8px 10px;
  cursor: pointer;
}

.dropdown view:hover {
  background: #f5f5f5;
}
.search-input {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 4px;
  padding: 0 10px;
  height: 40px;
}

.search-icon {
  position: absolute;
  right: 10px;
  font-size: 18px;
  color: #666;
}
.cuIcon-right {
  position: absolute;
  right: -12px;
  top: -10px;
}

.cuIcon-right:before {
  content: "\e6a3";
  color: #999;
}

.showbg {
  position: absolute;
  top: 45px;
  left: 0;
  background: #ffffff;
  line-height: 2.6;
  width: 100%;
  padding: 5px;
  border: 1px solid #eeeeee;
  border-radius: 4px;
  z-index: 999;
}

.cu-form-title:before {
  content: '*';
  color: red;
  vertical-align: sub;
  margin-right: 5px;
}

.asterisk:before {
  content: '*';
  color: red;
  vertical-align: sub;
  margin-right: 5px;
}
</style>
