<!--
 * @Author: zwq
 * @Date: 2025-10-23 13:43:55
 * @LastEditors: zwq
 * @LastEditTime: 2025-10-23 16:50:43
 * @Description:
-->
<template>
	<div class="app-container">
		<div v-for="item in groupClassArr" :key="item.planId">
			<small-title style="margin: 16px 0" size="sm" :no-padding="true">
				{{item.planName}}
			</small-title>
			<base-table
				:table-props="tableProps"
				:table-data="
					tableData.filter((titem) => titem.schedulingPlanId == item.planId)
				"></base-table>
		</div>
	</div>
</template>

<script>
import SmallTitle from '../Schedule/SmallTitle';

const tableProps = [
	{
		prop: 'classesName',
		label: '班次名称',
	},
	{
		prop: 'workTime',
		label: '班次时间',
	},
	{
		prop: 'teamName',
		label: '班组名称',
	},
	{
		prop: 'teamLeader',
		label: '组长',
	},
	{
		prop: 'teamLeaderPhone',
		label: '组长电话',
	},
];

export default {
	components: {
		SmallTitle,
	},
	data() {
		return {
			tableProps,
			tableData: [],
			groupClassArr: [],
		};
	},
	created() {},
	methods: {
		init(det) {
			this.tableData = det;
			//返回计划名和id
			const arr = det.map((item) => {
				const obj = {
					planName: item.schedulingPlanName,
					planId: item.schedulingPlanId,
				};
				return obj;
			});
			//去重
			const map = new Map();
			arr.forEach((item) => {
				if (!map.has(item.planId)) {
					map.set(item.planId, item);
				}
			});
			this.groupClassArr = Array.from(map.values());
		},
	},
};
</script>
