<template>
	<!-- 整改记录审批 -->
	<view class="page-wrap" v-bind:style="{paddingBottom:paddingBottom+'px'}">
		<uni-card margin="0" :is-shadow="true">
			<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model" :rules="rules"
				ref="wForm" errorType="border-bottom">
				<!-- 安全检查通知 -->

				<u-form-item label="编号" prop="CODE" borderBottom>
					<u--input disabled disabledColor="#fff" v-model="model.CODE" border="none" slot="right"
						inputAlign="right"></u--input>
				</u-form-item>
				<u-form-item label="整改截止时间" prop="ENDDATE" borderBottom>
					<u--input disabled disabledColor="#fff" v-model="model.ENDDATE" border="none" slot="right"
						inputAlign="right"></u--input>
				</u-form-item>
				<u-form-item label="整改落实人" prop="Nav_UserActualDeal.NAME" borderBottom>
					<u--input disabled disabledColor="#fff" v-model="model.Nav_UserActualDeal.NAME" border="none"
						slot="right" inputAlign="right"></u--input>
				</u-form-item>
				<u-form-item label="整改部门" prop="Nav_UserDeal.Nav_Department.NAME" borderBottom>
					<u--input disabled disabledColor="#fff" v-model="model.Nav_UserDeal.Nav_Department.NAME"
						border="none" slot="right" inputAlign="right"></u--input>
				</u-form-item>

				<u-form-item label="整改责任人" prop="Nav_UserDeal.NAME" borderBottom>
					<u--input disabled disabledColor="#fff" v-model="model.Nav_UserDeal.NAME" border="none" slot="right"
						inputAlign="right"></u--input>
				</u-form-item>

				<u-form-item label="验收人" prop="Nav_UserCheck.NAME" borderBottom>
					<u--input disabled disabledColor="#fff" v-model="model.Nav_UserCheck.NAME" border="none"
						slot="right" inputAlign="right"></u--input>
				</u-form-item>
				<u-form-item label="验收时间" prop="CHCECKTIME" borderBottom>
					<u--input disabled disabledColor="#fff" v-model="model.CHCECKTIME" border="none" slot="right"
						inputAlign="right"></u--input>
				</u-form-item>
				<u-form-item label="通知单编号" prop="Nav_SubmitNoticePerson.CODE" borderBottom>
					<u--input disabled disabledColor="#fff" v-model="model.Nav_SubmitNoticePerson.CODE" border="none"
						slot="right" inputAlign="right"></u--input>
				</u-form-item>
				<u-form-item label="检查问题" prop="Nav_SubmitContent.DESCREPTION" borderBottom>
					<u--input disabled disabledColor="#fff" v-model="model.Nav_SubmitContent.DESCREPTION" border="none"
						slot="right" inputAlign="right"></u--input>
				</u-form-item>

				<view class="label-title">整改建议与措施</view>
				<u-form-item borderBottom prop="Nav_SubmitContent.DEMAND">
					<u--textarea disabled autoHeight v-model="model.Nav_SubmitContent.DEMAND" placeholder="请输入整改建议与措施"
						border="surround"></u--textarea>
				</u-form-item>
				<view class="label-title">整改后情况描述</view>
				<u-form-item borderBottom prop="DEALDESCRIBE">
					<u--textarea disabled autoHeight v-model="model.DEALDESCRIBE" placeholder="请输入整改后情况描述"
						border="surround"></u--textarea>
				</u-form-item>

				<view class="upload-title">附件（整改前）</view>
				<full-upload v-model="model.Nav_Files" :isShowBtn='false'></full-upload>

				<view class="upload-title">附件（整改后）</view>
				<full-upload v-model="model.Nav_FilesAfter" :isShowBtn='false'></full-upload>

				<u-form-item label="整改责任人签名" borderBottom>
					<imageSign slot="right" v-if='model.Nav_SubmitContent.RiskContentState > 36'
						:user='model.Nav_UserDeal'>
					</imageSign>
				</u-form-item>
				<u-form-item label="验收人签名" borderBottom>
					<imageSign slot="right" v-if='model.Nav_SubmitContent.RiskContentState  >= 38'
						:user='model.Nav_UserCheck'>
					</imageSign>
				</u-form-item>

			</u--form>
		</uni-card>
		<!-- @reject="handleReject"
			@pass="handlePass" -->

		<view class="bottom-button">
			<check-action v-if="isLoadOK && tableKey === '1' && isAudit === 'true'" :okApi="okApi"
				:refuseApi="refuseApi" :dataSource="$store.state.auditModel"></check-action>
		</view>

	</view>
</template>

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

	import {
		GetBS044Check,
		CheckDealBS044Check
	} from '../../../../services/apply/subPages/BS/riskSubmit'

	import {
		auditOptionShow
	} from '../../../../services/common'
	import {
		data
	} from '../../../../uni_modules/uview-ui/libs/mixin/mixin'

	import imageSign from '@/components/custom/imageSign.vue'
	export default {
		components: {
			imageSign
		},
		data() {
			return {
				isLoadOK: false,
				isAudit: false,
				ApproveID: '',
				okApi: '',
				refuseApi: '',
				tableKey: '0',
				TaskID: '',
				DEALOPINION: '',
				paddingBottom: '170',
				model: {
					ID: '',
					ORG_ID: '',
					Nav_UserDeal: {
						NAME: '',
						Nav_Department: {
							NAME: ''
						}
					},
					Nav_UserCheck: {},
					Nav_SubmitNoticePerson: {},
					Nav_SubmitContent: {
						Nav_Question: {},
						RiskContentState: 0,
						DEMAND: '',
						DESCREPTION: ''
					},
					Nav_UserActualDeal: {
						NAME: ''
					},
					// Nav_SubmitNoticePerson: {
					// 	CODE: ''
					// },
					// Nav_SubmitContent: {
					// 	LastDateUser: '',
					// 	DEMAND: '',
					// 	DESCREPTION: ''
					// },
					// Nav_UserActualDeal: {},
					// Nav_UserActualDeal: {},
					Nav_Files: {},
					Nav_FilesAfter: {}
				},
				dataSource: {
					Nav_ApproveDetails: {}
				},
				rules: {
					'DEALDESCRIBE': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change']
					}
				}
			}
		},
		onLoad(option) {
			this.model.ID = option.ID
			this.model.TaskID = option.taskID
			this.TaskID = option.taskID
			this.tableKey = option.tableKey
			this.isAudit = option.isAudit


			this.ApproveID = option.ApproveID
			this.okApi = option.okApi
			this.refuseApi = option.refuseApi
			this.auditModel = {
				...this.$store.state.auditModel,
				TaskID: this.TaskID
			}

			if (!this.tableKey || this.tableKey != 1)
				this.paddingBottom = 10
			this.loadData()
		},
		methods: {
			loadData() {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "CODE", 1)
				extendRule(json, 'ID', 1, this.model.ID)
				extendInclude(json, "Nav_UserDeal")
				extendInclude(json, "Nav_UserCheck")
				extendInclude(json, "Nav_UserActualDeal")
				extendInclude(json, "Nav_SubmitNoticePerson")
				extendInclude(json, "Nav_UserDeal.Nav_Department")
				extendInclude(json, "Nav_SubmitContent.Nav_Question")
				extendInclude(json, "Nav_Files.Nav_ImgFile")
				extendInclude(json, "Nav_FilesAfter.Nav_ImgFile")
				json.IgnoreDataRule = true
				GetBS044Check(json).then(res => {
					this.model = res
					this.isLoadOK = true
				})
			},
			//CheckDealBS044Check

			sureCheck(val) {
				//驳回 10
				// const ele = this.$refs
				// ele['wForm'].validate().then(res => {
				// }).catch(err => {
				// 	console.log('校验失败', err)
				// })

				if (val && val == 10 && (this.DEALOPINION == undefined || this.DEALOPINION == null || this
						.DEALOPINION.length < 1)) {
					uni.$showErrorInfo("请填写驳回的验收意见！")
					return false
				}
				let json = initFilter(this.model.ORG_ID, this.model.ID, null, null, null, this.TaskID,
					val, this.DEALOPINION)
				CheckDealBS044Check(json).then(res => {
					uni.$showMsgFunc('操作成功!', () => {
						// if (this.tableKey == null || this.tableKey == 0) {
						// 	uni.navigateTo({
						// 		url: 'safeCheckIndex'
						// 	})
						// } else {
						uni.navigateBack()
						// }
					}, 'success', 1000)
				}).catch(
					// err => {
					// 	// console.log('校验失败', err)
					// 	uni.$showErrorInfo('校验失败！')
					// }
				)
			},

			// FullCheckUpdate() {
			// 	const ele = this.$refs
			// 	ele['wForm'].validate().then(res => {
			// 		this.model.OPERARTETYPE = 20
			// 		this.model.TaskID = this.TaskID
			// 		this.model.ENDDATE = uni.$u.timeFormat(new Date(), 'yyyy-MM-dd hh:mm:ss')
			// 		CheckDealBS044Check(this.model).then(res => {
			// 			debugger
			// 			uni.$showMsgFunc('操作成功!', () => {
			// 				if (this.tableKey == null || this.tableKey == 0) {
			// 					uni.navigateTo({
			// 						url: 'safeCheckIndex'
			// 					})
			// 				} else {
			// 					uni.navigateBack()
			// 				}
			// 			}, 'success', 1000)
			// 		}).catch(
			// 			// err => {
			// 			// 	// console.log('校验失败', err)
			// 			// 	uni.$showErrorInfo('校验失败！')
			// 			// }
			// 		)
			// 	}).catch(err => {
			// 		// console.log('校验失败', err)
			// 		uni.$showErrorInfo('校验失败！')
			// 	})
			// },
		},
		computed: {

		}
	}
</script>

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

	/* .todo-page {
		padding: 16px;
	}

	.todo-page .status-bar {
		height: 120px;
		background-image: linear-gradient(to right, #CFECFF, #6EB6FF);
		position: absolute;
		top: 0;
		left: 0;
		z-index: -10;
	}

	.todo-page .main {
		padding: 62px 8px;
		position: relative;
		z-index: 10;
		background-size: 100% 120px;
		background-repeat: no-repeat;
	}

	.todo-page .swiper-wrap {
		margin-bottom: 16px;
	}

	.tabs-bar {
		display: flex;
		flex-direction: row;
	}

	.tabs-bar .tab {
		display: flex;
		align-items: center;
		position: relative;
		margin-right: 20px;
		padding-bottom: 6px;
	}

	.tabs-bar .tab .t {
		position: relative
	}

	.tabs-bar .tab .t .name {
		font-size: 18px;
		line-height: 22px;
		color: #999;
	}

	.tabs-bar .tab .bottom-widget {
		width: 20px;
		height: 3px;
		background-color: #004F9D;
	}

	.content-list {
		padding: 10px 0;
	}

	.content-list .card {
		border-radius: 8px;
		margin-bottom: 12px;
		font-size: 14px;
		overflow: hidden;
		padding: 14px;
		box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
		border: 1px solid rgba(0, 0, 0, 0.1);
	}

	.content-list .card .card-body {
		display: flex;
		flex-direction: row;
	}

	.content-list .card .card-body .left {
		margin-right: 4px;
		width: 20px;
		padding-top: 4px;
	}

	.content-list .card .card-body .left .todo-icon {
		width: 16px;
		height: 16px;
	}

	.content-list .card .card-body .contain {
		flex: 1;
	}

	.content-list .card .card-body .content {
		margin-bottom: 6px;
		display: flex;
		flex-direction: row;
	}

	.content-list .card .card-body .content-text {
		color: #333333;
		line-height: 24px;
		font-weight: bold;
		font-size: 16px;
		flex: 1;
	}

	.content-list .card .card-body .content-bottom {
		display: flex;
		flex-direction: row;
		align-items: flex-end;
	}

	.content-list .card .card-body .date-time {
		flex: 1
	}

	.content-list .card .card-body .content-status {
		width: 56px;
	}

	.content-list .card .card-body .status {
		background: rgba(255, 87, 51, 0.2);
		color: rgba(255, 87, 51, 1);
		text-align: center;
		font-size: 12px;
		width: 56px;
		height: 18px;
		line-height: 18px;
		border-radius: 2px;
	}

	.content-list .card .card-body .status.normal {
		background: rgba(0, 161, 64, 0.2);
		color: rgba(0, 161, 64, 1);
	}

	.content-list .card .card-body .status.warn {
		background: rgba(202, 158, 3, 0.2);
		color: rgba(202, 158, 3, 1);
	}

	.content-list .card .card-body .time {
		font-weight: 400;
		line-height: 18px;
		color: #333333;
		display: flex;
		flex-direction: row;
		margin-top: 4px;
		align-items: center;
	}

	.content-list .card .card-body .time .point {
		width: 8px;
		height: 8px;
		border-radius: 50%;
		margin-right: 4px;
	}

	.content-list .card .card-body .time .point.green {
		background: #00A140;
	}

	.content-list .card .card-body .time .point.red {
		background: #EE0A24;
	}

	.content-list .card .card-body .label {
		color: #666666;
		font-size: 12px;
	}

	.content-list .card .card-body .value {
		font-size: 12px;
	}

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

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