<template>
	<view class="page-wrap">
		<uni-card margin="0" :is-shadow="true">
			<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model">

				<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"></u--input>
				</u-form-item>
				<u-form-item label="时间：" prop="CHANGE_SHIFT_TIME" borderBottom>
					<u--input v-model="model.CHANGE_SHIFT_TIME" border="none" slot="right" inputAlign="right" disabled
						disabledColor="#ffffff"></u--input>
				</u-form-item>
				<u-form-item label="地点：" prop="ADDRESS" borderBottom>
					<u--input v-model="model.ADDRESS" border="none" slot="right" inputAlign="right" disabled
						disabledColor="#ffffff"></u--input>
				</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"></u--input>
				</u-form-item>

				<u-form-item label="存在问题：" prop="CURRENT_CLASS_QUESTION" borderBottom
					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" borderBottom
					v-if="model.CURRENT_CLASS_STATUS==1">
				</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"
						slot="right"></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"
						slot="right"></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"
						slot="right"></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 disabledColor="#ffffff"></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--input v-model="model.DEVICE_STORAGE" border="none" inputAlign="right" disabled
						disabledColor="#ffffff"></u--input>
				</u-form-item>

				<u-form-item label="交班人员：" prop="PreUsers" borderBottom>
					<u--input slot="right" v-html="model.PreUsers" border="none" inputAlign="right" disabled
						disabledColor="#ffffff"></u--input>
				</u-form-item>

				<u-form-item label="上班运行记录：" prop="lastclass1" borderBottom>
					<u--input autoHeight v-model="model.lastclass1" border="none" inputAlign="right" disabled
						disabledColor="#ffffff"></u--input>
				</u-form-item>
				<u-form-item label="存在的问题：" prop="lastclass2" borderBottom>
				</u-form-item>
				<u--textarea autoHeight v-model="model.lastclass2" border="none" inputAlign="right" disabled
					disabledColor="#ffffff"></u--textarea>
				<u-form-item label="上班工作完成情况：" prop="lastclass3" borderBottom>
					<u--input autoHeight v-model="model.lastclass3" border="none" inputAlign="right" disabled
						disabledColor="#ffffff"></u--input>
				</u-form-item>
				<u-form-item label="存在的问题：" prop="lastclass4" borderBottom>
				</u-form-item>
				<u--textarea autoHeight v-model="model.lastclass4" border="none" inputAlign="right" disabled
					disabledColor="#ffffff"></u--textarea>
				<u-form-item label="接班人员：" prop="AfterUsers" borderBottom>
					<u--input slot="right" v-html="model.AfterUsers" border="none" inputAlign="right" disabled
						disabledColor="#ffffff"></u--input>
				</u-form-item>
				<view class="upload-title">附件</view>
				<full-upload v-model="model.Nav_Files" :listProp='listPropUpload' :listPropVal='listPropValUpload'
					:isShowBtn="false"></full-upload>
			</u--form>
		</uni-card>
		<button type="primary" class="bottom" v-if='isLoadOK&&tableKey==1' @click="onTableBtnAgree">同意</button>
	</view>
</template>

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

	import {
		getRequest,
		getChangeShiftRecordSign
	} 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 {
				listPropUpload: ['CHANGE_SHIFT_RECORD_ID'],
				listPropValUpload: [],
				model: {
					Nav_Class: "",
				},
				TaskID: "",
				tableKey: '0',
				isLoadOK: false,
			}
		},
		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, "", "CREATE_TIME", 1)
				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, 'Nav_Class');
				extendInclude(json, 'Nav_PreUsers.Nav_User');
				extendInclude(json, 'Nav_AfterUsers.Nav_User');
				extendInclude(json, "Nav_Files.Nav_ImgFile.Nav_File")
				getRequest(json, "/FO/ChangeShiftRecord/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;

					this.model.lastclass1 = this.model.LAST_CLASS_RECORD_STATUS == 0 ? '完整' : '不完整';
					this.model.lastclass2 = this.model.LAST_CLASS_RECORD_QUESTION == undefined ? "无" : this.model
						.LAST_CLASS_RECORD_QUESTION;
					this.model.lastclass3 = this.model.LAST_CLASS_FINISH_STATUS == 0 ? '完成' : '未完成';
					this.model.lastclass4 = this.model.LAST_CLASS_FINISH_QUESTION == undefined ? "无" : this.model
						.LAST_CLASS_FINISH_QUESTION;
					let strUserName1 = '';
					let strUserName2 = '';
					if (res.Nav_PreUsers && res.Nav_PreUsers.length > 0) {
						for (let i = 0; i < res.Nav_PreUsers.length; i++) {
							if (res.Nav_PreUsers[i].USER_SHIFT_STATUS == 0) {
								strUserName1 += (strUserName1.length > 0 ? " " : "") + "<text style='color:red'>" +
									res.Nav_PreUsers[i].Nav_User.NAME + "</text>";
							} else {
								strUserName1 += (strUserName1.length > 0 ? " " : "") + res.Nav_PreUsers[
									i].Nav_User.NAME;
							}

						}
					}
					if (res.Nav_AfterUsers && res.Nav_AfterUsers.length > 0) {
						for (let i = 0; i < res.Nav_AfterUsers.length; i++) {
							if (res.Nav_AfterUsers[i].USER_SHIFT_STATUS == 0) {
								strUserName2 += (strUserName2.length > 0 ? " " : "") +
									"&nbsp;<text style='color:red'>" +
									res.Nav_AfterUsers[i].Nav_User.NAME + "</text>";
							} else {
								strUserName2 += (strUserName2.length > 0 ? " " : "") + res.Nav_AfterUsers[
									i].Nav_User.NAME;
							}

						}
					}
					this.model.PreUsers = strUserName1;
					this.model.AfterUsers = strUserName2;

					this.isLoadOK = true;
				})
			},
			onTableBtnAgree() {
				let json = {};
				json.ID = this.model.ID;
				json.TaskID = this.TaskID;
				getRequest(json, "/FO/FOChangeShiftRecord/PersonalAgree").then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})

			}
		},
		computed: {

		}
	}
</script>

<style>
	@import url("@/style/css/editTemplate.css");
</style>