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

					<u-form-item label="编号" prop="CODE" borderBottom>
						<u--input v-model="dataModel.CODE" disabled disabledColor="#ffffff" placeholder="请输入编号" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="作业名称" prop="stepName" borderBottom>
						<u--input v-model="dataModel.Nav_OperationStep.NAME" disabled disabledColor="#ffffff"  placeholder="请输入作业名称" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="作业地点" prop="JOB_LOCATION" borderBottom>
						<u--input v-model="dataModel.JOB_LOCATION" disabled disabledColor="#ffffff" placeholder="请输入作业地点" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="交底时间" prop="DISCLOSURE_DATE" borderBottom>
						<u--input v-model="dataModel.DISCLOSURE_DATE" disabled disabledColor="#ffffff" placeholder="请输入交底时间" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="交底人" prop="disclosurePerson" borderBottom>
						<u--input v-model="dataModel.Nav_DisclosurePerson.NAME" disabled disabledColor="#ffffff" placeholder="请输入交底人" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="交底内容" prop="DisclosureContent" borderBottom>
					</u-form-item>
					<u--textarea v-model="dataModel.DisclosureContent" placeholder="请输入交底内容" border="none" inputAlign="right">
					</u--textarea>
					<u-form-item label="作业人员" prop="UserNames" borderBottom>
					</u-form-item>
					<u--textarea autoHeight type="textarea" v-html="dataModel.UserNames" border="none"
						inputAlign="left">
					</u--textarea>
				</u--form>
			</uni-card>
		</view>
			
		<view class="bottom-button">
			<button type="primary" class="bottom" v-if="isLoadOK&&tableKey==='1'&&!isAudit" @click="onTableBtnAgree">确认</button>
			<!-- <button type="primary" class="bottom" v-if='isLoadOK&&tableKey==1' @click="onTableBtnAgree">签到</button> -->
		</view>
		<!-- <query-selector :show="showPopup" :lists="userLists" :defaultValue="currentOperateUser.NAME"
			@close="handleClosePopup" @search="handleSearchUser" @select="handleSelectedUser" />
		<u-picker :show="comPickerInfo.showSheet" :columns="comPickerInfo.columns" @confirm="onConfirmPicker"
			@close="closePicker" @cancel="closePicker" keyName="NAME"></u-picker>
		<view class="bottom-button">
			<button type="primary" @click="submit">提交</button>
		</view> -->
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import {
		extendFilterGroup,
		extendGroupRule,
		extendInclude,
		extendOrder,
		extendRule,
		guid,
		initFilter,
		initFilterGroup,
		extendIgnoreDataRule
	} from '../../../../utils/common'
	import {
		getRequest,//getTechGet,
		getUserLists,
		saveTechRecord,
		getTechRecordSign
	} from '../../../../services/apply/FOServices/FOServices.js'
	import config from '../../../../config/common'

	export default {
		data() {
			return {
				ID:'',
				TaskID: '',
				tableKey:0,
				isLoadOK :false,
				isAudit: false,
				userLists: [],
				dataModel: {
					Nav_OperationStep:'',
					Nav_DisclosurePerson:''
				},
				subDataModel: {},
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#f56c6c'
					}
				}],
				comPickerInfo: {
					showSheet: false,
					columns: [],
					title: '',
					dataIndex: undefined,
					formIndex: undefined,
					name: ''
				},
				currentOperateUser: {},
				showPopup: false,
			}
		},
		onLoad(opt) {
			this.handleGetTechGet(opt)
		},
		methods: {
			handleGetTechGet(opt) {
				this.TaskID = opt.taskID ? opt.taskID : '';
				this.ID = opt.ID ? opt.ID : '';
				this.tableKey = opt.tableKey ? opt.tableKey : '0'
				this.okApi = opt.okApi
				this.refuseApi = opt.refuseApi
				this.ApproveID = opt.ApproveID
				this.isAudit = opt.isAudit
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "")
				 extendRule(json, 'ID', 1, opt.ID)
				// TODO: id 未获取
				getRequest(json,"/FO/FOTechDisclosureFrom/GetEdit").then(res => {
					this.dataModel = 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 ? "&nbsp;&nbsp;" : "") + "<text style='color:red'>" +
									res.Nav_Person[i].Nav_User.NAME + "</text>";
							} else {
							let user=res.Nav_Person[i].USER_ID!=null?res.Nav_Person[i].Nav_User.NAME:'';
								strUserName += (strUserName.length > 0 ? "&nbsp;&nbsp;" : "") + user;
							}
					
						}
					}
					this.dataModel.UserNames = strUserName
					this.isLoadOK = true
				})
			},
			onTableBtnAgree() {
				let json={};
				json.ID=this.ID;
				json.TaskID=this.TaskID;
				getTechRecordSign(json).then(res => {
					uni.$showMsgFunc('操作成功!', () => {
						uni.navigateBack()
					}, 'success', 1000)
				})
			
			}
		}
	}
</script>

<style scoped>
	.page-wrap {
		padding: 16px 16px 66px;
	}

	.card {
		margin-bottom: 18px;
	}

	.sub-form {
		margin-bottom: 16px;
	}

	.bottom-button {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		padding: 10px 16px;
		box-sizing: border-box;
		background: #fff;
		z-index: 999;
	}

	.upload-title {
		color: #303133;
		font-size: 15px;
		line-height: 22px;
		padding: 8px 0;
	}

	.page-wrap>>>.u-upload__button {
		margin-bottom: 0;
	}
</style>
