<template>
	<view class='base-info'>
		<view class="blank-info">
			<view class='my-feed' v-if="isAdd" @click="linkToIndex()">
				<view class="my-feed-info">
					<i class="iconfont icon-bianzu25" style="font-size: 16px;color: #2797ff;margin-right: 5px;"></i>
					<view>我的反馈记录</view>
				</view>
				<view>
					<u-icon name="arrow-right" size="16"></u-icon>
				</view>
			</view>
		</view>
		<!-- 反馈类型 -->

		<view class='label-info'>
			<i class="iconfont icon-Rectangle" style="font-size: 18px;color: #2797ff;"></i>
			<view>具体建议内容</view>
		</view>
		<view class="textarea-info">
			<u--textarea v-model="model.INFO" :disabled="!isAdd" placeholder="请输入反馈意见" border="none"
			height="120"></u--textarea>
		</view>
		
		<view class='label-info'>
			<i class="iconfont icon-Rectangle" style="font-size: 18px;color: #2797ff;"></i>
			<view>上传附件</view>
		</view>
		<view style="background-color: #fff;padding: 20px 15px 20px 15px;">
			<full-upload v-model="model.Nav_Files" :isShowBtn='isAdd' :listProp='listProp' :isShowBlueButton="false"
				:listPropVal='listPropVal'></full-upload>
		</view>


		<!-- <view class='label-info'>回复</view> -->
		<view class='label-info' v-if="model.STATUS === 30">
			<i class="iconfont icon-Rectangle" style="font-size: 18px;color: #2797ff;"></i>
			<view>回复</view>
		</view>
		<view class="textarea-info"  v-if="model.STATUS === 30">
			<u--textarea v-model="model.BACKINFO" :disabled="!isAdd" placeholder="请输入反馈意见" border="none"
				height="120"></u--textarea>
		</view>
		<view class="btn-info">
			<button @click="formSubmit" type="primary" v-if="isAdd" class='save-btn'>提交</button>
		</view>

		<show-toast></show-toast>

	</view>
</template>

<script>
	import {
		feedBack,
		feedBackGet
	} from '../../../services/common'
	import {
		guid,
		initFilter,
		extendRule,
		extendInclude
	} from '../../../utils/common'
		import showToast from '../../../components/custom/show-info/show-toast.vue'

	export default {
		data() {
			return {
				listProp: [],
				listPropVal: [],
				isAdd: true,
				model: {
					ID: '',
					INFO: '',
					USER_ID: '',
					DEPARTMENT_ID: '',
					STATUS: 0,
					Nav_Files: []
				},
				rules: {
					INFO: [{
						type: 'string',
						required: true,
						message: '反馈意见不能为空',
						trigger: ['blur', 'change']
					}, {
						max: 400,
						message: '反馈意见最多400字',
						trigger: ['blur', 'change']
					}]
				},
			}
		},
		onLoad(option) {
			if (option.isAdd) {
				if (option.isAdd === 'false')
					this.isAdd = false
			}
			if (this.isAdd == false) {
				this.model.ID = option.ID //数据加载
				this.loadData()
			} else {
				this.listProp.push('FDDEBACK_ID')
				this.model.ID = guid()
				this.listPropVal.push(this.model.ID)
			}
		},
		methods: {
			formSubmit() {
				if (this.model.INFO === '' || this.model.BACKINFO === '') {
					console.log(this.model.INFO,'000000011')
					this.$showToast({
						title: "反馈意见不能为空",
						content: "",
						icon: 'fail',
						success: res => {}
					});
					return
				}
					const appInfoData = uni.getStorageSync('appInfo')
					if (appInfoData.User == undefined) {
						uni.$showErrorInfo('获取人员信息失败')
						return false
					} else if (appInfoData.User.DEPARTMENT_ID == undefined) {
						uni.$showErrorInfo('获取人员部门失败')
						return false
					}

					this.model.ORG_ID = uni.getStorageSync('orgId')
					this.model.USER_ID = appInfoData.User.ID
					this.model.DEPARTMENT_ID = appInfoData.User.DEPARTMENT_ID
					this.model.STATUS = 10
					feedBack(this.model).then(res => {
						if (res.IsSuccessful) {
							uni.$showMsgFunc('反馈成功!', () => {
								uni.navigateBack()
							}, 'success', 1000)
						} else {
							uni.$showErrorInfo('操作失败')
						}
					})
			},
			linkToIndex() {
				uni.navigateTo({
					url: 'feedBackIndex'
				})
			},
			loadData() {
				this.pageIndex++
				const orgId = uni.getStorageSync('orgId')
				let json = initFilter(orgId, "", "CREATE_TIME", 1, this.pageIndex);
				extendRule(json, 'ID', 1, this.model.ID)
				extendInclude(json, "Nav_Files.Nav_ImgFile")
				feedBackGet(json).then(res => {
					this.model = res
				})
			},
		}
	}
</script>

<style scoped>
	.base-info {
		/* padding: 16px; */
		width: 100%;
		height: 100vh;
		position: relative;
		box-sizing: border-box;
		background-color: #ffffff;
		font-size: 16px;
	}

	.blank-info {
		padding: 0px 0px 5px 0px;
		background-color: #F1F2F8;
	}

	.my-feed {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		background-color: #ffffff;
		padding: 20px 10px 10px 10px;
	}
	.textarea-info {
		padding: 10px 15px;
	}
	.textarea-info >>> .u-textarea {
		background-color: #f5f7fa;
		border-radius: 10px;
	}

	.my-feed-info {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 2px;
	}

	.label-info {
		margin: 20px 0px 10px 10px;
		display: flex;
		flex-direction: row;
		align-items: center;
		text-align: center;
	}
	.tabs-info {
		height: 15px;
		width: 4px;
		background-color: #2797ff;
		margin: 0px 8px;
	}

	.info-form {}

	.save-btn {
		margin-top: 20px;
	}

	.upload-title {
		color: #303133;
		font-size: 15px;
		line-height: 22px;
		padding: 20px 10px;
	}
	.btn-info {
		padding: 20px;
	}
</style>