<template>
	<!-- 新增问题 -->
	<view class="addIssue">
		<view class="fixedheader">
			<headers :showBack="true" :themeType="true">
				<view class="headerName">
					{{pageTitle}}
				</view>
			</headers>
			<view class="tab flex2" style="background-color: #fff;">
				<view class="tabType" @click="radioChange('type1')"
					:class="checkedTab=='type1'?'checkedTab':'noCheckTab'">
					安全问题</view>
				<view class="tabType" @click="radioChange('type2')"
					:class="checkedTab=='type2'?'checkedTab':'noCheckTab'">
					排查记录</view>
			</view>
		</view>
		<!-- <view class="type flex"  v-if="COMPANY != 'zjwj'">
			<view class="name">类型：</view>
			<view>
				<radio-group @change="radioChange" class="radio-wrap">
					<label class="radio">
						<radio value="type1" checked="true" />安全问题
					</label>
					<label class="radio">
						<radio value="type2" />排查记录
					</label>
				</radio-group>
			</view>
		</view> -->
		<view class="content" :style="{paddingTop: mobileTopHeight + 100 + 'px'}">
			<template v-for="item in securityDangerList">
				<view class="type flex" v-show="item.originalFieldName == '责任区域' || item.originalFieldName == '检查部位'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
                      ? item.displayFieldName
                      : item.originalFieldName}}：</view>
					<picker @click="$refs.locationTree._show()" :disabled="true" class="picker">
						<view class="uni-input uni-select cl" v-if="checkPointName==''">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select flex2" v-else>
							<view style="width: 98%;" class="ellipsis">{{checkPointName}}</view>
						</view>
					</picker>
				</view>
				<view class="type flex3"
					v-if="item.originalFieldName == '补充说明' || item.originalFieldName == '整改要求' || item.originalFieldName == '事件描述' || item.originalFieldName == '详细部位'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
					  ? item.displayFieldName
					  : item.originalFieldName}}：</view>
					<textarea class="textarea" maxlength="-1" placeholder-class="cl" name="inspectContent"
						v-model="form[item.fieldName]" placeholder="请输入"></textarea>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '问题描述' || item.originalFieldName == '排查分类'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
					  ? item.displayFieldName
					  : item.originalFieldName}}：</view>
					<picker :disabled="true" @click="$refs.issueTree._show()" class="picker">
						<view class="uni-input uni-select cl" v-if="issueName==''">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select" v-else>{{issueName}}
							<image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '问题分类'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
					  ? item.displayFieldName
					  : item.originalFieldName}}：</view>
					<picker class="picker" :disabled="true">
						<view class="uni-input uni-select cl" v-if="issueName==''">
							请输入
						</view>
						<view class="uni-input uni-select" v-else>{{issueName}}
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '问题等级'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
					  ? item.displayFieldName
					  : item.originalFieldName}}：</view>
					<picker @change="(e)=>bindPickerChange(e,1)" :value="issueGradeIndex" class="picker"
						:range="issueGradeList" range-key="name">
						<view class="uni-input uni-select cl" v-if="form.level==''">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select" v-else>
							{{form.level==1?'一级':form.level==2?'二级':form.level==3?'三级':'四级'}}
							<image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '问题等级二'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
					  ? item.displayFieldName
					  : item.originalFieldName}}：</view>
					<picker @change="(e)=>bindPickerChange(e,9)" :value="priorityNameDicIndex" class="picker"
						:range="dangerItemList" range-key="name">
						<view class="uni-input uni-select cl" v-if="form.priorityNameDic==''">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select" v-else>
							{{dictionaryItemName(dangerItemList, form.priorityNameDic,'data','name')}}
							<image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '紧急程度'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
					  ? item.displayFieldName
					  : item.originalFieldName}}：</view>
					<picker @change="(e)=>bindPickerChange(e,2)" :value="urgencyIndex" class="picker"
						:range="urgencyList" range-key="name">
						<view class="uni-input uni-select cl" v-if="form.urgentLevel==''">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select" v-else>
							{{form.urgentLevel==1?'一般':form.urgentLevel==2?'严重':'紧要'}}
							<image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '检查时间'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
									  ? item.displayFieldName
									  : item.originalFieldName}}：</view>
					<dateTimePiccker :placeholder="'请选择'" :disabled="item.defaultDataType ? true : false"
						:start="startTime" fields="second" :default-value="form.inspectTime"
						@change="bindPickerChange($event,'startTime')" class="dateTimePiccker">
					</dateTimePiccker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '整改时限'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
									  ? item.displayFieldName
									  : item.originalFieldName}}：</view>
					<dateTimePiccker :placeholder="'请选择'" :start="startTime2" fields="minute"
						:default-value="form.changeLimitTime" @change="bindPickerChange($event,'startTime2')"
						class="dateTimePiccker">
					</dateTimePiccker>
				</view>
				<view class="type flex" v-show="item.originalFieldName == '分包单位' && COMPANY != 'zjwj'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
				      ? item.displayFieldName
				      : item.originalFieldName}}：</view>
					<picker @click="$refs.subpackageTree._show()" :disabled="true" class="picker">
						<view class="uni-input uni-select cl" v-if="form.enterpriseName==''">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select flex2" v-else>
							<view style="width: 98%;" class="ellipsis">{{form.enterpriseName}}</view>
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '整改人'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
				      ? item.displayFieldName
				      : item.originalFieldName}}：</view>
					<picker @change="(e)=>bindPickerChange(e,6)" :value="changePeopleIndex" class="picker"
						:range="personUpdateList" range-key="realName" v-if="isShowPicker">
						<view class="uni-input uni-select cl" v-if="changePeopleIndex==null">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select" v-else>{{personUpdateList[changePeopleIndex].realName}}
							<image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '复查人'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
				      ? item.displayFieldName
				      : item.originalFieldName}}：</view>
					<picker @click="$refs.reviewIdTree._show()" :disabled="true" class="picker">
						<view class="uni-input uni-select cl" v-if="form.reviewNames==''">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select flex2" v-else>
							<view style="width: 98%;" class="ellipsis">{{form.reviewNames}}</view>
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '核验人'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
				      ? item.displayFieldName
				      : item.originalFieldName}}：</view>
					<picker @click="$refs.verifyManIdTree._show()" :disabled="true" class="picker">
						<view class="uni-input uni-select cl" v-if="form.verifyManNames==''">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select flex2" v-else>
							<view style="width: 98%;" class="ellipsis">{{form.verifyManNames}}</view>
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '现场整改'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
				      ? item.displayFieldName
				      : item.originalFieldName}}：</view>
					<view class="flex">
						<text :class="form.status==2?'status':''">未完成</text>
						<switch :checked="form.status==5" @change="switchChange"
							style="margin: 0 10px;transform: scale(0.74,0.7)" />
						<text :class="form.status==5?'status':''">已完成</text>
					</view>
				</view>
				<view v-if="item.originalFieldName == '现场整改'" style="font-size: 12px;
				margin: 0 0 10px 17px;
				color: gray;">注：如果在检查的时候已经整改,请直接选择已完成</view>
				<view class="type flex3" v-if="COMPANY == 'zjwj'&& typeCheck == 'type1'">
					<view class="name">图纸定位：</view>
					<view class="name" style="color: #187cff;width:100px" @click="openImgDialog">在图纸中定位</view>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '责任专业'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
					  ? item.displayFieldName
					  : item.originalFieldName}}：</view>
					<picker @change="(e)=>bindPickerChange(e,10)" :value="dutyMajorIndex" class="picker"
						:range="majorItemList" range-key="name">
						<view class="uni-input uni-select cl" v-if="form.dutyMajor==''">
							请选择 <image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
						<view class="uni-input uni-select" v-else>
							{{dictionaryItemName(majorItemList, form.dutyMajor,'data','name')}}
							<image class="icon-down" src="/static/icon-down-black.png"></image>
						</view>
					</picker>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '隐患图片' || item.originalFieldName == '上传图片'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
				      ? item.displayFieldName
				      : item.originalFieldName}}：</view>
					<view class="uni-form-input imgBox_wrap">
						<view class="imgBox" v-show="imgFileList.length>0" v-for="(item,index) in imgFileList"
							:key="index">
							<image :src="url_config+'image/'+item.url" class="img"
								@click="previewImage(url_config+'image/'+item.url)">
							</image>
							<view @click="deleteImg(item,1)" style="margin: 5px;" class="deleteImg"></view>
						</view>
						<view class="addImgBox" @click="uploadImg(1)" v-if="imgFileList.length<5">
							<image src="/static/icon-add.png" class="icon-add"></image>
						</view>
					</view>
				</view>
				<view class="type" v-if="item.originalFieldName == '上传附件'">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
				      ? item.displayFieldName
				      : item.originalFieldName}}：</view>
					<view style="margin-left: 208rpx;" v-if="videoFileList.length>0">
						<view class="imgBox flex2" style="width:100%;height:28px;" v-for="(item,index) in videoFileList"
							:key="index">
							<view
								style="color: #4181FE;width: 28%;white-space: nowrap; overflow: hidden;text-overflow: ellipsis;"
								@click="playVideo(url_config+'image/'+item.url,'video')">
								{{item.name}}
							</view>
							<view @click="deleteImg(item,2)" style="margin: 5px;color: gray;left: 78px;"
								class="deleteImg">
							</view>
						</view>
					</view>
					<view class="addImgBox" @click="uploadVideo" v-if="videoFileList.length<=0"
						style="margin-left: 208rpx;">
						<image src="/static/icon-add.png" class="icon-add"></image>
					</view>
				</view>
				<view class="type flex" v-if="item.originalFieldName == '整改后图片' && form.status==5">
					<view class="name"><text class="star" v-if="item.isRequired == 1">*</text>{{item.displayFieldName
				      ? item.displayFieldName
				      : item.originalFieldName}}：</view>
					<view class="uni-form-input imgBox_wrap">
						<view class="imgBox" v-show="rectifyAfterImageList.length>0"
							v-for="(item,index) in rectifyAfterImageList" :key="index">
							<image :src="url_config+'image/'+item.url" class="img"
								@click="previewImage(url_config+'image/'+item.url)">
							</image>
							<view @click="deleteImg(item,3)" style="margin: 5px;" class="deleteImg"></view>
						</view>
						<view class="addImgBox" @click="uploadImg(3)" v-if="rectifyAfterImageList.length<5">
							<image src="/static/icon-add.png" class="icon-add"></image>
						</view>
					</view>
				</view>
			</template>
			<!-- <view class="addSaveBtn" @click="addSaveBtn">新增保存</view> -->
		</view>
		<view class="confrim-btn">
			<view @click="onNavigateBack">取消</view>
			<view @click="addSaveBtn">确定</view>
		</view>
		<!-- 图纸定位弹窗 -->
		<view class="unitDialog" v-if="imgDialog">
			<view class="unitContent" style="height: 65%;width: 89%;">
				<view class="name" style="text-align: center;">图纸定位</view>
				<view style="display: flex;margin-top: 20px;">
					<view class="add2" v-if="imgDialogUrl!=''" @click.stop="pointText()">
						{{imgDialogUrlText}}

					</view>
					<view class="add2" v-if="imgDialogUrl!=''" @click.stop="uploadImg(2)">更换图片</view>
				</view>
				<view class="uni-form-input imgBox_wrap" style="width: 100%;">
					<view class="imgBox" style="width: 100%; height: 100%;" v-show="imgDialogUrl.length>0"
						v-for="(item,index) in imgDialogUrl" :key="index">
						<image data-index='111' :src="url_config+'image/'+item.url" @click.stop="pointImage($event)">
							<view>
								<image src="/static//monitorPoint.png" class="point"
									:style="{top: item.y - 200 + 'px',left:item.x - 40 + 'px'}"
									v-for="(item,index) in pointList" :key="index" @click.stop="pointShow(index)">
								</image>
							</view>
							<view :style="{top: item.y - 200 + 'px',left:item.x - 40 + 'px'}"
								v-for="(item,index) in pointList" :key="index" v-if="imgIndex === index" class="point">
								<view class="lagCss">
									坐标 ：x : {{item.x}}
									y : {{item.y}}
									<view style="color: red;" @click.stop="removePoint(index)">删除</view>
								</view>
							</view>

					</view>

					<view class="addImgBox" style="width: 178px;
                 height: 163px;margin: 20%;" @click="uploadImg(2)" v-if="imgDialogUrl.length==0">
						<image src="/static/icon-add.png" class="icon-add"></image>
					</view>
				</view>
				<view class="butA">
					<view class='addSaveBtn' style=" margin-left: 105px;width: 40%;margin-top: 8%;"
						v-if="imgDialogUrl!=''" @click="imgDialogBtn">保存</view>

					<view class='addSaveBtn' style=" margin-left: 105px;width: 40%;margin-top: -5%;" v-else
						@click="imgDialog = false">
						取消</view>
				</view>

				<!-- <view class="text" style="text-align: center;
                 color: orange;margin-top: -40px;" v-else>
					暂无图纸,请上传
				</view> -->
			</view> -->
		</view>

		<!-- 分包单位弹窗 -->
		<view class="unitDialog" v-if="unitDialog" @click="unitDialog=false">
			<view class="unitContent">
				<!-- <view class="tabs flex2">
          <view @click.stop="checkTypeBtn(1)" :class="checkType==1?'checkName tabs_name':'noCheckName tabs_name'">
            专业分包商</view>
          <view @click.stop="checkTypeBtn(6)" :class="checkType==6?'checkName tabs_name':'noCheckName tabs_name'">
            劳务分包商</view>
        </view> -->
				<view class="unitList" v-if="subpackageLsit.length>0">
					<view class="title">公司名称</view>
					<view class="list_val" v-for="(item,index) in subpackageLsit" @click="checkSubpackage(item)"
						:class="index%2==0?'bg_999':''">{{item.enterpriseName}}</view>
				</view>
				<view class="placeholderBox" v-if="subpackageLsit.length==0">
					<image src="/static/noData.png" mode="" class="noDataImg"></image>
					<view class="text">
						暂无数据
					</view>
				</view>
			</view>
		</view>
		<!-- 标记点 -->
		<!-- 检查部位 -->
		<tki-tree ref="locationTree" :defaultList='form.regionIds' :multiple="true"
			@confirm="(val)=>checkPointBtn(val,1)" idKey='id' :range="checkPointList" rangeKey="regionName"
			confirmColor="#4e8af7" :selectParent="true" />

		<!-- 问题分类 -->
		<tki-tree ref="issueTree" @confirm="(val)=>checkPointBtn(val,2)" search idKey='id' :range="issueList"
			rangeKey="dangerName" confirmColor="#4e8af7" />
		<!-- 通知人 -->
		<tki-tree ref="informTree" :multiple="true" @confirm="(val)=>checkPointBtn(val,3)" idKey='id'
			:range="personList" rangeKey="workerName" confirmColor="#4e8af7" />
		<!-- 分包单位 -->
		<tki-tree ref="subpackageTree" :defaultList='form.enterpriseIds' :multiple="true"
			@confirm="(val)=>checkPointBtn(val,4)" idKey='id' :range="subpackageLsit" rangeKey="enterpriseName"
			confirmColor="#4e8af7" :selectParent="true" />
		<!-- 复查人 -->
		<tki-tree ref="reviewIdTree" :defaultList='form.reviewIds' :multiple="true"
			@confirm="(val)=>checkPointBtn(val,5)" idKey='userId' :range="reviewList" rangeKey="realName"
			confirmColor="#4e8af7" :selectParent="true" />
		<!-- 核验人 -->
		<tki-tree ref="verifyManIdTree" :defaultList='form.verifyManIds' :multiple="true"
			@confirm="(val)=>checkPointBtn(val,6)" idKey='userId' :range="personList" rangeKey="realName"
			confirmColor="#4e8af7" :selectParent="true" />
		<canversCom v-if="openImg" @imgUrl="imgUrl" :imgList="imgList"></canversCom>

	</view>
</template>

<script>
	import tkiTree from "@/components/tki-tree/tki-tree.vue"
	import canversCom from "@/pages/videoManage/component/canversCom.vue"
	import dateTimePiccker from '@/components/dateTimePicker/index.vue'
	import {
		dateformat
	} from "@/utils/tool.js"
	export default {
		components: {
			tkiTree,
			canversCom,
			dateTimePiccker

		},
		data() {
			return {
				mobileTopHeight: 0,
				isShowPicker: true,
				startTime: this.getDate({
					format: true,
				}),
				startTime2: this.getDate({
					format: true,
				}),
				checkedTab: 'type1',
				imgList: {},
				openImg: false,
				base64Image: '',
				imgIndex: -1,
				pointList: [],
				location: {
					left: '0',
					top: '0'
				},
				x: 0,
				y: 0,
				imgDialogUrlSu: false,
				imgDialogUrlText: "编辑隐患点",
				imgDialog: false,
				imgDialogUrl: [],
				pageTitle: '新增检查',
				projectSn: '',
				checkType: 1, //分包商类型   1专业分包  6劳务分包

				form: {
					regionIds: [], // 检查部位
					regionName: "",
					priorityNameDic: "",
					dangerItemContent: "",
					dangerItemId: "",
					dangerTypeId: "",
					dangerDesc: "",
					remark: "",
					routineId: 0,
					level: "",
					reviewNames: "",
					verifyManNames: "",
					urgentLevel: "",
					inspectManId: "",
					enterpriseIds: [],
					inspectTime: "",
					enterpriseSns: "",
					enterpriseName: "",
					changeLimitTime: "",
					changeId: "",
					reviewIds: [],
					verifyManIds: [],
					notifyPerson: [],
					status: 2, // 现场整改状态  2未完成   5已完成
					measurePoints: [],
					imageUrl: "",
					fileUrl: "",
					recordType: 1,
					dangerName: '',
					subsectionId: '', //分部工程
					subentryId: '', //分项工程
					floor: '', //巡检楼层
					addedDescription: '', //事件描述
					taskId: '', //任务ID
					itemId: '', // 任务子ID
					dutyMajor: "",
					rectifyAfterImage: "",
				},
				checkPointList: [], //获取检查部位数据
				checkPointName: '',
				issueList: [], //问题分类 || 问题描述
				issueName: '',
				issueGradeList: [{
						name: '一级',
						value: 1
					},
					{
						name: '二级',
						value: 2
					},
					{
						name: '三级',
						value: 3
					},
					{
						name: '四级',
						value: 4
					},
				], //问题等级
				issueGradeIndex: 0,
				urgencyList: [{
						name: '一般',
						value: 1
					},
					{
						name: '严重',
						value: 2
					},
					{
						name: '紧要',
						value: 3
					},
				], //紧急程度
				urgencyIndex: 0,
				personUpdateList: [], // 人员列表-整改人
				personList: [], //人员列表  -- 检查人、整改人、复查人、核验人、通知人
				inspectManIndex: null, //检查人
				changePeopleIndex: null, //整改人
				verifyManIndex: null, //核验人
				reviewIndex: null, //复查人
				notifier: '', //通知人
				unitDialog: false, //分包商弹窗
				subpackageLsit: [], //分包商数据列表
				videoFileList: [],
				imgFileList: [],
				rectifyAfterImageList: [],
				mapImgList: [],
				basicInfo: {},
				selectIndex: null,
				userInfo: '',
				typeCheck: 'type1', // 类型 type1为安全问题  type2为排查记录
				listData: [], //分部工程
				subListData: [], //分项工程
				subsectionIndex: -1, //分部工程
				subentryIndex: -1, ////分项工程
				unitEnterpriseId: "",
				taskId: '', //任务ID
				itemId: '', // 任务子ID
				defaultAuditPerson: "",
				reviewList: [],
				areaData: {},
				engineeringId: '',
				type: '',
				// 问题描述
				issuedata: "",
				securityDangerList: [],
				securityDangerFieldList: [],
				addForm1Rules: [],
				priorityNameDicIndex: 0,
				dangerItemList: [], // 问题等级二
				dutyMajorIndex: 0,
				majorItemList: [], // 责任专业
				dangerReviewInfo: {},
			}
		},
		onLoad(option) {
			this.pageTitle = option.type == 'add' ? '新增检查' : '编辑检查';
			this.projectSn = JSON.parse(uni.getStorageSync('projectDetail')).projectSn;
			this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
			this.getCheckPointList();
			this.getIssueList();
			this.getPersonList();
			// this.getReviewPeopleList();
			// this.getPersonUpdateList();
			this.getProgressListData()
			console.log('lll', option.taskId, option.itemId)
			this.taskId = option.taskId
			this.itemId = option.itemId
			this.form.taskId = option.taskId
			this.form.itemId = option.itemId
			console.log(dateformat(new Date()), 777888)
			if (option.engineeringId) this.engineeringId = option.engineeringId
			if (option.type) this.type = Number(option.type)
			this.getSecurityDangerFieldPage();
			this.getDicProjectTypeList();
			this.getXzSecurityDangerReviewVerifyList();
		},
		mounted() {
			var that = this
			uni.getSystemInfo({
				success(res) {
					that.mobileTopHeight = res.statusBarHeight ? res.statusBarHeight : 0;
					uni.setStorageSync('systemInfo', res)
					console.log(res)
				}
			})
			console.log('this.mobileTopHeight', this.mobileTopHeight)
		},
		computed: {
			dictionaryItemName() {
				return (dataList, value, key, name) => {
					const find = dataList.find(
						(item) => item[key] == value
					);
					return find ? find[name] : "";
				}
			}
		},
		methods: {
			getXzSecurityDangerReviewVerifyList() {
				this.sendRequest({
					url: 'xmgl/xzSecurityDangerReviewVerify/getEffectiveConfig',
					method: 'post',
					data: {
						sn: this.projectSn,
						companyProjectType: 2,
					},
					success: res => {
						if (res.code == 200) {
							const data = res.result;
							this.dangerReviewInfo = {
								...data
							};
						}
					}
				})
			},
			// 取消
			onNavigateBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			getDicProjectTypeList() {
				this.sendRequest({
					url: 'xmgl/dictionaryItem/list',
					method: 'get',
					data: {
						dictionaryEncoding: "xz_security_danger_item_record_priority_name_dic",
						projectSn: this.projectSn,
					},
					success: res => {
						console.log(res.result)
						if (res.code == 200) {
							this.dangerItemList = res.result;
						}
					}
				})
				this.sendRequest({
					url: 'xmgl/dictionaryItem/list',
					method: 'get',
					data: {
						dictionaryEncoding: "xz_security_quality_inspection_record_duty_major",
						projectSn: this.projectSn,
					},
					success: res => {
						console.log(res.result)
						if (res.code == 200) {
							this.majorItemList = res.result;
						}
					}
				})
			},
			// 获取安全隐患
			getSecurityDangerFieldPage(recordType) {
				this.sendRequest({
					url: 'xmgl/xzSecurityDangerField/getEffectiveConfig',
					method: 'post',
					data: {
						pageNo: 1,
						pageSize: -1,
						sn: this.projectSn,
						companyProjectType: 2,
						recordType: recordType ? recordType : this.form.recordType,
					},
					success: res => {
						console.log(res.result)
						if (res.code == 200) {
							this.securityDangerList = res.result
								.filter((item) => item.isEnabled == 1);
							this.securityDangerFieldList = res.result;
							this.addForm1Rules = res.result
								.filter((item) => item.isEnabled == 1 && item.isRequired == 1)
								.map((item) => {
									const tipName = item.displayFieldName ?
										item.displayFieldName :
										item.originalFieldName;
									return {
										required: true,
										originalFieldName: item.originalFieldName,
										fieldName: item.fieldName,
										message: `${tipName}必填`,
										trigger: "change",
									}
								});
							this.$nextTick(() => {
								setTimeout(() => {
									this.securityDangerListFn(this.form, this.form.recordType)
								}, 800)
							})
						}
					}
				})
			},
			getAllIds(tree, result = []) {
				//遍历树  获取id数组
				for (const i in tree) {
					result.push(tree[i]); // 遍历项目满足条件后的操作
					if (tree[i].children) {
						//存在子节点就递归
						this.getAllIds(tree[i].children, result);
					}
				}
				return result;
			},
			securityDangerListFn(obj, recordType) {
				this.securityDangerFieldList.forEach((item) => {
					if (!item.defaultDataType) return;
					if (item.originalFieldName == "责任区域") {
						this.$nextTick(() => {
							const resultList = this.getAllIds(this.checkPointList);
							obj[item.fieldName] = resultList.map(item => item.id);
							console.log("责任区域", item.fieldName, resultList);
							this.editCheckPointBtn(resultList, 1);
						});
					} else if (
						item.originalFieldName == "问题等级" ||
						item.originalFieldName == "问题等级二" ||
						item.originalFieldName == "紧急程度"
					) {
						obj[item.fieldName] = item.defaultDataType;
					} else if (item.originalFieldName == "检查时间") {
						let nowDate = dateformat(new Date());
						obj[item.fieldName] = nowDate;
					} else if (item.originalFieldName == "分包单位") {
						// this.$nextTick(() => {
						// 	obj[item.fieldName] = this.subpackageLsit.map((item) => item.id);
						// 	console.log(item.fieldName, this.subpackageLsit)
						// 	this.checkedSubcontractListUp();
						// });
					} else if (item.originalFieldName == "核验人") {
						// 默认选择核验人逻辑
						let index = this.personList.findIndex((item) => {
							return item.userId == this.userInfo.userId;
						});
						if (index != -1) {
							this.form.verifyManIds = [this.personList[index].userId];
							this.form.verifyManNames = this.personList[index].realName;
						} else {
							this.form.verifyManIds = [this.userInfo.userId];
							this.form.verifyManNames = this.userInfo.realName;
						}
					} else if (item.originalFieldName == "现场整改") {
						obj[item.fieldName] = item.defaultDataType;
					}
				});
			},
			// 筛选数据-问题描述
			onClick() {
				if (this.issuedata.length > 0) {
					console.log("issuedata", this.issuedata);
					console.log("=========原数据==========", this.issueList);
					this.issueList = []
					this.getIssueList()
					this.$refs.issueTree._show()
				} else {
					this.getIssueList()
					this.$refs.issueTree._show()
				}
			},
			//获取复查人
			getReviewPeopleList() {
				let data = {
					projectSn: this.projectSn,
					// enterpriseTypeId: 7,
					qualityRegionId: this.form.regionIds.join(','),
					// qualityRegionBindType: 2,
					// isSupervisingRoleName: 1
				}
				if (this.dangerReviewInfo.enableReview == 1) {
					data.roleName = this.dangerReviewInfo.reviewRoleName;
					data.enterpriseId = this.unitEnterpriseId.join(",");
				}
				this.sendRequest({
					url: 'xmgl/systemUser/getProjectChilderSystemUserList',
					method: 'post',
					data: {
						...data,
					},
					success: res => {
						console.log(res.result)
						if (res.result.length > 0) {
							this.reviewList = res.result;
							const find = this.securityDangerFieldList.find(
								(item) => item.originalFieldName == "复查人" && item.defaultDataType
							);
							console.log(find);
							if (find) {
								this.form[find.fieldName] = this.reviewList.map(
									(item) => item.userId
								);
								this.form.reviewNames = this.reviewList.map(
									(item) => item.realName
								).join(',');
							}
						} else {
							this.reviewList = [];
						}
					}
				})
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				if (type === 'start') {
					year = year;
				} else if (type === 'end') {
					// year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			imgUrl(val) {
				this.openImg = false
				this.imgUpload(val)

				this.openImg = true
			},

			//图片上传请求的接口
			imgUpload(baseImg) {
				console.log('进入----------图片上传请求的接口');
				let that = this
				let cuDate = new Date().getTime();
				let arr = []
				that.base64Image = baseImg
				let parmars = {
					base64Image: that.base64Image
				}

				this.sendRequest({
					url: 'xmgl/upload/uploadBase64',
					method: 'post',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					data: parmars,
					success: (res) => {
						console.log('转换后的地址----------', res.data.imageUrl);
						console.log('阶段代码  imgUpload 耗时2 ：' + (new Date().getTime() - cuDate))
						that.imgFileList[that.imgFileList.length - 1].url = res.data.imageUrl
					}
				})
			},
			imgDialogBtn() {
				this.imgDialog = false
				// this.pointList=[]
			},
			//点击点位展示的内容
			pointShow(index) {
				console.log("当前index : " + index + "- this.imgIndex: " + this.imgIndex)
				if (index === this.imgIndex) {
					this.imgIndex = -1
				} else {
					this.imgIndex = index
				}
			},
			//删除点位
			removePoint(index) {
				console.log('点击的内容', index);
				this.pointList.splice(index, 1);
				this.imgIndex = -1
			},
			//布点
			pointImage(event) {
				if (this.imgDialogUrlSu) {
					console.log("开始布点 ：", event);
					console.log("x：", event.detail.x);
					console.log("y ：", event.detail.y);
					let obj = {
						x: event.detail.x,
						y: event.detail.y
					}
					this.pointList.push(obj)
				}

			},
			//开始布点或者结束布点
			pointText() {
				this.imgDialogUrlText = this.imgDialogUrlSu ? "编辑隐患点" : "保存隐患点"
				this.imgDialogUrlSu = !this.imgDialogUrlSu

			},
			//打开图纸上传弹框
			openImgDialog() {
				this.imgDialog = true
			},
			toggle() {},
			//分部工程改动事件
			checkSubListData(e, type) {
				console.log(e, type)
				if (type === 1) {
					if (this.listData[e.detail.value] == "暂无数据") return;
					// 选择一级菜单
					this.subsectionIndex = e.detail.value;
					this.form.subsectionId = this.listData[this.subsectionIndex]?.id || -1; // 赋值给subsectionId字段

					this.subListData = this.listData[this.subsectionIndex].children || [];
					if (this.subListData.length) {
						this.subentryIndex = 0; // 如果存在子级菜单，则将分项索引初始化为0
						this.subentryId = this.subListData[0]?.id || -1; // 赋值给subentryId字段
					} else {
						this.subentryIndex = -1; // 如果不存在子级菜单，则将分项索引初始化为-1
						this.subentryId = -1; // 初始化为-1
					}
				} else {
					if (this.subListData[e.detail.value] == "暂无数据") return;
					// 选择二级菜单
					this.subentryIndex = e.detail.value;
					this.form.subentryId = this.subListData[this.subentryIndex]?.id || -1; // 赋值给subentryId字段
				}
			},
			//获取分部分项工程， 以父子节点形式呈现
			getProgressListData() {
				this.sendRequest({
					url: 'xmgl/subdivisionProject/getParentChildList',
					method: 'get',
					data: {
						projectSn: this.projectSn
					},
					success: res => {
						if (res.code == 200) {
							this.listData = res.result;
							console.log('获取分部分项工程， 以父子节点形式呈现', this.listData)
							if (this.listData.length >= 1) {
								this.form.subsectionId = this.listData[0].id
								if (this.listData[0].children.length >= 1) {
									this.subListData = this.listData[0].children;
									this.form.subentryId = this.listData[0].children[0].id;
								} else {
									this.subListData = ['暂无数据']
								}
							} else {
								this.listData = ['暂无数据']
							}
						}
					}
				})
			},
			//获取检查部位 列表
			getCheckPointList() {
				this.sendRequest({
					url: 'xmgl/qualityRegion/tree/page',
					method: 'post',
					data: {
						projectSn: this.projectSn,
						notSupervisingUnit: 1,
						pageNo: 1,
						pageSize: -1,
					},
					success: res => {
						if (res.code == 200) {
							this.checkPointList = res.result.records;
							console.log('-----------', this.checkPointList)
						}
					}
				})
			},
			dealFalseCheck(arr) {
				arr.map(item => {
					if (item.children) {
						item.checked = false;
						item.orChecked = false;
						this.dealFalseCheck(item.children)
					} else {
						item.checked = false;
						item.orChecked = false;
					}
				})
			},
			//确定选中--编辑回显
			editCheckPointBtn(val, type) {
				console.log(val, 888999)
				console.log(this.form, 101010)
				// type==1 检查部位 ；  2 问题分类 	3,通知人			
				if (type == 1) {
					this.form.enterpriseSns = "";
					this.form.enterpriseName = "";
					this.form.changeId = "";
					// console.log(val, type)
					this.changePeopleIndex = null;
					console.log(val);
					this.form.regionIds = val.map(item => item.id);
					let data = {};
					val.forEach((item) => {
						data = {
							...item,
							intendanceIds: data.intendanceIds ?
								data.intendanceIds + "," + item.intendanceIds : item.intendanceIds,
							intendanceNames: data.intendanceNames ?
								data.intendanceNames + "," + item.intendanceNames : item.intendanceNames,
							securityDutyIds: data.securityDutyIds ?
								data.securityDutyIds + "," + item.securityDutyIds : item.securityDutyIds,
							securityEnterpriseIds: data.securityEnterpriseIds ?
								data.securityEnterpriseIds + "," + item.securityEnterpriseIds : item
								.securityEnterpriseIds,
						};
					});
					this.areaData = data;
					console.log(val[0].parents)
					const dataName = val.reduce((prev, item) => {
						const arr = item.parents ? JSON.parse(JSON.stringify(item.parents)) : [];
						arr.push({
							id: item.id,
							regionName: item.regionName
						});
						const regionName = arr.map(ele => ele.regionName).join("/");
						prev.push(regionName);
						return prev
					}, []);
					this.checkPointName = dataName.join(',');
					this.form.regionName = dataName.join(',');

					this.form.regionIds = val.map(item => item.id);
					this.notifier = data.intendanceNames;
					this.form.notifyPerson = data.intendanceIds;
					// 重置检查部位
					this.dealFalseCheck(this.checkPointList);
					this.$refs.locationTree._reTreeList();
					console.log(11223344, data)
					if (data.securityEnterpriseIds) {
						this.getSubpackageLsit(data.securityEnterpriseIds);
					} else {
						this.subpackageLsit = [];
					}

					// 分包单位数据拿取
					// this.subpackageLsit = data.enterpriseInfos.reduce((prev, item) => {
					// 	const findIndex = prev.findIndex((ele) => ele.id === item.id);
					// 	if (findIndex == -1) {
					// 		prev.push(item);
					// 	}
					// 	return prev;
					// }, []);
					this.personUpdateList = []
					this.reviewList = [];
					this.reviewIndex = null
					this.form.reviewIds = []
					// this.getReviewPeopleList()
				}

			},
			//确定选中--回显  
			checkPointBtn(val, type) {
				this.form.level = ''
				// type==1 检查部位 ；  2 问题分类 	3,通知人			
				if (type == 1) {
					this.form.enterpriseSns = "";
					this.form.enterpriseName = "";
					this.form.changeId = "";
					// console.log(val, type)
					this.changePeopleIndex = null;
					console.log(val);
					let data = {};
					val.forEach((item) => {
						console.log(item);
						data = {
							...item,
							intendanceIds: data.intendanceIds ?
								data.intendanceIds + "," + item.intendanceIds : item.intendanceIds,
							intendanceNames: data.intendanceNames ?
								data.intendanceNames + "," + item.intendanceNames : item.intendanceNames,
							securityDutyIds: data.securityDutyIds ?
								data.securityDutyIds + "," + item.securityDutyIds : item.securityDutyIds,
							securityEnterpriseIds: data.securityEnterpriseIds ?
								data.securityEnterpriseIds + "," + item.securityEnterpriseIds : item
								.securityEnterpriseIds,
						};
					});
					console.log(222, data)
					this.areaData = data;
					console.log(this.checkPointList, data, this.personList)
					this.form.regionIds = val.map(item => item.id);
					console.log(val[0].parents)
					const dataName = val.reduce((prev, item) => {
						const arr = JSON.parse(JSON.stringify(item.parents));
						arr.push({
							id: item.id,
							regionName: item.regionName
						});
						const regionName = arr.map(ele => ele.regionName).join("/");
						prev.push(regionName);
						return prev
					}, []);
					this.checkPointName = dataName.join(',');
					this.form.regionName = dataName.join(',');

					this.form.changeId = val[0].dutyId;
					this.notifier = data.intendanceNames;
					this.form.notifyPerson = data.intendanceIds;
					// 重置检查部位
					this.dealFalseCheck(this.checkPointList);
					this.$refs.locationTree._reTreeList();
					console.log(data);
					// 分包单位数据拿取
					if (data.securityEnterpriseIds) {
						this.getSubpackageLsit(data.securityEnterpriseIds);
					} else {
						this.subpackageLsit = [];
					}
					this.personUpdateList = []
					// 整改人数据拿取
					// this.personUpdateList = val[0].systemUsers
					// this.personUpdateList.forEach((item, index) => {
					// 	if (item.userId == val[0].dutyId) {
					// 		this.changePeopleIndex = index
					// 	}
					// });
					this.reviewList = [];
					this.reviewIndex = null
					this.form.reviewIds = []
					// this.getReviewPeopleList()
				} else if (type == 2) {
					console.log('选择问题描述的数据', val);
					//设置问题描述
					this.form.dangerItemContent = val[0].dangerName;
					this.form.dangerItemId = val[0].id;
					this.form.level = val[0].level
					this.form.remark = val[0].remark //整改要求
					//设置问题类型
					if (val[0].parents.length == 0) {
						this.form.dangerTypeId = val[0].id;
						this.issueName = val[0].dangerName;
					} else {
						this.form.dangerTypeId = val[0].parents[0].id;
						this.issueName = val[0].parents.map(item => item.dangerName).join('/') + '/' + val[0]
							.dangerName;
						this.form.dangerName = val[0].dangerName
					}
					const find = this.securityDangerFieldList.find(
						(item) =>
						item.originalFieldName == "整改时限" && item.defaultDataType
					);
					if (find) {
						this.form.changeLimitTime = this.$dayjs()
							.add(val[0].changeLimit, "day")
							.format("YYYY-MM-DD HH:mm:ss");
					}
				} else if (type == 3) {
					console.log(val)
					this.notifier = val.map((item, index) => {
						return item.workerName
					}).join(',');
					this.form.notifyPerson = val.map((item, index) => {
						return item.workerName
					}).join(',')
				} else if (type == 4) {
					console.log(val)
					this.form.enterpriseIds = val.map(item => item.id);
					this.checkedSubcontractListUp(val);
				} else if (type == 5) {
					console.log(val)
					this.form.reviewIds = val.map(item => item.userId);
					this.form.reviewNames = val.map(item => item.realName).join(',');
				} else if (type == 6) {
					console.log(val)
					this.form.verifyManIds = val.map(item => item.userId);
					this.form.verifyManNames = val.map(item => item.realName).join(',');
				}

			},
			//获取问题分类
			getIssueList() {
				this.sendRequest({
					url: 'xmgl/xzSecurityDangerTypeRecord/selectDangerTypeAndItemList',
					method: 'post',
					data: {
						projectSn: this.projectSn,
						recordStatus: 0,
						dangerName: this.issuedata
					},
					success: (res) => {
						console.log(res)
						if (res.result.length > 0) {
							res.result.forEach(item => {
								if (item.children && item.children.length > 0) {
									item.children.forEach(itm => {
										if (itm.itemList && itm.itemList.length > 0) {
											itm.itemList.forEach(item2 => {
												item2.dangerName = item2.content
											})
											itm.children = itm.itemList
										}
									})
								}
							})

							this.issueList = res.result
						}
					}
				})
			},


			//补充说明
			supplementTextarea(e) {
				this.form.dangerDesc = e.detail.value
			},
			//整改要求
			claimTextarea(e) {
				this.form.remark = e.detail.value
			},
			//事件描述
			eventDescription(e) {
				this.form.addedDescription = e.detail.value
			},
			//巡检楼层
			eventfloor(e) {
				console.log('巡检楼层---', e);
				let input = e.detail.value;
				this.form.floor = parseInt(input); // 或者 this.form.floor = parseInt(input);
			},
			//获取分包公司
			getSubpackageLsit(securityEnterpriseIds) {
				let data = {
					// enterpriseTypeId: this.checkType,
					enterpriseIds: securityEnterpriseIds ?
						securityEnterpriseIds.split(",") : [],
					pageNo: 1,
					pageSize: 999,
					projectSn: this.projectSn,
				};
				this.sendRequest({
					url: 'xmgl/projectEnterprise/list',
					method: 'post',
					data: data,
					success: (res) => {
						if (res.result.records.length > 0) {
							this.subpackageLsit = res.result.records;
							this.securityDangerFieldList
								.filter((item) => item.originalFieldName == "分包单位")
								.forEach((item) => {
									if (!item.defaultDataType) return;
									this.$nextTick(() => {
										this.form[item.fieldName] = this.subpackageLsit.map(
											(item) => item.id
										);
										this.checkedSubcontractListUp();
									});
								});
						} else {
							this.subpackageLsit = [];
						}
					}
				})
			},

			//下拉选择回显
			bindPickerChange(e, type) {
				console.log(e)
				//type ==1 问题等级;2紧急情况;3检查人;4 检查时间;5整改时限; 6整改人; 7复查人; 8核验人;
				if (type == 1) {
					if (this.issueGradeList.length == 0) return;
					this.issueGradeIndex = e.detail.value;
					this.form.level = this.issueGradeList[e.detail.value].value;
				} else if (type == 2) {
					if (this.urgencyList.length == 0) return;
					this.urgencyIndex = e.detail.value;
					this.form.urgentLevel = this.urgencyList[e.detail.value].value;
				} else if (type == 3) {
					if (this.personList.length == 0) return;
					this.inspectManIndex = e.detail.value;
					this.form.inspectManId = this.personList[e.detail.value].userId
				} else if (type == 'startTime') {
					this.form.inspectTime = e.f3;
				} else if (type == 'startTime2') {
					this.form.changeLimitTime = `${e.f1} ${e.f8}`;
				} else if (type == 6) {
					if (this.personUpdateList.length == 0) return;
					this.changePeopleIndex = e.detail.value;
					this.form.changeId = this.personUpdateList[e.detail.value].userId;
					console.log(this.changePeopleIndex, this.form.changeId)
				} else if (type == 7) {
					if (this.reviewList.length == 0) return;
					this.reviewIndex = e.detail.value;
					this.form.reviewId = this.reviewList[e.detail.value].userId;
				} else if (type == 8) {
					if (this.personList.length == 0) return;
					this.verifyManIndex = e.detail.value;
					this.form.verifyManId = this.personList[e.detail.value].userId;
				} else if (type == 9) {
					if (this.dangerItemList.length == 0) return;
					this.priorityNameDicIndex = e.detail.value;
					this.form.priorityNameDic = this.dangerItemList[e.detail.value].data;
				} else if (type == 10) {
					if (this.majorItemList.length == 0) return;
					this.dutyMajorIndex = e.detail.value;
					this.form.dutyMajor = this.majorItemList[e.detail.value].data;
				}
			},


			//获取人员列表--- 检查人、整改人、复查人、核验人、通知人
			getPersonList() {
				let data = {
					projectSn: this.projectSn
				}
				if (this.dangerReviewInfo.enableVerify == 1) {
					data.roleName = this.dangerReviewInfo.verifyRoleName;
					data.enterpriseId = this.unitEnterpriseId.join(",");
				}
				this.sendRequest({
					url: 'xmgl/systemUser/getProjectChilderSystemUserList',
					method: 'post',
					data: {
						...data
					},
					success: res => {
						console.log(res.result)
						if (res.result.length > 0) {
							console.log('检查人员列表', this.personList);
							this.personList = res.result;
							// let index = this.personList.findIndex(item => {
							// 	return item.userId == this.userInfo.userId;
							// })
							// if (index != -1) {
							// 	// this.verifyManIndex = index;
							// 	this.form.verifyManIds = [this.personList[index].userId];
							// } else {
							// 	// this.defaultAuditPerson = this.userInfo.realName;
							// 	this.form.verifyManIds = [this.userInfo.userId];
							// }
						} else {
							this.personList = [];
						}
					}
				})
			},

			//获取人员列表--- 整改人
			getPersonUpdateList() {
				this.sendRequest({
					url: 'xmgl/systemUser/getProjectChilderSystemUserList',
					method: 'post',
					data: {
						projectSn: this.projectSn,
						enterpriseId: this.unitEnterpriseId.join(','),
						safeQualityRegionIdForDuty: this.form.regionIds.join(","),
					},
					success: res => {
						console.log(res.result)
						if (res.result.length > 0) {
							console.log('检查人员列表', this.personList);
							this.personUpdateList = res.result;
							this.personUpdateList.forEach((item, index) => {
								if (item.userId == this.form.changeId) {
									this.changePeopleIndex = index
								}
							});
						} else {
							this.personUpdateList = [];
						}
					}
				})
			},


			checkedSubcontractListUp(val) {
				const resultList = this.subpackageLsit.filter((item) => {
					return this.form.enterpriseIds.includes(item.id);
				});
				this.form.enterpriseSns = resultList
					.map((item) => item.enterpriseSn)
					.join(",");
				this.form.enterpriseName = resultList
					.map((item) => item.enterpriseName)
					.join(",");
				this.unitEnterpriseId = resultList.map((item) => item.id);

				this.form.changeId = "";
				this.changePeopleIndex = null;
				this.isShowPicker = false;
				this.$nextTick(() => {
					this.isShowPicker = true;
				});
				this.getPersonUpdateList();
				this.getPersonList();
				this.getReviewPeopleList();
				// let newArr = [];
				// if (this.areaData.systemUsers) {
				// 	this.areaData.systemUsers.filter((item) => {
				// 		if (item.userId && this.unitEnterpriseId.includes(item.enterpriseId)) {
				// 			newArr.push(item);
				// 		}
				// 	});
				// 	this.personUpdateList = newArr;
				// }
			},
			//选择的分包公司
			checkSubpackage(val) {
				// if (this.checkType == 1) {
				this.form.enterpriseSns = val.enterpriseSn;
				this.form.enterpriseName = val.enterpriseName;
				this.unitEnterpriseId = val.id;
				this.form.changeId = "";
				this.changePeopleIndex = null;
				this.isShowPicker = false;
				this.$nextTick(() => {
					this.isShowPicker = true;
				});
				let newArr = [];
				if (this.areaData.systemUsers) {
					this.areaData.systemUsers.filter((item) => {
						if (item.userId && item.enterpriseId == this.unitEnterpriseId) {
							newArr.push(item);
						}
					});
					this.personUpdateList = newArr;
				}
				// this.getPersonUpdateList();
				// } else {
				// 	this.form.enterpriseSns = val.enterpriseSns;
				// 	this.form.enterpriseName = val.enterpriseName;
				// }
				this.unitDialog = false;
			},


			//删除---公用
			deletesBtn(type) {
				window.event.stopPropagation();
				//type==1 分包单位
				if (type == 1) {
					this.form.enterpriseSns = '';
					this.form.enterpriseName = '';
				}
			},

			//现场整改是否完成
			switchChange(e) {
				if (e.detail.value) {
					this.form.status = 5;
				} else {
					this.form.status = 2;
				}
			},

			//选择分包单位
			clickUnit() {
				this.unitDialog = true;
				// this.getSubpackageLsit();
			},
			//切换分包商
			checkTypeBtn(type) {
				this.checkType = type;
				this.getSubpackageLsit();
			},

			//上传附件
			uploadImg(type) {
				var that = this
				if (type == 1) {
					this.$chooseImage({
						count: 5 - that.imgFileList.length,
						success(res) {
							const tempFilePaths = res.tempFilePaths;
							uni.uploadFile({
								url: that.url_config + 'upload/image', //仅为示例，非真实的接口地址
								filePath: tempFilePaths[0],
								name: 'files',
								success: (uploadFileRes) => {
									let data = {
										name: JSON.parse(uploadFileRes.data).data[0].filename,
										url: JSON.parse(uploadFileRes.data).data[0].imageUrl
									};
									that.imgFileList.push(data)
									uni.getImageInfo({
										src: tempFilePaths[0],
										success: (resInfo) => {
											console.log('传过去啦 resInfo', resInfo)
											that.imgList = {
												imgUrl: tempFilePaths[0],
												imgWidth: resInfo.width,
												imgHeight: resInfo.height,
												// team:'班组人员',
												// name: '张三'
											}
											that.openImg = true
										}
									})
									that.openImg = false

								}
							});
						}
					})
				} else if (type == 2) {
					this.$chooseImage({
						count: 1,
						success(res) {
							const tempFilePaths = res.tempFilePaths;
							uni.uploadFile({
								url: that.url_config + 'upload/image', //仅为示例，非真实的接口地址
								filePath: tempFilePaths[0],
								name: 'files',
								success: (uploadFileRes) => {
									let data = {
										name: JSON.parse(uploadFileRes.data).data[0].filename,
										url: JSON.parse(uploadFileRes.data).data[0].imageUrl
									};
									if (that.imgDialogUrl.length >= 1) {
										that.imgDialogUrl[0].url = data.url
										that.imgDialogUrl[0].name = data.name

									} else {
										that.imgDialogUrl.push(data)
									}
									console.log("上传图片的信息：", that.imgDialogUrl)
								}
							});
						}
					})
				} else if (type == 3) {
					this.$chooseImage({
						count: 5 - that.rectifyAfterImageList.length,
						success(res) {
							const tempFilePaths = res.tempFilePaths;
							uni.uploadFile({
								url: that.url_config + 'upload/image', //仅为示例，非真实的接口地址
								filePath: tempFilePaths[0],
								name: 'files',
								success: (uploadFileRes) => {
									let data = {
										name: JSON.parse(uploadFileRes.data).data[0].filename,
										url: JSON.parse(uploadFileRes.data).data[0].imageUrl
									};
									that.rectifyAfterImageList.push(data)
								}
							});
						}
					})
				} else {
					this.$chooseImage({
						count: 1 - that.mapImgList.length,
						success(res) {
							const tempFilePaths = res.tempFilePaths;
							uni.uploadFile({
								url: that.url_config + 'upload/image', //仅为示例，非真实的接口地址
								filePath: tempFilePaths[0],
								name: 'files',
								success: (uploadFileRes) => {
									let data = {
										name: JSON.parse(uploadFileRes.data).data[0].filename,
										url: JSON.parse(uploadFileRes.data).data[0].imageUrl
									};
									that.mapImgList.push(data)
								}
							});
						}
					})

				}


			},
			//删除附件
			deleteImg(val, type) {
				let that = this;
				uni.showModal({
					title: '提示',
					content: '确定删除该附件吗?',
					success: function(res) {
						if (res.confirm) {
							if (type == 1) {
								let fileArr = JSON.parse(JSON.stringify(that.imgFileList));
								fileArr.forEach((item, index) => {
									if (item.url == val.url) {
										fileArr.splice(index, 1)
									}
								})
								that.imgFileList = fileArr;
							} else if (type == 2) {
								let fileArr = JSON.parse(JSON.stringify(that.videoFileList));
								fileArr.forEach((item, index) => {
									if (item.url == val.url) {
										fileArr.splice(index, 1)
									}
								})
								that.videoFileList = fileArr;
							} else if (type == 3) {
								let fileArr = JSON.parse(JSON.stringify(that.rectifyAfterImageList));
								fileArr.forEach((item, index) => {
									if (item.url == val.url) {
										fileArr.splice(index, 1)
									}
								})
								that.rectifyAfterImageList = fileArr;
							}

						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});

			},
			//上传视频
			uploadVideo() {
				var that = this;
				uni.chooseVideo({
					count: 5 - that.videoFileList.length,
					sourceType: ['camera', 'album'],
					compressed: false,
					success: function(res) {
						let url = res.tempFilePath;
						uni.uploadFile({
							url: that.url_config + 'upload/image', //仅为示例，非真实的接口地址
							filePath: url,
							name: 'files',
							success: (uploadFileRes) => {
								let obj = {
									name: JSON.parse(uploadFileRes.data).data[0].fileInfo
										.originalFilename,
									url: JSON.parse(uploadFileRes.data).data[0].imageUrl
								}
								that.videoFileList.push(obj);
								console.log('上传视频后的数据', that.videoFileList);
							}
						})
					}
				})
			},
			//查看视频
			playVideo(url, type) {
				uni.navigateTo({
					url: '../carWashManage/mediaPlay?url=' + url + '&type=' + type
				})
			},
			//预览图片
			previewImage(url) {
				uni.previewImage({
					urls: [url]
				})
			},


			//新增保存
			async addSaveBtn() {
				let arr = [],
					arr2 = [],
					arr3 = [];


				this.videoFileList.forEach(item => {
					arr.push(item.name + "*" + this.url_config + 'image/' + item.url)
				})
				this.imgFileList.forEach(item => {
					arr2.push(item.name + "*" + this.url_config + 'image/' + item.url)
				})
				this.rectifyAfterImageList.forEach(item => {
					arr3.push(item.name + "*" + this.url_config + 'image/' + item.url)
				})

				// this.form.fileUrl = this.videoFileList.length>0?JSON.stringify(this.videoFileList):'';
				// this.form.imageUrl = this.imgFileList.length>0?JSON.stringify(this.imgFileList):'';
				this.form.fileUrl = arr.join(',')
				this.form.imageUrl = arr2.join(',')
				this.form.rectifyAfterImage = arr3.join(',')
				let data = {
					...this.form,
					regionIds: this.form.regionIds.join(","),
					enterpriseIds: this.form.enterpriseIds.join(","),
					reviewIds: this.form.reviewIds.join(","),
					verifyManIds: this.form.verifyManIds.join(","),
					level: this.form.level == 0 ? Number(this.form.level) + 1 : this.form.level,
					urgentLevel: this.form.urgentLevel == 0 ? Number(this.form.urgentLevel) + 1 : this.form
						.urgentLevel,
					dangerItemContent: this.issueName,
				};
				const every = this.addForm1Rules.every(item => {
					if (!data[item.fieldName] || Array.isArray(this.form[item.fieldName]) && this.form[
							item.fieldName].length == 0) {
						// item.originalFieldName == '责任专业' || 
						if (item.originalFieldName == '整改后图片') {
							if (this.form.status == 5) {
								uni.showToast({
									title: item.message,
									icon: 'none'
								})
								return false
							}
							return true
						}
						uni.showToast({
							title: item.message,
							icon: 'none'
						})
						return false
					}
					return true
				})
				console.log(333344, every)
				if (!every) return
				data.projectSn = this.projectSn;
				data.inspectManId = this.userInfo.userId
				data.creatorId = this.userInfo.userId
				if (this.engineeringId) data.engineeringId = this.engineeringId
				if (this.type) data.type = this.type
				let pointArr = []
				for (let i = 0; i < this.pointList.length; i++) {
					let obj =
						this.pointList[i].x +
						'*' +
						this.pointList[i].y
					pointArr.push(obj)
				}
				data.measurePoints = pointArr.join(',')
				console.log('data.measurePoints=============', data.measurePoints);
				if (this.typeCheck == "type1") {
					console.log(data);
					// 安全问题
					this.sendRequest({
						url: 'xmgl/xzSecurityQualityInspectionRecord/add',
						method: 'post',
						data: data,
						success: (res) => {
							console.log(res)
							if (res.code == 200) {
								uni.showToast({
									title: '保存成功'
								})
								setTimeout(() => {
									uni.navigateBack({
										delta: 1
									})
								}, 1200)
							} else {
								uni.showToast({
									title: res.message,
									icon: 'none'
								})
							}
						}
					})
				} else {
					console.log(this.taskId);
					console.log(this.itemId);
					// 排查记录
					let data2 = {
						...data,
						recordType: 2,
						routineInspect: 0,
						taskId: this.taskId || null, // 任务ID
						itemId: this.itemId || null, // 任务子ID
					}

					if (this.engineeringId) data2.engineeringId = this.engineeringId
					if (this.type) data2.type = this.type
					console.log(data.taskId);
					await this.sendRequest({
						url: 'xmgl/xzSecurityQualityInspectionRecord/add',
						method: 'post',
						data: data2,
						success: (res) => {
							console.log(res)
							if (res.code == 200) {
								uni.showToast({
									title: '保存成功'
								})
								setTimeout(() => {
									uni.navigateBack({
										delta: 1
									})
								}, 1200)
							} else {
								uni.showToast({
									title: res.message,
									icon: 'none'
								})
							}
						}
					})
				}
			},

			// 切换tab
			radioChange(value) {

				this.typeCheck = value
				this.checkedTab = value
				console.log('切换tab', this.form);
				// 重制内容
				this.form = {
					regionIds: [], // 检查部位
					regionName: "",
					priorityNameDic: "",
					dangerItemContent: "",
					dangerItemId: "",
					dangerTypeId: "",
					dangerDesc: "",
					remark: "",
					routineId: 0,
					level: "",
					reviewNames: "",
					verifyManNames: "",
					urgentLevel: "",
					inspectManId: "",
					enterpriseIds: [],
					inspectTime: "",
					enterpriseSns: "",
					enterpriseName: "",
					changeLimitTime: "",
					changeId: "",
					reviewIds: [],
					verifyManIds: [],
					notifyPerson: [],
					status: 2, // 现场整改状态  2未完成   5已完成
					measurePoints: [],
					imageUrl: "",
					fileUrl: "",
					rectifyAfterImage: "",
					recordType: 1,
					dangerName: '',
					subsectionId: '', //分部工程
					subentryId: '', //分项工程
					floor: '', //巡检楼层
					addedDescription: '', //事件描述
					taskId: '', //任务ID
					itemId: '', // 任务子ID
					dutyMajor: "",
				};
				this.issueName = ''
				this.checkPointName = ""
				this.videoFileList = [];
				this.imgFileList = [];
				this.rectifyAfterImageList = [];
				this.subsectionIndex = -1
				this.subentryIndex = -1
				this.changePeopleIndex = null
				// 分包单位数据拿取
				this.subpackageLsit = []
				// 整改人数据拿取
				this.personUpdateList = []
				let index = this.personList.findIndex(item => {
					return item.userId == this.userInfo.userId;
				})
				if (value) {
					this.form.recordType = value == 'type1' ? 1 : 2;
					this.getSecurityDangerFieldPage();
				}
				// if (index != -1) {
				// 	this.verifyManIndex = index;
				// 	this.form.verifyManId = this.personList[index].userId;
				// } else {
				// 	this.defaultAuditPerson = this.userInfo.realName;
				// 	this.form.verifyManId = this.userInfo.userId;
				// }
			}
		}
	}
</script>

<style scoped lang="scss">
	.confrim-btn {
		padding: 18rpx 26rpx;
		background-color: #FFFFFF;
		box-shadow: 0rpx -8rpx 8rpx 0rpx rgba(0, 0, 0, 0.05);
		display: flex;
		width: 100%;
		position: fixed;
		bottom: 0;

		>view {
			width: 50%;
			height: 76rpx;
			font-weight: 500;
			font-size: 28rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		>view:first-child {
			background-color: rgba(81, 129, 246, 0.1);
			border-radius: 6rpx 0rpx 0rpx 6rpx;
			color: #5181F6;
		}

		>view:last-child {
			background-color: #5181F6;
			border-radius: 0rpx 6rpx 6rpx 0rpx;
			color: #FFFFFF;
		}
	}

	.fixedheader {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		z-index: 2;

		.headerName {
			z-index: 1;
		}
	}

	.tab {
		width: 100%;
		height: 45px;
		text-align: center;
		box-shadow: 0 0 10px rgba(194, 194, 194, 0.5);
	}

	.tabType {
		width: 50%;
		line-height: 43px;
		border-bottom: 1px solid rgba(194, 194, 194, 0.2);

	}

	.checkedTab {
		color: #498CEC;
		border-bottom: 4rpx solid #498CEC;

	}

	.noCheckTab {
		padding-bottom: 2px;
	}

	.lagCss {
		width: 180px;
		height: 61px;
		background: #fff;
		text-align: center;
		line-height: 29px;
		border-radius: 10px;
	}

	.add2 {
		width: 120px;
		height: 30px;
		line-height: 30px;
		text-align: center;
		color: #fff;
		background: #4181fe;
		border-radius: 25px;
		font-size: 14px;
		margin: 0px 22px;
	}

	.point {
		height: 20px;
		width: 20px;
		position: absolute;
	}

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

	.flex2 {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.flex3 {
		display: flex;
	}

	.content {
		width: 100%;
		box-sizing: border-box;
		padding: 20px 30rpx 120rpx;
	}

	.type {
		font-size: 30rpx;
		line-height: 68rpx;
		margin-bottom: 16rpx;
		/* border-bottom: 1px solid rgba(194, 194, 194, 0.2); */
	}

	.type .name {
		margin-right: 6px;
		width: 204rpx;
		text-align: right;
		font-size: 28rpx;
		color: #808080;
	}

	.radio-wrap {
		display: flex;
		align-items: center;

		.radio {
			margin-right: 20px;
		}
	}

	.accessory {
		width: 100%;
		height: 70px;
		padding: 0 10px;
		box-sizing: border-box;
	}

	.accessoryImg {
		width: 110rpx;
		height: 120rpx;
		margin-right: 16rpx;
	}

	.picker {
		// width: 70%;
		border: 2rpx solid rgba(42, 43, 91, 0.3);
		padding: 0px 30rpx;
		box-sizing: border-box;
		border-radius: 10rpx;
		width: calc(100% - 204rpx);
		height: 68rpx;
	}

	.pickerone {
		// width: 70%;
		border: 2rpx solid rgba(42, 43, 91, 0.3);
		box-sizing: border-box;
		border-radius: 10rpx;
		width: calc(100% - 204rpx);




		.issueserch {
			width: 80rpx;
			// background: skyblue;
			display: flex;
			align-items: center;
			justify-content: center;

			.icon-down {
				width: 40rpx !important;
				height: 40rpx !important;
			}
		}
	}

	/deep/ .uni-easyinput__placeholder-class {
		font-size: 28rpx;
		color: #A2A4AF;
	}

	.uni-input {
		line-height: 32px;
	}

	.textarea {
		// width: calc(79% - 32px);
		width: calc(100% - 204rpx);
		border-radius: 10rpx;
		border: 2rpx solid rgba(42, 43, 91, 0.3);
		padding: 16rpx 28rpx;
		box-sizing: border-box;
		height: 68rpx;
		font-size: 28rpx;
	}

	.inpuStyle {
		width: calc(80% - 35px);
		border-radius: 20px;
		border: 1px solid rgba(42, 43, 91, 0.3);
		padding: 8px 15px;
		box-sizing: border-box;
		height: 35px;
		color: #000;
	}

	.uni-input {
		font-size: 28rpx;
	}

	.cl {
		border-radius: 5px;
		font-size: 28rpx;
		color: #A2A4AF;
	}


	.imgBox_wrap {
		display: flex;
		flex-wrap: wrap;
		margin-top: 10px;
		width: 75%;
	}

	.imgBox {
		width: 112rpx;
		height: 120rpx;
		display: inline-flex;
		position: relative;
		border-radius: 8rpx;

		.img {
			width: 100%;
			height: 100%;
			border-radius: 8rpx;
		}

		.deleteImg {
			position: absolute;
			right: -20rpx;
			top: -20rpx;
			color: #fff;
			width: 20rpx;
			height: 20rpx;
			background-image: url('@/static/workTicketManage/index-icon9.png');
			background-repeat: no-repeat;
			background-size: 100% 100%;

		}

	}

	.addImgBox {
		width: 118rpx;
		height: 120rpx;
		background: #FFFFFF;
		border-radius: 8rpx;
		border: 2rpx solid #D8DBE8;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		font-size: 24rpx;

		.icon-add {
			width: 40rpx;
			height: 40rpx;
		}
	}

	.unitDialog {
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		z-index: 111;
		background-color: rgba(0, 0, 0, 0.5);
	}

	.unitContent {
		width: 85%;
		height: 70%;
		margin: 25% auto 0;
		background-color: #fff;
		box-sizing: border-box;
		padding: 20px 30rpx;
		border-radius: 5px;
		box-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
	}

	.tabs {
		border-bottom: 1px solid rgba(153, 153, 153, 0.5);
	}

	.tabs_name {
		width: 40%;
		text-align: center;
		padding: 5px 10rpx;
		box-sizing: border-box;
		font-size: 30rpx;
	}

	.checkName {
		border-bottom: 2px solid #4181FE;
		color: #4181FE;
	}

	.noCheckName {
		padding-top: 4px;
	}

	.unitList {
		margin: 10px 0;
		font-size: 30rpx;

		.title {
			margin-bottom: 10px;
		}

		.list_val {
			padding: 8px 10px;
		}
	}

	.bg_999 {
		background-color: rgba(153, 153, 153, 0.1);
	}

	.ellipsis {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.status {
		color: #007AFF;
	}

	.addSaveBtn {
		margin: 30px auto;
		width: 60%;
		padding: 10px 0;
		text-align: center;
		background-color: #4181FE;
		color: #fff;
		font-size: 34rpx;
		border-radius: 30px;
		letter-spacing: 2px;
		box-shadow: 0 3px 10px rgba(65, 129, 254, 0.8);
	}

	.addSaveBtn:active {
		background-color: rgba(65, 129, 254, 0.8);
	}

	.radio-box {
		display: flex;
	}

	.radio-item {
		display: flex;
		margin-right: 20rpx;
		align-items: center;
		font-size: 28rpx;

		/deep/ .uni-radio-input {
			width: 32rpx;
			height: 32rpx;
		}
	}

	.radio-text {
		height: 72rpx;
	}

	.butA {
		display: flex;
		// position: absolute;
		top: 60%;

		width: 70%;
	}

	.icon-right {
		margin-left: 16rpx;
		width: 16rpx;
		height: 32rpx;
	}

	.dateTimePiccker {
		border: 2rpx solid #ccc;
		border-radius: 10rpx;
		// width: 67%;
		padding-left: 20rpx;
		width: calc(100% - 204rpx);
		font-size: 28rpx;
		height: 68rpx;
		line-height: 68rpx;
	}
</style>