<template>
	<view class="job-list" style="background-image: url('../../../packageRc/static/pageBg.png');position:relative;">
		<view class="job-list__content">

			<scroll-view class="job-list__scroll" scroll-y="true">
				<view class="job-list__item" v-for="job in perlist" :key="job.id" @tap="toDetails(job)">
					<view class="job-list__item-detail">
						<text>经办人:</text>
						<text>{{ job.agentUserName || '-' }}</text>
					</view>
					<view class="job-list__item-detail">
						<text>经办时间:</text>
						<text>{{ job.practicalSolutionTime }}</text>
					</view>
					<view class="job-list__item-detail">
						<text>经办部门:</text>
						<text>{{ job.agentDeptName }}</text>
					</view>
					<view class="job-list__item-detail">
						<text>说明:</text>
						<text>{{ job.blqksm  || '--'}}</text>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		serviceTraceability
	} from '@/apiRc/company/index.js';

	export default {
		name: 'personnelList',
		computed: {
			filterColor() {
				return (status) => {
					const item = this.alertTibs.find(item => item.value === status);
					return item ? item.color : '';
				}
			}
		},
		data() {
			return {
				openDeal: false,
				showTime: false,
				validType: [{
						label: '是',
						value: '1'
					},
					{
						label: '否',
						value: '0'
					},
				],
				alertTibs: [{
						value: '1',
						label: '已超期',
						color: '#ea362b'
					},
					{
						value: '2',
						label: '七天之内',
						color: '#f1a945'
					},
					{
						value: '3',
						label: '大于七天',
						color: '#377e27'
					},
					{
						value: '0',
						label: '已完成服务',
						color: '#808080'
					}

				],
				total: 0,
				// 去除加载更多相关的状态和方法
				// status: 'more',
				// loadMoreJobs: function() {},
				hopeSolveDate: '',
				searchKeyword: '',
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					id: undefined,
					demandType: '',
				},
				perlist: [],
				loading: false,

				formData: {},

			};
		},
		onLoad({
			id,
			demandType
		}) {
			this.queryParams.id = id
			this.queryParams.demandType = demandType
			this.getList(true);
		},
		methods: {
			// 获取列表
			async getList(reset = false) {
				if (this.loading) return;
				this.loading = true;

				// 重置数据
				if (reset) {
					this.perlist = [];
					this.queryParams.pageNum = 1;
				}
				const {
					code,
					data,
					total
				} = await serviceTraceability(this.queryParams)
				if (code === 200) {
					this.perlist = data; // 直接赋值获取到的数据，不再进行拼接
					this.total = total;
				}
				this.loading = false;
			},
			// 搜索功能处理
			handleSearch() {
				this.getList(true);
			},

			// 根据 value 查找 label
			getLabelByValue(list, value) {
				const found = list.find(item => item.value === value);
				return found ? found.label : '-';
			},
			getDictLabel(list, dictValue) {
				let arr = list.filter((ele) => ele.dictValue == dictValue);
				if (arr.length) {
					return arr[0].dictLabel;
				} else {
					return "--";
				}
			},


			toDetails({
				businessType,
				id
			}) {
				// 定义一个映射对象，将 businessType 映射到相应的页面路径和参数
				const navigationMap = {
					interview: {
						path: '/pages/services/serviceDetail',
						params: `?id=${id}&type=1&showTab=1`
					},
					assist: {
						path: '/pages/needs/needDetail',
						params: `?id=${id}&type=2&showTab=1`
					},
					entrepreneurship: {
						path: '/pages/needs/needDetail',
						params: `?id=${id}&type=3&showTab=1`
					},
					jobDemand: {
						path: '/pages/needs/needDetail',
						params: `?id=${id}&type=1&showTab=1&showInfo=1`
					},
					jobRecommendation: {
						path: '/pages/services/serviceDetail',
						params: `?id=${id}&type=3&showTab=1&showInfo=1`
					},
					otherNeeds: {
						path: '/pages/needs/needDetail',
						params: `?id=${id}&type=5&showTab=1`
					},
					policy: {
						path: '/pages/services/serviceDetail',
						params: `?id=${id}&type=2&showTab=1`
					},
					trainingNeeds: {
						path: '/pages/needs/needDetail',
						params: `?id=${id}&type=4&showTab=1`
					},
					trainingService: {
						path: '/pages/needs/needDetail',
						params: `?id=${id}&type=4&showTab=1`
					}
				};

				// // 检查 businessType 是否存在于映射中
				// if (businessType in navigationMap) {
				// 	const {
				// 		path,
				// 		params
				// 	} = navigationMap[businessType];
				// 	this.$tab.navigateTo(`${path}${params}`);
				// } else {
				// 	// 如果 businessType 不匹配任何已知的类型，可以这里处理错误或忽略
				// 	console.warn(`Unknown businessType: ${businessType}`);
				// }
			}
		},
	};
</script>

<style lang="scss" scoped>
	.job-list {

		background-color: #f4f4f4 !important;
		height: 100vh;
		background-repeat: no-repeat;
		background-size: 100% auto;
		padding: 32rpx;

		&__content {
			position: relative;
			padding: 32rpx;
			z-index: 10;
			background-color: #fff;
			border-radius: 32rpx 32rpx 0 0;
			border: 1px solid #fff;
			width: calc(100% - 64rpx);
		}

		&__scroll {
			margin-top: 10rpx;
			height: calc(100vh - 200rpx);
		}

		&__item {
			position: relative;
			padding: 32rpx;
			margin-bottom: 32rpx;
			background-color: #d0dcee;
			border-radius: 16rpx;
			font-size: 28rpx;
		}

		&__item-detail {
			margin-top: 20rpx;
			color: #8e8e8e;

			&>text:nth-child(1) {
				width: 200rpx;
			}

			view,
			text:last-child {
				margin-left: 10rpx;
				color: #333;
			}
		}

		.items {
			margin-top: 30rpx;
		}

		.post_job_btn {
			position: fixed;
			bottom: 120rpx;
			right: 16rpx;
			width: 150rpx;
			height: 150rpx;
			border-radius: 50%;
			z-index: 20;
			background: url('https://rc.jinan.gov.cn/qcwjyH5/static/images/addPersonnel.png') no-repeat;
			background-size: 100% 100%;
		}

		.dialog_form {
			padding: 30rpx;
			width: 80vw;

			.tadio {
				height: 100rpx;
			}

			.btn {
				margin-top: 100rpx;
			}
		}
	}
</style>
