1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2026-03-21 09:13:10 +00:00
Classworks/assets/cses2wakeup-CtQswMYs.js

8 lines
32 KiB
JavaScript

import{E as Oe,_ as Ye,e as L,c as G,f as D,F as He,d as O,G as Je,h as A,l as qe,g as Ge}from"./index-C305lth9.js";import{V as ie,a as M}from"./VRow-BQOh1CLA.js";import{V as I}from"./VAlert-CWWQx2wA.js";import{V as oe,a as Z}from"./VTabs-Dgx9Ksgk.js";import{a as K,V as ne}from"./VTooltip-i51F1dF1.js";import{c as de,d as X,b as Ze}from"./VTable-CsPj98NG.js";import{V as Ke}from"./VTextarea-6rLGvsne.js";import{u as Xe,a as ue,b as ce,c as Qe,m as $e,d as et,V as tt}from"./VTextField-0hAB9hej.js";import{p as ye,f as st,an as lt,n as rt,w as be,u as at,ao as it,ap as ot,aq as me,a5 as nt}from"./vendor-vuetify-DYDJMXkZ.js";import{e as N,o as dt,j as o,k as p,F as T,m as z,n as ut,b as Q,t as ct,I as mt,s as ft,X as m,Y as v,Z as i,a1 as c,S as y,$ as k,_ as b,a2 as C,ac as pt}from"./vendor-vue-PFj_oO9L.js";import{V as j,a as ht}from"./VChip-BAz4LI6s.js";import{V as fe}from"./VSwitch-G7IB1xuY.js";import{V as yt}from"./VSkeletonLoader-CtQHOFGP.js";import{V as bt}from"./VDataTable-LCSdqA8Q.js";import{V as gt}from"./VCheckbox-VmVYHMG6.js";import{V as kt}from"./VContainer-DopeAmBG.js";import"./VPagination-DtF5C3cQ.js";import"./VSelect-CY8W2KzJ.js";import"./VSheet-HyWrdTUo.js";import"./VCheckboxBtn-CeMEzWtF.js";function vt(){function s(n){var t,r;return[...((t=n.dataTransfer)==null?void 0:t.items)??[]].filter(l=>l.kind==="file").map(l=>l.webkitGetAsEntry()).filter(Boolean).length>0||[...((r=n.dataTransfer)==null?void 0:r.files)??[]].length>0}async function e(n){var r,l;const a=[],t=[...((r=n.dataTransfer)==null?void 0:r.items)??[]].filter(d=>d.kind==="file").map(d=>d.webkitGetAsEntry()).filter(Boolean);if(t.length)for(const d of t){const f=await ge(d,ke(".",d));a.push(...f.map(h=>h.file))}else a.push(...((l=n.dataTransfer)==null?void 0:l.files)??[]);return a}return{handleDrop:e,hasFilesOrFolders:s}}function ge(s){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return new Promise((n,a)=>{s.isFile?s.file(r=>n([{file:r,path:e}]),a):s.isDirectory&&s.createReader().readEntries(async r=>{const l=[];for(const d of r)l.push(...await ge(d,ke(e,d)));n(l)})})}function ke(s,e){return e.isDirectory?`${s}/${e.name}`:s}const Tt=ye({filterByType:String},"file-accept");function wt(s){const e=N(()=>s.filterByType?Dt(s.filterByType):null);function n(a){if(e.value){const t=a.filter(e.value);return{accepted:t,rejected:a.filter(r=>!t.includes(r))}}return{accepted:a,rejected:[]}}return{filterAccepted:n}}function Dt(s){const e=s.split(",").map(r=>r.trim().toLowerCase()),n=e.filter(r=>r.startsWith(".")),a=e.filter(r=>r.endsWith("/*")),t=e.filter(r=>!n.includes(r)&&!a.includes(r));return r=>{var f,h;const l=((f=r.name.split(".").at(-1))==null?void 0:f.toLowerCase())??"",d=((h=r.type.split("/").at(0))==null?void 0:h.toLowerCase())??"";return t.includes(r.type)||n.includes(`.${l}`)||a.includes(`${d}/*`)}}const xt=ye({chips:Boolean,counter:Boolean,counterSizeString:{type:String,default:"$vuetify.fileInput.counterSize"},counterString:{type:String,default:"$vuetify.fileInput.counter"},hideInput:Boolean,multiple:Boolean,showSize:{type:[Boolean,Number,String],default:!1,validator:s=>typeof s=="boolean"||[1e3,1024].includes(Number(s))},truncateLength:{type:[Number,String],default:22},...nt(et({prependIcon:"$file"}),["direction"]),modelValue:{type:[Array,Object],default:s=>s.multiple?[]:null,validator:s=>be(s).every(e=>e!=null&&typeof e=="object")},...Tt(),...$e({clearable:!0})},"VFileInput"),Vt=st()({name:"VFileInput",inheritAttrs:!1,props:xt(),emits:{"click:control":s=>!0,"mousedown:control":s=>!0,"update:focused":s=>!0,"update:modelValue":s=>!0,rejected:s=>!0},setup(s,e){let{attrs:n,emit:a,slots:t}=e;const{t:r}=lt(),{filterAccepted:l}=wt(s),d=rt(s,"modelValue",s.modelValue,u=>be(u),u=>!s.multiple&&Array.isArray(u)?u[0]:u),{isFocused:f,focus:h,blur:w}=Xe(s),x=N(()=>typeof s.showSize!="boolean"?s.showSize:void 0),W=N(()=>(d.value??[]).reduce((u,g)=>{let{size:E=0}=g;return u+E},0)),P=N(()=>me(W.value,x.value)),S=N(()=>(d.value??[]).map(u=>{const{name:g="",size:E=0}=u,F=je(g);return s.showSize?`${F} (${me(E,x.value)})`:F})),ve=N(()=>{var g;const u=((g=d.value)==null?void 0:g.length)??0;return s.showSize?r(s.counterSizeString,u,P.value):r(s.counterString,u)}),$=Q(),ee=Q(),V=Q(),Te=ct(()=>f.value||s.active),te=N(()=>["plain","underlined"].includes(s.variant)),_=ft(!1),{handleDrop:we,hasFilesOrFolders:De}=vt();function Y(){var u;V.value!==document.activeElement&&((u=V.value)==null||u.focus()),f.value||h()}function xe(u){var g;(g=V.value)==null||g.click()}function Ve(u){a("mousedown:control",u)}function Ce(u){var g;(g=V.value)==null||g.click(),a("click:control",u)}function Se(u){u.stopPropagation(),Y(),mt(()=>{d.value=[],ot(s["onClick:clear"],u)})}function je(u){if(u.length<Number(s.truncateLength))return u;const g=Math.floor((Number(s.truncateLength)-1)/2);return`${u.slice(0,g)}${u.slice(u.length-g)}`}function Ae(u){u.preventDefault(),u.stopImmediatePropagation(),_.value=!0}function Pe(u){u.preventDefault(),_.value=!1}async function Ee(u){if(u.preventDefault(),u.stopImmediatePropagation(),_.value=!1,!V.value||!De(u))return;const g=await we(u);se(g)}function Fe(u){if(!(!u.target||u.repack))if(s.filterByType)se([...u.target.files]);else{const g=u.target;d.value=[...g.files??[]]}}function se(u){const g=new DataTransfer,{accepted:E,rejected:F}=l(u);F.length&&a("rejected",F);for(const J of E)g.items.add(J);V.value.files=g.files,d.value=[...g.files];const H=new Event("change",{bubbles:!0});H.repack=!0,V.value.dispatchEvent(H)}return dt(d,u=>{(!Array.isArray(u)||!u.length)&&V.value&&(V.value.value="")}),at(()=>{const u=!!(t.counter||s.counter),g=!!(u||t.details),[E,F]=it(n),{modelValue:H,...J}=ue.filterProps(s),Re={...ce.filterProps(s),"onClick:clear":Se},Ne=n.webkitdirectory!==void 0&&n.webkitdirectory!==!1,Le=n.accept?String(n.accept):void 0,Me=Ne?void 0:s.filterByType??Le;return o(ue,z({ref:$,modelValue:s.multiple?d.value:d.value[0],class:["v-file-input",{"v-file-input--chips":!!s.chips,"v-file-input--dragging":_.value,"v-file-input--hide":s.hideInput,"v-input--plain-underlined":te.value},s.class],style:s.style,"onClick:prepend":xe},E,J,{centerAffix:!te.value,focused:f.value}),{...t,default:q=>{let{id:U,isDisabled:B,isDirty:le,isReadonly:re,isValid:We,hasDetails:Be}=q;return o(ce,z({ref:ee,prependIcon:s.prependIcon,onMousedown:Ve,onClick:Ce,"onClick:prependInner":s["onClick:prependInner"],"onClick:appendInner":s["onClick:appendInner"]},Re,{id:U.value,active:Te.value||le.value,dirty:le.value||s.dirty,disabled:B.value,focused:f.value,details:Be.value,error:We.value===!1,onDragover:Ae,onDrop:Ee}),{...t,default:Ie=>{var ae;let{props:{class:ze,..._e},controlRef:Ue}=Ie;return p(T,null,[p("input",z({ref:R=>V.value=Ue.value=R,type:"file",accept:Me,readonly:re.value,disabled:B.value,multiple:s.multiple,name:s.name,onClick:R=>{R.stopPropagation(),re.value&&R.preventDefault(),Y()},onChange:Fe,onDragleave:Pe,onFocus:Y,onBlur:w},_e,F),null),p("div",{class:ut(ze)},[!!((ae=d.value)!=null&&ae.length)&&!s.hideInput&&(t.selection?t.selection({fileNames:S.value,totalBytes:W.value,totalBytesReadable:P.value}):s.chips?S.value.map(R=>o(j,{key:R,size:"small",text:R},null)):S.value.join(", "))])])}})},details:g?q=>{var U,B;return p(T,null,[(U=t.details)==null?void 0:U.call(t,q),u&&p(T,null,[p("span",null,null),o(Qe,{active:!!((B=d.value)!=null&&B.length),value:ve.value,disabled:s.disabled},t.counter)])])}:void 0})}),Oe({},$,ee,V)}}),pe=()=>new Promise((s,e)=>{if(typeof window.jsyaml<"u")return s(window.jsyaml);const n=document.createElement("script");n.src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min.js",n.async=!0,n.onload=()=>s(window.jsyaml),n.onerror=()=>e(new Error("无法加载YAML解析库")),document.head.appendChild(n)});class he{constructor(e){this.data=e,this.version=null,this.subjects=[],this.schedules=[],this._parseData()}_parseData(){if(!this.data)return;this.version=this.data.version||1;const e=this.data.subjects||[];for(const a of e)this.subjects.push({name:a.name,simplified_name:a.simplified_name||null,teacher:a.teacher||null,room:a.room||null});const n=this.data.schedules||[];for(const a of n){const t=[];for(const r of a.classes||[])t.push({subject:r.subject,start_time:r.start_time,end_time:r.end_time});this.schedules.push({name:a.name,enable_day:a.enable_day,weeks:a.weeks||"all",classes:t})}}getSubjects(){return this.subjects}getSchedules(){return this.schedules}getScheduleByDay(e){const n=this.schedules.find(a=>a.enable_day===e);return n?n.classes:[]}toCsesData(){return{version:this.version,subjects:this.subjects,schedules:this.schedules}}}const Ct={name:"Cses2Wakeup",data(){return{activeTab:"text",file:null,jsonText:"",loading:!1,error:"",success:"",processedData:null,selectedRows:[],exportPeriods:[],selectedDays:[1,2,3,4,5,6,7],formatMode:"auto",yamlLibLoaded:!1,activeDay:null,subjectColors:{数学:"blue",语文:"red",英语:"green",物理:"purple",化学:"orange",生物:"teal",历史:"brown",地理:"indigo",政治:"pink",体育:"cyan",自习:"grey",早读:"amber",班会:"deep-purple",听力:"light-blue",信息技术:"light-green"},settings:{hideTeacherName:!1,hideRoom:!1,totalWeeks:30},tableHeaders:[{title:"",key:"data-table-select"},{title:"节次",key:"period"},{title:"周一",key:"1"},{title:"周二",key:"2"},{title:"周三",key:"3"},{title:"周四",key:"4"},{title:"周五",key:"5"},{title:"周六",key:"6"},{title:"周日",key:"7"}],timeTableHeaders:[{title:"节次",key:"period"},{title:"课程",key:"subject"},{title:"星期",key:"day"},{title:"开始时间",key:"startTime"},{title:"结束时间",key:"endTime"},{title:"教师",key:"teacher"},{title:"教室",key:"room"},{title:"周次",key:"weeks"}],dayNames:{1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",7:"周日"}}},computed:{timeTableData(){if(!this.processedData||!this.processedData.tableData)return[];const s=[],e=this.processedData.tableData.filter(a=>this.exportPeriods.includes(a.period)),n={};return e.sort((a,t)=>a.period-t.period).forEach((a,t)=>{n[a.period]=t+1}),e.forEach(a=>{for(let t=1;t<=7;t++){if(!this.selectedDays.includes(t))continue;const r=a[t];if(r)if(Array.isArray(r))r.forEach(l=>{!l||!l.name||s.push({originalPeriod:a.period,period:n[a.period],subject:l.name,day:this.dayNames[t],startTime:l.startTime,endTime:l.endTime,teacher:this.settings.hideTeacherName?"":l.teacher||"",room:this.settings.hideRoom?"":l.room||"",weeks:l.weekType?`1-${this.settings.totalWeeks}${l.weekType}`:`1-${this.settings.totalWeeks}`})});else{if(!r.name)continue;s.push({originalPeriod:a.period,period:n[a.period],subject:r.name,day:this.dayNames[t],startTime:r.startTime,endTime:r.endTime,teacher:this.settings.hideTeacherName?"":r.teacher||"",room:this.settings.hideRoom?"":r.room||"",weeks:r.weekType?`1-${this.settings.totalWeeks}${r.weekType}`:`1-${this.settings.totalWeeks}`})}}}),s.sort((a,t)=>{if(a.period!==t.period)return a.period-t.period;const r={周一:1,周二:2,周三:3,周四:4,周五:5,周六:6,周日:7};return r[a.day]-r[t.day]})},hasExportData(){return this.processedData&&this.exportPeriods.length>0},totalClassHours(){return this.timeTableData.length},daysWithSchedule(){const s=[];for(let e=1;e<=7;e++)this.selectedDays.includes(e)&&this.getDaySchedule(e).length>0&&s.push(e);return s}},methods:{async handleFileChange(){if(this.resetData(),!this.file)return;const s=this.file.name.toLowerCase();if(s.endsWith(".json")||s.endsWith(".js"))this.formatMode="json";else if((s.endsWith(".yml")||s.endsWith(".yaml"))&&(this.formatMode="yaml",!this.yamlLibLoaded))try{await pe(),this.yamlLibLoaded=!0}catch(e){this.error=`无法加载YAML解析库: ${e.message}`;return}try{const e=new FileReader;e.onload=async n=>{try{this.jsonText=n.target.result,await this.processInput()}catch(a){this.error=`文件读取失败: ${a.message}`}},e.onerror=()=>{this.error="文件读取失败"},e.readAsText(this.file)}catch(e){this.error=`文件处理失败: ${e.message}`}},handleTextChange(){this.resetData()},resetData(){this.error="",this.success="",this.processedData=null,this.selectedRows=[],this.exportPeriods=[]},async processInput(){if(!this.jsonText&&!this.file){this.error="请粘贴文本或上传文件";return}this.loading=!0,this.error="",this.success="";try{await this.$nextTick();let s;try{if(this.formatMode==="yaml"||this.formatMode==="auto"&&this.isYaml(this.jsonText)){const n=this.parseYaml(this.jsonText);s=new he(n).toCsesData()}else s=JSON.parse(this.jsonText)}catch(n){throw new Error(`格式解析错误: ${n.message}`)}if(!this.validateCsesFormat(s))throw new Error("不是有效的CSES格式数据");const e=this.processCsesData(s);this.processedData=e,this.selectedDays=[1,2,3,4,5],this.success="数据处理成功!",e.tableData&&e.tableData.length>0&&(this.selectedRows=[...e.tableData],this.exportPeriods=e.tableData.map(n=>n.period))}catch(s){this.error="数据处理失败:"+s.message,console.error(s)}finally{this.loading=!1}},validateCsesFormat(s){return s instanceof he?s.version===1&&Array.isArray(s.subjects)&&Array.isArray(s.schedules):!(!s||typeof s!="object"||s.version!==1||!Array.isArray(s.subjects)||!Array.isArray(s.schedules))},processCsesData(s){const{schedules:e,subjects:n}=s,a=Object.fromEntries(n.map(l=>[l.name,l])),t=[];let r=0;e.forEach(l=>{l.classes&&l.classes.length>r&&(r=l.classes.length)});for(let l=1;l<=r;l++)t.push({period:l,1:null,2:null,3:null,4:null,5:null,6:null,7:null});return e.forEach(l=>{const d=l.enable_day;if(!d||d<1||d>7)return;let f="";l.weeks==="odd"?f="单":l.weeks==="even"&&(f="双"),l.classes.forEach((h,w)=>{if(!h.subject)return;const x=w+1;if(x>r)return;const W=a[h.subject]||{},P={name:h.subject,teacher:W.teacher||"",room:W.room||"",period:x,startTime:h.start_time,endTime:h.end_time,day:d,weekType:f},S=t[x-1][d];S?f&&S.weekType&&f!==S.weekType?(Array.isArray(t[x-1][d])||(t[x-1][d]=[S]),t[x-1][d].push(P)):f===S.weekType?t[x-1][d]=P:f||(t[x-1][d]=P):t[x-1][d]=P})}),{tableData:t,originalData:s}},updateSelectedPeriods(s){this.exportPeriods=[],s&&s.length>0&&(this.exportPeriods=[...new Set(s.filter(e=>e&&typeof e.period=="number").map(e=>e.period))])},getTimeTableData(){return this.timeTableData},downloadCSV(){var t;if(!((t=this.processedData)!=null&&t.tableData)){this.error="没有可下载的数据";return}if(this.exportPeriods.length===0){this.error="请至少选择一节要导出的课";return}if(this.daysWithSchedule.length===0||this.totalClassHours===0){this.error="没有课程数据可导出";return}let s=`课程名称,星期,开始节数,结束节数,老师,地点,周数
`;for(const r of this.daysWithSchedule){const l=this.groupByPeriod(this.getDaySchedule(r));for(const d of l)for(const f of d.items){const h={周一:1,周二:2,周三:3,周四:4,周五:5,周六:6,周日:7}[f.day],w=this.settings.hideTeacherName?"":f.teacher||"",x=this.settings.hideRoom?"":f.room||"";s+=`${f.subject},${h},${f.period},${f.period},${w},${x},${f.weeks}
`}}const e="\uFEFF",n=new Blob([e+s],{type:"text/csv;charset=utf-8"}),a=document.createElement("a");a.href=URL.createObjectURL(n),a.download=`course_schedule_${this.totalClassHours}课时.csv`,a.click(),URL.revokeObjectURL(a.href),this.success=`导出成功!共计 ${this.totalClassHours} 课时`},showExportPreview(){if(!this.hasExportData){this.error="请先选择要导出的节次";return}const s=this.timeTableData.slice(0,5).map(e=>`${e.subject} (${e.day}${e.period}节)`).join(`
`);this.timeTableData.length>5?this.success=`导出预览 (共${this.totalClassHours}课时):
${s}
...等${this.totalClassHours-5}节课程`:this.success=`导出预览 (共${this.totalClassHours}课时):
${s}`,this.$nextTick(()=>{this.daysWithSchedule.length>0&&!this.activeDay&&(this.activeDay=this.daysWithSchedule[0])})},isYaml(s){const e=s.trim();if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e),!1}catch{}return/^\s*[a-zA-Z0-9_-]+\s*:/.test(e)||/\n\s*[a-zA-Z0-9_-]+\s*:/.test(e)},parseYaml(s){try{if(typeof window.jsyaml<"u")return window.jsyaml.load(s);throw new Error("YAML解析器未加载")}catch(e){throw new Error(`YAML解析错误: ${e.message}`)}},getDaySchedule(s){return this.timeTableData?this.getUnfilteredTimeTableData().filter(n=>({周一:1,周二:2,周三:3,周四:4,周五:5,周六:6,周日:7})[n.day]===s):[]},getUnfilteredTimeTableData(){if(!this.processedData||!this.processedData.tableData)return[];const s=[],e=this.processedData.tableData.filter(a=>this.exportPeriods.includes(a.period)),n={};return e.sort((a,t)=>a.period-t.period).forEach((a,t)=>{n[a.period]=t+1}),e.forEach(a=>{for(let t=1;t<=7;t++){const r=a[t];if(r)if(Array.isArray(r))r.forEach(l=>{!l||!l.name||s.push({originalPeriod:a.period,period:n[a.period],subject:l.name,day:this.dayNames[t],startTime:l.startTime,endTime:l.endTime,teacher:this.settings.hideTeacherName?"":l.teacher||"",room:this.settings.hideRoom?"":l.room||"",weeks:l.weekType?`1-${this.settings.totalWeeks}${l.weekType}`:`1-${this.settings.totalWeeks}`})});else{if(!r.name)continue;s.push({originalPeriod:a.period,period:n[a.period],subject:r.name,day:this.dayNames[t],startTime:r.startTime,endTime:r.endTime,teacher:this.settings.hideTeacherName?"":r.teacher||"",room:this.settings.hideRoom?"":r.room||"",weeks:r.weekType?`1-${this.settings.totalWeeks}${r.weekType}`:`1-${this.settings.totalWeeks}`})}}}),s.sort((a,t)=>{if(a.period!==t.period)return a.period-t.period;const r={周一:1,周二:2,周三:3,周四:4,周五:5,周六:6,周日:7};return r[a.day]-r[t.day]})},groupByPeriod(s){const e={};return s.forEach(n=>{e[n.period]||(e[n.period]={period:n.period,originalPeriod:n.originalPeriod,items:[],timeSlots:[]}),e[n.period].items.push(n),e[n.period].timeSlots.push({startTime:n.startTime,endTime:n.endTime})}),Object.values(e).forEach(n=>{n.uniqueTimeSlots=[],n.timeSlots.forEach(a=>{n.uniqueTimeSlots.some(t=>t.startTime===a.startTime&&t.endTime===a.endTime)||n.uniqueTimeSlots.push(a)}),n.uniqueTimeSlots.sort((a,t)=>a.startTime.localeCompare(t.startTime))}),Object.values(e).sort((n,a)=>n.period-a.period)},formatTime(s){return s?s.substring(0,5):""},getSubjectColor(s){return this.subjectColors[s]||"grey"},selectAllDays(){this.selectedDays=[1,2,3,4,5,6,7]},clearSelectedDays(){this.selectedDays=[]}},async mounted(){try{await pe(),this.yamlLibLoaded=!0}catch(s){this.error=s.message}this.$watch("daysWithSchedule",s=>{s.length>0&&!this.activeDay&&(this.activeDay=s[0])})}},St={class:"d-flex align-center"},jt={class:"d-flex align-center"},At={key:2,class:"text-caption mb-2"},Pt={class:"d-flex align-center mb-2"},Et={class:"d-flex align-center mb-3"},Ft={class:"d-flex align-center mb-3"},Rt={key:0,class:"course-cell"},Nt={key:0},Lt={key:1},Mt={key:2,class:"week-type"},Wt={key:0},Bt={key:1},It={key:2,class:"week-type"},zt={class:"text-center font-weight-bold"};function _t(s,e,n,a,t,r){return m(),v(kt,{class:"fill-height"},{default:i(()=>[o(ie,null,{default:i(()=>[o(M,{cols:"12"},{default:i(()=>[o(L,{class:"elevation-12",border:""},{default:i(()=>[o(G,{class:"d-flex align-center primary lighten-1 white--text py-3 px-4"},{default:i(()=>[o(D,{color:"white",class:"mr-2"},{default:i(()=>[...e[15]||(e[15]=[c("mdi-swap-horizontal",-1)])]),_:1}),e[16]||(e[16]=c(" 课程表转换工具 ",-1))]),_:1}),o(He,null,{default:i(()=>[...e[17]||(e[17]=[c(" 将CSES格式的JSON或YAML文本转换为WakeUp软件使用的课程表 ",-1)])]),_:1}),o(O,null,{default:i(()=>[t.error?(m(),v(I,{key:0,type:"error",class:"mb-4 mt-3 mx-2",variant:"tonal",border:"start",closable:"","onClick:close":e[0]||(e[0]=l=>t.error="")},{default:i(()=>[p("div",St,[o(D,{class:"mr-2"},{default:i(()=>[...e[18]||(e[18]=[c("mdi-alert-circle",-1)])]),_:1}),c(" "+y(t.error),1)])]),_:1})):k("",!0),t.success?(m(),v(I,{key:1,type:"success",class:"mb-4 mt-3 mx-2",variant:"tonal",border:"start",closable:"","onClick:close":e[1]||(e[1]=l=>t.success="")},{default:i(()=>[p("div",jt,[o(D,{class:"mr-2"},{default:i(()=>[...e[19]||(e[19]=[c("mdi-check-circle",-1)])]),_:1}),c(" "+y(t.success),1)])]),_:1})):k("",!0),o(oe,{modelValue:t.activeTab,"onUpdate:modelValue":e[2]||(e[2]=l=>t.activeTab=l),class:"mb-4 mx-2",color:"primary",rounded:""},{default:i(()=>[o(Z,{value:"text",class:"px-5"},{default:i(()=>[o(D,{start:""},{default:i(()=>[...e[20]||(e[20]=[c("mdi-text-box",-1)])]),_:1}),e[21]||(e[21]=c(" 文本粘贴 ",-1))]),_:1}),o(Z,{value:"file",class:"px-5"},{default:i(()=>[o(D,{start:""},{default:i(()=>[...e[22]||(e[22]=[c("mdi-file-upload",-1)])]),_:1}),e[23]||(e[23]=c(" 文件上传 ",-1))]),_:1})]),_:1},8,["modelValue"]),o(Je,{modelValue:t.formatMode,"onUpdate:modelValue":e[3]||(e[3]=l=>t.formatMode=l),color:"primary",class:"mb-4 mx-2",mandatory:"",density:"comfortable",border:"",rounded:""},{default:i(()=>[o(A,{value:"auto"},{default:i(()=>[...e[24]||(e[24]=[c("自动检测",-1)])]),_:1}),o(A,{value:"json"},{default:i(()=>[...e[25]||(e[25]=[c("JSON",-1)])]),_:1}),o(A,{value:"yaml",disabled:!t.yamlLibLoaded},{default:i(()=>[e[26]||(e[26]=c(" YAML ",-1)),o(K,{activator:"parent",location:"bottom"},{default:i(()=>[c(y(t.yamlLibLoaded?"YAML解析库已加载":"正在加载YAML解析库..."),1)]),_:1})]),_:1},8,["disabled"])]),_:1},8,["modelValue"]),t.jsonText&&t.formatMode==="auto"?(m(),b("div",At," 检测到的格式: "+y(r.isYaml(t.jsonText)?"YAML":"JSON"),1)):k("",!0),o(de,{modelValue:t.activeTab,"onUpdate:modelValue":e[6]||(e[6]=l=>t.activeTab=l)},{default:i(()=>[o(X,{value:"text"},{default:i(()=>[p("div",Pt,[o(Ke,{modelValue:t.jsonText,"onUpdate:modelValue":e[4]||(e[4]=l=>t.jsonText=l),label:"粘贴JSON或YAML文本",loading:t.loading,disabled:t.loading,"row-height":"25",rows:"6",placeholder:"请在此粘贴CSES格式的数据...",onInput:r.handleTextChange},null,8,["modelValue","loading","disabled","onInput"])])]),_:1}),o(X,{value:"file"},{default:i(()=>[o(Vt,{modelValue:t.file,"onUpdate:modelValue":e[5]||(e[5]=l=>t.file=l),accept:".js,.json,.yml,.yaml",label:"选择课程表文件","prepend-icon":"mdi-file-upload",loading:t.loading,disabled:t.loading,onChange:r.handleFileChange,hint:"支持JSON、YAML格式文件","persistent-hint":"",rules:[l=>!l||l.size<2e6||"文件大小不能超过 2 MB"]},null,8,["modelValue","loading","disabled","onChange","rules"]),t.file&&t.formatMode==="auto"?(m(),v(I,{key:0,type:"info",class:"mb-4",variant:"tonal",density:"compact"},{default:i(()=>[...e[27]||(e[27]=[c(" 将根据文件扩展名自动检测格式 ",-1)])]),_:1})):k("",!0)]),_:1})]),_:1},8,["modelValue"]),o(M,{cols:"12"},{default:i(()=>[o(L,{flat:"",class:"pa-4 rounded-lg",border:""},{default:i(()=>[p("div",Et,[o(D,{color:"primary",class:"mr-2"},{default:i(()=>[...e[28]||(e[28]=[c("mdi-calendar-multiselect",-1)])]),_:1}),e[33]||(e[33]=p("h3",{class:"text-subtitle-1 font-weight-medium mr-auto"},"选择导出天数",-1)),o(A,{variant:"text",color:"primary",class:"ml-2",onClick:r.selectAllDays},{default:i(()=>[o(D,{start:"",size:"small"},{default:i(()=>[...e[29]||(e[29]=[c("mdi-checkbox-multiple-marked",-1)])]),_:1}),e[30]||(e[30]=c(" 全选 ",-1))]),_:1},8,["onClick"]),o(A,{variant:"text",color:"error",class:"ml-2",onClick:r.clearSelectedDays},{default:i(()=>[o(D,{start:"",size:"small"},{default:i(()=>[...e[31]||(e[31]=[c("mdi-checkbox-multiple-blank-outline",-1)])]),_:1}),e[32]||(e[32]=c(" 清除 ",-1))]),_:1},8,["onClick"])]),o(ht,{modelValue:t.selectedDays,"onUpdate:modelValue":e[7]||(e[7]=l=>t.selectedDays=l),multiple:"",class:"mb-2",color:"primary"},{default:i(()=>[(m(),b(T,null,C(7,l=>o(j,{key:l,value:l,filter:"",variant:"tonal",class:"filter-chip",label:""},{default:i(()=>[c(y(t.dayNames[l])+" ",1),r.getDaySchedule(l).length>0?(m(),v(ne,{key:0,content:r.getDaySchedule(l).length,color:"primary",inline:""},null,8,["content"])):k("",!0)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"])]),_:1})]),_:1}),o(M,{cols:"12"},{default:i(()=>[o(L,{flat:"",class:"pa-4 rounded-lg",border:""},{default:i(()=>[p("div",Ft,[o(D,{color:"primary",class:"mr-2"},{default:i(()=>[...e[34]||(e[34]=[c("mdi-cog",-1)])]),_:1}),e[35]||(e[35]=p("h3",{class:"text-subtitle-1 font-weight-medium"},"显示配置",-1))]),o(ie,null,{default:i(()=>[o(M,{cols:"12",sm:"6"},{default:i(()=>[o(fe,{modelValue:t.settings.hideTeacherName,"onUpdate:modelValue":e[8]||(e[8]=l=>t.settings.hideTeacherName=l),label:"不显示教师姓名",color:"primary",inset:"","hide-details":""},null,8,["modelValue"])]),_:1}),o(M,{cols:"12",sm:"6"},{default:i(()=>[o(fe,{modelValue:t.settings.hideRoom,"onUpdate:modelValue":e[9]||(e[9]=l=>t.settings.hideRoom=l),label:"不显示教室信息",color:"primary",inset:"","hide-details":""},null,8,["modelValue"])]),_:1}),o(M,{cols:"12",sm:"6"},{default:i(()=>[o(tt,{modelValue:t.settings.totalWeeks,"onUpdate:modelValue":e[10]||(e[10]=l=>t.settings.totalWeeks=l),modelModifiers:{number:!0},label:"总周数",type:"number",min:"1",max:"30",rules:[l=>l>0||"周数必须大于0"],density:"comfortable",variant:"outlined","prepend-inner-icon":"mdi-calendar-week",class:"mt-3"},null,8,["modelValue","rules"])]),_:1})]),_:1})]),_:1})]),_:1}),t.loading?(m(),v(L,{key:3,class:"my-4",outlined:""},{default:i(()=>[o(O,null,{default:i(()=>[o(yt,{type:"table",class:"mx-auto"})]),_:1})]),_:1})):k("",!0),t.processedData?(m(),v(j,{key:4,color:"primary",class:"ml-2","prepend-icon":"mdi-book-open-variant"},{default:i(()=>[c(y(t.processedData.tableData.length)+" 节课程 ",1)]),_:1})):k("",!0),t.processedData&&t.exportPeriods.length===0?(m(),v(I,{key:5,type:"warning",class:"mb-4",closable:""},{default:i(()=>[...e[36]||(e[36]=[c(" 请选择要导出的节次 ",-1)])]),_:1})):k("",!0),t.processedData?(m(),v(L,{key:6,class:"my-4",elevation:"1"},{default:i(()=>[o(G,{class:"d-flex align-center pa-4 bg-primary-lighten-5"},{default:i(()=>[o(D,{color:"primary",class:"mr-2"},{default:i(()=>[...e[37]||(e[37]=[c("mdi-table",-1)])]),_:1}),e[39]||(e[39]=p("span",{class:"font-weight-bold"},"课程表",-1)),o(j,{color:"primary",class:"ml-3",size:"small",pill:""},{default:i(()=>[o(D,{start:"",size:"x-small"},{default:i(()=>[...e[38]||(e[38]=[c("mdi-book-open-variant",-1)])]),_:1}),c(" "+y(t.processedData.tableData.length)+" 节课程 ",1)]),_:1})]),_:1}),o(O,{class:"pa-0"},{default:i(()=>[o(bt,{"items-selected":t.selectedRows,"onUpdate:itemsSelected":[e[12]||(e[12]=l=>t.selectedRows=l),r.updateSelectedPeriods],headers:t.tableHeaders,items:t.processedData.tableData,"hide-default-footer":"",class:"elevation-1","items-per-page":-1,"item-value":"period","show-select":"","select-strategy":"single-independent","sort-by":[],"disable-sort":""},pt({"item.data-table-select":i(({item:l})=>[o(gt,{modelValue:t.exportPeriods,"onUpdate:modelValue":e[11]||(e[11]=d=>t.exportPeriods=d),value:l.period,"hide-details":"",density:"compact"},null,8,["modelValue","value"])]),_:2},[C(7,l=>({name:`item.${l}`,fn:i(({item:d})=>[d[l]?(m(),b("div",Rt,[Array.isArray(d[l])?(m(!0),b(T,{key:0},C(d[l],(f,h)=>(m(),b("div",{key:h,class:"course-item"},[c(y(f.name)+" ",1),!t.settings.hideTeacherName&&f.teacher?(m(),b("span",Nt,[e[40]||(e[40]=p("br",null,null,-1)),c(y(f.teacher),1)])):k("",!0),!t.settings.hideRoom&&f.room?(m(),b("span",Lt,[e[41]||(e[41]=p("br",null,null,-1)),c(y(f.room),1)])):k("",!0),f.weekType?(m(),b("span",Mt,y(f.weekType)+"周 ",1)):k("",!0)]))),128)):(m(),b(T,{key:1},[c(y(d[l].name)+" ",1),!t.settings.hideTeacherName&&d[l].teacher?(m(),b("span",Wt,[e[42]||(e[42]=p("br",null,null,-1)),c(y(d[l].teacher),1)])):k("",!0),!t.settings.hideRoom&&d[l].room?(m(),b("span",Bt,[e[43]||(e[43]=p("br",null,null,-1)),c(y(d[l].room),1)])):k("",!0),d[l].weekType?(m(),b("span",It,y(d[l].weekType)+"周 ",1)):k("",!0)],64))])):k("",!0)])}))]),1032,["items-selected","headers","items","onUpdate:itemsSelected"])]),_:1})]),_:1})):k("",!0),r.hasExportData?(m(),v(L,{key:7,class:"my-4",elevation:"1"},{default:i(()=>[o(G,{class:"d-flex align-center pa-4 bg-primary-lighten-5"},{default:i(()=>[o(D,{color:"primary",class:"mr-2"},{default:i(()=>[...e[44]||(e[44]=[c("mdi-timetable",-1)])]),_:1}),e[48]||(e[48]=p("span",{class:"font-weight-bold"},"每日课程时间表",-1)),o(j,{class:"ml-3",size:"small",color:"primary",pill:""},{default:i(()=>[o(D,{start:"",size:"x-small"},{default:i(()=>[...e[45]||(e[45]=[c("mdi-clock-outline",-1)])]),_:1}),c(" "+y(r.totalClassHours)+" 课时 ",1)]),_:1}),t.exportPeriods.length>0?(m(),v(K,{key:0},{activator:i(({props:l})=>[o(j,z({class:"ml-2",size:"small",color:"info"},l,{pill:""}),{default:i(()=>[o(D,{start:"",size:"x-small"},{default:i(()=>[...e[46]||(e[46]=[c("mdi-information-outline",-1)])]),_:1}),e[47]||(e[47]=c(" 节次已重排 ",-1))]),_:1},16)]),default:i(()=>[p("span",null,"已将选中的节次 "+y(t.exportPeriods.join(", "))+" 重新排序为连续的 1-"+y(t.exportPeriods.length),1)]),_:1})):k("",!0)]),_:1}),o(O,null,{default:i(()=>[r.daysWithSchedule.length>0?(m(),v(oe,{key:0,modelValue:t.activeDay,"onUpdate:modelValue":e[13]||(e[13]=l=>t.activeDay=l),class:"mb-4",color:"primary",grow:"","align-tabs":"center"},{default:i(()=>[(m(!0),b(T,null,C(r.daysWithSchedule,l=>(m(),v(Z,{key:l,value:l,class:"px-2 font-weight-medium"},{default:i(()=>[c(y(t.dayNames[l])+" ",1),o(ne,{content:r.getDaySchedule(l).length,color:"primary",inline:""},null,8,["content"])]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])):k("",!0),o(de,{modelValue:t.activeDay,"onUpdate:modelValue":e[14]||(e[14]=l=>t.activeDay=l)},{default:i(()=>[(m(!0),b(T,null,C(r.daysWithSchedule,l=>(m(),v(X,{key:l,value:l},{default:i(()=>[o(Ze,{density:"compact",class:"rounded","headers-length":6,"disable-sort":""},{default:i(()=>[e[50]||(e[50]=p("thead",null,[p("tr",null,[p("th",{class:"text-center"},"节次"),p("th",null,"课程"),p("th",null,"时间"),p("th",null,"教师"),p("th",null,"教室"),p("th",null,"周次")])],-1)),p("tbody",null,[(m(!0),b(T,null,C(r.groupByPeriod(r.getDaySchedule(l)),(d,f)=>(m(),b("tr",{key:f},[p("td",zt,[c(y(d.period)+" ",1),d.originalPeriod!==d.period?(m(),v(K,{key:0},{activator:i(({props:h})=>[o(D,z({size:"x-small"},{ref_for:!0},h,{color:"info",class:"ml-1"}),{default:i(()=>[...e[49]||(e[49]=[c("mdi-sync",-1)])]),_:1},16)]),default:i(()=>[c(" 原节次: "+y(d.originalPeriod),1)]),_:2},1024)):k("",!0)]),p("td",null,[(m(!0),b(T,null,C(d.items,(h,w)=>(m(),b("div",{key:w,class:"mb-1"},[o(j,{size:"small",color:r.getSubjectColor(h.subject),label:"","text-color":"white",class:"mr-1"},{default:i(()=>[c(y(h.subject),1)]),_:2},1032,["color"]),d.items.length>1?(m(),v(j,{key:0,size:"x-small",class:"ml-1",color:h.weekType==="单"?"warning":"success"},{default:i(()=>[c(y(h.weekType)+"周 ",1)]),_:2},1032,["color"])):k("",!0)]))),128))]),p("td",null,[(m(!0),b(T,null,C(d.uniqueTimeSlots,(h,w)=>(m(),b("div",{key:w,class:"mb-1"},[o(j,{size:"x-small",class:"time-chip"},{default:i(()=>[c(y(r.formatTime(h.startTime))+" - "+y(r.formatTime(h.endTime)),1)]),_:2},1024)]))),128))]),p("td",null,[t.settings.hideTeacherName?(m(),b(T,{key:1},[c("-")],64)):(m(!0),b(T,{key:0},C(d.items,(h,w)=>(m(),b("div",{key:w,class:"mb-1"},y(h.teacher||"-"),1))),128))]),p("td",null,[t.settings.hideRoom?(m(),b(T,{key:1},[c("-")],64)):(m(!0),b(T,{key:0},C(d.items,(h,w)=>(m(),b("div",{key:w,class:"mb-1"},y(h.room||"-"),1))),128))]),p("td",null,[(m(!0),b(T,null,C(d.items,(h,w)=>(m(),b("div",{key:w,class:"mb-1"},y(h.weeks),1))),128))])]))),128))])]),_:2},1024)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"]),r.hasExportData&&r.daysWithSchedule.length===0?(m(),v(I,{key:1,type:"info",class:"mt-3"},{default:i(()=>[...e[51]||(e[51]=[c(" 没有找到任何课程数据 ",-1)])]),_:1})):k("",!0)]),_:1})]),_:1})):k("",!0)]),_:1}),o(qe,{class:""},{default:i(()=>[o(Ge),o(A,{color:"primary",variant:"outlined",loading:t.loading,disabled:!t.jsonText&&!t.file||t.loading,onClick:r.processInput,"prepend-icon":"mdi-cog-refresh"},{default:i(()=>[...e[52]||(e[52]=[c(" 处理数据 ",-1)])]),_:1},8,["loading","disabled","onClick"]),o(A,{color:"info",disabled:!r.hasExportData,onClick:r.showExportPreview,class:"ml-2","prepend-icon":"mdi-eye",border:""},{default:i(()=>[...e[53]||(e[53]=[c(" 刷新 ",-1)])]),_:1},8,["disabled","onClick"]),o(A,{color:"success",variant:"outlined",disabled:!r.hasExportData,onClick:r.downloadCSV,class:"ml-2","prepend-icon":"mdi-download",border:""},{default:i(()=>[...e[54]||(e[54]=[c(" 下载CSV ",-1)])]),_:1},8,["disabled","onClick"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}const ns=Ye(Ct,[["render",_t],["__scopeId","data-v-c07f22af"]]);export{ns as default};