<template>
	<view class="container uni-container">
		<view class="example">
			<!-- 自定义表单校验 1-->
			<u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="70" labelAlign="right">
				<view class=" flex  flex-direction ">
					<u-form-item label="任务名称" prop="taskName" :required="true">
						<u-input v-model="formData.taskName" placeholder="请输入项目名称" />
					</u-form-item>
					<u-form-item label="所属单位" prop="orgId" @click="showSex(); hideKeyboard()" :required="true">
						<u--input suffixIcon="arrow-right" suffixIconStyle="color: #909399" v-model="formData.orgId"
							disabled disabledColor="#ffffff" placeholder="请选择所属单位">
						</u--input>
					</u-form-item>
					<!-- 	<u-form-item label="所属部门" prop="deptId" @click="showSex3(); hideKeyboard()">
						<u--input suffixIcon="arrow-right" suffixIconStyle="color: #909399" v-model="formData.deptId"
							disabled disabledColor="#ffffff" placeholder="请选择所属部门 (注:单位/部门二选一)">
						</u--input>
					</u-form-item> -->
					<u-form-item label="检查项目" :required="true" prop="inspectIds"
						@click="showCheckboxShow(); hideKeyboard()">
						<u--input suffixIcon="arrow-right" suffixIconStyle="color: #909399"
							v-model="formData.inspectIds" disabled disabledColor="#ffffff" placeholder="请选择检查项目">
						</u--input>
					</u-form-item>
				</view>
				<u-form-item label="巡查内容补充" prop="taskContent" class="xuncha" label-width="220rpx">
					<u--textarea v-model="formData.taskContent" placeholder="请输入内容" :maxlength="200" count height="100">
					</u--textarea>
				</u-form-item>
				<u-form-item label="上传附件">
					<!-- 选择文件上传，limit="1则最多选择一张图片，del-icon隐藏删除按钮 -->
					<uni-file-picker v-model="formData.attId" del-icon limit="1" auto-upload file-mediatype="all"
						@select="select" @delete="deleteFile">
						<button type="primary" class="selectBtn">选择文件</button>
						<!-- 加载中 -->
						<isLodingModel v-if="loading"></isLodingModel>
					</uni-file-picker>
				</u-form-item>
				<u-form-item label="已上传附件" v-if="bianji&&formData.attId.length" labelWidth="100">
							<u-icon name="close" color="#4CB2B6" size="24" @click="closeImage()">
							</u-icon>
							<!-- #ifdef MP-WEIXIN -->
							<text style="color:#00a3f4;cursor: pointer;margin-left: 50rpx !important;"
								@click.native="viewSee(formData.attId[0])">点击预览文件</text>
							<!-- #endif -->
							<!-- #ifdef H5 -->
							<a style="color:#00a3f4;cursor: pointer;margin-left: 50rpx !important;" @click="viewSee(formData.attId[0])">点击预览文件</a>
							<!-- #endif -->
				</u-form-item>
				<uni-row class="zan-cun">
					<!-- <uni-col :span="12">
						<u-button @click="submit('customForm')" type="primary" shape="circle" size="default"
							color="#4CB2B6" text="立即发布">
							:text="bianji?'确认修改':'确认提交'"
						</u-button>
					</uni-col> -->
					<uni-col :span="24">
						<!-- 		<u-modal :show="show" :title="title" :content='content' :asyncClose="true" @cancel="cancel"
							@confirm="confirm" :showCancelButton='true' :showConfirmButton='true'></u-modal> -->
						<u-button @click="submit('customForm')" type="primary" color="#4CB2B6" shape="circle"
							size="default" text="暂存"></u-button>
						<u-modal :show="showNew" title="已存入草稿箱,是否立即发布" @confirm="sureNew" @cancel="cancelNew"
							:showCancelButton='true' :showConfirmButton='true'></u-modal>
					</uni-col>
				</uni-row>
			</u--form>
			<!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭所属单位的弹出内容选中 ，选择单位-->
			<u-popup :show="checkboxShow2" :round="10" @close="checkboxShow2=false" style="position: relative;">
			<!-- 	<view class="u-page__tag-item">
					<u-search placeholder="请输入所属单位" v-model="keyword" bgColor="#edf6f9" borderColor="#4cb2b6"
						:show-action="false"></u-search>
				</view> -->
				<view class="popup-button">
					<uni-row>
						<uni-col :span='12'>
							<u-button shape="circle" type="primary" color="#4CB2B6" text="确定" @click="checkboxConfirm2">
							</u-button>
						</uni-col>
						<uni-col :span='12'>
							<u-button type="primary" plain color="#4CB2B6" text="取消" shape="circle"
								@click="checkboxCancel2">
							</u-button>
						</uni-col>
					</uni-row>
				</view>
				<view class="page-body" :style="'height:' + (height-80)+ 'px'">
					<scroll-view class="nav-left" scroll-y :style="'height:' + height + 'px'"
						:scroll-top="scrollLeftTop" scroll-with-animation>
						<view class="nav-left-item" :class="index == categoryActive ? 'active' : ''"
							v-for="(item, index) in list2" @click="categoryClickMain(index,item)" :key="index">
							{{item[0]}}
						</view>
					</scroll-view>
					<scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
						:style="'height:' + height + 'px'" scroll-with-animation>
						<view v-for="(item, index) in list2" :key="index" class="box">
							<view style="height: 60rpx;font-size: 32rpx;color:#000;font-weight: 600;padding: 25rpx;">
								{{ item[0]}}
							</view>
							<!-- <view :id="i == 0 ? 'first' : ''" class="nav-right-item"> -->
							<view class="nav-right-item">
								<u-checkbox-group size='20' iconSize='18' placement="row" iconPlacement='right'
									v-model="items.checkedList2" v-for="(items, i) in item" :key="i"
									@change="checkboxChange2(items.dwid,$event)">
									<u-checkbox v-if="i>0" activeColor="green" :customStyle="{marginBottom: '5px'}"
										:label="items.orgName" :name="items.dwid">
									</u-checkbox>
								</u-checkbox-group>
							</view>
						</view>
					</scroll-view>
				</view>
			</u-popup>


			<!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭检查项的弹出内容选中  选择检查项-->
			<u-popup :show="checkboxShow" :round="10" @close="checkboxShow=false" style="position: relative;">
				<!-- <view class="u-page__tag-item">
					<u-search placeholder="请输入检查项" v-model="keyword" bgColor="#edf6f9" borderColor="#4cb2b6"
						:show-action="false"></u-search>
				</view> -->
				<view class="popup-button">
					<uni-row>
						<uni-col :span='12'>
							<u-button shape="circle" type="primary" color="#4CB2B6" text="确定" @click="checkboxConfirm">
							</u-button>
						</uni-col>
						<uni-col :span='12'>
							<u-button type="primary" plain color="#4CB2B6" text="取消" shape="circle"
								@click="checkboxCancel">
							</u-button>
						</uni-col>
					</uni-row>
				</view>
				<view class="page-body" :style="'height:' +(height-80) + 'px'">
					<scroll-view class="nav-left" scroll-y :style="'height:' + (height-100) + 'px'"
						:scroll-top="scrollLeftTop" scroll-with-animation>
						<view class="nav-left-item" :class="index == categoryActive ? 'active' : ''"
							v-for="(item, index) in list" @click="categoryClickMain(index,item)" :key="index">
							{{ item.label }}
						</view>
					</scroll-view>
					<scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
						:style="'height:' + height + 'px'" scroll-with-animation>
						<view v-for="(item, index) in list" :key="index" class="box">
							<view style="height: 60rpx;font-size: 32rpx;color:#000;font-weight: 600;padding: 25rpx;">
								{{item.label}}
							</view>
							<!-- <view :id="i == 0 ? 'first' : ''" class="nav-right-item"> -->
							<view class="nav-right-item">
								<u-checkbox-group size='20' iconSize='18' placement="row" iconPlacement='right'
									v-model="items.checkedList" v-for="(items, i) in item.inspectInfoDOList" :key="i"
									@change="checkboxChange(items.id,$event)">
									<u-checkbox activeColor="green" :customStyle="{marginBottom: '5px'}"
										:label="items.inspName" :name="items.id">
									</u-checkbox>
								</u-checkbox-group>
							</view>
						</view>
					</scroll-view>
				</view>
			</u-popup>

			<!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭所属部门的弹出内容选中 ，选择部门-->
			<u-popup :show="checkboxShow3" :round="10" @close="checkboxShow3=false" style="position: relative;">
				<view class="popup-button">
					<uni-row>
						<uni-col :span='12'>
							<u-button shape="circle" type="primary" color="#4CB2B6" text="确定" @click="checkboxConfirm3">
							</u-button>
						</uni-col>
						<uni-col :span='12'>
							<u-button type="primary" plain color="#4CB2B6" text="取消" shape="circle"
								@click="checkboxCancel3">
							</u-button>
						</uni-col>
					</uni-row>
				</view>
				<view class="page-body" :style="'height:' + height + 'px'">
					<scroll-view class="nav-left" scroll-y :style="'height:' + height + 'px'"
						:scroll-top="scrollLeftTop" scroll-with-animation>
						<view class="nav-left-item" :class="index == categoryActive ? 'active' : ''"
							v-for="(item, index) in list3Jia" @click="categoryClickMain(index,item)" :key="index">
							{{ item.name}}
						</view>
					</scroll-view>
					<scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
						:style="'height:' + height + 'px'" scroll-with-animation>
						<view v-for="(item, index) in list3Jia" :key="index" class="box">
							<view style="height: 60rpx;font-size: 32rpx;color:#000;font-weight: 600;padding: 25rpx;">
								{{ `单位${item.id}` }}
							</view>
							<!-- <view :id="i == 0 ? 'first' : ''" class="nav-right-item"> -->
							<view class="nav-right-item">
								<u-checkbox-group size='20' iconSize='18' placement="row" iconPlacement='right'
									v-model="items.checkedList3" v-for="(items, i) in list3" :key="i"
									@change="checkboxChange3(items.id,$event)">
									<u-checkbox activeColor="green" :customStyle="{marginBottom: '5px'}"
										:label="items.name" :name="items.id">
									</u-checkbox>
								</u-checkbox-group>
							</view>
						</view>
					</scroll-view>
				</view>
			</u-popup>


			<!-- <image :src="jiezhiTime" mode="heightFix" style="width: 20px;height: 20px;"></image> -->
		</view>
	</view>
</template>
<script>
	import {
		addCheckActiveCreate, // 主动检查添加
		addCheckActiveErrorsubmit, // 主动检查生成隐患
		addCheckActiveCompany, //所属单位
		jiase, //检查项数据列表
		addCheckActiveDepartment, //所属部门
		editCheckActiveCreate, //编辑主动检查
		getCheckActiveTask, //获取编辑主动检查的数据
		getCheckActiveTaskXin, //最新--获取编辑主动检查的数据
		saveCheckRelease
	} from "@/api/check_active";
	import {
		uploadAvatar
	} from "@/api/system/user"
	import {
		getAccessToken
	} from '@/utils/auth'
	import {
		downSee,
		checkType
	} from '@/utils/common'
	import config from '@/config'
	import store from "@/store"
	const baseUrl = config.baseUrl
	let that = null;
	export default {
		data() {
			return {
				keyword: '',
				list3Jia: [{
					name: '测试部门'
				}],
				showNew: false, //确认立即发布弹框
				showGender: false, //所属单位下拉框展示
				//————————————下拉结束
				checkboxShow: false, //选择检查项目弹框
				checkboxShow2: false, //选择检查单位弹框
				checkboxShow3: false, //选择检查部门弹框
				checkedList: [], //检查项目已选择列表
				checkedList2: [], //检查单位已选择列表
				checkedList3: [], //检查部门已选择列表
				// 生成隐患弹窗
				show: false,
				list: [], //选择检查项目的数据
				list2: [], //选择单位项目的数据
				list3: [], //选择单位项目的数据
				// 每页数据量
				pageSize: 5,
				// 当前页
				pageNo: 1,
				// 数据总量
				total: 0,
				// tableData数据加载中
				tableData: '',
				loading: false,
				title: '生成隐患',
				content: '确认将此检查项目生成为隐患',
				// 自定义表单数据
				formData: {
					taskName: '', //任务名称
					inspectIds: '', //检查项目
					taskContent: '', //任务描述
					orgId: '', //页面上显示的检查单位
					deptId: '', //页面上显示的部门
					attId: [], //附件
				},
				formDataChuangMu: {
					"deptId": [],
					// "attId": 0,
					"inspectIds": [],
					"orgId": [], //检查单位id
					// "orgType": "",
					"status": 0, //0代表启用
					"taskContent": "", //任务描述
					"sender": this.$store.state.user.id,
					// "taskId": 0,
					"taskName": "", //任务名称
					// "taskScore": 0,
					"taskStatus": "0",
					"taskType": "", //任务类型 1对应主动检查
					"attId": ''
				},
				fileList1: [],
				// 自定义表单校验规则
				customRules: {
					taskName: {
						status: 'string',
						required: true,
						message: '任务名称需在2-20个字符之间',
						trigger: ['blur', 'change'],
						min: 2,
						max: 20,
					},
					inspectIds: {
						status: 'string',
						required: true,
						message: '检查项目不能为空',
						trigger: ['blur', 'change']
					},
					orgId: {
						status: 'string',
						required: true,
						message: '所属单位不能为空',
						trigger: ['blur', 'change']
					},
					// deptId:{
					// 	status: 'string',
					// 	required: true,
					// 	message: '所属部门不能为空',
					// 	trigger: ['blur', 'change']
					// }
				},
				bianji: false, //是否编辑进来的
				ids: '', //创建成功的id
				//侧边栏联动
				height: 0,
				categoryActive: 0,
				scrollTop: 0,
				scrollLeftTop: 0,
				arr: [0, 584, 1168, 1752, 2336, 2805, 3274, 3858, 4442, 4911, 5380, 5734, 6203, 6672,
					7017
				], //初始值，后边计算会根据手机适配覆盖
				leftItemHeight: 51, //49行会计算出新值进行覆盖
				navLeftHeight: 0, //左边scroll-view 内层nav的总高度
				diff: 0, //左边scroll-view 内层nav的总高度与视口之差
				tabBarHeight: 0 //如果此页面为Tab页面，自己改变高度值,,一般tab高度为51

			}
		},
		computed: {},
		watch: {
			loading: {
				handler(newLength, oldLength) {
					this.$modal.isLoadingModel(this.loading)
				},
				immediate: true
			}
		},
		// 在 vue页面，向起始页通过事件传递数据
		onLoad: function(option) {
			console.log(option, 'mmmmmmmmm');
			this.formDataChuangMu.taskType = option.type
			if (option.id) {
				this.bianji = true
				const ids = parseInt(option.id)
				const json = JSON.stringify({
					id: ids,
					// pageNo: this.pageNo,
					// pagesSize: this.pageSize
				})
				getCheckActiveTaskXin({
					id: ids
				}).then(response => { //获取编辑主动检查的数据
				console.log(response,'responseresponse');
					const res = response.data
					this.formData.taskName = res.taskInfo.taskName
					this.formData.taskContent = res.taskInfo.taskContent
					this.formData.attId[0]= res.taskInfo.attId?res.taskInfo.attId:''
					this.formDataChuangMu.attId= res.taskInfo.attId?res.taskInfo.attId:''
					if (res.orgList&&res.orgList.length != 0) {
						let item = []
						res.orgList.map(v => { //单位
							this.formDataChuangMu.orgId.push(v.id)
							item.push(v.orgName)
						})
						this.formData.orgId = item.join(',')
					}
					if (res.inspectList.length != 0) {
						let arr = []
						res.inspectList.map(v => { //项目
							this.formDataChuangMu.inspectIds.push(v.id)
							arr.push(v.inspName)
						})
						this.formData.inspectIds = arr.join(',')
					}
					// if (res.deptList.length != 0) {
					// 	this.formData.deptId = '已选择部门'
					// 	res.deptList.map(v => {  //部门
					// 			this.formDataChuangMu.deptId.push(v.id)
					// 		})
					// }



				});
				this.formDataChuangMu["id"] = ids

			}


		},
		onReady() {
			// this.checkedTotal3(this.pageNo)  部门
			this.checkedTotal(this.pageNo)
			this.getData(this.pageNo)
			this.height = uni.getSystemInfoSync().windowHeight - this.tabBarHeight
			// 设置自定义表单校验规则，必须在节点渲染完毕后执行 
			this.$refs.customForm.setRules(this.customRules)
		},
		methods: {
			closeImage(){
				this.formData.attId=[]
				this.formDataChuangMu.attId =''
				this.$forceUpdate()
			},
			//查看已上传附件
			viewSee(val){
				downSee(val)
			},
			//上传文件
			selectBtn() {
				this.$refs.files.upload()
			},
			// 隐藏键盘
			hideKeyboard() {
				uni.hideKeyboard()
			},
			// 生成隐患弹出层   //暂存为草稿箱弹出层
			cancel() {
				this.show = false;
			},
			confirm() {
				setTimeout(() => {
					// 0.5秒后自动关闭
					this.show = false;
				}, 500)
			},
			//popup检查项确定
			checkboxConfirm() {
				this.checkboxShow = false
				let arr = []
				this.checkedList.map(v => {
					v.map(i => {
						arr.push(i)
					})
				})
				this.formDataChuangMu.inspectIds = [...new Set(arr)]
				let items = []
				if (this.checkedList.length != 0) {
					this.list.map(i => {
						i.inspectInfoDOList.map(k => {
							this.formDataChuangMu.inspectIds.map(j => {
								if (k.id == j) {
									items.push(k.inspName)
								}
							})

						})
					})
					this.formData.inspectIds = items.join(',')
				} else {
					this.formData.inspectIds = ''
				}
			},
			//popup取消
			checkboxCancel() {
				this.checkboxShow = false
				this.checkedList = []
				this.formData.inspectIds = ''
			},
			//popup检查单位确定============
			checkboxConfirm2() {
				this.checkboxShow2 = false
				let arr = []
				console.log(this.checkedList2,'this.checkedList2');
				this.checkedList2.map(v => {
					v.map(i => {
						arr.push(i)
					})
				})
				this.formDataChuangMu.orgId = [...new Set(arr)]
				let items = []
				if (this.checkedList2.length != 0) {
					for (let v in this.list2) {
						this.list2[v].map(i => {
							// 	i.map(k => {
							this.formDataChuangMu.orgId.map(j => {
								if (i.dwid == j) {
									items.push(i.orgName)
								}
							})
							// 	})
						})
					}

					this.formData.orgId = items.join(',')
				} else {
					this.formData.orgId = ''
				}
			},
			//popup取消
			checkboxCancel2() {
				this.checkboxShow2 = false
				this.checkedList2 = []
				this.formData.orgId = ''
			},
			//========
			// //popup检查部门确定============
			// checkboxConfirm3() {
			// 	this.checkboxShow3 = false
			// 	this.checkedList3.map(v => {
			// 		v.map(i => {
			// 			this.formDataChuangMu.deptId.push(i)
			// 		})
			// 	})
			// 	if (this.checkedList3.length != 0) {
			// 		this.formData.deptId = '已选择部门'
			// 	}else{
			// 		this.formData.deptId =''
			// 	}
			// },
			// //popup取消
			// checkboxCancel3() {
			// 	this.checkboxShow3 = false
			// 	this.checkedList3 = []
			// 	this.formData.deptId =''
			// },
			// checkboxChange3(i, n) {
			// 	if (i && n.length != 0) {
			// 		this.checkedList3.push(n)
			// 	} else if (i && n.length == 0) {
			// 		this.checkedList3 = this.checkedList3.filter(item => item != i)
			// 	}
			// 	console.log(this.checkedList3, 'this.checkedList3');
			// },
			// // 展示部门选择的弹出层
			// showSex3(pageNo, value = '') {
			// 	this.checkboxShow3 = true

			// },
			// checkedTotal3(pageNo) { //部门
			// 	this.loading = true
			// 	this.pageNo = pageNo
			// 	addCheckActiveDepartment({}).then(response => { //所属部门数据列表
			// 		console.log(response, 'response部门');
			// 		this.list3 = response.data
			// 		console.log(this.list3, 'this.list3');
			// 		const json = JSON.stringify({
			// 			id: this.formDataChuangMu["id"],
			// 			pageNo: this.pageNo,
			// 			pagesSize: this.pageSize
			// 		})
			// 		if (this.bianji) {
			// 			getCheckActiveTaskXin({
			// 				id: this.formDataChuangMu["id"]
			// 			}).then(response => { //获取编辑所属部门的数据
			// 				const res = response.data
			// 				res.deptList.map(
			// 					v => { //进入编辑界面以前勾选的所属部门把他放进this.list[0].deptList.中添加一个checkedList
			// 						this.list3.map(listK => {
			// 							if (v.id == listK.id) {
			// 								listK.checkedList3 = [v.id]
			// 							}
			// 						})
			// 						this.checkedList3.push([v.id]) //这句话有问题    传到后端的数据
			// 					})
			// 			});
			// 		}
			// 	});
			// },
			//========

			checkboxChange(i, n) { //输出的是选中的项目id数组 
				if (i && n.length != 0) {
					this.checkedList.push(n)
				} else if (i && n.length == 0) {
					this.checkedList = this.checkedList.filter(item => item != i)
				}
			},
			checkboxChange2(i, n) {
				if (i && n.length != 0) {
					this.checkedList2.push(n)
				} else if (i && n.length == 0) {
					this.checkedList2 = this.checkedList2.filter(item => item != i)	
				}
			},
			// 展示检查项的弹出层
			showCheckboxShow(pageNo, value = '') {
				this.checkboxShow = true
				// this.checkedTotal(this.pageNo)
			},
			// 展示单位选择的弹出层
			showSex(pageNo, value = '') {
				this.checkboxShow2 = true

			},
			checkedTotal(pageNo) {
				this.pageNo = pageNo
				jiase({
					inspType: 'dict_inspect_type'
				}).then(response => { //检查项数据列表
					this.list = response.data
					const json = JSON.stringify({
						id: this.formDataChuangMu["id"],
						// pageNo: this.pageNo,
						// pagesSize: this.pageSize
					})
					if (this.bianji) {
						getCheckActiveTaskXin({
							id: this.formDataChuangMu["id"]
						}).then(response => { //获取编辑主动检查项的数据
							const res = response.data
							res.inspectList.map(
								v => { //进入编辑界面以前勾选的检查项把他放进this.list[0].inspectInfoDOList中添加一个checkedList
									this.list.map(i => {
										i.inspectInfoDOList.map(listK => {
											if (v.id == listK.id) {
												listK.checkedList = [v.id]
											}
										})
									})

									this.checkedList.push([v.id]) //这句话有问题    传到后端的数据
								})
						});
					}
				});
			},
			//侧边栏导航联动
			getHeightList() {
				let _this = this;
				let selectorQuery = uni.createSelectorQuery();
				selectorQuery.selectAll('.nav-left-item').boundingClientRect(function(rects) {
					_this.leftItemHeight = rects[0].height;
					_this.navLeftHeight = _this.leftItemHeight * this.list.length;
					_this.diff = _this.navLeftHeight - _this.height;
				});
				selectorQuery.selectAll('.box').boundingClientRect(function(rects) {
					let arr = [0];
					let top = 0;
					if (rects) {
						rects.forEach(function(rect) {
							top += rect.height;
							arr.push(top);
						});
					};
					_this.arr = arr;
				}).exec();
			},
			scroll(e) {
				let _this = this;
				if (this.timeoutId) {
					clearTimeout(this.timeoutId);
				}
				this.timeoutId = setTimeout(function() {
					//节流
					_this.scrollHeight = e.detail.scrollTop + 1 + _this.height / 2;
					//+1不要删除，解决最后一项某种情况下翻到底部，左边按钮并不会切换至最后一个
					//若想使切换参考线为屏幕顶部请删除 _this.height/2
					for (let i = 0; i < _this.arr.length; i++) {
						let height1 = _this.arr[i];
						let height2 = _this.arr[i + 1];
						if (!height2 || (_this.scrollHeight >= height1 && _this.scrollHeight < height2)) {
							_this.categoryActive = i;
							_this.diff > 0 && (_this.scrollLeftTop = Math.round((_this.categoryActive * _this
								.diff) / (this.list.length - 1)));
							return false;
						}
					}
					_this.categoryActive = 0;
					_this.timeoutId = undefined;
				}, 10);
			},
			categoryClickMain(index, item) {
				this.categoryActive = index;
				this.scrollTop == this.arr[index] ? (this.scrollTop = this.scrollTop + 1) : (this.scrollTop = this.arr[
					index]); //防止两次相等造成点击不触发滚动时间
			},
			getData(pageNo, value = '') {
				// this.loading = true
				this.pageNo = pageNo
				const form = {
					// pageNo: this.pageNo,
					// pageSize: this.pageSize,
					userId: this.$store.state.user.id
				}
				addCheckActiveCompany( //获取所属单位JSON.stringify(form)
					form
				).then(response => {
					// response.data.map((v,index)=>{
					// 	console.log(index,'indexindexindexindex');
					// })
					// for(let key in response.data){
					// 	key=checkType('backend_org_type',key)
					// }

					for (let key in response.data) {
						response.data[key].unshift(checkType('backend_org_type', key))
					}
					this.list2 = response.data
					const json = JSON.stringify({
						id: this.formDataChuangMu["id"],
						pageNo: this.pageNo,
						pagesSize: this.pageSize
					})
					if (this.bianji) {
						getCheckActiveTaskXin({
							id: this.formDataChuangMu["id"]
						}).then(response => { //获取编辑主动检查单位的数据                
						console.log(response,'ressss');
							const res = response.data
							for (let g in this.list2) {
								// g.map(v => { //进入编辑界面以前勾选的检查项把他放进this.list.orgList中添加一个checkedList
								this.list2[g].map(i => {
									// i.orgDOList.map(listK => {
									if (i.id == this.list2[g].id) {
										console.log(i,'[i.id][i.id][i.id]',this.list2);
										this.list2[g].checkedList2 = [i.id]
										
									}
									// })
								})
								this.checkedList2.push([this.list2[g].id]) //这句话有问题    传到后端的数据
								// })
							}

						});
					}
				});
			},
			sureNew() { //确认发布
				saveCheckRelease({
					id: this.ids
				}).then(response => {
					if (response.data) {
						uni.showToast({
							title: `发布成功`
						})
						setTimeout(() => {
							uni.redirectTo({
								url: `/pagesA/fire/check_active/index?current=2&type=${this.formDataChuangMu.taskType}`
							});
						}, 500);


					}
				})
				this.showNew = false
			},
			cancelNew() { //取消发布--暂存
				this.showNew = false
				console.log(this.formDataChuangMu.taskType, 'this.formDataChuangMu.taskType');
				setTimeout(() => {
					setTimeout(() => {
						uni.redirectTo({
							url: `/pagesA/fire/check_active/index?current=3&type=${this.formDataChuangMu.taskType}`
						});
					}, 500);


				}, 0);
			},
			select(e) {
				// 根据所选图片的个数，多次调用上传函数
				let promises = [];
				for (let i = 0; i < e.tempFilePaths.length; i++) {
					const promise = this.uploadFiles(e.tempFilePaths, i);
					promises.push(promise);
				}
				Promise.all(promises).then(result => {});
			},
			// 上传文件函数
			async uploadFiles(tempFilePaths, i) {
				this.loading = true
				const that = this;
				await uni.uploadFile({
					url: baseUrl + '/admin-api/infra/file/upload', //后端用于处理图片并返回图片地址及文件的接口
					filePath: tempFilePaths[i],
					name: 'file',
					header: {
						Authorization: 'Bearer ' + getAccessToken()
					}, //请求token
					success: res => {
						let data = JSON.parse(res.data);
						this.formData.attId[0] = data.data
						this.formDataChuangMu.attId = data.data
						uni.showToast({
							title: '文件上传成功！'
						});
						that.loading = false
					},
					fail: () => {
						uni.showToast({
							icon: 'error',
							title: '文件上传失败！'
						});
						this.loading = false
					}
				});
			},
			// 移出图片函数
			async deleteFile(e) {
				this.formData.attId = [];
				// console.log('移除了：');
			},
			submit(ref) {
				this.$refs[ref].validate().then(res => {
					this.formDataChuangMu.taskContent = this.formData.taskContent
					this.formDataChuangMu.taskName = this.formData.taskName
					if (this.bianji) {

						editCheckActiveCreate(JSON.stringify(this.formDataChuangMu)).then(response => { //编辑接口
							if (response.code == 0) {
								uni.showToast({
									title: '创建成功'
								});
								this.showNew = true
								this.ids = response.data

							} else {
								uni.showToast({
									title: response.msg
								});
							}
						});
					} else {
						addCheckActiveCreate(JSON.stringify(this.formDataChuangMu)).then(response => { //修改接口

							if (response.code == 0) {
								this.showNew = true
								this.ids = response.data
							} else {
								uni.showToast({
									title: response.msg
								});
							}
						});
					}
				}).catch(err => {
					uni.$u.toast('校验失败')
				})
			},
			// 
			// submitError(ref) {
			// 	this.$refs[ref].validate().then(res => {
			// 		console.log('success', res);
			// 		addCheckActiveErrorsubmit(this.formData).then(response => {
			// 			console.log('response.data.msg0,', response.data.msg);
			// 			uni.showLoading({
			// 				title: response.data.msg
			// 			});
			// 			setTimeout(() => {
			// 				uni.hideLoading();
			// 				this.$tab.navigateTo('/pagesA/fire/check_active/index')
			// 			}, 2000);
			// 		});
			// 	}).catch(err => {
			// 		console.log('err', err);
			// 		uni.$u.toast('校验失败')
			// 	})
			// },
			// 触底的事件
			scrolltolower() {
				// 判断是否还有下一页数据
				if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
					title: `数据加载完毕`
				})
				// 判断是否正在请求其它数据，如果是，则不发起额外的请求
				if (this.loading) return
				this.pageNo += 1
				this.showCheckboxShow(this.pageNo)
				this.showSex(this.pageNo)
			},
		},
	}
</script>
<style lang="scss" scoped>
	page {
		height: 100%;
		background-color: #f5f7f9;
		position: relative;
	}

	.buttomBorder {
		height: 0px;
		border: 1px dashed #CBD5E1;
	}

	/deep/ .uni-section .uni-section-header {
		padding: 0px;
	}

	/deep/ .u-form-item__body {
		font-weight: 500;
		flex-direction: column !important;
	}

	/deep/ .u-form-item__body__left__content__label {
		width: 144rpx !important;
		margin-bottom: 16rpx;
		margin-left: 20rpx;
		font-size: 30rpx !important;
		color: #274647 !important;
	}

	.arrow-icon {
		//主动检查箭头
		position: absolute;
		right: 14px;
		top: 49px;
		transform: rotate(90deg);
	}

	/deep/ .u-input[data-v-fdbb9fe6],
	/deep/ .u-input.data-v-fdbb9fe6,/deep/ .u-input {
		background-color: #fff;
	}

	/deep/.u-button[data-v-3bf2dba7],
	/deep/.u-button.data-v-3bf2dba7,/deep/.u-button {
		width: 60% !important;
	}

	/deep/ .u-form-item__body__right__message {
		//校验的文字的位置
		margin-left: 10rpx !important;
	}

	/deep/ .uicon-close {
		//关闭按钮背景色    
		// background-color: rgba(199, 203, 210, .9);
		border-radius: 10%;
	}

	//*号位置
	/deep/.u-form-item__body__left__content__required[data-v-5e7216f1],
	/deep/.u-form-item__body__left__content__required.data-v-5e7216f1,/deep/.u-form-item__body__left__content__required {
		left: 14rpx !important;

	}

	// 巡查内容补充的位置

	.xuncha {
		/deep/.u-form-item__body__left {
			width: 220rpx !important;
		}
	}

	.checkbox {
		.checkbox-item {
			box-sizing: border-box;
			padding-top: 40px;
		}
	}

	//侧边联动
	.page-body {
		display: flex;
		background: #fff;
		overflow: hidden;
	}

	.nav {
		display: flex;
		width: 100%;
	}

	.nav-left {
		width: 25%;
		background: #fafafa;
	}

	.nav-left-item {
		height: 150rpx;
		border-right: solid 1px #f1f1f1;
		border-bottom: solid 1px #f1f1f1;
		font-size: 30upx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

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

	.nav-right {
		width: 75%;
	}

	/deep/.nav-right-item {
		width: 100%;
		display: flex;
		flex-wrap: wrap;
	}

	/deep/.u-checkbox {
		width: 80% !important;
		margin-bottom: 30rpx !important;
	}

	/deep/ .u-checkbox-group {
		width: 100%;
		// justify-content: flex-end;
	}

	.box {
		display: block;
		overflow: hidden;
		border-bottom: 20upx solid #f3f3f3;
		/* min-height: 100vh; */
		/*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
	}

	.box:last-child {
		border: none;
		min-height: 100vh;
	}

	.u-checkbox-group--row.data-v-3d1b15f2 {
		display: flex;
		flex-direction: row;
	}

	.nav-right-item {
		margin-top: 20rpx;
		float: left;
		padding: 11upx;
		font-size: 28upx;
		background: #fff;

		/deep/.u-checkbox__icon-wrap[data-v-532d01c7],/deep/.u-checkbox__icon-wrap {
			//复选框的样式
			margin: 0 20rpx;
		}

		/deep/ uni-view[data-v-3d1b15f2] {
			//复选框上线的间距
			margin: 20rpx 0 !important;
		}

		// /deep/ .u-checkbox__icon-wrap--square{
		// 	margin: 20rpx;
		// }
		.u-checkbox-label--right[data-v-532d01c7],.u-checkbox-label--right{
			margin-right: 40rpx;

		}
	}

	.nav-right-item image {
		width: 150upx;
		height: 150upx;
	}

	.active {
		font-weight: 700;
		color: #274647;
		background: #fff;
		border-right: 0;
	}

	::-webkit-scrollbar {
		/*取消小程序的默认导航条样式*/
		width: 0;
		height: 0;
		color: transparent;
	}

	.selectBtn {
		width: 200rpx;
		margin-left: 0;
		font-size: 30rpx;
		background-color: #4cb2b6;
	}

	/deep/.uni-input-input,
	/deep/.u-input__content__field-wrapper__field.data-v-fdbb9fe6 {
		overflow: hidden;
		-o-text-overflow: ellipsis;
		text-overflow: ellipsis;
		white-space: nowrap;
		display: block;
	}

	/deep/ .u-checkbox uni-text,
	/deep/ .u-checkbox text {
		line-height: 40rpx !important;
		white-space: normal;
		word-break: break-all;
		word-warp: break-word;
	}

	.popup-button {
		width: 100%;
		position: absolute;
		left: 0;
		bottom: 84rpx;
		z-index: 9999;
	}

	.zan-cun,
	/deep/ .uni-row {
		margin-top: 200rpx;
	}

	.u-page__tag-item {
		width: 90%;
		margin: 30rpx 0;
		margin-left: 5%;
	}
	.box[data-v-524457c8]:last-child,.box.data-v-524457c8:last-child,.box:last-child{
		padding-bottom: 354rpx;
	}
</style>
