<template>
	<view style="padding-bottom: 80px;">
		<view class="card">
			<view class="background"></view>
			<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model" class="demo-ruleForm">
				<view style="position: relative;">
					<view style="position: absolute;left: -10px;color: #3d4b70;top: -3px;">*</view>
				</view>

				<view style="font-size: 15px; font-weight: bold;color: #3d4b70;margin-bottom: 10px;">基本信息</view>
				<u-form-item label="交底时间" prop="CHECKDATETIME" borderBottom >
					<u--input disabled disabledColor="#fff" v-model="model.DISCLOSURE_DATE"  border="none" inputAlign="right" fontSize="14px"></u--input>
					<!-- <u-icon style="margin-left: 4px;" name="arrow-down" size="12"></u-icon> -->
				</u-form-item>
				<u-form-item label="交底地点" prop="LOCATION" borderBottom>
					<u--input disabledColor="#ffffff" disabled v-model="model.JOB_LOCATION" border="none" inputAlign="right" fontSize="14px" placeholder="请输入交底地点"></u--input>
				</u-form-item>
				<u-form-item label="交底人：" prop="Nav_User.NAME"  borderBottom>
					<u--input disabledColor="#fff" v-model="(model.Nav_User||{}).NAME" disabled  fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 0px" border="none" inputAlign="right">
					</u--input>
				</u-form-item>
				<u-form-item label="被交底人：" prop="UserNames">
				
				</u-form-item>
				<rich-text autoHeight v-html="model.UserNames" border="none" disabled class="richtext"></rich-text>
				<u-form-item label="交底内容" prop="LOCATION">
				
				</u-form-item>
				<u--textarea v-model="model.DisclosureContent" disabled  border="surround"></u--textarea>
				<view class="upload-title">附件：</view>
				<full-upload v-model="model.Nav_Files" :isShowBtn='false'></full-upload>
				<u-form-item label="交底人签字" >
				</u-form-item>
				<image style="width: 150px;height: 60px;" :src="imgurl+model.Nav_User.FILE_PATH" v-if="model.Nav_User&&model.Nav_User.FILE_PATH">
				</image>
				<u-form-item label="被交底人签字" >
				</u-form-item>
				<view v-for="item of model.Nav_Person">
					<image style="width: 150px;height: 60px;" :src="imgurl+item.Nav_User.FILE_PATH" v-if="item.DEAL_STATUS== 1">
					</image>
				</view>

			</u--form>
			
		</view>
		<view class="bottom-button" style="padding: 10px 16px;" v-if="isLoadOK&&tableKey==1">
			<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_User: {
						NAME: ''
					},
					Nav_Department: {
						NAME: ''
					},
					Nav_Person: [],
				},
				imgurl :config.uni_app_web_api_url+ ':5199' ,
				listPropUpload: ['PRE_SHIFT_MEETING_RECORD_ID'],
				listPropValUpload: [],
				TaskID: "",
				tableKey: '0',
				isLoadOK: false,
				ID: '',
			}
		},
		onLoad(option) {
			this.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.ID);
				getRequest(json, "/FO/FOTechDisclosureFromSafe/GetEdit").then(res => {
					this.model = res
					let strUserName = ''
					if (res.Nav_Person && res.Nav_Person.length > 0) {
						for (let i = 0; i < res.Nav_Person.length; i++) {
							if (res.Nav_Person[i].DEAL_STATUS == 0) {
								strUserName += (strUserName.length > 0 ? " " : "") +
									"<view style='color:#E35D58;background-color:rgba(227,93,88,0.2);padding:5px;line-height:20px;white-space:nowrap;'>" +
									res.Nav_Person[i].Nav_User.NAME + "</view>";
							} else {
								strUserName += (strUserName.length > 0 ? " " : "") +
									"<text style='padding:5px;line-height:20px;white-space:nowrap;color:#303133'>" +
									res.Nav_Person[i].Nav_User.NAME + "</text>";
							}
							if(res.Nav_Person[i].DEAL_STATUS == 1){
						
								res.Nav_Person[i].imgurl = config.uni_app_web_api_url+ ':5199' + res.Nav_Person[i].Nav_User.FILE_PATH
								console.log(res.Nav_Person[i].imgurl)
							}
					
						}
					}
					this.model.UserNames = strUserName;
					this.isLoadOK = true;
				})
			},
			onTableBtnAgree() {
				let json = {};
				json.ID = this.ID;
				json.TaskID = this.TaskID;
				getRequest(json, "/FO/FOTechDisclosureFromSafe/PersonalAgree").then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})

			}
		},
		computed: {

		}
	}
</script>

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