<template>
	<view class="mainBox">
		<uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back" title="需求审核"
			@clickLeft="back">
		</uni-nav-bar>
		<u-cell-group>
			<u-cell title="审核结果" arrow-direction="down">
				<uni-data-picker v-model="examForm.approvalResult" slot="value" placeholder="请选择"
					:localdata="auditResultOptions" @change="handleAuditResultChange">
				</uni-data-picker>
			</u-cell>
			<u-cell title="审核意见" arrow-direction="down">
				<u--textarea slot="value" placeholder="请输入" border="surround"
					v-model="examForm.rejectCause"></u--textarea>
			</u-cell>
			<view class="footerButton">
				<u-button type="default" text="返回" @click="back"></u-button>
				<u-button type="primary" @click="save" text="">确认</u-button>
			</view>
		</u-cell-group>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import {
		auditSalesDemand
	} from '@/api/salesServiceManagement/demandList/index.js'
	export default {
		components: {},
		data() {
			return {
				examForm: {
					approvalResult: '',
					rejectCause: '',
					id: ''
				},
				auditResultOptions: [{
						value: 0,
						text: '驳回'
					},
					{
						value: 1,
						text: '同意'
					}
				],
			}
		},
		onLoad(data) {
			this.examForm.id = data.id;
			console.log(data, '00')
		},
		methods: {
			handleAuditResultChange(e) {
				console.log(e, 'e')
			},
			async save() {
				if (!this.examForm.approvalResult) {
					if (this.examForm.approvalResult != '0') {
						this.$refs.uToast.show({
							type: "warning",
							message: "请选择审核结果",
						})
						return
					}
				}
				const data = uni.getStorageSync('userInfo');
				let pdata = {
					...this.examForm,
					approvalUserId: data.userId,
					approvalUserName: data.name
				};
				console.log(pdata, 'pdata')
				const res = await auditSalesDemand(pdata);
				if (res) {
					this.back()
				}
				// this.back()
			},
		},
	}
</script>

<style lang="scss" scoped>
	/deep/.u-cell__body__content {
		flex: none;
		margin-right: 16rpx;
	}

	.mainBox {
		padding-bottom: 84rpx;
	}

	.footerButton {
		width: 100%;
		height: 84rpx;
		display: flex;
		position: fixed;
		bottom: 0;

		/deep/.u-button {
			height: 100%;
		}

		>view {
			flex: 1;

		}
	}

	// /deep/.u-button {
	// 	height: 100%;
	// }

	/deep/.u-subsection__item__text {
		font-size: 28rpx !important;
	}
</style>