<template>
	<view :class="{showHiddenWindowActive:showHiddenWindow}">
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">安全环保检查发起</block>
		</cu-custom>
		<view class="form">
			<view class="wui-form-list">
				<view class="cu-form-group" v-if="!forbidEdit">
					<view class="title">检查题目:</view>
					<radio-group @change="changeRadioGroup($event)">
						<label class="radio">
							<radio value="安全" :checked="form.INSPECTION_CATEGORY === '安全'" />安全
						</label>
						<label class="radio">
							<radio value="环保" :checked="form.INSPECTION_CATEGORY === '环保'" />环保
						</label>
						<label class="radio">
							<radio value="综合" :checked="form.INSPECTION_CATEGORY === '综合'" />综合
						</label>
					</radio-group>
				</view>
				<view class="cu-form-group" v-else>
					<view class="title">检查标题:</view>
					<view>{{form.INSPECTION_CATEGORY}}现场检查记录</view>
				</view>
				<view class="cu-form-group">
					<view class="title" style="height: auto;">
						<view>被检查单位:</view>
					</view>
					<block v-if="!forbidEdit">
						<view class="picker-tree-box">
							<view class="picker-tree" @tap="showZgTree('tkiTree1', 1)">
								{{ form.UNITS_NAME || '请选择' }}
							</view>
						</view>
						<tki-tree ref="tkiTree1" :selectParent=true :range="treeNode" rangeKey="UNITS_NAME"
							@confirm="zgtreeConfirm($event,'inspectedSiteuserList')" @cancel="zgtreeCancel"></tki-tree>
					</block>
					<block v-else>{{ form.UNITS_NAME }}</block>
				</view>
				<view class="cu-form-group" v-if="form.UNITS_NAME">
					<view class="title">被检查单位现场负责人:</view>
					<picker @change="inspectedSiteuserChange" :disabled="forbidEdit"
						:value="form.INSPECTED_SITEUSER_INDEX" :range="inspectedSiteuserList" range-key="NAME">
						<view class="picker">
							{{ form.PERSON_NAME || '请选择' }}
						</view>
					</picker>
				</view>

				<view class="cu-form-group">
					<view class="title">检查场所:</view>
					<input :disabled="forbidEdit" v-model="form.INSPECTION_PLACE" placeholder="请输入检查场所"></input>
				</view>

				<view class="cu-form-group">
					<view class="title" style="height: auto;">
						<view>检查类型:</view>
					</view>
					<block v-if="!forbidEdit">
						<view class="picker-tree-box">
							<view class="picker-tree" @tap="showZgTree('tkiTree2', 2)">
								{{ form.INSPECTION_TYPE_NAME || '请选择' }}
							</view>
						</view>
						<tki-tree ref="tkiTree2" :selectParent=true :range="inspectionTypeTreeList" rangeKey="name"
							@confirm="zgtreeConfirm($event,'inspectionTypeTreeList')" @cancel="zgtreeCancel"></tki-tree>
					</block>
					<block v-else>{{ form.INSPECTION_TYPE_NAME }}</block>
				</view>

				<view class="cu-form-group">
					<view class="title">检查开始时间:</view>
					<ruiDatePicker v-if="!forbidEdit" fields="minute" :value="form.INSPECTION_TIME_START || '请选择'"
						@change="changeStartDate"></ruiDatePicker>
					<text v-else>{{ form.INSPECTION_TIME_START }}</text>
				</view>

				<view class="cu-form-group">
					<view class="title">检查结束时间:</view>
					<!-- 以今天为止 <ruiDatePicker v-if="!forbidEdit" :start="todayDate" fields="minute" :value="form.INSPECTION_TIME_END || '请选择'"
                         @change="changeEndDate"></ruiDatePicker> -->
					<ruiDatePicker v-if="!forbidEdit" fields="minute" :value="form.INSPECTION_TIME_END || '请选择'"
						@change="changeEndDate"></ruiDatePicker>
					<view v-else>{{form.INSPECTION_TIME_END}}</view>
				</view>

				<view v-if="forbidEdit" class="cu-form-group">
					<view class="title">记录填写时间:</view>
					<view>{{form.CREATTIME}}</view>
				</view>

				<view class="cu-form-group">
					<view class="title">检查情况:</view>
					<button v-if="!forbidEdit" class="cu-btn round bg-blue" @click="addSituation">添加</button>
				</view>
				<view v-if="forbidEdit" v-show="form.situationList && form.situationList.length > 0"
					class="ace-content">
					<view class="add_pard_item" v-for="(item,index) of form.situationList" :key="'SITUATION'+index">
						<view class="cu-form-textarea">
							<textarea disabled v-model="item.SITUATION"></textarea>
						</view>
					</view>
				</view>
				<view v-else class="ace-content">
					<view class="add_pard_item" v-for="(item,index) of form.situationList" :key="index">
						<view class="add_pard_del" @click="removeSituation(item, index)" v-if="index !== 0">
							<text class="cuIcon-roundclosefill text-red f40"></text>
						</view>
						<view class="cu-form-textarea">
							<textarea placeholder="请输入检查情况..." v-model="item.SITUATION"></textarea>
						</view>
					</view>
				</view>

				<view class="cu-form-textarea">
					<view class="cu-form-title text-hui">检查人员</view>
					<textarea :disabled="forbidEdit" v-model="form.INSPECTION_USERS"
						placeholder="请输入检查人员..."></textarea>
				</view>

				<view class="cu-form-group">
					<view class="title">发现问题:</view>
					<button v-if="!forbidEdit" class="cu-btn round bg-blue" @click="addHidden">添加</button>
				</view>

				<view style="padding: 20upx">
					<uni-table border stripe emptyText="暂无更多数据">
						<uni-tr>
							<uni-th align="center" style="font-weight: bold;width: 100upx">序号</uni-th>
							<uni-th align="center" style="font-weight: bold">隐患部位</uni-th>
							<uni-th align="center" style="font-weight: bold">隐患描述</uni-th>
							<uni-th align="center" style="font-weight: bold;width: 160upx">操作</uni-th>
						</uni-tr>
						<uni-tr v-for="(item, index) in form.hiddenList" :key="'hidden'+index">
							<uni-td>{{ index + 1 }}</uni-td>
							<uni-td>{{ item.HIDDENPART_NAME?item.HIDDENPART_NAME:item.HIDDENPART }}</uni-td>
							<uni-td>{{ item.HIDDENDESCR }}</uni-td>
							<uni-td style="text-align: center;">
								<icon type="info" size="26" style="margin-right: 8px" @tap="showHidden(item, index)" />
								<icon type="cancel" size="26" @tap="removeHidden(item, index)" v-if="!forbidEdit" />
							</uni-td>
						</uni-tr>
					</uni-table>
				</view>
				<view class="cu-form-textarea" v-if="forbidEdit">
					<view class="cu-form-title text-hui">签字</view>
					<image :src="baseImgPath + form.PERSON_SIGN_IMG" style="width: 100%;height: 200upx;"
						mode="aspectFit"></image>
				</view>
				<view class="cu-form-group" v-if="forbidEdit">
					<view class="title">签字时间:</view>
					<view>{{form.PERSON_SIGN_TIME}}</view>
				</view>
			</view>
		</view>
		<view class="cu-bar btn-group" style="margin-top: 30upx;">
			<button v-if="!forbidEdit" class="cu-btn bg-blue margin-tb-sm lg"
				@click="$noMultipleClicks(goSubmit,'1')">提交</button>
			<button v-if="forbidEdit" class="cu-btn bg-green margin-tb-sm lg"
				@click="$noMultipleClicks(goback)">返回</button>
		</view>
		<view class="padding flex flex-direction"></view>

		<uni-drawer ref="showHiddenWindow" mode="right" :mask-click="true" @change="change($event,'showHiddenWindow')">
			<scroll-view scroll-y="true" style="height: 100vh;">
				<view class="de-drawer">
					<view class="cu-bar bg-white">
						<view class="action">
							隐患照片
						</view>
						<view class="action">
							{{hiddenForm.hiddenImgs.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 hiddenForm.hiddenImgs" :key="index"
								@tap="ViewImage" :data-id="item.IMGFILES_ID" data-type="0"
								:data-url="hiddenForm.hiddenImgs[index].FILEPATH">
								<image v-if="item.IMGFILES_ID"
									:src="baseImgPath + hiddenForm.hiddenImgs[index].FILEPATH" mode="aspectFill">
								</image>
								<image v-else :src="hiddenForm.hiddenImgs[index].FILEPATH" mode="aspectFill"></image>
								<view class="cu-tag bg-red" @tap.stop="DelImg" data-type="0" :data-index="index"
									v-if="!forbidEdit">
									<text class='cuIcon-close'></text>
								</view>
							</view>
							<view class="solids" @tap="ChooseImage(0)"
								v-if="hiddenForm.hiddenImgs.length<4 && !forbidEdit">
								<text class='cuIcon-cameraadd'></text>
							</view>
						</view>
					</view>
					<view class="cu-bar bg-white">
						<view class="action">
							隐患视频
						</view>
						<view class="action">
							{{hiddenForm.hiddenVideos.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 hiddenForm.hiddenVideos" :key="vindex"
								@tap="ViewVideo" data-type="0" :data-url="hiddenForm.hiddenVideos[vindex].FILEPATH"
								style="background-color: #000">
								<image src="/static/icon-apps/video.png" mode="aspectFill" @click="playVideo"
									:data-src="hiddenForm.hiddenVideos[vindex].FILEPATH"></image>
								<view class="cu-tag bg-red" @tap.stop="DelVideo" data-type="0" :data-index="vindex"
									v-if="!forbidEdit">
									<text class='cuIcon-close'></text>
								</view>
							</view>
							<view class="solids" @tap="chooseVideo(0)"
								v-if="hiddenForm.hiddenVideos.length == 0 && !forbidEdit">
								<text class='cuIcon-cameraadd'></text>
							</view>
						</view>
					</view>
					<view class="cu-form-textarea">
						<view class="cu-form-title text-hui">隐患描述</view>
						<textarea maxlength="-1" :disabled="forbidEdit" v-model="hiddenForm.HIDDENDESCR"
							placeholder="请对隐患进行详细描述(必填项)"></textarea>
					</view>
					<view class="cu-form-group">
						<view class="title">隐患部位</view>
						<view class="picker-tree-box">
							<input :disabled="forbidEdit" v-model="hiddenForm.HIDDENPART" placeholder="请输入隐患部位"></input>
						</view>
					</view>

					<view class="cu-form-group">
						<view class="title">隐患级别</view>
						<view class="picker-tree-box">
							<picker @change="hiddenLevelChange" :disabled="forbidEdit"
								:value="hiddenForm.HIDDENLEVEL_INDEX" :range="hiddenLevelTreeList" range-key="label">
								<view class="picker">
									{{ hiddenForm.HIDDENLEVEL_NAME || '请选择' }}
								</view>
							</picker>
						</view>
					</view>

					<view class="cu-form-group">
						<view class="title">隐患类型</view>
						<view class="picker-tree-box">
							<view class="picker-tree" @tap="forbidEdit ? null : showZgTree('tkiTree5', 5)">
								{{hiddenForm.HIDDENTYPE_NAME || '请选择'}}
							</view>
						</view>
						<tki-tree ref="tkiTree5" :selectParent=false :range="hiddenTypeTreeList" rangeKey="name"
							@confirm="zgtreeConfirm($event,'hiddenTypeTreeList')" @cancel="zgtreeCancel">
						</tki-tree>
					</view>
					<view class="cu-form-group">
						<view class="title">隐患处置:</view>
						<radio-group @change="changeRadioGroup1($event)">
							<!--              <label class="radio"><radio value="1" :checked="hiddenForm.RECTIFICATIONTYPE === '1'" />立即整改</label>-->
							<label class="radio">
								<radio value="2" :checked="hiddenForm.RECTIFICATIONTYPE === '2'" />限期整改
							</label>
						</radio-group>
					</view>
					<view class="cu-form-group" v-if="hiddenForm.RECTIFICATIONTYPE === '2'">
						<view class="title">整改期限:</view>
						<ruiDatePicker :start="todayDate" fields="minute"
							:value="hiddenForm.RECTIFICATIONDEADLINE || '请选择'" @change="changeDiscoverDate"
							v-if="!forbidEdit"></ruiDatePicker>
						<view v-else>{{hiddenForm.RECTIFICATIONDEADLINE}}</view>
					</view>
					<!--          <view class="cu-bar bg-white" v-if="hiddenForm.RECTIFICATIONTYPE === '1'">-->
					<!--            <view class="action">-->
					<!--              隐患照片-->
					<!--            </view>-->
					<!--            <view class="action">-->
					<!--              {{hiddenForm.zgImgs.length}}/4-->
					<!--            </view>-->
					<!--          </view>-->
					<!--          <view class="cu-form-group" v-if="hiddenForm.RECTIFICATIONTYPE === '1'">-->
					<!--            <view class="grid col-4 grid-square flex-sub">-->
					<!--              <view class="bg-img" v-for="(item,index) in hiddenForm.zgImgs" :key="index" @tap="ViewImage1" :data-id="item.IMGFILES_ID" data-type="0" :data-url="hiddenForm.zgImgs[index].FILEPATH">-->
					<!--                <image v-if="item.IMGFILES_ID" :src="baseImgPath + hiddenForm.zgImgs[index].FILEPATH" mode="aspectFill"></image>-->
					<!--                <image v-else :src="hiddenForm.zgImgs[index].FILEPATH" mode="aspectFill"></image>-->
					<!--                <view class="cu-tag bg-red" @tap.stop="DelImg1"  data-type="0" :data-index="index">-->
					<!--                  <text class='cuIcon-close'></text>-->
					<!--                </view>-->
					<!--              </view>-->
					<!--              <view class="solids" @tap="ChooseImage1(0)" v-if="hiddenForm.zgImgs.length<4">-->
					<!--                <text class='cuIcon-cameraadd'></text>-->
					<!--              </view>-->
					<!--            </view>-->
					<!--          </view>-->
					<!--          <view class="cu-form-textarea" v-if="hiddenForm.RECTIFICATIONTYPE === '1'">-->
					<!--            <view class="cu-form-title text-hui">整改描述</view>-->
					<!--            <textarea maxlength="-1" :disabled="modalName!=null" v-model="hiddenForm.RECTIFYDESCR" placeholder="请输入整改描述(必填项)"></textarea>-->
					<!--          </view>-->

					<view class="cu-form-group">
						<view class="title" style="height: auto;">
							<view>整改部门:</view>
						</view>
						<block v-if="!forbidEdit">
							<view class="picker-tree-box">
								<view class="picker-tree" @tap="showZgTree('tkiTree6', 1)">
									{{ hiddenForm.RECTIFICATIONDEPT_NAME || '请选择' }}
								</view>
							</view>
							<tki-tree ref="tkiTree6" :selectParent=true :range="treeNode" rangeKey="UNITS_NAME"
								@confirm="zgtreeConfirm($event,'rectificationSiteuserColumns')" @cancel="zgtreeCancel">
							</tki-tree>
						</block>
						<block v-else>{{ hiddenForm.RECTIFICATIONDEPT_NAME }}</block>
					</view>
					<view class="cu-form-group" v-if="hiddenForm.RECTIFICATIONDEPT_NAME">
						<view class="title">整改人:</view>
						<picker @change="rectificationSiteuserConfirmPicker" :disabled="forbidEdit"
							:value="hiddenForm.RECTIFICATIONOR_INDEX" :range="rectificationSiteuserColumns"
							range-key="NAME">
							<view class="picker">
								{{ hiddenForm.RECTIFICATIONOR_NAME || '请选择' }}
							</view>
						</picker>
					</view>
          <view style="display: flex;padding: 50upx 30upx 100upx 30upx">
			  <view style="flex: 1">
				  <button class="cu-btn" style="width: 95%;" @tap="cancelHidden">取消</button>
			  </view>
			  <view v-if="hiddenIsEdit" style="flex: 1">
				  <button class="cu-btn bg-blue shadow" style="width: 95%;" @tap="saveHidden">保存</button>
			  </view>
			</view>
					<!-- <view class="de-drawer-bottom">
						<view class="cz-btn">
							<text class="cu-btn" @click="cancelHidden">取消</text>
						</view>
						<view v-if="hiddenIsEdit" class="done-btn" @click="saveHidden">
							<text class="cu-btn bg-blue">保存</text>
						</view>
					</view> -->
				</view>
			</scroll-view>
		</uni-drawer>
		<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" :autoplay="true"></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>
		<view class="cu-modal" :class="{'show':signModalShow}">
			<sign @confirm="subCanvas" @cancel="signModalShow = false"></sign>
		</view>
	</view>
</template>

<script>
	import {
		basePath,
		corpinfoId,
		deptId,
		loginUser,
		formatDate,
		loginSession,
		baseImgPath,
		loginUserId
	} from '@/common/tool.js';
	import tkiTree from "@/components/select-tree/select-tree.vue"
	import sign from '@/components/sign/sign.vue';
	import gcoord from '@/common/gcoord.js'
	import ruiDatePicker from '@/components/rattenking-dtpicker/rattenking-dtpicker.vue'
	import moreSelect from '@/components/more-select/more-select.vue';
	import uniPopup from '@/components/more-select/uni-popup/uni-popup.vue';
	import punishVue from "./punish.vue"
	export default {
		components: {
			tkiTree,
			ruiDatePicker,
			sign,
			moreSelect,
			uniPopup,
			punishVue
		},
		data() {
			return {
				// 罚单开关
				punishFormType: false,
				baseImgPath: baseImgPath,
				isUps: false,
				forbidEdit: true, // 禁止修改
				msg: 'add',
				noClick: true,
				treeNode: [], //部门下拉数据
				inspectedSiteuserList: [], // 被检查单位现场负责人下拉数据
				inspectionTypeTreeList: [], // 检查类型下拉数据
				rectificationSiteuserColumns: [],
				inspectorList: [], // 检查人员(二维数组)下拉数据
				form: {
					INSPECTION_USERS: '',
					KEYPROJECTCHECK_ID: '', // 检查ID
					OUTSOURCED_ID: '', // 检查ID
					INSPECTION_CATEGORY: '', // 检查标题
					INSPECTION_SOURCE: '5', // 检查来源(4-监管端 5-企业端)
					INSPECTION_ORIGINATOR_ID: '', // 检查发起人
					UNITS_ID: '', // 被检查单位
					UNITS_NAME: '',
					PERSONNELMANAGEMENT_ID: '', // 被检查单位现场负责人
					INSPECTED_SITEUSER_INDEX: '',
					PERSON_NAME: '',
					INSPECTED_EXPLAIN: '', // 申辩内容
					INSPECTED_SITEUSER_SIGN_IMG: '', // 被检查单位现场负责人签字
					INSPECTED_SITEUSER_SIGN_TIME: '', // 被检查单位现场负责人签字时间
					INSPECTION_TYPE: '', // 检查类型
					INSPECTION_TYPE_NAME: '',
					INSPECTION_PLACE: '', // 检查场所
					INSPECTION_TIME_START: '', // 检查开始时间
					INSPECTION_TIME_END: '', // 检查结束时间
					INSPECTION_STATUS: '0', // 状态(0.暂存 1.检查人待确认、2.被检查人待确认、3.归档 -1.检查人异议打回 -2被检查人申辩)
					POSITIONDESC: '', // 隐患位置描述
					CREATTIME: '',
					inspectorList: [{
						INSPECTION_INSPECTOR_ID: '', //检查人员主键
						INSPECTION_DEPARTMENT_ID: '', //检查人员部门ID
						INSPECTION_DEPARTMENT_NAME: '',
						INSPECTION_USER_ID: '', //检查人员ID
						INSPECTION_USER_INDEX: '',
						INSPECTION_USER_NAME: ''
					}], // 检查人员
					situationList: [{
						INSPECTION_SITUATION_ID: '',
						SITUATION: ''
					}], // 检查情况
					hiddenList: [{
						...this.hiddenForm
					}], // 隐患信息集合

					INSPECTION_USER_SIGN_TIME: '',
					INSPECTION_USER_OPINION: ''

				}, // 数据
				hiddenIds: [], // 检查保存后返回的隐患ID集合
				delSituations: [], // 编辑时删除的原来检查情况
				delInspectors: [], // 编辑时删除的原来检查情况
				delHiddens: [], // 编辑时删除的原来发现问题
				delHiddenFiles: [], // 编辑时删除的原来发现问题附件
				rules: [{
						name: 'INSPECTION_CATEGORY',
						message: '请输入检查标题'
					},
					{
						name: 'UNITS_ID',
						message: '请选择被检查单位'
					},
					{
						name: 'PERSONNELMANAGEMENT_ID',
						message: '请选择被检查单位现场负责人'
					},
					{
						name: 'INSPECTION_TYPE',
						message: '请选择检查类型不能为空'
					},
					{
						name: 'INSPECTION_PLACE',
						message: '请输入检查场所'
					},
					{
						name: 'INSPECTION_TIME_START',
						message: '请选择检查开始时间'
					},
					{
						name: 'INSPECTION_TIME_END',
						message: '请选择作业结束时间'
					},
					{
						name: 'INSPECTION_USERS',
						message: '请输入检查人员'
					},
				],
				showHiddenWindow: false, // 隐患添加窗口显隐
				hiddenIsEdit: true,
				hiddenRegionTreeList: [], // 隐患部位下拉数据
				hiddenLevelTreeList: [{
					value: 'hiddenLevel1002',
					label: '一般隐患'
				}, {
					value: 'hiddenLevel1004',
					label: '轻微隐患'
				}], // 隐患级别下拉数据
				PUNISHList: [{
					value: '1',
					label: '是'
				}, {
					value: '2',
					label: '否'
				}], // 是否罚款下拉
				hiddenTypeTreeList: [], // 隐患类型下拉数据
				hiddenType2TreeList: [], // 隐患类型2下拉数据
				creatorList: [], // 隐患责任人下拉数据
				hiddenForm: {
					ISRELEVANT: '2',
					HIDDEN_ID: '', // 隐患ID
					HIDDENDESCR: '', // 隐患描述
					HIDDENPART: '', // 隐患部位
					HIDDENPART_NAME: '',
					HIDDENLEVEL: '', // 隐患级别
					HIDDENLEVEL_NAME: '',
					HIDDENTYPE: '', // 隐患类型1
					HIDDENTYPE_NAME: '',
					HIDDENTYPE2: '', // 隐患类型2
					HIDDENTYPE2_NAME: '',
					LONGITUDE: '', // 隐患位置经度
					LATITUDE: '', // 隐患位置纬度
					DISCOVERYTIME: '', // 隐患发现时间
					HIDDENFINDDEPT: '', // 隐患发现部门(隐患责任人部门)
					HIDDENFINDDEPT_NAME: '',
					CREATOR: '', // 发现人(隐患责任人)
					CREATOR_INDEX: '',
					CREATOR_NAME: '',
					SOURCE: '5', // 隐患描述
					hiddenImgs: [],
					zgImgs: [],
					hiddenVideos: [],
					RECTIFICATIONTYPE: '2',
					RECTIFICATIONDEADLINE: '',
					RECTIFYDESCR: '',
					RECTIFICATIONDEPT_NAME: '',
					RECTIFICATIONDEPT: '',
					RECTIFICATIONOR_INDEX: '',
					HIDDENLEVEL_INDEX: '',
					RECTIFICATIONOR_NAME: '',
					RECTIFICATIONOR: '',
                    punishForm: '',
				},
				modalShow: false,
				videoSrc: '',
				hiddenRules: [{
						name: 'HIDDENDESCR',
						message: '输入隐患描述'
					},
					{
						name: 'HIDDENPART',
						message: '请输入隐患部位'
					},
					{
						name: 'HIDDENLEVEL',
						message: '请选择隐患级别'
					},
					{
						name: 'HIDDENTYPE',
						message: '请选择隐患类型'
					},
					{
						name: 'RECTIFICATIONDEPT',
						message: '请选择整改部门'
					},
					{
						name: 'RECTIFICATIONOR',
						message: '请选择整改人'
					}
				],
				todayDate: '',
				modalName: null,
				cityIndex: 0,

				signImgList: [],
				signModalShow: false
			}
		},
		onLoad(event) {
			this.todayDate = formatDate(new Date(), 'yyyy-MM-dd hh:mm');
			this.form.OUTSOURCED_ID = event.OUTSOURCED_ID;
			this.form.KEYPROJECTCHECK_ID = event.KEYPROJECTCHECK_ID;
			this.form.hiddenList = []
			if (this.form.KEYPROJECTCHECK_ID) {
				this.msg = "edit";
				this.getData();
			} else {
				// 初始化作业负责人
				this.form.APPLY_DEPARTMENT_ID = loginUser.DEPARTMENT_ID;
				this.form.APPLY_DEPARTMENT_NAME = loginUser.DEPARTMENT_NAME;
				this.form.APPLY_USER_ID = loginUser.USER_ID;
				this.form.APPLY_USER = loginUser.NAME;
				this.getOutSource(this.form.OUTSOURCED_ID);
				this.forbidEdit = false;
			}
			// 初始化现场作业负责人
			this.getDept()
			this.getDict()
			loginSession();

		},
		methods: {
			getData() {
				var _this = this;
				uni.showLoading({
					title: '请稍候'
				})
				uni.request({
					url: basePath + '/app/keyprojectcheck/goEdit',
					method: 'POST',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						KEYPROJECTCHECK_ID: _this.form.KEYPROJECTCHECK_ID,
					},
					success: (res) => {
						if ("success" == res.data.result) {
							uni.hideLoading();
							_this.form = res.data.pd; //参数map
							for (let i = 0; i < _this.form.inspectorList.length; i++) {
								_this.inspectorList.push([])
							}
							if (Number(_this.form.INSPECTION_STATUS) < 1) {
								_this.forbidEdit = false;
							}
						} else if ("exception" == data.result) {
							uni.showToast({
								title: '错误',
								duration: 2000
							});
						}
					}
				});
			},
			goSubmit() {
				var _this = this;
				let required = true
				uni.showLoading({
					title: '请稍候'
				})
				this.rules.map(({
					name,
					message
				}) => {
					if (!this.form[name] || this.form[name] === '请选择') {
						uni.showToast({
							icon: 'none',
							title: message,
							duration: 1500
						});
						required = false
					}
				})
				if (!required) {
					return
				}
				for (let i = 0; i < this.form.situationList.length; i++) {
					if (!this.form.situationList[i].SITUATION) {
						uni.showToast({
							title: `请填写第${i + 1}项检查情况`,
							icon: 'none'
						})
						return
					}
				}
				for (var x in this.form.inspectorList) {
					var vector = 0
					for (var y in this.form.inspectorList) {
						if (this.form.inspectorList[y].INSPECTION_USER_ID === this.form.inspectorList[x]
							.INSPECTION_USER_ID) vector++
					}
					if (vector > 1) {
						uni.showToast({
							title: '检查人重复!请检查数据',
							icon: "none"
						})
						return
					}
				}

				// 封装隐患图片和视频附件
				var hiddenList = [],
					fileList = [];
				for (let i = 0; i < this.form.hiddenList.length; i++) {
					fileList = []
					for (let j = 0; j < this.form.hiddenList[i].hiddenImgs.length; j++) {
						if (!this.form.hiddenList[i].hiddenImgs[j].IMGFILES_ID) {
							var file = {};
							file.type = 3;
							file.FILEPATH = this.form.hiddenList[i].hiddenImgs[j].FILEPATH;
							fileList.push(file);
						}
					}
					for (let j = 0; j < this.form.hiddenList[i].zgImgs.length; j++) {
						if (!this.form.hiddenList[i].zgImgs[j].IMGFILES_ID) {
							var file = {};
							file.type = 4;
							file.FILEPATH = this.form.hiddenList[i].zgImgs[j].FILEPATH;
							fileList.push(file);
						}
					}
					if (this.form.hiddenList[i].hiddenVideos.length > 0) {
						if (!this.form.hiddenList[i].hiddenVideos[0].IMGFILES_ID) {
							var file = {};
							file.type = 102;
							file.FILEPATH = this.form.hiddenList[i].hiddenVideos[0].FILEPATH;
							fileList.push(file);
						}
					}
					hiddenList.push(fileList)
				}

				var index = this.form.inspectorList.findIndex(item => {
					return item.INSPECTION_USER_ID === loginUser.USER_ID
				})
				if (index < 0) {
					this.form.inspectorList.push({
						INSPECTION_INSPECTOR_ID: '', //检查人员主键
						INSPECTION_DEPARTMENT_ID: loginUser.DEPARTMENT_ID, //检查人员部门ID
						INSPECTION_DEPARTMENT_NAME: loginUser.DEPARTMENT_NAME,
						INSPECTION_USER_ID: loginUser.USER_ID, //检查人员ID
						INSPECTION_USER_INDEX: '',
						INSPECTION_USER_NAME: loginUser.NAME
					})
				}
				this.$set(this.form, 'INSPECTORJSON', JSON.stringify(this.form.inspectorList))
				this.$set(this.form, 'SITUATIONJSON', JSON.stringify(this.form.situationList))
				this.$set(this.form, 'HIDDENJSON', JSON.stringify(this.form.hiddenList))
				this.$set(this.form, 'delInspectors', this.delInspectors.join(','))
				this.$set(this.form, 'delSituations', this.delSituations.join(','))
				this.$set(this.form, 'delHiddens', this.delHiddens.join(','))
				this.$set(this.form, 'delHiddenFiles', this.delHiddenFiles.join(','))
				this.$set(this.form, 'CREATOR', loginUser.USER_ID)
				this.$set(this.form, 'CORPINFO_ID', corpinfoId)
				this.$set(this.form, 'ACTION_USER', loginUser.NAME)

				this.submit(hiddenList)
			},
			uploadImg(hiddenList) {
				var _this = this;
				uni.showLoading({
					title: '上传中'
				})
				for (let i = 0; i < hiddenList.length; i++) {
					let hiddenID = _this.hiddenIds[i].HIDDEN_ID
					let fileList = hiddenList[i]
					for (let j = 0; j < fileList.length; j++) {
						uni.uploadFile({
							url: basePath + '/app/imgfiles/add',
							filePath: fileList[j].FILEPATH,
							name: 'FFILE',
							formData: {
								'TYPE': fileList[j].type,
								'FOREIGN_KEY': hiddenID
							},
							success: (res) => {
								console.info(res)
								uni.hideLoading();
							},
							fail: (err) => {
								uni.hideLoading();
								uni.showModal({
									content: err.errMsg,
									showCancel: false
								});
							}
						})
					}
				}
				_this.goback()
			},
			submit(hiddenList) {
				console.log(this)
				var _this = this;
				uni.request({
					url: basePath + '/app/keyprojectcheck/add',
					method: 'POST',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						CORPINFO_ID: corpinfoId,
						..._this.form,
						CREATOR: loginUserId,
						OPERATOR: loginUserId,
					},
					success: (res) => {
						console.log(res)
						if ("success" == res.data.result) {
							_this.hiddenIds = res.data.pd.hiddenList
							console.info(_this.hiddenIds)
							if (hiddenList.length === 0) {
								_this.goback()
							} else {
								for (var i = 0; i < res.data.pd.hiddenList.length; i++) {
									// 写入隐患id
									if (_this.form.hiddenList[i].punishForm) {
										_this.form.hiddenList[i].punishForm.HIDDEN_ID = res.data.pd.hiddenList[
											i].HIDDEN_ID
										// 调用子组件方法写入罚单
										_this.fnSubmit(_this.form.hiddenList[i].punishForm)
									}
								}
								_this.uploadImg(hiddenList)

							}
						} else {
							uni.showToast({
								title: res.data.msaesge,
								duration: 2000
							});
						}
					}
				});
			},
			// 迁移的子页面保存方法,创建罚单
			fnSubmit(ordForm) {
				if (ordForm) {
					this.punishForm = ordForm
				}
				for (const key in this.punishRules) {
					if (!this.punishForm[key]) {
						uni.showToast({
							title: this.punishRules[key],
							icon: 'none'
						})
						return
					}
				}
				uni.request({
					url: basePath + '/app/keyprojectpunish/add',
					method: 'POST',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						...this.punishForm,
						CORPINFO_ID: corpinfoId,
						CREATOR: loginUserId,
						OPERATOR: loginUserId,
					},
					success: (res) => {
						if ("success" == res.data.result) {
							this.modalShow = false
						} else {
							uni.showToast({
								title: res.data.msaesge,
								duration: 2000
							});
						}
					}
				});
			},
			changeRadioGroup(e) {
				this.form.INSPECTION_CATEGORY = e.detail.value
			},
			changeRadioGroup1(e) {
				this.hiddenForm.RECTIFICATIONTYPE = e.detail.value
			},
			changeStartDate(e) {
				this.form.INSPECTION_TIME_START = e
				this.$forceUpdate(); //强制刷新
			},
			changeEndDate(e) {
				this.form.INSPECTION_TIME_END = e
				this.$forceUpdate(); //强制刷新
			},
			showZgTree(ref, index) {
				if (index > 7) {
					this.$refs[ref][0]._show();
				} else {
					this.$refs[ref]._show();
				}
			},
			radioISRELEVANT(e) {
				this.hiddenForm.ISRELEVANT = e
			},
			zgtreeCancel(e) {
				this.isUps = false;
			},
			zgtreeConfirm(e, list, i) {
				if (list === 'inspectedSiteuserList') { // 被检查单位现场负责人
					this.form.UNITS_ID = e[0].UNITS_ID
					this.form.UNITS_NAME = e[0].UNITS_NAME
					this.form.INSPECTED_SITEUSER_INDEX = ''
					this.form.PERSONNELMANAGEMENT_ID = ''
					this.form.PERSON_NAME = ''
					this.getUserList(list, e[0].UNITS_ID)
				}
				if (list === 'rectificationSiteuserColumns') {
					this.hiddenForm.RECTIFICATIONDEPT = e[0].UNITS_ID
					this.hiddenForm.RECTIFICATIONDEPT_NAME = e[0].UNITS_NAME
					this.hiddenForm.RECTIFICATIONOR_NAME = ''
					this.hiddenForm.RECTIFICATIONOR = ''
					this.getUserList(list, e[0].UNITS_ID)
				}
				if (list === 'inspectionTypeTreeList') { // 检查类型
					this.form.INSPECTION_TYPE = e[0].id
					this.form.INSPECTION_TYPE_NAME = e[0].name
				}
				if (list === 'inspectorList') { // 检查人员
					this.form.inspectorList[i].INSPECTION_DEPARTMENT_ID = e[0].id
					this.form.inspectorList[i].INSPECTION_DEPARTMENT_NAME = e[0].name
					this.form.inspectorList[i].INSPECTION_USER_INDEX = ''
					this.form.inspectorList[i].INSPECTION_USER_ID = ''
					this.form.inspectorList[i].INSPECTION_USER_NAME = ''
				}
				if (list === 'hiddenRegionTreeList') { // 隐患部位
					this.hiddenForm.HIDDENPART = e[0].id
					this.hiddenForm.HIDDENPART_NAME = e[0].name
				}
				if (list === 'hiddenLevelTreeList') { // 隐患级别
					this.hiddenForm.HIDDENLEVEL = e[0].id
					this.hiddenForm.HIDDENLEVEL_NAME = e[0].name
				}
				if (list === 'hiddenTypeTreeList') { // 隐患级别
					this.hiddenForm.HIDDENTYPE = e[0].id
					this.hiddenForm.HIDDENTYPE_NAME = e[0].name
				}
				if (list === 'hiddenType2TreeList') { // 隐患级别
					this.hiddenForm.HIDDENTYPE2 = e[0].id
					this.hiddenForm.HIDDENTYPE2_NAME = e[0].name
				}
				if (list === 'creatorList') { // 隐患级别
					this.hiddenForm.HIDDENFINDDEPT = e[0].id
					this.hiddenForm.HIDDENFINDDEPT_NAME = e[0].name
					this.hiddenForm.CREATOR_INDEX = ''
					this.hiddenForm.CREATOR = ''
					this.hiddenForm.CREATOR_NAME = ''
				}
			},
			inspectedSiteuserChange(e) {
				this.form.INSPECTED_SITEUSER_INDEX = e.detail.value;
				this.form.PERSONNELMANAGEMENT_ID = this.inspectedSiteuserList[e.detail.value].PERSONNELMANAGEMENT_ID;
				this.form.PERSON_NAME = this.inspectedSiteuserList[e.detail.value].NAME;
			},
			rectificationSiteuserConfirmPicker(e) {
				this.hiddenForm.RECTIFICATIONOR_INDEX = e.detail.value;
				this.hiddenForm.RECTIFICATIONOR = this.rectificationSiteuserColumns[e.detail.value].PERSONNELMANAGEMENT_ID;
				this.hiddenForm.RECTIFICATIONOR_NAME = this.rectificationSiteuserColumns[e.detail.value].NAME;
			},
			hiddenLevelChange(e) {
				this.hiddenForm.HIDDENLEVEL_INDEX = e.detail.value;
				this.hiddenForm.HIDDENLEVEL = this.hiddenLevelTreeList[e.detail.value].value;
				this.hiddenForm.HIDDENLEVEL_NAME = this.hiddenLevelTreeList[e.detail.value].label;
			},
			inspectorChange(e, index) {
				this.form.inspectorList[index].INSPECTION_USER_INDEX = e.detail.value;
				this.form.inspectorList[index].INSPECTION_USER_ID = this.inspectorList[index][e.detail.value].USER_ID;
				this.form.inspectorList[index].INSPECTION_USER_NAME = this.inspectorList[index][e.detail.value].NAME;
			},
			addSituation() {
				this.form.situationList.push({
					INSPECTION_SITUATION_ID: '',
					SITUATION: ''
				})
			},
			removeSituation(item, index) {
				var _this = this;
				uni.showModal({
					title: '提示',
					cancelText: '确认',
					confirmText: '取消',
					content: '确定删除检查情况吗?',
					success: function(res) {
						if (res.cancel) {
							_this.form.situationList.splice(index, 1)
							if (item.INSPECTION_SITUATION_ID) {
								_this.delSituations.push(item.INSPECTION_SITUATION_ID)
							}
						}
					}
				});
			},

			addInspector() {
				this.form.inspectorList.push({
					INSPECTION_INSPECTOR_ID: '', //检查人员主键
					INSPECTION_DEPARTMENT_ID: '', //检查人员部门ID
					INSPECTION_DEPARTMENT_NAME: '',
					INSPECTION_USER_ID: '', //检查人员ID
					INSPECTION_USER_INDEX: '',
					INSPECTION_USER_NAME: ''
				})
			},
			removeInspector(item, index) {
				var _this = this;
				uni.showModal({
					title: '提示',
					cancelText: '确认',
					confirmText: '取消',
					content: '确定移除检查人员吗?',
					success: function(res) {
						if (res.cancel) {
							_this.form.inspectorList.splice(index, 1);
							if (item.INSPECTION_INSPECTOR_ID) {
								_this.delInspectors.push(item.INSPECTION_INSPECTOR_ID)
							}
						}
					}
				});
			},

			removeHidden(item, index) {
				var _this = this;
				uni.showModal({
					title: '提示',
					cancelText: '确认',
					confirmText: '取消',
					content: '确定移除发现问题吗?',
					success: function(res) {
						if (res.cancel) {
							console.info(_this.form)
							_this.form.hiddenList.splice(index, 1);
							if (item.HIDDEN_ID) {
								_this.delHiddens.push(item.HIDDEN_ID)
							}
						}
					}
				});
			},
			// 打开隐患添加窗口
			addHidden() {
				this.resetHd()
				this.hiddenForm.RECTIFICATIONDEPT = this.treeNode[0].UNITS_ID
				this.hiddenForm.RECTIFICATIONDEPT_NAME = this.treeNode[0].UNITS_NAME //默认整改部门为相关方单位
				this.hiddenForm.RECTIFICATIONOR = this.form.PERSONNELMANAGEMENT_ID;
				this.hiddenForm.RECTIFICATIONOR_NAME = this.form.PERSON_NAME;
				this.getUserList('rectificationSiteuserColumns', this.treeNode[0].UNITS_ID)
				this.creatorList = [{
					NAME: loginUser.NAME,
					USER_ID: loginUser.USER_ID
				}]
				this.form.inspectorList.forEach(item => {
					this.creatorList.push({
						USER_ID: item.INSPECTION_USER_ID,
						NAME: item.INSPECTION_USER_NAME
					})
				})
				this.$refs['showHiddenWindow'].open()
				this.showHiddenWindow = true
				this.hiddenIsEdit = true
			},

			// 打开隐患添加窗口
			showHidden(item) {
				console.log(item)
				this.resetHd()
				this.creatorList = [{
					NAME: loginUser.NAME,
					USER_ID: loginUser.USER_ID
				}]
				this.hiddenForm = item
				this.$refs['showHiddenWindow'].open()
				this.showHiddenWindow = true
				this.hiddenIsEdit = false
			},
			// 保存隐患
			saveHidden() {
				let required = true

				if (this.hiddenForm.hiddenImgs.length <= 0) {
					uni.showToast({
						icon: 'none',
						title: '请上传隐患图片',
						duration: 1500
					});
					return;
				}
				if (this.hiddenForm.RECTIFICATIONTYPE === '2') {
					if (!this.hiddenForm.RECTIFICATIONDEADLINE) {
						uni.showToast({
							title: '请选择整改期限',
							icon: "none"
						})
						return;
					}
				}
				if (this.hiddenForm.RECTIFICATIONTYPE === '1') {
					if (this.hiddenForm.zgImgs.length === 0) {
						uni.showToast({
							title: '请上传整改照片',
							icon: "none"
						})
						return;
					}
					if (!this.hiddenForm.RECTIFYDESCR) {
						uni.showToast({
							title: '请输入整改描述',
							icon: "none"
						})
						return;
					}
				}
				this.hiddenRules.map(({
					name,
					message
				}) => {
					if (!this.hiddenForm[name] || this.hiddenForm[name] === '请选择' || this.hiddenForm[name] ===
						'请输入') {
						uni.showToast({
							icon: 'none',
							title: message,
							duration: 1500
						});
						required = false
					}
				})
				if (!required) {
					return
				}
				uni.showLoading({
					title: '请稍候'
				})
				this.form.inspectorList.forEach(item => {
					if (item.INSPECTION_USER_ID === this.hiddenForm.CREATOR) {
						this.hiddenForm.HIDDENFINDDEPT = item.INSPECTION_DEPARTMENT_ID
					}
				})
				if (this.hiddenForm.RECTIFICATIONTYPE === '1') {
					this.hiddenForm.RECTIFICATIONDEADLINE = ''
				}
				if (this.$refs.punish) {
					this.hiddenForm.punishForm = this.$refs.punish.punishForm
				}
				this.form.hiddenList.push(this.hiddenForm)
				this.punishFormType = false
				this.cancelHidden()
				uni.hideLoading();
			},
			// 取消添加隐患
			cancelHidden() {
				this.$refs['showHiddenWindow'].close()
				this.showHiddenWindow = false
			},
			// 抽屉状态发生变化触发
			change(e, type) {
				this[type] = e
			},
			ViewImage(e) {
				if (e.currentTarget.dataset.type == 0) {
					let files = [];
					for (var i = 0; i < this.hiddenForm.hiddenImgs.length; i++) {
						if (e.currentTarget.dataset.id) {
							files.push(this.baseImgPath + this.hiddenForm.hiddenImgs[i].FILEPATH)
						} else {
							files.push(this.hiddenForm.hiddenImgs[i].FILEPATH)
						}
					}
					uni.previewImage({
						urls: files,
						current: e.currentTarget.dataset.id ? this.baseImgPath + e.currentTarget.dataset.url : e
							.currentTarget.dataset.url
					});
				} else {
					let files = [];
					for (var i = 0; i < this.hiddenForm.hiddenImgs.length; i++) {
						files.push(this.hiddenForm.hiddenImgs[i].FILEPATH)
					}
					uni.previewImage({
						urls: files,
						current: e.currentTarget.dataset.url
					});
				}
			},
			ViewImage1(e) {
				let files = [];
				for (var i = 0; i < this.hiddenForm.zgImgs.length; i++) {
					if (e.currentTarget.dataset.id) {
						files.push(this.baseImgPath + this.hiddenForm.zgImgs[i].FILEPATH)
					} else {
						files.push(this.hiddenForm.zgImgs[i].FILEPATH)
					}
				}
				uni.previewImage({
					urls: files,
					current: e.currentTarget.dataset.id ? this.baseImgPath + e.currentTarget.dataset.url : e
						.currentTarget.dataset.url
				});
			},
			ViewSignImage(e) {
				if (e.currentTarget.dataset.type == 0) {
					let files = [];
					for (var i = 0; i < this.hiddenForm.hiddenImgs.length; i++) {
						files.push(this.baseImgPath + this.hiddenForm.hiddenImgs[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.hiddenForm.hiddenImgs[i].IMGFILES_ID) {
									_this.delHiddenFiles.push(_this.hiddenForm.hiddenImgs[index].FILEPATH)
								} else {
									this.hiddenForm.hiddenImgs.splice(e.currentTarget.dataset.index, 1)
								}
							} else {
								if (_this.imgList1[i].IMGFILES_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].IMGFILES_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)
								}
							}
						}
					}
				})
			},
			DelImg1(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.hiddenForm.zgImgs[i].IMGFILES_ID) {
									_this.delHiddenFiles.push(_this.hiddenForm.zgImgs[index].FILEPATH)
								} else {
									this.hiddenForm.zgImgs.splice(e.currentTarget.dataset.index, 1)
								}
							}
						}
					}
				})
			},
			delSignImg(e) {
				var _this = this;
				let i = e.currentTarget.dataset.index
				uni.showModal({
					title: '秦港-双基双控',
					content: '确定要删除这张图片吗?',
					cancelColor: "#000000",
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							_this.signImgList.splice(i, 1)
						}
					}
				})
			},
			//图片上传
			ChooseImage(e) {
				var _this = this;
				var ss = 4 - this.hiddenForm.hiddenImgs.length;
				uni.chooseImage({
					count: ss, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
					sourceType: ['camera', 'album'], //从相册选择
					success: (res) => {
						for (let i = 0; i < res.tempFilePaths.length; i++) {
							if (e == 0) {
								let img = {};
								img.IMGFILES_ID = '';
								img.FILEPATH = res.tempFilePaths[i];
								this.hiddenForm.hiddenImgs.push(img)
							} else {
								let img = {};
								img.IMGFILES_ID = '';
								img.FILEPATH = res.tempFilePaths[i];
								this.imgList1.push(img)
							}
						}
					}
				});
			},
			//图片上传
			ChooseImage1(e) {
				var _this = this;
				var ss = 4 - this.hiddenForm.zgImgs.length;
				uni.chooseImage({
					count: ss, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
					sourceType: ['camera', 'album'], //从相册选择
					success: (res) => {
						for (let i = 0; i < res.tempFilePaths.length; i++) {
							if (e == 0) {
								let img = {};
								img.IMGFILES_ID = '';
								img.FILEPATH = res.tempFilePaths[i];
								this.hiddenForm.zgImgs.push(img)
							} else {
								let img = {};
								img.IMGFILES_ID = '';
								img.FILEPATH = res.tempFilePaths[i];
								this.imgList1.push(img)
							}
						}
					}
				});
			},

			ViewVideo(e) {

			},
			DelVideo(e) {
				uni.showModal({
					title: '秦港-双基双控',
					content: '确定要删除这个视频吗?',
					cancelColor: "#000000",
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.hiddenForm.hiddenVideos = []
						}
					}
				})
			},
			chooseVideo(e) {
				var _this = this;
				uni.chooseVideo({
					maxDuration: 60,
					count: 1, //默认9
					// sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
					sourceType: ['camera', 'album'], //从相册选择
					success: (res) => {
						if (e == 0) {
							let img = {};
							img.IMGFILES_ID = '';
							img.FILEPATH = res.tempFilePath;
							this.hiddenForm.hiddenVideos.push(img)
						} else {
							let img = {};
							img.IMGFILES_ID = '';
							img.FILEPATH = res.tempFilePaths[0];
							this.hiddenForm.hiddenVideos.push(img)
						}
					}
				});
			},
			playVideo(e) {
				if (e.currentTarget.dataset.src) {
					this.videoSrc = e.currentTarget.dataset.src
				}
				if (this.form.KEYPROJECTCHECK_ID) {
					this.videoSrc = this.baseImgPath + this.hiddenForm.hiddenVideos[0].FILEPATH
				}
				this.modalShow = true
			},
			changeDiscoverDate(e) {
				this.hiddenForm.RECTIFICATIONDEADLINE = e
				this.$forceUpdate(); //强制刷新
			},
			creatorChange(e) {
				this.hiddenForm.CREATOR_INDEX = e.detail.value;
				this.hiddenForm.CREATOR = this.creatorList[e.detail.value].USER_ID;
				this.hiddenForm.CREATOR_NAME = this.creatorList[e.detail.value].NAME;
			},

			/** 坐标定位 */
			showMapModal() {
				var _this = this
				uni.navigateTo({
					url: '/pages/map/mapPro',
					events: {
						// 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
						acceptDataFromOpenedPage: function(e) {
							_this.hiddenForm.LONGITUDE = e.data.longitue;
							_this.hiddenForm.LATITUDE = e.data.latitude;
						}
					},
				})
			},

			getDept() {
				var _this = this;
				uni.request({
					url: basePath + '/app/keyProjects/listAllUnits', //部门下拉接口
					method: 'POST',
					dataType: 'json',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						CORPINFO_ID: corpinfoId,
						OUTSOURCED_ID: _this.form.OUTSOURCED_ID,
					},
					success: (res) => {
						if ("success" == res.data.result) {
							_this.treeNode = res.data.varList;
							_this.form.UNITS_NAME = _this.treeNode[0].UNITS_NAME
							_this.form.UNITS_ID = _this.treeNode[0].UNITS_ID
							_this.getUserList('inspectedSiteuserList', _this.treeNode[0].UNITS_ID)
						} else {
							uni.showToast({
								title: res.data.message,
								duration: 2000
							});
						}
					}
				});
			},

			//获取人员列表
			getUserList(list, dept, i) {
				//发送 post 请求
				var _this = this
				uni.request({
					url: basePath + '/app/keyProjects/listAllPersonnel',
					method: 'POST',
					dataType: 'json',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						UNITS_ID: dept,
						NOMAIN: '1',
						tm: new Date().getTime()
					},
					success: function(res) {
						if ("success" == res.data.result) {
							_this[list] = res.data.varList;
						} else {
							uni.showToast({
								title: res.data.message,
								duration: 2000
							});
						}
					}
				})
			},
			//获取重点工程信息 并初始化赋值
			getOutSource(ID) {
				//发送 post 请求
				var _this = this
				uni.request({
					url: basePath + '/app/keyProjects/goEdit',
					method: 'POST',
					dataType: 'json',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						OUTSOURCED_ID: ID,
						tm: new Date().getTime()
					},
					success: function(res) {
						if ("success" == res.data.result) {
							console.log(res.data.pd);
							_this.form.PERSONNELMANAGEMENT_ID = res.data.pd.PERSONNELMANAGEMENT_ID;
							_this.form.PERSON_NAME = res.data.pd.NAME;
						} else {
							uni.showToast({
								title: res.data.message,
								duration: 2000
							});
						}
					}
				})
			},
			//获取数据字典数据
			getDict() {
				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: '60e6481d96e44a5390ff5c347c4d1ffe'
					},
					success: function(res) {
						_this.inspectionTypeTreeList = eval(res.data.zTreeNodes);
					}
				});

				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);
						} else {
							uni.showToast({
								title: res.data.message,
								duration: 2000
							});
						}
					}
				})

				// 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 == 'jdyh001' || data[i].children[j].id ==
				// 					'hiddenLevel1001') {
				// 					data[i].children.splice(j, 1)
				// 				}
				// 			}
				// 			if (data[i].id == 'hiddenLevel0002') {
				// 				data.splice(i, 1)
				// 			}
				// 		}
				// 		_this.hiddenLevelTreeList = data
				// 	}
				// })

				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: '3babc15144444bdc8d763d0af2bdfff6'
					},
					success: function(res) {
						var jons = res.data.zTreeNodes;
						_this.hiddenTypeTreeList = JSON.parse(jons);
					}
				})

				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: '18c0a9aea6e54feab9f4ab3f46e0bc86'
					},
					success: function(res) {
						var jons = res.data.zTreeNodes;
						_this.hiddenType2TreeList = JSON.parse(jons);
					}
				})
			},

			goback() {
				var pages = getCurrentPages(); // 获取当前页面栈
				var prePage = pages[pages.length - 2]; // 上二级页面
				prePage.$vm.initflag = true; // A 页面 init方法 为true
				uni.navigateBack({
					delta: 1
				});
				uni.hideLoading();
			},

			resetHd() {
				this.hiddenForm = {
					ISRELEVANT: '2',
					HIDDEN_ID: '', // 隐患ID
					HIDDENDESCR: '', // 隐患描述
					HIDDENPART: '', // 隐患部位
					HIDDENPART_NAME: '',
					HIDDENLEVEL: '', // 隐患级别
					HIDDENLEVEL_NAME: '',
					HIDDENTYPE: '', // 隐患类型1
					HIDDENTYPE_NAME: '',
					HIDDENTYPE2: '', // 隐患类型2
					HIDDENTYPE2_NAME: '',
					LONGITUDE: '', // 隐患位置经度
					LATITUDE: '', // 隐患位置纬度
					DISCOVERYTIME: '', // 隐患发现时间
					HIDDENFINDDEPT: '', // 隐患发现部门(隐患责任人部门)
					HIDDENFINDDEPT_NAME: '',
					CREATOR: '', // 发现人(隐患责任人)
					CREATOR_INDEX: '',
					CREATOR_NAME: '',
					SOURCE: '5', // 隐患描述
					hiddenImgs: [],
					zgImgs: [],
					hiddenVideos: [],
					RECTIFICATIONTYPE: '2',
					RECTIFICATIONDEADLINE: '',
					RECTIFYDESCR: '',
					RECTIFICATIONDEPT_NAME: '',
					RECTIFICATIONDEPT: '',
					RECTIFICATIONOR_INDEX: '',
					RECTIFICATIONOR_NAME: '',
					RECTIFICATIONOR: '',
				}
			},
			subCanvas(e) {
				this.signImgList.splice(0, this.signImgList.length);
				this.signImgList.push(e);
				this.$set(this.form, 'INSPECTION_USER_SIGN_TIME', formatDate(new Date(), 'yyyy-MM-dd hh:mm'))
				this.signModalShow = false;
			},
		}
	}
</script>

<style>
	.right_icon {
		position: relative;
		padding-right: 36upx;
		width: 200upx;
		text-align: right;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.right_icon ::after {
		font-family: cuIcon;
		display: block;
		content: "\e6a3";
		position: absolute;
		font-size: 17px;
		color: #8799a3;
		line-height: 50px;
		width: 30px;
		text-align: center;
		top: -28upx;
		bottom: 0;
		right: -22upx;
		margin: auto;
	}

	.modal_content {
		display: flex;
		text-align: left;
	}

	.modal_left {
		flex-basis: 50%;
		padding: 50upx 20upx;
		border-right: 1px solid #000000;
	}

	.modal_right {
		flex-basis: 50%;
		padding: 50upx;
	}

	.modal_left_title,
	.modal_right_title {
		font-size: 16px;
		color: #000000;
		font-weight: 700;
	}

	.checkbox-item {
		display: flex;
		align-items: center;
		padding: 0 30upx;
		min-height: 100upx;
		background-color: #ffffff;
		border-bottom: 1upx solid #ddd;
	}

	.checkbox-item:last-child {
		border-bottom: none;
	}

	.showHiddenWindowActive {
		overflow: hidden;
		height: 100vh;
	}
</style>