<template>
	<view class="">
		<uni-popup ref="popup" type="share" backgroundColor="#fff">
			<view class="select-container">
				<view class="title">
					<text class="btn cancel" @tap="close">取消</text>
					评价 ★
					<text class="btn confirm" @tap="submit">确定</text>
				</view>
				<uni-forms :modelValue="formData" class="form" label-width='170rpx'>
					<uni-forms-item label="服务态度" name="attitudeRating">
						<uni-rate v-model="formData.attitudeRating" showText />
					</uni-forms-item>
					<uni-forms-item label="响应速度" name="responseSpeed">
						<uni-rate v-model="formData.responseSpeed" showText />
					</uni-forms-item>
					<uni-forms-item label="整体满意度" name="serviceRating">
						<uni-rate v-model="formData.serviceRating" showText />
					</uni-forms-item>
					<uni-forms-item label="评价" name="comment" class="pingjia">
						<textarea class="textarea" type="text" v-model="formData.comment" placeholder="验收意见" />
					</uni-forms-item>
				</uni-forms>
			</view>
			<u-toast ref="uToast"></u-toast>
		</uni-popup>
	</view>
</template>

<script>
	import uniRate from './RatingComponent.vue'
	import {
		evaluateSave
	} from '@/api/salesServiceManagement/workOrder/index.js'
	export default {
		components: {
			uniRate
		},
		data() {
			return {
				acceptShow: false,
				formData: {
					attitudeRating: '',
					responseSpeed: '',
					serviceRating: '',
					comment: '',
					workId: ''
				},
				contactInfoVOS: [],
				stateLiist: [{
						value: 1,
						text: '通过'
					},
					{
						value: 0,
						text: '不通过'
					}
				],
			}
		},
		methods: {
			open(id) {
				this.acceptShow = true;
				this.$refs.popup.open()
				this.formData = {
					attitudeRating: '',
					responseSpeed: '',
					serviceRating: '',
					comment: '',
					workId: id,
				}
				console.log(this.formData, 'fffffm')
			},
			submit() {
				if (!this.formData.attitudeRating) {
					this.$refs.uToast.show({
						type: "warning",
						message: "请选择服务态度",
					})
					return;
				}
				if (!this.formData.responseSpeed) {
					this.$refs.uToast.show({
						type: "warning",
						message: "请选择响应速度",
					})
					return;
				}
				if (!this.formData.serviceRating) {
					this.$refs.uToast.show({
						type: "warning",
						message: "请选择整体满意度",
					})
					return;
				}
				uni.showLoading({
					title: '加载中'
				})
				evaluateSave(this.formData).then((res) => {
					this.$emit('getList');
					this.close();
					uni.hideLoading();
				}).then((err) => {
					uni.hideLoading();
				})
			},
			close() {
				this.$refs.popup.close()
			}
		}
	}
</script>

<style scoped lang="scss">
	.select-container {
		min-height: 50vh;

		.title {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			background-color: $j-primary-border-green;
			font-weight: bold;
			padding: 0 20rpx;
			position: relative;
			font-size: 32rpx;
			color: #fff;

			.btn {
				width: 80rpx;
				height: 32rpx;
				display: inline-block;
				font-size: 30rpx;
				border: 1px solid #fff;
				text-align: center;
				line-height: 30rpx;
				margin: 0;
			}
		}

		.form {
			padding: 20rpx 14rpx 0;
			
			/deep/ .uni-forms-item{
				display: flex;
				align-items: center;
				margin-bottom: 20rpx;
			}

			/deep/ .uni-forms-item__label {
				font-size: 28rpx;
			}
			
			.pingjia{
				align-items: flex-start;
				
				/deep/ .uni-forms-item__label{
					width: 130rpx !important;
				}
			}

			.textarea {
				border: 1px solid #ddd;
			}
		}
	}
</style>