<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="YEAR" borderBottom>
						<u--input v-model="dataModel.YEAR" disabled disabledColor="#ffffff" placeholder="请输入年度" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="征集截至时间" prop="COMPLETE_DATE" borderBottom>
						<u--input v-model="dataModel.COMPLETE_DATE" disabled disabledColor="#ffffff" placeholder="请输入征集截至时间" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="意向方针" prop="GuidelineName" borderBottom>
						<u--input v-model="dataModel.Nav_Guidelines.NAME" disabled disabledColor="#ffffff" placeholder="请输入意向方针" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="满意度" prop="RATE" borderBottom>
						<u--input v-model="dataModel.RATE" disabled disabledColor="#ffffff" placeholder="请输入满意度" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="征集人数" prop="ALL_USER_COUNT" borderBottom>
						<u--input v-model="dataModel.ALL_USER_COUNT" disabled disabledColor="#ffffff" placeholder="请输入征集人数" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="参与人数" prop="USER_COUNT" borderBottom>
						<u--input v-model="dataModel.USER_COUNT" disabled disabledColor="#ffffff" placeholder="请输入参与人数" border="none" inputAlign="right">
						</u--input>
					</u-form-item>
					<u-form-item label="参与率" prop="USER_RATE" borderBottom>
						<u--input v-model="dataModel.USER_RATE" 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>
			</uni-card>
		</view>
		<u-sticky offset-top="20">
			<view class="sub-form">
				<uni-collapse :border="false" accordion>
					<uni-card margin="0" spacing="0" padding="0" :is-shadow="true">
						<uni-collapse-item title="征集明细">
							<view class="sub-form-wrap" style="height: 500px; overflow: auto">
								<u--form labelPosition="left" labelWidth="auto" labelAlign="center"
									:model="subDataModel" ref="sForm2" errorType="border-bottom">
									<u-swipe-action>
										<u-swipe-action-item style="margin-bottom: 16px;" :options="options"
											v-for="(item, index) in dataModel.Nav_Feedbacks">
											<uni-card margin="0" spacing="0" :is-shadow="false"
												style="margin-bottom: 10px;">
												<u-form-item label="填写人" prop="ChildUserName" borderBottom>
													<u--input disabled disabledColor="#fff" v-model="item['Nav_User'].NAME"
																		border="none" inputAlign="right"></u--input>
													
												</u-form-item>
												<u-form-item label="部门" prop="ChildDepartName" borderBottom>
													<u--input disabled disabledColor="#fff" v-model="item['Nav_Department'].NAME"
																		border="none" inputAlign="right"></u--input>
													
												</u-form-item>
												<u-form-item label="填写时间" prop="ChildCreateTime" borderBottom>
													<u--input disabled disabledColor="#fff" v-model="item.CREATE_TIME"
																		border="none" inputAlign="right"></u--input>
													
												</u-form-item>
												<u-form-item label="是否满意" prop="IS_AGREE_SHOW" borderBottom>
													<u--input disabled disabledColor="#fff" v-model="item.IS_AGREE_SHOW"
																		border="none" inputAlign="right"></u--input>
													
												</u-form-item>
												<u-form-item label="其他意见" prop="OTHER_SUGGESTIONS" borderBottom>
													<u--input disabled disabledColor="#fff" v-model="item.OTHER_SUGGESTIONS"
																		border="none" inputAlign="right"></u--input>
													
												</u-form-item>
											</uni-card>
										</u-swipe-action-item>
									</u-swipe-action>
								</u--form>
							</view>
						</uni-collapse-item>
					</uni-card>
				</uni-collapse>
			</view>
		</u-sticky>
			
		<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,
		getPolicyCollectSign
	} 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_Guidelines:{
						NAME:''
					},
					// Nav_Collects:{
					// 	Nav_Collect:{
					// 		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,"/PT/PTSafetyPolicySurvey/GetCollectEdit").then(res => {
					this.dataModel = res
					if(res.RATE)
					{
						res.RATE =res.RATE+'%'
					}
					if(res.USER_RATE)
					{
						res.USER_RATE =res.USER_RATE+'%'
					}
					if(res.GUIDELINES_ID == null)
					{
						res.Nav_Guidelines =[]
					}
					//数据组装
					let strUserName = ''
					if (res.Nav_Collects && res.Nav_Collects.length > 0) {
						for (let i = 0; i < res.Nav_Collects.length; i++) {
							let user=res.Nav_Collects[i].COLLECT_ID!=null?res.Nav_Collects[i].Nav_Collect.NAME:'';
								strUserName += (strUserName.length > 0 ? "</br>" : "") + user;
						}
					}
					if (res.Nav_Feedbacks && res.Nav_Feedbacks.length > 0) {
						for (let i = 0; i < res.Nav_Feedbacks.length; i++) {
							if(res.Nav_Feedbacks[i].IS_AGREE == 1)
							{
								res.Nav_Feedbacks[i].IS_AGREE_SHOW ="是"
							}
							else{
								res.Nav_Feedbacks[i].IS_AGREE_SHOW ="否"
							}
						}
					}
					this.dataModel.UserNames = strUserName
					this.isLoadOK = true
				})
			},
			onTableBtnAgree() {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "")
				 extendRule(json, 'ID', 1, this.ID)
				 extendRule(json, 'TASK_ID', 1, this.TaskID)
				getPolicyCollectSign(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>
