317317 <v-icon start size =" x-small" >mdi-clock-outline</v-icon >
318318 {{ totalClassHours }} 课时
319319 </v-chip >
320+ <v-tooltip v-if =" exportPeriods.length > 0" >
321+ <template v-slot :activator =" { props } " >
322+ <v-chip class =" ml-2" size =" small" color =" info" v-bind =" props" pill >
323+ <v-icon start size =" x-small" >mdi-information-outline</v-icon >
324+ 节次已重排
325+ </v-chip >
326+ </template >
327+ <span >已将选中的节次 {{ exportPeriods.join(', ') }} 重新排序为连续的 1-{{ exportPeriods.length }}</span >
328+ </v-tooltip >
320329 </v-card-title >
321330 <v-card-text >
322331 <!-- 美化日期导航标签 -->
348357 <tbody >
349358 <template v-for =" (group , index ) in groupByPeriod (getDaySchedule (day )) " :key =" index " >
350359 <tr >
351- <td class =" text-center font-weight-bold" >{{ group.period }}</td >
360+ <td class =" text-center font-weight-bold" >
361+ {{ group.period }}
362+ <v-tooltip v-if =" group.originalPeriod !== group.period" >
363+ <template v-slot :activator =" { props } " >
364+ <v-icon size =" x-small" v-bind =" props" color =" info" class =" ml-1" >mdi-sync</v-icon >
365+ </template >
366+ 原节次: {{ group.originalPeriod }}
367+ </v-tooltip >
368+ </td >
352369 <td >
353370 <div v-for =" (item, i) in group.items" :key =" i" class =" mb-1" >
354371 <v-chip size =" small" :color =" getSubjectColor(item.subject)" label text-color =" white" class =" mr-1" >
@@ -625,6 +642,14 @@ export default {
625642 row => this .exportPeriods .includes (row .period )
626643 );
627644
645+ // 创建节次映射 - 将原始节次映射到新的连续节次
646+ const periodMap = {};
647+ selectedRows
648+ .sort ((a , b ) => a .period - b .period )
649+ .forEach ((row , index ) => {
650+ periodMap[row .period ] = index + 1 ; // 重新映射为连续的1,2,3...
651+ });
652+
628653 // 对每个选中的节次和每天的课程进行处理
629654 selectedRows .forEach (row => {
630655 for (let day = 1 ; day <= 7 ; day++ ) {
@@ -640,7 +665,8 @@ export default {
640665 if (! course || ! course .name ) return ;
641666
642667 timeTableData .push ({
643- period: row .period ,
668+ originalPeriod: row .period , // 保留原始节次
669+ period: periodMap[row .period ], // 使用重新计算的节次
644670 subject: course .name ,
645671 day: this .dayNames [day],
646672 startTime: course .startTime ,
@@ -655,7 +681,8 @@ export default {
655681 if (! courses .name ) continue ;
656682
657683 timeTableData .push ({
658- period: row .period ,
684+ originalPeriod: row .period , // 保留原始节次
685+ period: periodMap[row .period ], // 使用重新计算的节次
659686 subject: courses .name ,
660687 day: this .dayNames [day],
661688 startTime: courses .startTime ,
@@ -981,7 +1008,7 @@ export default {
9811008 const teacher = this .settings .hideTeacherName ? " " : (item .teacher || " " );
9821009 const room = this .settings .hideRoom ? " " : (item .room || " " );
9831010
984- // 每节课单独导出
1011+ // 每节课单独导出,使用重新计算的节次
9851012 csvContent += ` ${ item .subject } ,${ dayNumber} ,${ item .period } ,${ item .period } ,${ teacher} ,${ room} ,${ item .weeks } \n ` ;
9861013 }
9871014 }
@@ -1003,7 +1030,7 @@ export default {
10031030 this .success = ` 导出成功!共计 ${ this .totalClassHours } 课时` ;
10041031 },
10051032
1006- // 添加导出数据预览功能
1033+ // 修改showExportPreview方法
10071034 showExportPreview () {
10081035 if (! this .hasExportData ) {
10091036 this .error = " 请先选择要导出的节次" ;
@@ -1015,10 +1042,18 @@ export default {
10151042 ).join (' \n ' );
10161043
10171044 if (this .timeTableData .length > 5 ) {
1018- this .success = ` 导出预览 (共${ this .totalClassHours } 课时):\n ${ previewContent} \n ...等${ this .totalClassHours - 5 } 节 ` ;
1045+ this .success = ` 导出预览 (共${ this .totalClassHours } 课时):\n ${ previewContent} \n ...等${ this .totalClassHours - 5 } 节课程 ` ;
10191046 } else {
10201047 this .success = ` 导出预览 (共${ this .totalClassHours } 课时):\n ${ previewContent} ` ;
10211048 }
1049+
1050+ // 刷新视图,确保节次重排效果显示
1051+ this .$nextTick (() => {
1052+ // 如果当前没有选中天数,自动选择第一个有课程的天数
1053+ if (this .daysWithSchedule .length > 0 && ! this .activeDay ) {
1054+ this .activeDay = this .daysWithSchedule [0 ];
1055+ }
1056+ });
10221057 },
10231058
10241059 // 添加YAML解析相关方法
@@ -1075,6 +1110,14 @@ export default {
10751110 row => this .exportPeriods .includes (row .period )
10761111 );
10771112
1113+ // 创建节次映射
1114+ const periodMap = {};
1115+ selectedRows
1116+ .sort ((a , b ) => a .period - b .period )
1117+ .forEach ((row , index ) => {
1118+ periodMap[row .period ] = index + 1 ;
1119+ });
1120+
10781121 // 对每个选中的节次和每天的课程进行处理
10791122 selectedRows .forEach (row => {
10801123 for (let day = 1 ; day <= 7 ; day++ ) {
@@ -1087,7 +1130,8 @@ export default {
10871130 if (! course || ! course .name ) return ;
10881131
10891132 timeTableData .push ({
1090- period: row .period ,
1133+ originalPeriod: row .period ,
1134+ period: periodMap[row .period ],
10911135 subject: course .name ,
10921136 day: this .dayNames [day],
10931137 startTime: course .startTime ,
@@ -1102,7 +1146,8 @@ export default {
11021146 if (! courses .name ) continue ;
11031147
11041148 timeTableData .push ({
1105- period: row .period ,
1149+ originalPeriod: row .period ,
1150+ period: periodMap[row .period ],
11061151 subject: courses .name ,
11071152 day: this .dayNames [day],
11081153 startTime: courses .startTime ,
@@ -1125,14 +1170,15 @@ export default {
11251170 });
11261171 },
11271172
1128- // 添加按节次分组的方法
1173+ // 修改groupByPeriod方法,添加原始节次信息
11291174 groupByPeriod (daySchedule ) {
11301175 // 按节次分组
11311176 const groups = {};
11321177 daySchedule .forEach (item => {
11331178 if (! groups[item .period ]) {
11341179 groups[item .period ] = {
11351180 period: item .period ,
1181+ originalPeriod: item .originalPeriod , // 保存原始节次
11361182 items: [],
11371183 timeSlots: []
11381184 };
0 commit comments