<template>
	<view>
		<!-- 顶部 -->
		<cu-custom bgColor="bg-blue" :isBack="true">
			<block slot="backText">编辑施工日志</block>
			<block slot="content"></block>
			<block slot="right">
				<view class=" flex justify-center">
					<template v-if="dateList[0].taskStatus == '0' || dateList[0].taskStatus == '1'">
						<button @click="repeal()" class="margin-top-ssm cu-btn line-blue round text-white" style="width: 130rpx;height: 66rpx;padding: 0;">废除</button>
					</template>
					<template v-else>
						<button @click="save(2)" class="margin-top-ssm cu-btn line-blue round text-white" style="width: 130rpx;height: 66rpx;padding: 0;">上报</button>
					</template>
				 	<!-- <button  @click="save()" class="margin-top-ssm cu-btn line-blue round text-white" style="width: 160rpx;height: 66rpx;padding: 0;">保存</button> -->
					<button class="margin-top-ssm  cu-btn round line-blue text-white">
						<button class="cu-btn  line-blue " style="padding:0 20rpx 0 10rpx"  @click="save(1)">
							<text class="text-white">预览</text>
						</button>
						<template v-if="!(dateList[0].taskStatus == '0' || dateList[0].taskStatus == '1')">
							<text class="bg-white" style="width: 1rpx;height: 30rpx;"></text>
							<button class=" cu-btn  line-blue " style="padding:0 10rpx 0 20rpx" @click="save()">
								<text class="text-white">保存</text>
							</button>
						</template>
					</button>
				</view>
			</block>
		</cu-custom>
		<!-- 项目合同段信息 -->
		<!-- <view style="background-color: #fff;padding: 22rpx;margin-bottom: 20rpx;"> 
			<view style="font-size: 30rpx;color: #101010;font-weight: bold;">{{project.project_name}}</view>
			<view style="font-size: 28rpx;color: #101010;margin-top: 10rpx;">{{project.contractName}}</view>
		</view> -->
		<view v-for="(data,cur) in dateList" :key="cur" class="bg-white">
			<view class="cu-form-group_1 flex justify-between">
				<view>
					<text  class="title">日志{{cur+1}}</text>
					<button class="cu-btn round sm margin-left-sm" v-if="!(data.taskStatus==0 || data.taskStatus==1)" @click="addNow(cur)">复制当前</button>
				</view>
				<button class="cu-btn round sm" @click="delOne(cur)" v-if="!(data.taskStatus==0 || data.taskStatus==1)&&(cur != 0)">删除</button>
			</view>
			<template v-if="isZJ">
				<form>
					<view class="cu-form-group_1">
						<view class="title">施工日期</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" disabled="" v-model="data.date"  name="input"></input>
					</view>
					<!-- <view class="cu-form-group_1">
						<view class="title" style="width: 260rpx;">检测，记录日期</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.jzWorkDate"  name="input"></input>
					</view> -->
					<view class="cu-form-group_1">
						<view class="title">复查日期</view>
						<picker mode="date" :value="data.jzWorkDate" :disabled="(data.taskStatus==0)||(data.taskStatus==1)"  @change="bindDateChange($event,cur)" style="width: 100%;padding-left: 36rpx;">
							<view style="color: rgb(138, 138, 138);">{{data.jzWorkDate}}</view>
						</picker>
					</view>
					<view class="cu-form-group_1">
						<view class="title">天气</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.weather" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1">
						<view class="title">最低气温</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.minimumTemperature" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1">
						<view class="title">最高气温</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.highestTemperature" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1">
						<view class="title">编号</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.jzNumber" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
				</form>
				<form>
					<view class="cu-form-group_2">
						<view class="title">单位工程</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.unitProject" :disabled="(data.taskStatus==0)||(data.taskStatus==1)"  placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">分项工程</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.processName" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">分部工程</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.subproject" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">桩号、部位</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.buildParts" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title flex justify-between">
							<text>关联工序</text>
							<button class="cu-btn round line-blue sm" v-if="!(data.taskStatus==0 || data.taskStatus==1)" @click="toSelectProcess(cur)" style="font-size: 26rpx;">
								<text class="cuIcon-add"></text>新增
							</button>
						</view>
						<view>
							<view class="text-gray" v-if="data.processList && data.processList.length < 1">可多选，添加关联工序后可在资料填报页面查看关联的施工日志</view>
							<template v-else>
								<view v-for="(process,index) in data.processList" :key="process.id" style="margin-bottom: 10rpx;">
									<text class="text-gray process-line" style="position: relative;">{{process.pathName || process.name}}
										<image src="/static/index/delete-blue.png" style="width: 32rpx;height: 32rpx;position: absolute;bottom: 0;" @click="deleProcess(index,cur)" v-if="!(data.taskStatus==0 || data.taskStatus==1)"></image>
									</text>
									<!-- <text class="text-blue cuIcon-roundclose" style="margin-left: 6rpx;font-size: 32rpx;font-weight: bold;top: 4rpx;position: relative;" @click="deleProcess(index)"></text> -->
								</view>
							</template>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">重要记事</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.importantEvents" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">质量检查</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.qualityInspection" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">施工技术交底</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.zjBuild" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">安全技术交底</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.security" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
				</form>
			</template>
			<template v-else-if="isCQ">
				<form>
				<view class="cu-form-group_1">
					<view class="title">日期</view>
					<input placeholder-style="color:#AEAEAE" placeholder="请输入" disabled="" v-model="data.date"  name="input"></input>
				</view>
				<view class="cu-form-group_1">
					<view class="title">天气</view>
					<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.weather" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
				</view>
				<view class="cu-form-group_1">
					<view class="title">气温</view>
					<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.averageTemperature" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
				</view>
				<view class="cu-form-group_2">
					<view class="title flex justify-between">
						<text>关联工序</text>
						<button class="cu-btn round line-blue sm" @click="toSelectProcess(cur)" v-if="!(data.taskStatus==0 || data.taskStatus==1)" style="font-size: 26rpx;">
							<text class="cuIcon-add"></text>新增
						</button>
					</view>
					<view>
						<view class="text-gray" v-if="data.processList && data.processList.length < 1">可多选，添加关联工序后可在资料填报页面查看关联的施工日志</view>
						<template v-else>
							<view v-for="(process,index) in data.processList" :key="process.id" style="margin-bottom: 10rpx;">
								<text class="text-gray process-line" style="position: relative;">{{process.pathName || process.name}}
									<image src="/static/index/delete-blue.png" style="width: 32rpx;height: 32rpx;position: absolute;bottom: 0;" @click="deleProcess(index,cur)" v-if="!(data.taskStatus==0 || data.taskStatus==1)"></image>
								</text>
								<!-- <text class="text-blue cuIcon-roundclose" style="margin-left: 6rpx;font-size: 32rpx;font-weight: bold;top: 4rpx;position: relative;" @click="deleProcess(index)"></text> -->
							</view>
						</template>
					</view>
				</view>
				<view class="cu-form-group_1">
					<view class="title">编号</view>
					<view>
						<input placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.jzNumber" :disabled="(data.taskStatus==0)||(data.taskStatus==1)"  placeholder="请输入"></input>
					</view>
				</view>
				<view class="cu-form-group_1">
					<view class="title">工程桩号</view>
					<view>
						<input placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.buildParts" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></input>
					</view>
				</view>
				<view class="cu-form-group_1">
					<view class="title">工程部位</view>
					<view>
						<input placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.unitProject" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></input>
					</view>
				</view>
				<view class="cu-form-group_2">
					<view class="title">请描述当前施工情况、持续时间、工程完成情况、存在问题及处理情况，工程验收与变更及试验等</view>
					<view>
						<textarea placeholder-style="color:#AEAEAE" maxlength="-1" placeholder="请描述当前施工情况、持续时间、工程完成情况、存在问题及处理情况，工程验收与变更及试验等" v-model="data.problem" :disabled="(data.taskStatus==0)||(data.taskStatus==1)"></textarea>
					</view>
				</view>
				<view v-for="(people,index) in data.constructionPeopleList" :key="index">
					<view class="cu-form-group_1 group-mar">
						<view class="title">工种</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="people.federationOfTradeUnions" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1 group-mar">
						<view class="title">作业部位</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="people.workSite" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1 group-mar">
						<view class="title">数量</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="people.number" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1 group-mar">
						<view class="title">作业部位</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="people.workSiteTwo" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1 group-mar">
						<view class="title">数量</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="people.numberTwo" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1 group-mar">
						<view class="title">总数</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="people.sum" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
				</view>
				<view class="cu-form-group_1">
					<view class="title">总计</view>
					<input placeholder-style="color:#AEAEAE" placeholder="请输入"  v-model="data.total" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
				</view>
				<view class="cu-form-group_2">
					<view v-for="(device,index) in data.constructionEquipmentList" :key="index">
						<view class="title flex justify-between">
							<text>设备信息</text>
							<template v-if="!((data.taskStatus==0)||(data.taskStatus==1))">
							<template v-if="index == 0">
								<button class="cu-btn round line-blue sm" @click="addNewInfo(data.constructionEquipmentList)" v-if="data.constructionEquipmentList.length < 5" style="font-size: 26rpx;">
									<text class="cuIcon-add"></text>新增
								</button>
								<button class="cu-btn round line-blue sm" @click="deleInfo(data.constructionEquipmentList,index)" v-else style="font-size: 26rpx;">
									<text class="cuIcon-roundclose"></text>删除
								</button>
							</template>
							<template v-else>
								<button class="cu-btn round line-blue sm" @click="deleInfo(data.constructionEquipmentList,index)" style="font-size: 26rpx;">
									<text class="cuIcon-roundclose"></text>删除
								</button>
							</template>
							</template>
						</view>
						<view>
							<view class="cu-form-group_1 group-mar">
								<view class="title">主要设备</view>
								<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="device.primaryDeviceName" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
							</view>
							<view class="cu-form-group_1 group-mar">
								<view class="title">型号</view>
								<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="device.model" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
							</view>
							<view class="cu-form-group_1 group-mar">
								<view class="title">在场数量</view>
								<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="device.numberOfPeoplePresent" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
							</view>
							<view class="cu-form-group_1 group-mar">
								<view class="title">工作数量</view>
								<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="device.numberOfJobs" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
							</view>
							<view class="cu-form-group_1 group-mar">
								<view class="title">停置数量</view>
								<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="device.numberOfStops" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
							</view>
							<view class="cu-form-group_1 group-mar">
								<view class="title">停止原因</view>
								<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="device.stopReason" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
							</view>
							<view class="cu-form-group_1 group-mar">
								<view class="title">备注</view>
								<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="device.remark" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
							</view>
						</view>
					</view>
				</view>
				<view class="cu-form-group_2">
					<view class="title">质量安全</view>
					<view>
						<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.quality" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
					</view>
				</view>
				<view class="cu-form-group_2">
					<view class="title">材料进场与试验情况</view>
					<view>
						<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.entrance" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
					</view>
				</view>
				</form>
			</template>
			<template v-else-if="isTH">
				<form>
					<view class="cu-form-group_1">
						<view class="title">日期</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" disabled="" v-model="data.date"  name="input"></input>
					</view>
					<view class="cu-form-group_1">
						<view class="title">天气</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.weather" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1">
						<view class="title">平均气温</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.averageTemperature" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					
				</form>
				<form>
					<view class="cu-form-group_2">
						<view class="title">工程部位</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.processName" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title flex justify-between">
							<text>关联工序</text>
							<button class="cu-btn round line-blue sm" @click="toSelectProcess(cur)" v-if="!(data.taskStatus==0 || data.taskStatus==1)" style="font-size: 26rpx;">
								<text class="cuIcon-add"></text>新增
							</button>
						</view>
						<view>
							<view class="text-gray" v-if="data.processList && data.processList.length < 1">可多选，添加关联工序后可在资料填报页面查看关联的施工日志</view>
							<template v-else>
								<view v-for="(process,index) in data.processList" :key="process.id" style="margin-bottom: 10rpx;">
									<text class="text-gray process-line" style="position: relative;">{{process.pathName || process.name}}
										<image src="/static/index/delete-blue.png" style="width: 32rpx;height: 32rpx;position: absolute;bottom: 0;" @click="deleProcess(index,cur)" v-if="!(data.taskStatus==0 || data.taskStatus==1)"></image>
									</text>
									<!-- <text class="text-blue cuIcon-roundclose" style="margin-left: 6rpx;font-size: 32rpx;font-weight: bold;top: 4rpx;position: relative;" @click="deleProcess(index)"></text> -->
								</view>
							</template>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">施工部位及内容/人员设备情况/劳务工种及人数</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.buildContent" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_1">
						<view class="title">工班长</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.monitor" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_2">
						<view class="title">设计施工图内容</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.designContent" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">技术及安全交底</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.technologySecurity" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">测量及试验情况</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.measurement" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">检查及验收情况</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.acceptance" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">质量及安全施工情况</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.quality" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">材料构件设备进场情况</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.entrance" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">存在问题及其他</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.problem" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
				</form>
			</template>
			<template v-else>
				<form>
					<view class="cu-form-group_1">
						<view class="title">日期</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" disabled="" v-model="data.date"  name="input"></input>
					</view>
					<view class="cu-form-group_1">
						<view class="title">天气</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.weather" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_1">
						<view class="title">平均气温</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.averageTemperature" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					
				</form>
				<form>
					<view class="cu-form-group_2">
						<view class="title">分项工程</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.processName" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">施工部位</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.buildParts" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title flex justify-between">
							<text>关联工序</text>
							<button class="cu-btn round line-blue sm" @click="toSelectProcess(cur)" v-if="!(data.taskStatus==0 || data.taskStatus==1)" style="font-size: 26rpx;">
								<text class="cuIcon-add"></text>新增
							</button>
						</view>
						<view>
							<view class="text-gray" v-if="data.processList && data.processList.length < 1">可多选，添加关联工序后可在资料填报页面查看关联的施工日志</view>
							<template v-else>
								<view v-for="(process,index) in data.processList" :key="process.id" style="margin-bottom: 10rpx;">
									<text class="text-gray process-line" style="position: relative;">{{process.pathName || process.name}}
										<image src="/static/index/delete-blue.png" style="width: 32rpx;height: 32rpx;position: absolute;bottom: 0;" @click="deleProcess(index,cur)" v-if="!(data.taskStatus==0 || data.taskStatus==1)"></image>
									</text>
									<!-- <text class="text-blue cuIcon-roundclose" style="margin-left: 6rpx;font-size: 32rpx;font-weight: bold;top: 4rpx;position: relative;" @click="deleProcess(index)"></text> -->
								</view>
							</template>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">施工内容</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.buildContent" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">人员设备情况/劳务工种及人数</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.peopleAndFacility" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_1">
						<view class="title">工班长</view>
						<input placeholder-style="color:#AEAEAE" placeholder="请输入" v-model="data.monitor" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" name="input"></input>
					</view>
					<view class="cu-form-group_2">
						<view class="title">设计施工图内容</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.designContent" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">技术及安全交底</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.technologySecurity" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">测量及试验情况</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.measurement" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">检查及验收情况</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.acceptance" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">质量及安全施工情况</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.quality" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">材料构件设备进场情况</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.entrance" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
					<view class="cu-form-group_2">
						<view class="title">存在问题及其他</view>
						<view>
							<textarea placeholder-style="color:#AEAEAE" maxlength="-1" v-model="data.problem" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" placeholder="请输入"></textarea>
						</view>
					</view>
				</form>
			</template>
			
		</view>
		<view class="cu-bar bg-white tabbar" style="border: none;"></view>
		<view class="cu-bar bg-white tabbar border shop" style="position: fixed;bottom: 0;left: 0;width: 100%;border-top: 1rpx solid #EAEAEA;">
			<view class="flex solid-bottom padding justify-between" style="width: 100%;">
				<text></text>
				<button class="cu-btn round" @click="addOne" v-if="!(dateList[0].taskStatus == '0' || dateList[0].taskStatus == '1')">新增</button>
			</view>
		</view>
		<!-- <form>
			<view class="cu-form-group_1"  @click="navTo(2)" style="justify-content: space-between;">
				<view class="title">监理员</view>
				<input placeholder-style="color:#AEAEAE" placeholder="请选择" v-model="data.supervisionWorker"  disabled=""  style="width: 520rpx;"></input>
				<text class='cuIcon-right'></text>
			</view>
			<view class="cu-form-group_1" @click="navTo(1)" style="justify-content: space-between;">
				<view class="title">施工员</view>
				<input placeholder-style="color:#AEAEAE" placeholder="请选择" v-model="data.constructionWorker" disabled=""  style="width: 520rpx;"></input>
				<text class='cuIcon-right'></text>
			</view>
		</form> -->
	    <!-- 时间弹窗 -->
	    <view class="cu-modal bottom-modal" :class="modalShow?'show':''" >
	    	<view class="cu-dialog" style="background-color: white;border-radius: 20rpx 20rpx 0 0;">
	    		<view class="cu-bar bg-white">
	    			<view class="action text-gray"></view>
	    			<view class="action text-black text-bold" style="color: #101010;">选择时间</view>
	    			<view class="action text-gray" @tap="showdialog()">取消</view>
	    		</view>
	    		<view style="padding-bottom: 10rpx;">
	    		      <calendar @selected-change="datechange"   :showBack="false" :dotStyle="dotStyle"></calendar>
	    		</view>
	    	</view>
	    </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dotStyle:{color: 'black'},
				project:"",
				time:"",
				constructionList:[],
				supervisionList:[],
				modalShow:false,
				// data:{
					
				// },
				dateList:[{
					pageNumber:1,
					recorderId:uni.getStorageSync("userInfo").id,
					contractId:uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).contractId,
					processList:[],
					constructionPeopleList:[{},{},{}],
					constructionEquipmentList:[{}],
				}],
				curIndex:0,
				
				rules:[
					{name: 'date', required: true, type: 'required', errmsg: '请填写填报日期'},
					{name: 'averageTemperature', required: true, type: 'required', errmsg: '请填写平均气温'},
					{name: 'weather', required: true, type: 'required', errmsg: '请填写天气'},
					{name: 'startTime', required: true, type: 'required', errmsg: '请填写开工时间'},
					{name: 'itemName', required: true, type: 'required', errmsg: '请填写工程名称'},
					{name: 'site', required: true, type: 'required', errmsg: '请填写施工部位'},
					{name: 'orgPlan', required: true, type: 'required', errmsg: '请填写施工组织计划'},
					{name: 'safetyDegree', required: true, type: 'required', errmsg: '请填写安全交底'},
					{name: 'technologyDegree', required: true, type: 'required', errmsg: '请填写技术交底'},
					{name: 'releaseTask', required: true, type: 'required', errmsg: '请填写下达施工任务'},
					{name: 'importantNote', required: true, type: 'required', errmsg: '请填写重记事'},
					{name: 'supervisionWorker', required: true, type: 'required', errmsg: '请选择监理员'},
					{name: 'constructionWorker', required: true, type: 'required', errmsg: '请填写施工员'},
				],
				updateOrInsert:0,//0为新增 ， 1为编辑
				upId:null,
				
				// processList:[],
				isZJ:0,
				isCQ:false,
				isTH:false,
				
				contractId : uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).contractId,
				project:uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id),
				recorderId:uni.getStorageSync("userInfo").id,
			}
		},
		onLoad(e) {
			this.dateList[0].date = e.time;
			this.dateList[0].jzWorkDate = e.time;
			this.project= uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
			this.updateOrInsert=e.type;
			this.upId = e.id;
			
			if(this.project.id == 'fa7d50a0c01a4a568f123bff0d91' || this.project.id == 'a140fd60f08941e8851d90e86960'){
				this.isCQ = true;
			}
			
			if(this.project.id == 'fe2655f6012a41148ee39209c405'){
			  	this.isTH = true;
			}
			
			if(this.updateOrInsert==1){//获取日志信息进行绑定
				//this.findData(this.upId);
				this.getDataByDate(e.time);
			}else{
				//获取合同段的地址，根据地址获取温度和天气
				var that =this;
				var cityName = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).project_place;
				console.log(that.project)
				that.http.request("/app/diary/getWeather",{
					projectId:that.project.id,
					contractId:that.contractId,
					date:e.time
				}).then((res)=>{
					that.$set(that.dateList[0],'averageTemperature',res.tempSection);
					let arr = res.tempSection.split('~');
					if(arr.length == 2){
						that.$set(that.dateList[0], 'minimumTemperature', arr[0]);
						that.$set(that.dateList[0], 'highestTemperature', arr[1]);
					}
					
					that.$set(that.dateList[0], 'weather', res.weather);
					//that.data.averageTemperature =res.tempSection;
					//that.data.weather = res.weather
				})
			}
			
			this.getIsZJ();
			
			//监听选择工序
			uni.$on('selectProcess',this.selectProcess)
			
			uni.$on('report',this.reportSuccess)
		},
		onUnload(){
			uni.$off('selectProcess',this.selectProcess)
			
			uni.$off('report',this.reportSuccess)
		},
		methods: {
			showdialog(){
				this.modalShow= !this.modalShow;
			},
			datechange(e) {
			    this.data.startTime=e.fullDate
				this.showdialog();
			},
			navTo(value){
				uni.navigateTo({
					url:"/pages/constructionLog/personnel/personnel?type="+value
				})
			},
			//获取该日志的数据，编辑
			findData(id){
				var that =this;
				that.http.request('/app/working/getDataById', {id:id}).then((result)=>{
					that.data = result.data;
					if(that.data.proList){
						that.processList = that.data.proList;
					}
					that.$delete(that.data,'prefix');				
				})  
			},
			// save(){
			// 	var that =this;
			// /* 	let result= that.$formValidate.validate(this.data,this.rules)//表单验证
			// 	if(result.isOk){ */
			// 		let param =that.data;
			// 		param.contractId= this.project.contractId;
			// 		param.creator= uni.getStorageSync("userInfo").id;
			// 		param.state= that.data.state==null ? 0 : that.data.state;
			// 		param.deleted= that.data.deleted==null ? 0 : that.data.deleted;
			// 		param.createTime=new Date();
			// 	    that.http.request('/app/diary/addOrUpdate', param).then((result)=>{
			// 	    	if(result.result=="1"){
			// 	    		that.$prompt.none(result.msg);
			// 	    		setTimeout(function(){
			// 	    			uni.navigateBack({
			// 	    				delta:1
			// 	    			})
			// 	    		},500)						   
			// 	    	}else{
			// 	    		 that.$prompt.Error("保存失败");						  
			// 	    	}
			// 	    })
			// 	/* }else{
			// 		that.$prompt.none(result.errmsg)
			// 	} */
				
			// }
			save(type){
				if(!this.verification()){
					uni.showToast({
					    title: '每份日志至少要填写一项内容',
						icon:'none',
					    duration: 2000
					});
					return;
				}
				var isjzWorkDate = true;
				//this.data.contractId = this.project.contractId;
				//this.data.recorderId = uni.getStorageSync("userInfo").id;
				for (let j=0; j < this.dateList.length; j++){
					let arr = [];
					if(this.dateList[j].processList){
						for (let i = 0; i < this.dateList[j].processList.length; i++) {
							arr.push(this.dateList[j].processList[i].id);
						}
					}
					this.dateList[j].processId = arr.join(',');
					
					if(this.isZJ && !this.dateList[j].jzWorkDate){
						isjzWorkDate = false;
					}
				}
				
				if(this.isZJ && !isjzWorkDate){
					uni.showToast({
					    title: '每份日志都要填写复查日期',
						icon:'none',
					    duration: 2000
					});
					return;
				}
				
				//this.http.request('/app/working/addEntity.json',JSON.stringify(this.dateList),1).then((res)=>{
				this.http.request('/app/working/addEntity.json',{voStr:JSON.stringify(this.dateList),storeName:uni.getStorageSync("storeName")}).then((res)=>{
					if(res.result=="1"){
						let urlArr = [];
						for (let i = 0; i < res.datas.length; i++) {
							this.dateList[i].id = res.datas[i].id;
							this.dateList[i].outUrl = res.datas[i].outUrl;
							urlArr.push(res.datas[i].outUrl);
						}
						this.$prompt.none(res.msg);
						setTimeout(()=>{
							if(type == 1){
								//跳去预览
								uni.navigateTo({
									url: "/pages/view/preview/preview?previews=" + urlArr.join(',')
								})
							}else if(type == 2){
								getApp().globalData.diary = res.datas[0];
								uni.navigateTo({
									url:"/pages/dataReport/dailyReport?urlName="+"working"+"&isZJ="+this.isZJ
								})
							}else{
								uni.navigateBack({
									delta:1
								})
							}
						},500)						   
					}else{
						 this.$prompt.Error("保存失败,"+res.msg);					  
					}
				})
			},
			
			//跳转选择工序
			toSelectProcess(index){
				this.curIndex = index;
				uni.navigateTo({
					url:"/pages/constructionLog2/selectProcess/selectProcess"
				})
			},
			//选择工序
			selectProcess(process){
				//console.log(process);
				//console.log(this.dateList[this.curIndex]);
				if(!this.dateList[this.curIndex].processList){
					this.dateList[this.curIndex].processList = [];
				}
				this.dateList[this.curIndex].processList.push(process);
			},
			//移除工序
			deleProcess(index,curIndex){
				this.dateList[curIndex].processList.splice(index,1);
			},
			
			verification(){
				let verify = true;
				if(this.isZJ){
					for (let i = 0; i < this.dateList.length; i++) {
						if(!this.dateList[i].jzWorkDate && !this.dateList[i].unitProject &&
							!(this.dateList[i].processList && this.dateList[i].processList.length > 0) &&  !this.dateList[i].processName && !this.dateList[i].subproject &&  !this.dateList[i].buildParts &&  !this.dateList[i].importantEvents  &&  !this.dateList[i].qualityInspection &&  !this.dateList[i].zjBuild &&  !this.dateList[i].security 
						){
							verify = false;
						}else{
							verify = true;
						}
					}
				}else if(this.isCQ){
					verify = true;
				}else if(this.isTH){
					for (let i = 0; i < this.dateList.length; i++) {
						if(!this.dateList[i].processName  &&
							!(this.dateList[i].processList && this.dateList[i].processList.length > 0) && !this.dateList[i].buildContent &&
						    !this.dateList[i].monitor && !this.dateList[i].designContent &&
							!this.dateList[i].technologySecurity && !this.dateList[i].measurement &&
							!this.dateList[i].acceptance && !this.dateList[i].quality && !this.dateList[i].entrance &&
							!this.dateList[i].problem
						){
							verify = false;
						}else{
							verify = true;
						}
					}
				}else{
					for (let i = 0; i < this.dateList.length; i++) {
						if(!this.dateList[i].processName && !this.dateList[i].buildParts &&
							!(this.dateList[i].processList && this.dateList[i].processList.length > 0) && !this.dateList[i].buildContent &&
							!this.dateList[i].peopleAndFacility && !this.dateList[i].monitor && !this.dateList[i].designContent &&
							!this.dateList[i].technologySecurity && !this.dateList[i].measurement &&
							!this.dateList[i].acceptance && !this.dateList[i].quality && !this.dateList[i].entrance &&
							!this.dateList[i].problem
						){
							verify = false;
						}else{
							verify = true;
						}
					}
				}
				
				return verify
			},
			addOne(){
				let constructionPeopleList = null;
				let constructionEquipmentList = null;
				if(this.isCQ){
					constructionPeopleList=[{},{},{}];
					constructionEquipmentList=[{}];
				}
				
				this.dateList.push({
					date:this.dateList[0].date,//日期
					jzWorkDate:this.dateList[0].jzWorkDate,
					weather:this.dateList[0].weather,//天气
					averageTemperature:this.dateList[0].averageTemperature,//
					minimumTemperature:this.dateList[0].minimumTemperature,//
					highestTemperature:this.dateList[0].highestTemperature,//
					zj:this.isZJ,
					pageNumber:this.dateList[this.dateList.length-1].pageNumber+1,
					processList:[],
					recorderId:this.dateList[0].recorderId,
					contractId:this.dateList[0].contractId,
					constructionPeopleList:constructionPeopleList,
					constructionEquipmentList:constructionEquipmentList
				})
			},
			addNow(index){
				let addObj = Object.assign({},this.dateList[index]);
				addObj.pageNumber = addObj.pageNumber+1;
				if(addObj.processList){
					addObj.processList = [].concat(addObj.processList);
				}
				addObj.id = '';
				
				if(this.isCQ){
					let arr = [];
					addObj.constructionPeopleList.forEach(element => {
					    arr.push(Object.assign({},element));
					})
					addObj.constructionPeopleList = arr;
					
					let arr2 = [];
					addObj.constructionEquipmentList.forEach(element => {
					    arr2.push(Object.assign({},element));
					})
					addObj.constructionEquipmentList = arr2;
				}
				
				for (let i = index+1; i < this.dateList.length; i++) {
					this.dateList[i].pageNumber += 1;
				}
				//console.log(addObj)
				this.dateList.splice(index+1,0,addObj);
				//console.log(this.dateList)
			},
			delOne(index){
				uni.showModal({
					title: '删除',
					content: '是否删除 日志'+(index+1)+' ?'+'删除后无法还原',
					success:(res) => {
						if (res.confirm) {
							//console.log('用户点击确定');
							
							//没保存过直接删
							if(!this.dateList[index].id){
								this.dateList.splice(index,1);
								return;
							}
							//保存过的需要请求
							this.http.request('/app/working/del', {
								id: this.dateList[index].id,
							}).then((result) => {
								if(result.result ==1){
									this.dateList.splice(index,1);
								}else{
									this.$prompt.Error("删除失败");
								}
							})
						} else if (res.cancel) {
							//console.log('用户点击取消');
						}
					}
				});		
			},
			getDataByDate(date){
				this.http.request('/app/working/getDataByDate', {
					date: date,
					recorderId:this.recorderId,
					contractId:this.contractId,
				}).then((result) => {
					if(result.result ==1){
						if(result.datas){
							for (let i = 0; i < result.datas.length; i++) {
								result.datas[i].contractId = this.contractId;
								result.datas[i].processList = result.datas[i].proList;
							}
							this.dateList =result.datas;
						}else{
							this.$prompt.Error(result.msg);
						}
						
					}else{
						this.$prompt.Error(result.msg);
					}
				})
			},
			getPageNumber(){
				let max = 1;
				for (let i = 0; i < this.dateList.length; i++) {
					if(this.dateList[i].pageNumber > max){
						max = this.dateList[i].pageNumber;
					}
				}
				return max+1;
			},
			
			bindDateChange(e,index){
				this.dateList[index].jzWorkDate = e.detail.value;
			},
			
			getIsZJ(){
				this.http.request('/app/working/checkProjectIsZj', {
						projectId:this.project.id
					}).then((result)=>{
					if(result.result == '1'){
						this.isZJ = 1;
						this.dateList[0].zj = 1;
					}else{
						this.isZJ = 0;
						this.dateList[0].zj = 0;
					}
				})
			},
			
			addNewInfo(list){
				if(list.length>5){
				  return;
				}
					
				list.push({})
			},
			deleInfo(list,index){
				list.splice(index,1);
			},
			
			repeal(){
				let { account } = uni.getStorageSync('userInfo')
				uni.showModal({
					title: '废除',
					content: '是否废除任务?',
					success:(res) => {
						if (res.confirm) {
							this.http.request('/app/task/repeal', {
								taskId: this.dateList[0].taskId,
								opUserName: account ? account : '',
							}).then((result) => {
								console.log(result)
								if(result.result ==1){
									this.$prompt.none("废除成功");
									this.getDataByDate(this.dateList[0].date);
								}else{
									this.$prompt.Error("废除失败");
								}
							})
						} else if (res.cancel) {
							//console.log('用户点击取消');
						}
					}
				});	
			},
			reportSuccess(){
				//上报成功，刷新
				this.getDataByDate(this.dateList[0].date);
			}
		},
		onShow(){
			/* 监听选择施工人员页面的handleFun方法 */
		    // uni.$on("handleFun", res => {
			   // this.data.constructionWorker="";
			   // this.constructionList=res;
			   // res.forEach((item)=>{
				  //  this.data.constructionWorker+=item.user_name
			   // })
		    // })
			/* 监听选择监理人员页面的handleFun方法 */
			// uni.$on("handleFunBy", res => {
			//    this.data.supervisionWorker="";
			//    this.supervisionList=res;
			//    res.forEach((item)=>{
			// 	   this.data.supervisionWorker+=item.user_name
			//    })
			// })
		},
	}
</script>

<style>
    .solid-top-type{
    	   border-top: 0px solid #eee;
    }
	.cu-form-group_1{display: flex;align-items: center;padding:0 22rpx;background-color: #fff;border-bottom: 2rpx solid #EAEAEA;height: 88rpx;}
	.cu-form-group_1 .title{font-size: 30rpx;color: #101010;width: 154rpx;}
	.cu-form-group_1 input{font-size: 30rpx;color: #8a8a8a;}
	.cu-form-group_2{padding: 22rpx;background-color: #fff;border-bottom: 2rpx solid #EAEAEA;}
	.cu-form-group_2 .title{font-size: 30rpx;color: #101010;padding-bottom: 18rpx;}
	.cu-form-group_2 textarea{font-size: 30rpx;color: #8a8a8a;width: 100%;}
	.cu-modal.show {
		overflow-y: auto;
		pointer-events: auto; 
	}
	
	.process-line{
		text-decoration:underline;
	}
	.cuIcon-roundclose:before{
		font-weight: bold;
	}
	.group-mar{padding: 0;margin:0 36rpx;}
</style>
