<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="CREATE_TIME" borderBottom>
						<u--input v-model="dataModel.CREATE_TIME" disabled disabledColor="#ffffff" placeholder="请输入发起时间" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="发起部门" prop="DepartmentName" borderBottom>
						<u--input v-model="dataModel.Nav_Department.NAME" disabled disabledColor="#ffffff"  placeholder="请输入发起部门" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="发起人员" prop="UserName" borderBottom>
						<u--input v-model="dataModel.Nav_User.NAME" disabled disabledColor="#ffffff" placeholder="请输入发起人员" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="执行状况" prop="PERFORM_STATUS" borderBottom>
						<u--input v-model="dataModel.PERFORM_STATUS" disabled disabledColor="#ffffff" placeholder="请输入发起人员" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="变化描述" prop="DESCRIPTION" borderBottom>
						<u--input v-model="dataModel.DESCRIPTION" disabled disabledColor="#ffffff" placeholder="请输入变化描述" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="变化后执行任务" prop="TASK" borderBottom>
						<u--input v-model="dataModel.Nav_Task.NAME" disabled disabledColor="#ffffff" placeholder="请输入变化带来的风险" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="执行情况" prop="PERFORM_DESCRIPTION" borderBottom>
						<u--input v-model="dataModel.PERFORM_DESCRIPTION" disabled disabledColor="#ffffff" placeholder="请输入执行情况" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="未执行原因" prop="REASON" borderBottom>
						<u--input v-model="dataModel.REASON" disabled disabledColor="#ffffff" placeholder="请输入未执行原因" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<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-item label="变化类型" prop="TypeNames" borderBottom>
					</u-form-item>
					<u--textarea autoHeight type="textarea" v-html="dataModel.TypeNames" border="none"
						inputAlign="left">
					</u--textarea>
					<u-form-item label="附件" prop="UserFiles" borderBottom>
					</u-form-item>
					<u-link v-for="item in dataModel.UserFiles" :href="item.url" :text="item.name">
					</u-link>
				</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,
	} from '../../../../services/apply/subPages/SCPT/PTServices'
	import config from '../../../../config/common'

	export default {
		data() {
			return {
				ID:'',
				TaskID: '',
				tableKey:0,
				isLoadOK :false,
				isAudit: false,
				userLists: [],
				dataModel: {
					Nav_Department:{NAME:''},
					Nav_User:{NAME:''},
					Nav_Task:{NAME:''},
				},
				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,"/PR/PRChangeTaskImplement/GetUserEdit").then(res => {
					this.dataModel = res
					//数据组装
					let strTypeName = ''
					if (res.Nav_Types && res.Nav_Types.length > 0) {
						for (let i = 0; i < res.Nav_Types.length; i++) {
							let user=res.Nav_Types[i].TYPE_ID!=null?res.Nav_Types[i].Nav_Type.NAME:'';
								strTypeName += (strTypeName.length > 0 ? "</br>" : "") + user;
						}
					}
					//数据组装
					let strUserName = ''
					if (res.Nav_Users && res.Nav_Users.length > 0) {
						for (let i = 0; i < res.Nav_Users.length; i++) {
							let user=res.Nav_Users[i].USER_ID!=null?res.Nav_Users[i].Nav_User.NAME:'';
								strUserName += (strUserName.length > 0 ? "</br>" : "") + user;
						}
					}
					//数据组装
					let strUserFiles = [{
						url: '',
						name:''
					}]
					if (res.Nav_Files && res.Nav_Files.length > 0) {
						for (let i = 0; i < res.Nav_Files.length; i++) {
							strUserFiles.push({
								url: config.uni_app_web_local_api_url+res.Nav_Files[i].Nav_ImgFile.FILE_PATH,
								name:res.Nav_Files[i].Nav_ImgFile.FILE_NAME
							})
						}
					}
					this.dataModel.TypeNames = strTypeName
					this.dataModel.UserNames = strUserName
					this.dataModel.UserFiles = strUserFiles
					this.isLoadOK = true
				})
			}
		}
	}
</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>
