<template>
	<popup title="需求详情" @close="handleClose">
		<template v-slot:cnt>
			<div class="m-info" v-if="detailType == '政府支撑'">
				<el-row>
					<el-col :span="12">
						<div class="subtitle">
							<i class="i-chunk"></i>
							事件详情
							<i class="i-line"></i>
						</div>
						<div class="row">
							<div class="item">
								<div class="field">项目标题：</div>
								<div class="value">{{ info.title }}</div>
							</div>
						</div>
						<div class="row">
							<div class="item">
								<div class="field">项目方案：</div>
								<div class="value">{{ info.content }}</div>
							</div>
						</div>
						<div class="row">
							<div class="item">
								<div class="field">内部备注：</div>
								<div class="value">{{ info.remark }}</div>
							</div>
						</div>
						<div class="row">
							<div class="item">
								<div class="field">当前处理部门：</div>
								<div class="value">{{ info.department }}</div>
							</div>
						</div>
						<div class="row">
							<div class="item">
								<div class="field">分类：</div>
								<div class="value">{{ info.class }}{{ info.sub_class }}</div>
							</div>
						</div>
						<div class="row">
							<div class="item">
								<div class="field">标签：</div>
								<div class="value">{{ info.label }}</div>
							</div>
						</div>
						<div class="row">
							<div class="item">
								<div class="field">操作：</div>
								<!-- <div class="value">{{ info.report_user_mobile }}</div> -->
							</div>
						</div>
					</el-col>
					<el-col :span="12">
						<div class="subtitle">
							<i class="i-chunk"></i>
							处理进展
							<i class="i-line"></i>
						</div>
						<el-timeline class="timeline">
							<el-timeline-item v-for="(item, index) in progress" :key="index" :class="index == progress.length - 1 ? 'sucess' : ''">
								<div class="status-box">
									<div class="status2" v-if="index == progress.length - 1">{{ item.type }}</div>
									<div class="status1" v-else>{{ item.type }}</div>
									<div class="timestamp">{{ item.date }}</div>
								</div>
								<div class="content">
									<div class="field">处理部门：</div>
									<div class="value">{{ item.department }}</div>
								</div>
								<div class="content">
									<div class="field">说明：</div>
									<div class="value">{{ item.remark }}</div>
								</div>
							</el-timeline-item>
						</el-timeline>
					</el-col>
				</el-row>
			</div>
			<div class="m-info" v-if="detailType == '服务支撑' || detailType == '商家支撑'">
				<div class="row">
					<div class="item">
						<div class="field">所属网格：</div>
						<div class="value">{{ info.grid }}</div>
					</div>
					<div class="item">
						<div class="field">需求类型：</div>
						<div class="value">{{ info.parent_category }} {{ info.category }}</div>
					</div>
					<div class="item">
						<div class="field">上报类型：</div>
						<div class="value">{{ info.report_type }}</div>
					</div>
					<div class="item">
						<div class="field">上报人：</div>
						<div class="value">{{ info.report_user_name }}</div>
					</div>
					<div class="item">
						<div class="field">上报时间：</div>
						<div class="value">{{ info.report_time }}</div>
					</div>
					<div class="item">
						<div class="field">上报人联系电话：</div>
						<div class="value">{{ info.report_user_mobile }}</div>
					</div>
				</div>

				<div class="row">
					<div class="item">
						<div class="field">需求人：</div>
						<div class="value">{{ info.demand_user_name }}</div>
					</div>
					<div class="item">
						<div class="field">服务时间：</div>
						<div class="value">{{ info.want_service_time }}</div>
					</div>
					<div class="item">
						<div class="field">需求内容：</div>
						<div class="value">{{ info.content }}</div>
					</div>
				</div>

				<div class="row">
					<div class="item">
						<div class="field">服务方：</div>
						<div class="value">{{ info.server_name }}</div>
					</div>
					<div class="item">
						<div class="field">实际服务时间：</div>
						<div class="value">{{ info.service_start_time }}{{ info.service_end_time }}</div>
					</div>
					<div class="item">
						<div class="field">完成情况：</div>
						<div class="value">{{ info.finish_result }}</div>
					</div>
					<div class="item">
						<div class="field">评价：</div>
						<div class="value">{{ info.score }}</div>
					</div>
				</div>
			</div>
			<div class="m-info" v-else>
				<div class="row">
					<div class="item">
						<div class="field">需求类别：</div>
						<div class="value">{{ info.parent_type_name }} {{ info.child_type_name }}</div>
					</div>
					<div class="item">
						<div class="field">需求标题 ：</div>
						<div class="value">{{ info.title }}</div>
					</div>
					<div class="item" style="width: 100%;">
						<div class="field">详细说明：</div>
						<div class="value">{{ info.content }}</div>
					</div>
					<div class="item">
						<div class="field">查找有该需求人员 ：</div>
						<div class="value">{{ info.resi_search_tag_name }}</div>
					</div>
					<div class="item">
						<div class="field">服务方 ：</div>
						<div class="value">{{ info.service_name }}</div>
					</div>
					<div class="item">
						<div class="field">服务范围 ：</div>
						<div class="value">{{ info.scope_name }}</div>
					</div>
					<div class="item">
						<div class="field">服务时间：</div>
						<div class="value">{{ info.start_service_time }}至{{ info.end_service_time }}</div>
					</div>
				</div>
			</div>
		</template>
	</popup>
</template>

<script>
import popup from '@/views/dataBoard/cpts/popup';
import { requestPostBi } from '@/js/dai/request-bipass';

export default {
	name: 'needDetails',
	props: {
		detailId: {
			type: String,
			default: ''
		},
		detailType: {
			type: String,
			default: ''
		}
	},

	components: { popup },
	created() {},
	data() {
		return {
			progress: [],
			info: {}
		};
	},

	mounted() {
		this.getApiData();
	},

	methods: {
		handleClose() {
			this.$emit('close');
		},

		async getApiData() {
			this.getInfo();
		},

		// 根据房屋id获取详情
		async getInfo() {
			let url = '';
			if (this.detailType == '政府支撑') {
				url = 'gov_support';
			} else if (this.detailType == '服务支撑') {
				url = 'service_support';
			} else if (this.detailType == '商家支撑') {
				url = 'busi_support';
			} else {
				url = 'common_support';
			}

			const { data, code, msg } = await requestPostBi(
				url,
				{
					queryParam: {
						need_id: this.detailId
					}
				},
				{
					// mockId: 60235478,
				}
			);
			if (code === 0) {
				this.info = { ...this.info, ...data[0] };
				if (this.detailType == '政府支撑') {
					this.progress = this.info.progress;
				}
				console.log('this.info', this.info);
			} else {
				this.$message.error(msg);
			}
		}
	}
};
</script>
<style scoped>
.m-info .row .item .field {
	width: 140px !important;
}
</style>
<style lang="scss" src="@/assets/scss/dataBoard/popup-info.scss" scoped></style>
