<template>
	<view v-bind:style="{paddingBottom:paddingBottom+'px'}">
	<view class="card" >
		<view class="background"></view>
		<!-- <uni-card margin="0" :is-shadow="true"> -->
			<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model" class="demo-ruleForm">
				<u-form-item label="记录日期：" prop="RECORD_DATE" borderBottom>
					<u--input v-model="model.RECORD_DATE" border="none" slot="right" inputAlign="right" disabled
						disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="班次：" prop="Nav_Class.NAME" borderBottom>
					<u--input v-if="model.Nav_Class" v-model="model.Nav_Class.NAME" border="none" slot="right" inputAlign="right" disabled
						disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="岗位：" prop="Nav_DepartmentPost.NAME" borderBottom>
					<u--input v-model="model.Nav_DepartmentPost.NAME" border="none" slot="right" inputAlign="right"
						disabled disabledColor="#ffffff" fontSize="14px" ></u--input>
				</u-form-item>
				<u-form-item label="当班人员：" prop="UserNames" borderBottom class="peoplecur">
					<view v-for="(item,index) in model.UserNames" :key="index">
						<view :style="item.type == 'red'?'color:red':''" class="peoplewrap">{{item.value}}</view>
						<!-- <u--input slot="right" v-model="item" border="none" inputAlign="right" disabled 
						disabledColor="#ffffff" fontSize="14px" class="peoplecur"></u--input> -->
					</view>
					
				</u-form-item>

				<u-form-item label="本班运行情况：" prop="CURRENT_CLASS_STATUS" borderBottom>
					<u--input autoHeight v-html="model.current1" border="none" inputAlign="right" disabled
						disabledColor="#ffffff" slot="right" fontSize="14px"></u--input>
				</u-form-item>

				<u-form-item label="存在问题：" prop="CURRENT_CLASS_QUESTION" v-if="model.CURRENT_CLASS_STATUS==1">
				</u-form-item>
				<u--textarea autoHeight v-model="model.current2" border="none" inputAlign="right"
					v-if="model.CURRENT_CLASS_STATUS==1" disabled disabledColor="#ffffff"></u--textarea>
				<u-form-item label="处理情况：" prop="CURRENT_CLASS_MEASURE" v-if="model.CURRENT_CLASS_STATUS==1" disabled
					disabledColor="#ffffff" >
				</u-form-item>
				<u--textarea autoHeight v-model="model.current3" border="none" inputAlign="right"
					v-if="model.CURRENT_CLASS_STATUS==1" disabled disabledColor="#ffffff"></u--textarea>
				<u-form-item label="设备运行状况：" prop="DEVICE_STATUS" borderBottom>
					<u--input autoHeight v-html="model.device1" border="none" inputAlign="right" disabled
						disabledColor="#ffffff" slot="right" fontSize="14px"></u--input>
				</u-form-item>

				<u-form-item label="存在问题：" prop="DEVICE_QUESTION" borderBottom v-if="model.DEVICE_STATUS==1">
				</u-form-item>
				<u--textarea autoHeight v-model="model.device2" border="none" inputAlign="right"
					v-if="model.DEVICE_STATUS==1" disabled disabledColor="#ffffff"></u--textarea>
				<u-form-item label="处理情况：" prop="DEVICE_MEASURE" borderBottom v-if="model.DEVICE_STATUS==1">
				</u-form-item>
				<u--textarea autoHeight v-model="model.device3" border="none" inputAlign="right"
					v-if="model.DEVICE_STATUS==1" disabled disabledColor="#ffffff"></u--textarea>
				<u-form-item label="现场环境情况：" prop="ENVIRONMENT_STATUS" borderBottom>
					<u--input autoHeight v-html="model.environment1" border="none" inputAlign="right" disabled
						disabledColor="#ffffff" slot="right" fontSize="14px"></u--input>
				</u-form-item>

				<u-form-item label="存在问题：" prop="ENVIRONMENT_QUESTION" borderBottom v-if="model.ENVIRONMENT_STATUS==1">
				</u-form-item>
				<u--textarea autoHeight v-model="model.environment2" border="none" inputAlign="right"
					v-if="model.ENVIRONMENT_STATUS==1" disabled disabledColor="#ffffff"></u--textarea>
				<u-form-item label="处理情况：" prop="ENVIRONMENT_MEASURE" borderBottom v-if="model.ENVIRONMENT_STATUS==1">
				</u-form-item>
				<u--textarea autoHeight v-model="model.environment3" border="none" inputAlign="right"
					v-if="model.ENVIRONMENT_STATUS==1" disabled disabledColor="#ffffff"></u--textarea>
				<u-form-item label="劳保用品使用情况：" prop="SUPPLIES_STATUS" borderBottom>
					<u--input autoHeight v-html="model.supplies1" border="none" inputAlign="right" disabled
						disabledColor="#ffffff" slot="right" fontSize="14px"></u--input>
				</u-form-item>

				<u-form-item label="存在问题：" prop="SUPPLIES_QUESTION" borderBottom v-if="model.SUPPLIES_STATUS==1">
				</u-form-item>
				<u--textarea autoHeight v-model="model.supplies2" border="none" inputAlign="right"
					v-if="model.SUPPLIES_STATUS==1" disabled></u--textarea>
				<u-form-item label="处理情况：" prop="SUPPLIES_MEASURE" borderBottom v-if="model.SUPPLIES_STATUS==1">
				</u-form-item>
				<u--textarea autoHeight v-model="model.supplies3" border="none" inputAlign="right"
					v-if="model.SUPPLIES_STATUS==1" disabled disabledColor="#ffffff"></u--textarea>
				<u-form-item label="设备工具材料使用存放情况：" prop="DEVICE_STORAGE" borderBottom>
				</u-form-item>
				<u--textarea v-model="model.DEVICE_STORAGE" border="none" inputAlign="right" disabled
					disabledColor="#ffffff"></u--textarea>
				<view class="upload-title">附件</view>
				<full-upload v-model="model.Nav_Files" :listProp='listPropUpload'
					:listPropVal='listPropValUpload' :isShowBtn="false"></full-upload>
			</u--form>
		<!-- </uni-card> -->
		<view class="btn-wrap"  v-if="isLoadOK&&tableKey==1&&isAudit">
			<u--form>
				<view class="btn-wrap">
					<view>
						<u--textarea height='3em' v-model="DEALOPINION" placeholder="请输入审批意见"></u--textarea>
					</view>
					<view class="buttons">
						<u-button type="primary" color="#3d4b70" class="btn first-btn" @click="onChargeUserAgree(1)"
							text="同意"></u-button>
						<u-button color="#3d4b70" :plain="true" @click="onChargeUserAgree(2)" text="驳回"></u-button>
					</view>
				</view>
			</u--form>
		</view>
		
	</view>
	<view class="bottom"  style="padding: 10px 16px;" v-if="isLoadOK&&tableKey==1&&this.isSign">
		<u-button type="primary"  
		@click="onTableBtnAgree" color="#3d4b70">签到</u-button>
	</view>
	
		</view>
</template>

<script>
	import {
		initFilter,
		extendRule,
		extendInclude
	} from '../../../../utils/common'

	import {
		getRequest,
	} from '../../../../services/apply/FOServices/FOServices'

	import '../../../../utils/showMsg.js'
	import color from '../../../../uni_modules/uview-ui/libs/config/color'
	import config from '../../../../config/common'

	export default {
		data() {
			return {
				model: {
					Nav_Class: "",
					Nav_DepartmentPost: ""
				},
				listPropUpload: ['CURRENT_CLASS_RECORD_ID'],
				listPropValUpload: [],
				paddingBottom: '170',
				TaskID: "",
				tableKey: '0',
				isLoadOK: false,
				isSign: true,
				isAudit: true,
				DEALOPINION: "",

			}
		},
		onLoad(option) {
			this.model.ID = option.ID;
			this.TaskID = option.taskID;
			this.tableKey = option.tableKey ? option.tableKey : '0'
			this.loadData()
		},
		methods: {
			loadData() {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "CODE", 1)
				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, 'Nav_Users.Nav_User');
				extendInclude(json, 'Nav_ChargeUser');
				extendInclude(json, 'Nav_Class');
				extendInclude(json, 'Nav_Files.Nav_ImgFile');
				extendInclude(json, 'Nav_DepartmentPost');
				getRequest(json,"/FO/CurrentClassRecord/Get").then(res => {
					this.model = res
					this.model.current1 = this.model.SHIFT_STATUS > 0 ? this.model.CURRENT_CLASS_STATUS == 0 ?
						'正常' : "<text style='color:red'>不正常</text>" : null;
					this.model.current2 = this.model.SHIFT_STATUS > 0 ? this.model.CURRENT_CLASS_STATUS == 0 ?
						'无' : this.model.CURRENT_CLASS_QUESTION : null;
					this.model.current3 = this.model.SHIFT_STATUS > 0 ? this.model.CURRENT_CLASS_STATUS == 0 ?
						'无' : this.model.CURRENT_CLASS_MEASURE : null;
					this.model.device1 = this.model.SHIFT_STATUS > 0 ? this.model.DEVICE_STATUS == 0 ? '正常' :
						"<text style='color:red'>不正常</text>" : null;
					this.model.device2 = this.model.SHIFT_STATUS > 0 ? this.model.DEVICE_STATUS == 0 ? '无' : this
						.model
						.DEVICE_QUESTION : null;
					this.model.device3 = this.model.SHIFT_STATUS > 0 ? this.model.DEVICE_STATUS == 0 ? '无' : this
						.model
						.DEVICE_MEASURE : null;
					this.model.environment1 = this.model.SHIFT_STATUS > 0 ? this.model.ENVIRONMENT_STATUS == 0 ?
						'正常' : "<text style='color:red'>不正常</text>" : null;
					this.model.environment2 = this.model.SHIFT_STATUS > 0 ? this.model.ENVIRONMENT_STATUS == 0 ?
						'无' : this.model.ENVIRONMENT_QUESTION : null;
					this.model.environment3 = this.model.SHIFT_STATUS > 0 ? this.model.ENVIRONMENT_STATUS == 0 ?
						'无' : this.model.ENVIRONMENT_MEASURE : null;
					this.model.supplies1 = this.model.SHIFT_STATUS > 0 ? this.model.SUPPLIES_STATUS == 0 ? '正常' :
						"<text style='color:red'>不正常</text>" : null;
					this.model.supplies2 = this.model.SHIFT_STATUS > 0 ? this.model.SUPPLIES_STATUS == 0 ? '无' :
						this.model.SUPPLIES_QUESTION : null;
					this.model.supplies3 = this.model.SHIFT_STATUS > 0 ? this.model.SUPPLIES_STATUS == 0 ? '无' :
						this.model.SUPPLIES_MEASURE : null;
					// let strUserName = ''
					let strUserName = []
					
					if (res.Nav_Users && res.Nav_Users.length > 0) {
						for (let i = 0; i < res.Nav_Users.length; i++) {
							// strUserName.push(res.Nav_Users[i].Nav_User.NAME)
							if (res.Nav_Users[i].USER_SHIFT_STATUS == 0) {
								strUserName.push({
									type:'red',
									value:res.Nav_Users[i].Nav_User.NAME
								})
								// strUserName += (strUserName.length > 0 ? " " : "") + "&nbsp;<text style='color:red;margin:0px 5px'>" +
								// 	res.Nav_Users[i].Nav_User.NAME + "</text>";
							} else {
								strUserName.push({
									type:'normal',
									value:res.Nav_Users[i].Nav_User.NAME
								})
								// strUserName += (strUserName.length > 0 ? " " : "") + res.Nav_Users[
								// 	i].Nav_User.NAME;
							}

						}
					}
					
					this.model.UserNames = strUserName;
					if (this.model.SHIFT_STATUS == 2) {
						this.isSign = true;
						this.isAudit = false;
					} else if (this.model.SHIFT_STATUS == 3) {
						this.isSign = false;
						this.isAudit = true;
					}
					this.isLoadOK = true
				})
			},
			onTableBtnAgree() {
				let json = {};
				json.ID = this.model.ID;
				json.TaskID = this.TaskID;
				getRequest(json,"/FO/FOCurrentClassRecord/UserSignin").then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})
			},
			onChargeUserAgree(agree) {
				let json = {};
				json.ID = this.model.ID;
				json.TaskID = this.TaskID;
				json.CODE = agree;
				json.AUDIT_OPINION = this.DEALOPINION;
				json.DEPARTMENT_ID = this.model.DEPARTMENT_ID;
				json.CLASS_ID = this.model.CLASS_ID;
				getRequest(json,"/FO/FOCurrentClassRecord/ChargeUserAgree").then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})
			}
		}
	}
</script>

<style>
	/* @import url("@/style/css/editTemplate.css"); */
	.background {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: #edf1fd;
		z-index: -1;
	}
	.peoplecur>>>.u-form-item__body__right {
		overflow: auto;
		white-space: nowrap;
		
	}
	.peoplecur>>>.u-form-item__body__right__content__slot {
		justify-content: flex-end;
	}
	.peoplewrap {
		overflow: hidden;
		white-space: nowrap;
		margin: 0px 3px;
	}
	.card {
		/* margin-bottom: 18px; */
		margin: 20px 16px 10px 16px;
		/* border: 1px solid #EBEEF5; */
		padding: 20px 30px 80px 30px;
		/* box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 3px 1px; */
		background-color: #ffffff;
		border-radius: 10px;
	}
	.bottom {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		padding: 10px 16px;
		box-sizing: border-box;
		background: #edf1fd;
		z-index: 999;
	}

	.btn-wrap {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		box-sizing: border-box;
		padding: 16px;
		z-index: 1000;
		background: #fff;
		box-shadow: 0 -1px 2px 0 rgba(0, 0, 0, .05);
	}

	.buttons {
		margin-top: 10px;
		display: flex;
		justify-content: space-between;
	}

	.buttons .first-btn {
		margin-right: 20px;
	}
	.demo-ruleForm>>>.u-form-item__body__left__content__label {
		font-size: 14px;
		color: #8e8b9c;
		/* justify-content: flex-start; */
	}
	
	.demo-ruleForm>>>.u-form-item__body__left__content__ {
		left: -11px;
		top: 0px
	}
	
	.demo-ruleForm>>>.u-textarea__field {
		font-size: 14px;
	}
	.btn-wrap>>>.u-textarea__field {
		font-size: 14px;
	}
	
	.btn-wrap>>>.u-cell__title-text {
		font-size: 14px;
	}
	.demo-ruleForm>>>.u-cell__title-text {
		font-size: 14px;
	}
	.upload-title {
		font-size: 14px;
		color: #8e8b9c;
		line-height: 22px;
		padding: 8px 0px;
	}
</style>