<template>
	<view class='center'>
		<view style="background: linear-gradient( 180deg, #1FCA7C 0%, #F2F2F2 100%);">
			<u-navbar :autoBack="true" title="报修详情" placeholder="true" bgColor="transparent" leftIconColor="#FFF"
				:title-style="{color: '#FFF'}">
			</u-navbar>
			<view class="h-300 flex flex-row-between v-center  ml-60 mr-35">
				<view class="flex-column" style="color: #1BB871;">
					<text class="fs-52">分配工单</text>
					<text class="fs-30">今日分配我知道</text>
				</view>
				<image class="h-225 w-225" src="/pagesMain/static/icon_bxxq.png"></image>
			</view>
		</view>

		<view class="overflow-y"
			style="background: white;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;margin-top: -20rpx;">
			<scroll-view scroll-y style="height: 100%;">
				<view class="mar-20">
					<view class="flex-column-center fs-24">
						<image class="w-40 h-40 mr-10" src="/static/icon_gd.png"></image>
						<text style="flex: 1;text-align: left;"
							class="fs-32 fw-700">{{data.communityName+data.room}}</text>
						<text
							:style="{ color: data.state==1?'#FF682D':data.state==2?'#EEA616':data.state==3?'#1FCA7C':'#23BBEE'}">{{data.state==1?'待处理':data.state==2?'待支付':data.state==3?'已完成':data.state==4?'已取消':''}}</text>
					</view>
					<view class="flex-column br-12 fs-28 mt-30" style="background: #EBF5F0;">
						<view class="flex pad-30">
							<text class="fw-700 w-200" style="text-align: left;">业主姓名：</text>
							<text>{{$wskj.isNullStr(data.proprietorName)}}</text>
						</view>
						<view class="flex pad-30">
							<text class="fw-700 w-200" style="text-align: left;">业主房间号</text>
							<text>{{data.room}}</text>
						</view>
						<view class="flex pad-30">
							<text class="fw-700 w-200" style="text-align: left;">业主手机号</text>
							<text>{{data.proprietorPhone}}</text>
						</view>
					</view>
					<view class="flex-column-center fs-32 fw-700 mt-30">
						<image class="w-10 h-40 mr-15" style="background-color: #1FCA7C;"></image>
						<text>报修信息</text>
					</view>
					<view class="flex-column br-12 fs-28 mtb-30 pad-30" style="background: #EBF5F0;">
						<text style="text-align: left;">{{data.repairsDescription}}</text>
					</view>
					<scroll-view scroll-x="true" scroll-with-animation="true">
						<view class="flex">
							<view class="w-140 h-140 mr-15"
								v-for="(itemImg, index2) in $wskj.splitList(data.repairsImg)" :key="index2">
								<image class="w-140 h-140" :src="itemImg"></image>
							</view>
						</view>
					</scroll-view>
					<view class="flex mt-20 h-40 lh-40">
						<text class="fw-700 fs-28">报修时间:</text>
						<text class="fs-24 ml-10">{{data.repairsTime}}</text>
					</view>
					<view v-if="data.state==2||data.state==3" class="flex-column br-12 fs-28 mt-30"
						style="background: #EBF5F0;">
						<view class="flex pad-30">
							<text class="fw-700 w-200" style="text-align: left;">负责人：</text>
							<text>{{data.accountName}}</text>
						</view>
						<view class="flex pad-30">
							<text class="fw-700 w-200" style="text-align: left;">维修费用：</text>
							<text>{{data.money}}元</text>
						</view>
						<view v-if="data.state==3" class="flex pad-30">
							<text class="fw-700 w-200" style="text-align: left;">完成时间：</text>
							<text>{{data.completeTime}}</text>
						</view>

					</view>
					<view v-if="data.state==4" class="flex pad-30 br-12 mt-30" style="background: #EBF5F0;">
						<text class="fw-700 w-200" style="text-align: left;">关闭时间：</text>
						<text>{{data.closeTime}}</text>
					</view>
				</view>
			</scroll-view>
			<u-popup :show="show" mode="center" @close="close" @open="open" round="10">
				<view class="flex-column mlr-50  pb-30" style="width:600rpx;text-align: center;">
					<text class="fs-32 fw-600 mtb-20">设置维修费用</text>
					<input class="br-6 mtb-20 h-100" placeholder="请输入维修费用金额" type="digit"
						style="background: #EBF5F0; border-radius: 20rpx;" v-model="price" />
					<view class="fullscreen-btn" @click="onCz('提交',index)">
						确定
					</view>
				</view>
			</u-popup>
		</view>
		<view class="h-140 pt-20">
			<view @click="onCz('设置费用')" class="full-btn" style="color: #FF682D;" v-if="data.state==1">
				设置费用
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				price: '',
				type: 0,
				reason: '',
				submitShow: false,
				images: '',
				id: '',
				data: {},
			};
		},
		onLoad(e) {
			this.id = e.id
			this.getData()
		},
		methods: {
			open() {
				this.show = true
			},
			close() {
				this.show = false
			},
			getData() {
				const params = {
					url: '/api/repairs/' + this.id,
					method: 'GET',
				}
				this.$request(params).then(res => {
					this.data = res.data
				})
			},

			onCz(e) {
				if (e == "设置费用") {
					this.open();
					return
				}
				if (e == "提交") {
					if (this.price == '') {
						this.$wskj.toast("请设置正确的金额")
						return
					}
					this.setMoney()
					return
				}
			},
			setMoney() {
				const params = {
					url: '/api/repairs/setMoney/' + this.data.repairsId + '/' + this.price,
					method: 'PUT',
				}
				this.$request(params).then(res => {
					this.close()
					this.getData()
				})
			}
		},
	};
</script>

<style scoped>
	.center {
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: white;
	}
</style>