1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-09-03 16:19:22 +00:00
Classworks/assets/examschedule-Czp1n8x5.js

3 lines
45 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{g as ke,p as xe,an as T,a8 as We,a5 as Ge,al as A,aq as Re,c as _e,i as g,n as Ee,e as R,aK as Xe,a7 as Ae,d as l,y,t as r,aj as Qe,aL as Ze,av as Be,E as ne,aM as be,_ as Fe,M as z,A as P,o as v,j as x,B as b,w as n,v as C,C as D,O as Ce,F as te,G as le,P as pe,X as Oe,z as E,l as M,D as $e,q as B,x as q,aN as et,aO as tt,K as lt,ad as nt,W as ae,H as we,N as at,Y as it,S as ot,aP as st,k as rt}from"./index-B01HL2YE.js";import{V as ie}from"./VAlert-C_dUaWCb.js";import{V as Je}from"./VSkeletonLoader-sErXiQwV.js";import{V as ut}from"./VTooltip-B8rVhLY6.js";import{V as ve,b as dt}from"./VChip-DGb8BoIB.js";import{V as U,a as Q}from"./VRow-CmZZJImz.js";import{V as Z}from"./VTextField-DDMIr0_j.js";import{V as mt}from"./VTextarea-BaoCeePe.js";import{V as Ie}from"./VMenu-3aVeBIH6.js";import{a as Pe,m as ct,V as Ue}from"./VDatePicker-Jh1kvgOm.js";import{V as ft}from"./VContainer-yTxlmOws.js";function W(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;return String(t).padStart(e,"0")}const gt=xe({allowedValues:Function,ampm:Boolean,color:String,disabled:Boolean,displayedValue:null,double:Boolean,format:{type:Function,default:t=>t},max:{type:Number,required:!0},min:{type:Number,required:!0},scrollable:Boolean,readonly:Boolean,rotate:{type:Number,default:0},step:{type:Number,default:1},modelValue:{type:Number}},"VTimePickerClock"),ze=ke()({name:"VTimePickerClock",props:gt(),emits:{change:t=>!0,input:t=>!0},setup(t,e){let{emit:i}=e;const u=T(null),a=T(null),o=T(void 0),s=T(!1),m=T(null),f=T(null),I=Xe(d=>i("change",d),750),{textColorClasses:oe,textColorStyles:F}=We(()=>t.color),{backgroundColorClasses:_,backgroundColorStyles:he}=Ge(()=>t.color),K=A(()=>t.max-t.min+1),L=A(()=>t.double?K.value/2:K.value),H=A(()=>360/L.value),se=A(()=>H.value*Math.PI/180),S=A(()=>t.modelValue==null?t.min:t.modelValue),$=A(()=>.62),re=A(()=>{const d=[];for(let h=t.min;h<=t.max;h=h+t.step)d.push(h);return d});Re(()=>t.modelValue,d=>{o.value=d});function ue(d){o.value!==d&&(o.value=d),i("input",d)}function O(d){return!t.allowedValues||t.allowedValues(d)}function de(d){if(!t.scrollable||t.disabled)return;d.preventDefault();const h=Math.sign(-d.deltaY||1);let w=S.value;do w=w+h,w=(w-t.min+K.value)%K.value+t.min;while(!O(w)&&w!==S.value);w!==t.displayedValue&&ue(w),I(w)}function me(d){return t.double&&d-t.min>=L.value}function ee(d){return me(d)?$.value:1}function ye(d){const h=t.rotate*Math.PI/180;return{x:Math.sin((d-t.min)*se.value+h)*ee(d),y:-Math.cos((d-t.min)*se.value+h)*ee(d)}}function ce(d,h){const w=(Math.round(d/H.value)+(h?L.value:0))%K.value+t.min;return d<360-H.value/2?w:h?t.max-L.value+1:t.min}function c(d){const{x:h,y:w}=ye(d);return{left:`${Math.round(50+h*50)}%`,top:`${Math.round(50+w*50)}%`}}function k(d,h){const w=h.x-d.x,G=h.y-d.y;return Math.sqrt(w*w+G*G)}function V(d,h){const w=2*Math.atan2(h.y-d.y-k(d,h),h.x-d.x);return Math.abs(w*180/Math.PI)}function p(d){m.value===null&&(m.value=d),f.value=d,ue(d)}function N(d){var Se,Ne;if(d.preventDefault(),!s.value&&d.type!=="click"||!u.value)return;const{width:h,top:w,left:G}=(Se=u.value)==null?void 0:Se.getBoundingClientRect(),{width:Y}=((Ne=a.value)==null?void 0:Ne.getBoundingClientRect())??{width:0},{clientX:fe,clientY:Ke}="touches"in d?d.touches[0]:d,De={x:h/2,y:-h/2},Ve={x:fe-G,y:w-Ke},Te=Math.round(V(De,Ve)-t.rotate+360)%360,Me=t.double&&k(De,Ve)<(Y+Y*$.value)/4,Ye=Math.ceil(15/H.value);let X;for(let ge=0;ge<Ye;ge++)if(X=ce(Te+ge*H.value,Me),O(X)||(X=ce(Te-ge*H.value,Me),O(X)))return p(X)}function J(d){t.disabled||(d.preventDefault(),window.addEventListener("mousemove",N),window.addEventListener("touchmove",N),window.addEventListener("mouseup",j),window.addEventListener("touchend",j),m.value=null,f.value=null,s.value=!0,N(d))}function j(d){d.stopPropagation(),window.removeEventListener("mousemove",N),window.removeEventListener("touchmove",N),window.removeEventListener("mouseup",j),window.removeEventListener("touchend",j),s.value=!1,f.value!==null&&O(f.value)&&i("change",f.value)}_e(()=>g("div",{class:R([{"v-time-picker-clock":!0,"v-time-picker-clock--indeterminate":t.modelValue==null,"v-time-picker-clock--readonly":t.readonly}]),onMousedown:J,onTouchstart:J,onWheel:de,ref:u},[g("div",{class:"v-time-picker-clock__inner",ref:a},[g("div",{class:R([{"v-time-picker-clock__hand":!0,"v-time-picker-clock__hand--inner":me(t.modelValue)},oe.value]),style:Ee([{transform:`rotate(${t.rotate+H.value*(S.value-t.min)}deg) scaleY(${ee(S.value)})`},F.value])},null),re.value.map(d=>{const h=d===S.value;return g("div",{class:R([{"v-time-picker-clock__item":!0,"v-time-picker-clock__item--active":h,"v-time-picker-clock__item--disabled":t.disabled||!O(d)},h&&_.value]),style:Ee([c(d),h&&he.value])},[g("span",null,[t.format(d)])])})])]))}}),vt=xe({ampm:Boolean,color:String,disabled:Boolean,hour:Number,minute:Number,second:Number,period:String,readonly:Boolean,useSeconds:Boolean,value:Number,viewMode:String},"VTimePickerControls"),Le=ke()({name:"VTimePickerControls",props:vt(),emits:{"update:period":t=>!0,"update:viewMode":t=>!0},setup(t,e){let{emit:i,slots:u}=e;const{t:a}=Ae();return _e(()=>{let o=t.hour;return t.ampm&&(o=o?(o-1)%12+1:12),g("div",{class:"v-time-picker-controls"},[g("div",{class:R({"v-time-picker-controls__time":!0,"v-time-picker-controls__time--with-seconds":t.useSeconds})},[l(y,{active:t.viewMode==="hour",color:t.viewMode==="hour"?t.color:void 0,disabled:t.disabled,variant:"tonal",class:R({"v-time-picker-controls__time__btn":!0,"v-time-picker-controls__time--with-ampm__btn":t.ampm,"v-time-picker-controls__time--with-seconds__btn":t.useSeconds}),text:t.hour==null?"--":W(`${o}`),onClick:()=>i("update:viewMode","hour")},null),g("span",{class:R(["v-time-picker-controls__time__separator",{"v-time-picker-controls--with-seconds__time__separator":t.useSeconds}])},[r(":")]),l(y,{active:t.viewMode==="minute",color:t.viewMode==="minute"?t.color:void 0,class:R({"v-time-picker-controls__time__btn":!0,"v-time-picker-controls__time__btn__active":t.viewMode==="minute","v-time-picker-controls__time--with-ampm__btn":t.ampm,"v-time-picker-controls__time--with-seconds__btn":t.useSeconds}),disabled:t.disabled,variant:"tonal",text:t.minute==null?"--":W(t.minute),onClick:()=>i("update:viewMode","minute")},null),t.useSeconds&&g("span",{class:R(["v-time-picker-controls__time__separator",{"v-time-picker-controls--with-seconds__time__separator":t.useSeconds}]),key:"secondsDivider"},[r(":")]),t.useSeconds&&l(y,{key:"secondsVal",active:t.viewMode==="second",color:t.viewMode==="second"?t.color:void 0,variant:"tonal",onClick:()=>i("update:viewMode","second"),class:R({"v-time-picker-controls__time__btn":!0,"v-time-picker-controls__time__btn__active":t.viewMode==="second","v-time-picker-controls__time--with-seconds__btn":t.useSeconds}),disabled:t.disabled,text:t.second==null?"--":W(t.second)},null),t.ampm&&g("div",{class:"v-time-picker-controls__ampm"},[l(y,{active:t.period==="am",color:t.period==="am"?t.color:void 0,class:R({"v-time-picker-controls__ampm__am":!0,"v-time-picker-controls__ampm__btn":!0,"v-time-picker-controls__ampm__btn__active":t.period==="am"}),disabled:t.disabled,text:a("$vuetify.timePicker.am"),variant:t.disabled&&t.period==="am"?"elevated":"tonal",onClick:()=>t.period!=="am"?i("update:period","am"):null},null),l(y,{active:t.period==="pm",color:t.period==="pm"?t.color:void 0,class:R({"v-time-picker-controls__ampm__pm":!0,"v-time-picker-controls__ampm__btn":!0,"v-time-picker-controls__ampm__btn__active":t.period==="pm"}),disabled:t.disabled,text:a("$vuetify.timePicker.pm"),variant:t.disabled&&t.period==="pm"?"elevated":"tonal",onClick:()=>t.period!=="pm"?i("update:period","pm"):null},null)])])])}),{}}}),ht=be(24),je=be(12),yt=je.map(t=>t+12);be(60);const Ct=xe({allowedHours:[Function,Array],allowedMinutes:[Function,Array],allowedSeconds:[Function,Array],disabled:Boolean,format:{type:String,default:"ampm"},max:String,min:String,viewMode:{type:String,default:"hour"},modelValue:null,readonly:Boolean,scrollable:Boolean,useSeconds:Boolean,...Be(ct({title:"$vuetify.timePicker.title"}),["landscape"])},"VTimePicker"),He=ke()({name:"VTimePicker",props:Ct(),emits:{"update:hour":t=>!0,"update:minute":t=>!0,"update:period":t=>!0,"update:second":t=>!0,"update:modelValue":t=>!0,"update:viewMode":t=>!0},setup(t,e){let{emit:i,slots:u}=e;const{t:a}=Ae(),o=T(null),s=T(null),m=T(null),f=T(null),I=T(null),oe=T(null),F=T("am"),_=Qe(t,"viewMode","hour"),he=T(null),K=T(null),L=A(()=>{let c;if(t.allowedHours instanceof Array?c=p=>t.allowedHours.includes(p):c=t.allowedHours,!t.min&&!t.max)return c;const k=t.min?Number(t.min.split(":")[0]):0,V=t.max?Number(t.max.split(":")[0]):23;return p=>p>=Number(k)&&p<=Number(V)&&(!c||c(p))}),H=A(()=>{let c;const k=!L.value||o.value===null||L.value(o.value);if(t.allowedMinutes instanceof Array?c=h=>t.allowedMinutes.includes(h):c=t.allowedMinutes,!t.min&&!t.max)return k?c:()=>!1;const[V,p]=t.min?t.min.split(":").map(Number):[0,0],[N,J]=t.max?t.max.split(":").map(Number):[23,59],j=V*60+Number(p),d=N*60+Number(J);return h=>{const w=60*o.value+h;return w>=j&&w<=d&&k&&(!c||c(h))}}),se=A(()=>{let c;const V=(!L.value||o.value===null||L.value(o.value))&&(!H.value||s.value===null||H.value(s.value));if(t.allowedSeconds instanceof Array?c=Y=>t.allowedSeconds.includes(Y):c=t.allowedSeconds,!t.min&&!t.max)return V?c:()=>!1;const[p,N,J]=t.min?t.min.split(":").map(Number):[0,0,0],[j,d,h]=t.max?t.max.split(":").map(Number):[23,59,59],w=p*3600+N*60+Number(J||0),G=j*3600+d*60+Number(h||0);return Y=>{const fe=3600*o.value+60*s.value+Y;return fe>=w&&fe<=G&&V&&(!c||c(Y))}}),S=A(()=>t.format==="ampm");Re(()=>t.modelValue,c=>de(c)),Ze(()=>{de(t.modelValue)});function $(){return o.value!=null&&s.value!=null&&(!t.useSeconds||m.value!=null)?`${W(o.value)}:${W(s.value)}`+(t.useSeconds?`:${W(m.value)}`:""):null}function re(){const c=$();c!==null&&i("update:modelValue",c)}function ue(c){return c?(c-1)%12+1:12}function O(c,k){return c%12+(k==="pm"?12:0)}function de(c){if(c==null||c==="")o.value=null,s.value=null,m.value=null;else if(c instanceof Date)o.value=c.getHours(),s.value=c.getMinutes(),m.value=c.getSeconds();else{const[k,,V,,p,N]=c.trim().toLowerCase().match(/^(\d+):(\d+)(:(\d+))?([ap]m)?$/)||new Array(6);o.value=N?O(parseInt(k,10),N):parseInt(k,10),s.value=parseInt(V,10),m.value=parseInt(p||0,10)}F.value=o.value==null||o.value<12?"am":"pm"}function me(c,k){const V=L.value;if(!V)return k;const p=S.value?k<12?je:yt:ht;return((p.find(J=>V((J+k)%p.length+p[0]))||0)+k)%p.length+p[0]}function ee(c){if(F.value=c,o.value!=null){const k=o.value+(F.value==="am"?-12:12);o.value=me("hour",k)}return i("update:period",c),re(),!0}function ye(c){_.value==="hour"?o.value=S.value?O(c,F.value):c:_.value==="minute"?s.value=c:m.value=c}function ce(c){switch(_.value||"hour"){case"hour":i("update:hour",c);break;case"minute":i("update:minute",c);break;case"second":i("update:second",c);break}const k=o.value!==null&&s.value!==null&&(t.useSeconds?m.value!==null:!0);_.value==="hour"?_.value="minute":t.useSeconds&&_.value==="minute"&&(_.value="second"),!(o.value===f.value&&s.value===I.value&&(!t.useSeconds||m.value===oe.value)||$()===null)&&(f.value=o.value,I.value=s.value,t.useSeconds&&(oe.value=m.value),k&&re())}_e(()=>{const c=Pe.filterProps(t),k=Le.filterProps(t),V=ze.filterProps(Be(t,["format","modelValue","min","max"]));return l(Pe,ne(c,{color:void 0,class:["v-time-picker",t.class],style:t.style}),{title:()=>{var p;return((p=u.title)==null?void 0:p.call(u))??g("div",{class:"v-time-picker__title"},[a(t.title)])},header:()=>l(Le,ne(k,{ampm:S.value,hour:o.value,minute:s.value,period:F.value,second:m.value,viewMode:_.value,"onUpdate:period":p=>ee(p),"onUpdate:viewMode":p=>_.value=p,ref:he}),null),default:()=>l(ze,ne(V,{allowedValues:_.value==="hour"?L.value:_.value==="minute"?H.value:se.value,double:_.value==="hour"&&!S.value,format:_.value==="hour"?S.value?ue:p=>p:p=>W(p,2),max:_.value==="hour"?S.value&&F.value==="am"?11:23:59,min:_.value==="hour"&&S.value&&F.value==="pm"?12:0,size:20,step:_.value==="hour"?1:5,modelValue:_.value==="hour"?o.value:_.value==="minute"?s.value:m.value,onChange:ce,onInput:ye,ref:K}),null),actions:u.actions})})}}),pt={name:"ExamConfigEditor",props:{configId:{type:String,required:!0},dialogMode:{type:Boolean,default:!1}},emits:["saved","error","opened","deleted"],data(){return{localConfig:{examName:"",message:"",room:"",examInfos:[]},loading:!1,saving:!1,deleting:!1,deleteDialog:!1,error:"",success:"",isEditMode:!1,showJsonPreview:!1,defaultExamTips:["请保持卷面整洁,字迹清晰,诚信应考。在听到终考铃时立刻起立,停止作答。","沉着 冷静 细心 守记","答题不守记,自己两行泪。"]}},computed:{formattedJson(){try{return JSON.stringify(this.localConfig,null,2)}catch(t){return console.error("格式化JSON时出错:",t),"无效的JSON格式"}},isValidConfig(){return this.localConfig.examName&&this.localConfig.message&&this.localConfig.examInfos&&this.localConfig.examInfos.length>0&&this.localConfig.examInfos.every(t=>t.name&&t.start&&t.end)},validationErrors(){const t=[];if((!this.localConfig.examName||this.localConfig.examName.trim()==="")&&t.push("考试名称不能为空"),(!this.localConfig.message||this.localConfig.message.trim()==="")&&t.push("考试提示不能为空"),!this.localConfig.examInfos||this.localConfig.examInfos.length===0)t.push("至少需要添加一个考试科目");else{this.localConfig.examInfos.forEach((e,i)=>{const u=`${i+1}个科目`;if((!e.name||e.name.trim()==="")&&t.push(`${u}的名称不能为空`),e.start||t.push(`${u}的开始时间不能为空`),e.end||t.push(`${u}的结束时间不能为空`),e.start&&e.end){const a=new Date(e.start),o=new Date(e.end);isNaN(a.getTime())&&t.push(`${u}的开始时间格式不正确`),isNaN(o.getTime())&&t.push(`${u}的结束时间格式不正确`),!isNaN(a.getTime())&&!isNaN(o.getTime())&&(o<=a&&t.push(`${u}的结束时间必须晚于开始时间`),(o-a)/(1e3*60*60)>24&&t.push(`${u}的考试时长不能超过24小时`))}});for(let e=0;e<this.localConfig.examInfos.length;e++)for(let i=e+1;i<this.localConfig.examInfos.length;i++){const u=this.localConfig.examInfos[e],a=this.localConfig.examInfos[i];if(u.start&&u.end&&a.start&&a.end){const o=new Date(u.start),s=new Date(u.end),m=new Date(a.start),f=new Date(a.end);!isNaN(o.getTime())&&!isNaN(s.getTime())&&!isNaN(m.getTime())&&!isNaN(f.getTime())&&o<f&&s>m&&t.push(`${e+1}个科目与第${i+1}个科目的时间有重叠`)}}}return t},hasValidationErrors(){return this.validationErrors.length>0}},watch:{configId:{immediate:!0,handler(t){t&&this.loadConfig()}}},methods:{async loadConfig(){var t;this.loading=!0,this.error="";try{const e=await z.loadData(`es_${this.configId}`);e?(this.localConfig={examName:"",message:"",room:"",examInfos:[],...e},Array.isArray(this.localConfig.examInfos)||(this.localConfig.examInfos=[]),this.localConfig.examInfos.forEach(i=>{if(i.start){const u=this.parseDateTime(i.start);i.start=this.formatDateTimeLocal(u),i.startDate=u,i.startTime=this.formatTimeOnly(u),i.startFormatted=this.formatDisplayDateTime(u),i.startDateMenu=!1}if(i.end){const u=this.parseDateTime(i.end);i.end=this.formatDateTimeLocal(u),i.endDate=u,i.endTime=this.formatTimeOnly(u),i.endFormatted=this.formatDisplayDateTime(u),i.endDateMenu=!1}})):(console.error("加载配置失败:",e),this.error="加载配置失败: "+(((t=e.error)==null?void 0:t.message)||"未知错误"),this.$emit("error",this.error))}catch(e){console.error(e),this.error="加载配置失败: "+e.message,this.$emit("error",this.error)}finally{this.loading=!1}},async saveConfig(){var t;if(!this.isValidConfig){const e=this.validationErrors;return e.length>0?this.error=`配置验证失败:${e.join("")}`:this.error="请填写完整的配置信息",!1}this.saving=!0,this.error="";try{const e={...this.localConfig,examInfos:this.localConfig.examInfos.map(u=>({...u,start:this.formatDisplayDateTime(u.start),end:this.formatDisplayDateTime(u.end)}))},i=await z.saveData(`es_${this.configId}`,e);return i?(this.success="配置保存成功",this.$emit("saved",e),!0):(this.error="保存配置失败: "+(((t=i.error)==null?void 0:t.message)||"未知错误"),this.$emit("error",this.error),!1)}catch(e){return this.error="保存配置失败: "+e,this.$emit("error",this.error),!1}finally{this.saving=!1}},addExamInfo(){const t=new Date,e=new Date(t.getTime()+60*60*1e3),i=new Date(e.getTime()+2*60*60*1e3),u={name:"新科目",start:this.formatDateTimeLocal(e),end:this.formatDateTimeLocal(i),startDate:e,startTime:this.formatTimeOnly(e),startFormatted:this.formatDisplayDateTime(e),startDateMenu:!1,endDate:i,endTime:this.formatTimeOnly(i),endFormatted:this.formatDisplayDateTime(i),endDateMenu:!1};this.localConfig.examInfos.push(u)},removeExamInfo(t){this.localConfig.examInfos.splice(t,1)},moveExamInfo(t,e){const i=t+e;if(i>=0&&i<this.localConfig.examInfos.length){const u=this.localConfig.examInfos.splice(t,1)[0];this.localConfig.examInfos.splice(i,0,u)}},async copyToClipboard(){try{await navigator.clipboard.writeText(this.formattedJson),this.success="JSON已复制到剪贴板"}catch(t){this.error="复制失败: "+t.message}},toggleEditMode(){this.isEditMode=!this.isEditMode,this.error="",this.success=""},quickEdit(){this.isEditMode=!0,this.error="",this.success=""},selectDefaultTip(t){this.localConfig.message&&this.localConfig.message.trim()!==""?this.localConfig.message+=`
`+t:this.localConfig.message=t},formatDateTimeLocal(t){if(!t)return"";let e;if(typeof t=="string"?t.includes("/")?e=new Date(t.replace(/\//g,"-")):e=new Date(t):e=new Date(t),isNaN(e.getTime()))return"";const i=e.getFullYear(),u=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),s=String(e.getMinutes()).padStart(2,"0");return`${i}-${u}-${a}T${o}:${s}`},formatDisplayDateTime(t){if(!t)return"";const e=new Date(t);if(isNaN(e.getTime()))return t;const i=e.getFullYear(),u=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),s=String(e.getMinutes()).padStart(2,"0");return`${i}/${u}/${a} ${o}:${s}`},parseDateTime(t){return t?typeof t=="string"?t.includes("/")?new Date(t.replace(/\//g,"-")):new Date(t):new Date(t):new Date},formatTimeOnly(t){if(!t)return"00:00";const e=new Date(t);if(isNaN(e.getTime()))return"00:00";const i=String(e.getHours()).padStart(2,"0"),u=String(e.getMinutes()).padStart(2,"0");return`${i}:${u}`},updateStartDateTime(t){const e=this.localConfig.examInfos[t];if(!e.startDate||!e.startTime)return;const i=new Date(e.startDate),[u,a]=e.startTime.split(":");i.setHours(parseInt(u),parseInt(a),0,0),e.start=this.formatDateTimeLocal(i),e.startFormatted=this.formatDisplayDateTime(i)},updateEndDateTime(t){const e=this.localConfig.examInfos[t];if(!e.endDate||!e.endTime)return;const i=new Date(e.endDate),[u,a]=e.endTime.split(":");i.setHours(parseInt(u),parseInt(a),0,0),e.end=this.formatDateTimeLocal(i),e.endFormatted=this.formatDisplayDateTime(i)},async openConfig(){try{const t=await z.getKeyCloudUrl(`es_${this.configId}`,{autoMigrate:!0,autoConfig:!0});if(t.success&&t.url){const e=`https://es.zerocat.dev/exam/?configUrl=${encodeURIComponent(t.url)}`;window.open(e,"_blank"),this.success="配置已在新窗口中打开",this.$emit("opened",{configId:this.configId,url:t.url})}else throw new Error(t.error||"获取云端地址失败")}catch(t){this.error="打开配置失败: "+t.message,this.$emit("error","打开配置失败: "+t.message)}},confirmDelete(){this.deleteDialog=!0},async deleteConfig(){this.deleting=!0;try{const i=(await z.loadData("es_list")||[]).filter(a=>a.id!==this.configId);if(!await z.saveData("es_list",i))throw new Error("更新云端列表失败");this.deleteDialog=!1,this.$emit("deleted",{success:!0,message:"配置删除成功",configId:this.configId})}catch(t){console.error("删除配置失败:",t),this.$emit("deleted",{success:!1,message:"删除失败: "+t.message})}finally{this.deleting=!1}}}},wt={class:"d-flex align-center"},kt={class:"d-flex align-center"},xt={key:4,class:"d-flex justify-space-between align-center mb-4"},_t={class:"d-flex align-center gap-2"},bt={key:5},Dt={class:"mb-8"},Vt={class:"text-h3 font-weight-bold",style:{"line-height":"1.2"}},Tt={class:"text-subtitle-1 text-grey",style:{"white-space":"pre-wrap","line-height":"1.8"}},Mt={key:0,class:"mb-8"},St={class:"d-flex align-center"},Nt={class:""},Et={class:"mb-3"},It={class:"d-flex align-center mb-1"},Pt={class:"text-h6 font-weight-medium text-success"},Ut={class:"d-flex align-center mb-1"},zt={class:"text-h6 font-weight-medium text-error"},Lt={key:1,class:"text-center py-12"},Ht={class:"json-preview"},Rt={key:6},At={class:"text-caption text-medium-emphasis ml-2"},Bt={class:"w-100"},Ft={key:1,class:"text-center py-8"};function Ot(t,e,i,u,a,o){return v(),P("div",null,[a.error?(v(),x(ie,{key:0,type:"error",class:"mb-4 mt-3 mx-2",variant:"tonal",border:"start",closable:"","onClick:close":e[0]||(e[0]=s=>a.error="")},{default:n(()=>[g("div",wt,[l(C,{class:"mr-2"},{default:n(()=>[...e[9]||(e[9]=[r("mdi-alert-circle",-1)])]),_:1}),r(" "+D(a.error),1)])]),_:1})):b("",!0),a.success?(v(),x(ie,{key:1,type:"success",class:"mb-4 mt-3 mx-2",variant:"tonal",border:"start",closable:"","onClick:close":e[1]||(e[1]=s=>a.success="")},{default:n(()=>[g("div",kt,[l(C,{class:"mr-2"},{default:n(()=>[...e[10]||(e[10]=[r("mdi-check-circle",-1)])]),_:1}),r(" "+D(a.success),1)])]),_:1})):b("",!0),o.hasValidationErrors&&!a.loading?(v(),x(ie,{key:2,type:"warning",class:"mb-4 mt-3 mx-2",variant:"tonal",border:"start"},{default:n(()=>[e[12]||(e[12]=g("div",{class:"d-flex align-center"},[g("span",{class:"font-weight-bold"},"配置验证失败,请检查以下问题:")],-1)),l(Ce,{density:"compact",class:"bg-transparent"},{default:n(()=>[(v(!0),P(te,null,le(o.validationErrors,(s,m)=>(v(),x(pe,{key:m,class:"px-0 py-0"},{prepend:n(()=>[l(C,{size:"small",color:"warning"},{default:n(()=>[...e[11]||(e[11]=[r("mdi-circle-small",-1)])]),_:1})]),default:n(()=>[l(Oe,{class:"text-body-2"},{default:n(()=>[r(D(s),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})):b("",!0),a.loading?(v(),x(M,{key:3,class:"my-4",outlined:""},{default:n(()=>[l(E,null,{default:n(()=>[l(Je,{type:"article",class:"mx-auto"})]),_:1})]),_:1})):b("",!0),a.loading?b("",!0):(v(),P("div",xt,[g("div",_t,[l(y,{color:"success",variant:"elevated","prepend-icon":"mdi-open-in-new",onClick:o.openConfig,class:"mr-2 text-none",disabled:!o.isValidConfig},{default:n(()=>[...e[13]||(e[13]=[r(" 打开 ExamSchedule ",-1)])]),_:1},8,["onClick","disabled"]),o.isValidConfig?b("",!0):(v(),x(ut,{key:0,activator:"parent",location:"bottom"},{default:n(()=>[...e[14]||(e[14]=[g("span",null,"请先完善配置信息后再打开",-1)])]),_:1}))]),l($e,{modelValue:a.isEditMode,"onUpdate:modelValue":e[2]||(e[2]=s=>a.isEditMode=s),color:"primary",variant:"outlined",divided:""},{default:n(()=>[l(y,{class:"text-error","prepend-icon":"mdi-delete",onClick:o.confirmDelete},{default:n(()=>[...e[15]||(e[15]=[r(" 删除配置 ",-1)])]),_:1},8,["onClick"]),l(y,{value:!1,"prepend-icon":"mdi-eye"},{default:n(()=>[...e[16]||(e[16]=[r(" 预览 ",-1)])]),_:1}),l(y,{value:!0,"prepend-icon":"mdi-pencil"},{default:n(()=>[...e[17]||(e[17]=[r(" 编辑 ",-1)])]),_:1})]),_:1},8,["modelValue"])])),!a.loading&&!a.isEditMode?(v(),P("div",bt,[g("div",Dt,[g("div",Vt,D(a.localConfig.examName||"未设置考试名称"),1),g("div",Tt,D(a.localConfig.message||"未设置考试提示"),1),a.localConfig.room?(v(),x(ve,{key:0,size:"large",class:"px-4 py-2"},{default:n(()=>[l(C,{start:""},{default:n(()=>[...e[18]||(e[18]=[r("mdi-home",-1)])]),_:1}),r(" 考场:"+D(a.localConfig.room),1)]),_:1})):b("",!0)]),a.localConfig.examInfos&&a.localConfig.examInfos.length>0?(v(),P("div",Mt,[l(Q,null,{default:n(()=>[(v(!0),P(te,null,le(a.localConfig.examInfos,(s,m)=>(v(),x(U,{key:m,cols:"12",md:"6",lg:"4"},{default:n(()=>[l(M,{variant:"tonal",class:"h-100",hover:""},{default:n(()=>[l(B,{class:"bg-primary-lighten-5 pa-4"},{default:n(()=>[g("div",St,[l(C,{class:"mr-2"},{default:n(()=>[...e[19]||(e[19]=[r("mdi-book-open-page-variant",-1)])]),_:1}),g("span",Nt,D(s.name||"未设置科目"),1)])]),_:2},1024),l(E,{class:"pa-4"},{default:n(()=>[g("div",Et,[g("div",It,[l(C,{size:"small",class:"mr-2",color:"success"},{default:n(()=>[...e[20]||(e[20]=[r("mdi-clock-start",-1)])]),_:1}),e[21]||(e[21]=g("span",{class:"text-body-2 text-grey-darken-1"},"开始时间",-1))]),g("div",Pt,D(s.startFormatted||s.start||"未设置"),1)]),g("div",null,[g("div",Ut,[l(C,{size:"small",class:"mr-2",color:"error"},{default:n(()=>[...e[22]||(e[22]=[r("mdi-clock-end",-1)])]),_:1}),e[23]||(e[23]=g("span",{class:"text-body-2 text-grey-darken-1"},"结束时间",-1))]),g("div",zt,D(s.endFormatted||s.end||"未设置"),1)])]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1})])):(v(),P("div",Lt,[l(C,{size:"80",color:"grey-lighten-2",class:"mb-4"},{default:n(()=>[...e[24]||(e[24]=[r(" mdi-calendar-blank ",-1)])]),_:1}),e[27]||(e[27]=g("div",{class:"text-h5 text-grey-darken-1 mb-2"},"暂无考试科目安排",-1)),e[28]||(e[28]=g("div",{class:"text-body-1 text-grey mb-4"},' 点击上方"添加科目"按钮开始配置考试时间表 ',-1)),l(y,{color:"primary",variant:"outlined",onClick:o.quickEdit},{default:n(()=>[l(C,{start:""},{default:n(()=>[...e[25]||(e[25]=[r("mdi-plus",-1)])]),_:1}),e[26]||(e[26]=r(" 立即添加 ",-1))]),_:1},8,["onClick"])])),l(M,{class:"mb-4",elevation:"2",border:""},{default:n(()=>[l(B,{class:"d-flex align-center text-white cursor-pointer",onClick:e[3]||(e[3]=s=>a.showJsonPreview=!a.showJsonPreview)},{default:n(()=>[l(C,{class:"mr-2"},{default:n(()=>[...e[29]||(e[29]=[r("mdi-code-json",-1)])]),_:1}),e[31]||(e[31]=r(" JSON配置预览 ",-1)),l(q),l(y,{color:"white",variant:"outlined","prepend-icon":"mdi-content-copy",size:"small",onClick:et(o.copyToClipboard,["stop"])},{default:n(()=>[...e[30]||(e[30]=[r(" 复制 ",-1)])]),_:1},8,["onClick"]),l(y,{color:"white",variant:"text",size:"small",icon:a.showJsonPreview?"mdi-chevron-up":"mdi-chevron-down",class:"ml-2"},null,8,["icon"])]),_:1}),l(tt,null,{default:n(()=>[lt(l(E,{class:"pa-4"},{default:n(()=>[l(M,{variant:"tonal",class:"pa-4"},{default:n(()=>[g("pre",Ht,[g("code",null,D(o.formattedJson),1)])]),_:1})]),_:1},512),[[nt,a.showJsonPreview]])]),_:1})]),_:1})])):b("",!0),!a.loading&&a.isEditMode?(v(),P("div",Rt,[l(M,{class:"mb-4",elevation:"1",border:""},{default:n(()=>[l(B,{class:"d-flex align-center"},{default:n(()=>[l(C,{class:"mr-2"},{default:n(()=>[...e[32]||(e[32]=[r("mdi-information",-1)])]),_:1}),e[33]||(e[33]=r(" 基本信息 ",-1))]),_:1}),l(E,{class:"pa-4"},{default:n(()=>[l(Q,null,{default:n(()=>[l(U,{cols:"12",md:"6"},{default:n(()=>[l(Z,{modelValue:a.localConfig.examName,"onUpdate:modelValue":e[4]||(e[4]=s=>a.localConfig.examName=s),label:"考试名称","prepend-inner-icon":"mdi-calendar-text",variant:"outlined",rules:[s=>!!s||"考试名称不能为空"],required:""},null,8,["modelValue","rules"])]),_:1}),l(U,{cols:"12",md:"6"},{default:n(()=>[l(Z,{modelValue:a.localConfig.room,"onUpdate:modelValue":e[5]||(e[5]=s=>a.localConfig.room=s),label:"考场号标准ES尚不支持此配置","prepend-inner-icon":"mdi-home",variant:"outlined"},null,8,["modelValue"])]),_:1})]),_:1}),l(mt,{modelValue:a.localConfig.message,"onUpdate:modelValue":e[6]||(e[6]=s=>a.localConfig.message=s),label:"考试提示","prepend-inner-icon":"mdi-message-text",variant:"outlined",rows:"3",placeholder:"输入考试相关的提示信息..."},null,8,["modelValue"]),!a.localConfig.message||a.localConfig.message.trim()===""?(v(),x(dt,{key:0,class:"mt-2",column:""},{default:n(()=>[(v(!0),P(te,null,le(a.defaultExamTips,(s,m)=>(v(),x(ve,{key:m,color:"primary",variant:"outlined",size:"small",onClick:f=>o.selectDefaultTip(s),class:"ma-1"},{default:n(()=>[l(C,{start:"",size:"small"},{default:n(()=>[...e[34]||(e[34]=[r("mdi-plus",-1)])]),_:1}),r(" "+D(s),1)]),_:2},1032,["onClick"]))),128))]),_:1})):b("",!0),g("div",At,[l(C,{size:"small",class:"mr-1"},{default:n(()=>[...e[35]||(e[35]=[r("mdi-lightbulb-outline",-1)])]),_:1}),e[36]||(e[36]=r(" 点击上方选项快速添加常用考试提示 ",-1))])]),_:1})]),_:1}),l(M,{class:"mb-4",elevation:"1",border:""},{default:n(()=>[l(B,{class:"d-flex align-center"},{default:n(()=>[l(C,{class:"mr-2"},{default:n(()=>[...e[37]||(e[37]=[r("mdi-format-list-bulleted",-1)])]),_:1}),e[39]||(e[39]=r(" 考试科目安排 ",-1)),l(q),l(y,{color:"primary","prepend-icon":"mdi-plus",size:"small",onClick:o.addExamInfo},{default:n(()=>[...e[38]||(e[38]=[r(" 添加科目 ",-1)])]),_:1},8,["onClick"])]),_:1}),l(E,{class:"pa-0"},{default:n(()=>[a.localConfig.examInfos&&a.localConfig.examInfos.length>0?(v(),x(Ce,{key:0},{default:n(()=>[(v(!0),P(te,null,le(a.localConfig.examInfos,(s,m)=>(v(),x(pe,{key:m,class:"border-b pa-4"},{default:n(()=>[g("div",Bt,[l(Q,null,{default:n(()=>[l(U,{cols:"12",md:"4"},{default:n(()=>[l(Z,{modelValue:s.name,"onUpdate:modelValue":f=>s.name=f,label:"科目名称","prepend-inner-icon":"mdi-book",variant:"outlined",density:"comfortable",rules:[f=>!!f||"科目名称不能为空"]},null,8,["modelValue","onUpdate:modelValue","rules"])]),_:2},1024),l(U,{cols:"12",md:"3"},{default:n(()=>[l(Ie,{modelValue:s.startDateMenu,"onUpdate:modelValue":f=>s.startDateMenu=f,"close-on-content-click":!1,transition:"scale-transition","offset-y":"","min-width":"auto"},{activator:n(({props:f})=>[l(Z,ne({modelValue:s.startFormatted,"onUpdate:modelValue":I=>s.startFormatted=I,label:"开始时间","prepend-inner-icon":"mdi-clock-start",variant:"outlined",density:"comfortable",readonly:""},{ref_for:!0},f,{rules:[I=>!!I||"开始时间不能为空"]}),null,16,["modelValue","onUpdate:modelValue","rules"])]),default:n(()=>[l(M,{"min-width":"600"},{default:n(()=>[l(B,{class:"text-center py-2"},{default:n(()=>[...e[40]||(e[40]=[r(" 选择开始时间 ",-1)])]),_:1}),l(E,{class:"pa-0"},{default:n(()=>[l(Q,{"no-gutters":""},{default:n(()=>[l(U,{cols:"6",class:"border-e"},{default:n(()=>[l(Ue,{modelValue:s.startDate,"onUpdate:modelValue":[f=>s.startDate=f,f=>o.updateStartDateTime(m)],color:"primary",locale:"zh-cn","show-adjacent-months":"",elevation:"0"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),l(U,{cols:"6"},{default:n(()=>[l(He,{modelValue:s.startTime,"onUpdate:modelValue":[f=>s.startTime=f,f=>o.updateStartDateTime(m)],color:"primary",format:"24hr",scrollable:"",elevation:"0"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024)]),_:2},1024),l(ae,null,{default:n(()=>[l(q),l(y,{color:"grey",variant:"text",onClick:f=>s.startDateMenu=!1},{default:n(()=>[...e[41]||(e[41]=[r(" 取消 ",-1)])]),_:2},1032,["onClick"]),l(y,{color:"primary",variant:"text",onClick:f=>s.startDateMenu=!1},{default:n(()=>[...e[42]||(e[42]=[r(" 确定 ",-1)])]),_:2},1032,["onClick"])]),_:2},1024)]),_:2},1024)]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1024),l(U,{cols:"12",md:"3"},{default:n(()=>[l(Ie,{modelValue:s.endDateMenu,"onUpdate:modelValue":f=>s.endDateMenu=f,"close-on-content-click":!1,transition:"scale-transition","offset-y":"","min-width":"auto"},{activator:n(({props:f})=>[l(Z,ne({modelValue:s.endFormatted,"onUpdate:modelValue":I=>s.endFormatted=I,label:"结束时间","prepend-inner-icon":"mdi-clock-end",variant:"outlined",density:"comfortable",readonly:""},{ref_for:!0},f,{rules:[I=>!!I||"结束时间不能为空"]}),null,16,["modelValue","onUpdate:modelValue","rules"])]),default:n(()=>[l(M,{"min-width":"600"},{default:n(()=>[l(B,{class:"text-center py-2"},{default:n(()=>[...e[43]||(e[43]=[r(" 选择结束时间 ",-1)])]),_:1}),l(E,{class:"pa-0"},{default:n(()=>[l(Q,{"no-gutters":""},{default:n(()=>[l(U,{cols:"6",class:"border-e"},{default:n(()=>[l(Ue,{modelValue:s.endDate,"onUpdate:modelValue":[f=>s.endDate=f,f=>o.updateEndDateTime(m)],color:"primary",locale:"zh-cn","show-adjacent-months":"",elevation:"0"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),l(U,{cols:"6"},{default:n(()=>[l(He,{modelValue:s.endTime,"onUpdate:modelValue":[f=>s.endTime=f,f=>o.updateEndDateTime(m)],color:"primary",format:"24hr",scrollable:"",elevation:"0"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024)]),_:2},1024),l(ae,null,{default:n(()=>[l(q),l(y,{color:"grey",variant:"text",onClick:f=>s.endDateMenu=!1},{default:n(()=>[...e[44]||(e[44]=[r(" 取消 ",-1)])]),_:2},1032,["onClick"]),l(y,{color:"primary",variant:"text",onClick:f=>s.endDateMenu=!1},{default:n(()=>[...e[45]||(e[45]=[r(" 确定 ",-1)])]),_:2},1032,["onClick"])]),_:2},1024)]),_:2},1024)]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1024),l(U,{cols:"12",md:"2",class:"d-flex align-center"},{default:n(()=>[l(y,{icon:"mdi-delete",color:"error",variant:"text",size:"small",onClick:f=>o.removeExamInfo(m)},{default:n(()=>[l(C,null,{default:n(()=>[...e[46]||(e[46]=[r("mdi-delete",-1)])]),_:1})]),_:2},1032,["onClick"]),m>0?(v(),x(y,{key:0,icon:"mdi-arrow-up",color:"primary",variant:"text",size:"small",onClick:f=>o.moveExamInfo(m,-1)},{default:n(()=>[l(C,null,{default:n(()=>[...e[47]||(e[47]=[r("mdi-arrow-up",-1)])]),_:1})]),_:2},1032,["onClick"])):b("",!0),m<a.localConfig.examInfos.length-1?(v(),x(y,{key:1,icon:"mdi-arrow-down",color:"primary",variant:"text",size:"small",onClick:f=>o.moveExamInfo(m,1)},{default:n(()=>[l(C,null,{default:n(()=>[...e[48]||(e[48]=[r("mdi-arrow-down",-1)])]),_:1})]),_:2},1032,["onClick"])):b("",!0)]),_:2},1024)]),_:2},1024)])]),_:2},1024))),128))]),_:1})):(v(),P("div",Ft,[l(C,{size:"48",color:"grey-lighten-1",class:"mb-2"},{default:n(()=>[...e[49]||(e[49]=[r(" mdi-book-plus ",-1)])]),_:1}),e[51]||(e[51]=g("p",{class:"text-body-2 text-grey-darken-1 mb-4"},' 暂无考试科目,点击"添加科目"按钮开始添加 ',-1)),l(y,{color:"primary","prepend-icon":"mdi-plus",onClick:o.addExamInfo},{default:n(()=>[...e[50]||(e[50]=[r(" 添加科目 ",-1)])]),_:1},8,["onClick"])]))]),_:1})]),_:1})])):b("",!0),l(we,{modelValue:a.deleteDialog,"onUpdate:modelValue":e[8]||(e[8]=s=>a.deleteDialog=s),"max-width":"400"},{default:n(()=>[l(M,null,{default:n(()=>[l(B,{class:"d-flex align-center"},{default:n(()=>[l(C,{color:"error",class:"mr-2"},{default:n(()=>[...e[52]||(e[52]=[r("mdi-delete-alert",-1)])]),_:1}),e[53]||(e[53]=r(" 确认删除配置 ",-1))]),_:1}),l(E,null,{default:n(()=>[e[54]||(e[54]=r(" 确定要删除配置 ",-1)),g("strong",null,D(a.localConfig.examName||`配置 ${i.configId}`),1),e[55]||(e[55]=r(" 吗? ",-1)),e[56]||(e[56]=g("br",null,null,-1)),e[57]||(e[57]=g("small",{class:"text-grey"},"此操作不可撤销,将会删除所有相关数据",-1))]),_:1}),l(ae,null,{default:n(()=>[l(q),l(y,{color:"grey",variant:"text",onClick:e[7]||(e[7]=s=>a.deleteDialog=!1)},{default:n(()=>[...e[58]||(e[58]=[r(" 取消 ",-1)])]),_:1}),l(y,{color:"error",variant:"outlined",onClick:o.deleteConfig,loading:a.deleting},{default:n(()=>[...e[59]||(e[59]=[r(" 删除 ",-1)])]),_:1},8,["onClick","loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}const qe=Fe(pt,[["render",Ot],["__scopeId","data-v-a9cabba0"]]),Jt={name:"ExamScheduleManager",components:{ExamConfigEditor:qe},data(){return{configs:[],loading:!1,error:"",success:"",renameDialog:!1,editDialog:!1,configToRename:null,editingConfig:null,newConfigName:"",renaming:!1,saving:!1}},async mounted(){await this.loadConfigs()},methods:{async initializeExampleData(){const t=[{id:"exam_example_001",examName:"期末考试安排",message:"请按时参加考试,携带学生证和身份证",examInfos:[{name:"数学",start:"2025/01/15 09:00",end:"2025/01/15 11:00"},{name:"英语",start:"2025/01/16 14:00",end:"2025/01/16 16:00"}]},{id:"exam_example_002",examName:"期中考试安排",message:"考试期间请保持安静",examInfos:[{name:"物理",start:"2025/01/20 10:00",end:"2025/01/20 12:00"},{name:"化学",start:"2025/01/21 14:00",end:"2025/01/21 16:00"}]},{id:"exam_example_003",examName:"模拟考试安排",message:"模拟考试,请认真对待",examInfos:[{name:"语文",start:"2025/01/25 09:00",end:"2025/01/25 11:30"}]}],e=t.map(i=>({id:i.id}));await z.saveData("es_list",e);for(let i of t){const u={...i};delete u.id,await z.saveData(`es_${i.id}`,u)}return t},async loadConfigs(){this.loading=!0,this.error="";try{const t=await z.loadData("es_list");if(t&&t&&t.length>0){this.configs=[];for(let e of t)try{const i=await z.loadData(`es_${e.id}`);i&&this.configs.push({id:e.id,...i})}catch(i){console.warn(`加载配置 es_${e.id} 失败:`,i)}}else this.configs=await this.initializeExampleData()}catch(t){this.error="加载配置列表失败: "+t.message,this.configs=[]}finally{this.loading=!1}},async createNewConfig(){var i,u;const t=Date.now().toString(),e={examName:"新考试配置",message:"请编辑此配置",room:rt("server.classNumber")||"待定",examInfos:[{name:"科目1",start:"2025/08/29 16:27",end:"2025/08/29 17:27"}]};try{const a=await z.saveData(`es_${t}`,e);if(!a)throw new Error(((i=a.error)==null?void 0:i.message)||"保存失败");this.configs.push({id:t,...e});const o=this.configs.map(f=>({id:f.id})),s=await z.saveData("es_list",o);if(!s)throw new Error(((u=s.error)==null?void 0:u.message)||"更新列表失败");this.success="新配置创建成功";const m=this.configs.find(f=>f.id===t);m&&(this.editingConfig=m,this.editDialog=!0)}catch(a){this.error="创建配置失败: "+a.message}},showRenameDialog(t){this.configToRename=t,this.newConfigName=t.examName||`配置 ${t.id}`,this.renameDialog=!0},async renameConfig(){var t;if(!(!this.configToRename||!this.newConfigName)){this.renaming=!0;try{const e={examName:this.newConfigName,message:this.configToRename.message,examInfos:this.configToRename.examInfos},i=await z.saveData(`es_${this.configToRename.id}`,e);if(!i)throw new Error(((t=i.error)==null?void 0:t.message)||"保存失败");const u=this.configs.findIndex(a=>a.id===this.configToRename.id);u!==-1&&(this.configs[u].examName=this.newConfigName),this.success="配置重命名成功",this.renameDialog=!1,this.configToRename=null,this.newConfigName=""}catch(e){this.error="重命名配置失败: "+e.message}finally{this.renaming=!1}}},showEditDialog(t){this.editingConfig=t,this.editDialog=!0},closeEditDialog(){this.editDialog=!1,this.editingConfig=null,this.saving=!1},async saveConfigInDialog(){if(this.$refs.configEditor){this.saving=!0;try{await this.$refs.configEditor.saveConfig()}catch(t){console.error("保存配置失败:",t)}finally{this.saving=!1}}},onConfigSaved(){this.success="配置保存成功!",this.loadConfigs(),setTimeout(()=>{this.success=""},3e3)},onConfigError(t){this.error=t||"保存配置时发生错误",setTimeout(()=>{this.error=""},5e3)},onConfigOpened(t){this.success="配置已在新窗口中打开",setTimeout(()=>{this.success=""},3e3)},onConfigDeleted(t){t.success?(this.success=t.message||"配置删除成功",this.editDialog=!1,this.loadConfigs()):this.error=t.message||"删除失败"}}},jt={class:"d-flex align-center"},qt={class:"d-flex align-center"},Kt={class:"d-flex justify-space-between align-center mb-4"},Yt={class:"d-flex align-center"},Wt={class:"d-flex align-center"},Gt={class:"d-flex align-center mt-1"},Xt={class:"d-flex align-center"};function Qt(t,e,i,u,a,o){const s=qe;return v(),x(ft,{class:"fill-height"},{default:n(()=>[l(Q,null,{default:n(()=>[l(U,{cols:"12"},{default:n(()=>[l(M,{class:"elevation-12",border:""},{default:n(()=>[l(B,{class:"d-flex align-center primary lighten-1 white--text py-3 px-4"},{default:n(()=>[l(C,{color:"white",class:"mr-2"},{default:n(()=>[...e[6]||(e[6]=[r("mdi-calendar-check",-1)])]),_:1}),e[7]||(e[7]=r(" 考试看板 ",-1))]),_:1}),l(at,null,{default:n(()=>[...e[8]||(e[8]=[r(" 不只是考试看板。 ",-1)])]),_:1}),l(E,null,{default:n(()=>[a.error?(v(),x(ie,{key:0,type:"error",class:"mb-4 mt-3 mx-2",variant:"tonal",border:"start",closable:"","onClick:close":e[0]||(e[0]=m=>a.error="")},{default:n(()=>[g("div",jt,[l(C,{class:"mr-2"},{default:n(()=>[...e[9]||(e[9]=[r("mdi-alert-circle",-1)])]),_:1}),r(" "+D(a.error),1)])]),_:1})):b("",!0),a.success?(v(),x(ie,{key:1,type:"success",class:"mb-4 mt-3 mx-2",variant:"tonal",border:"start",closable:"","onClick:close":e[1]||(e[1]=m=>a.success="")},{default:n(()=>[g("div",qt,[l(C,{class:"mr-2"},{default:n(()=>[...e[10]||(e[10]=[r("mdi-check-circle",-1)])]),_:1}),r(" "+D(a.success),1)])]),_:1})):b("",!0),g("div",Kt,[g("div",Yt,[l(y,{color:"primary","prepend-icon":"mdi-plus",class:"mr-2",onClick:o.createNewConfig},{default:n(()=>[...e[11]||(e[11]=[r(" 新建配置 ",-1)])]),_:1},8,["onClick"]),l(y,{color:"info","prepend-icon":"mdi-refresh",loading:a.loading,onClick:o.loadConfigs,variant:"outlined"},{default:n(()=>[...e[12]||(e[12]=[r(" 刷新 ",-1)])]),_:1},8,["loading","onClick"])]),a.configs.length>0?(v(),x(ve,{key:0,color:"primary","prepend-icon":"mdi-format-list-numbered"},{default:n(()=>[r(D(a.configs.length)+" 个配置 ",1)]),_:1})):b("",!0)]),a.loading?(v(),x(M,{key:2,class:"my-4",outlined:""},{default:n(()=>[l(E,null,{default:n(()=>[l(Je,{type:"list-item-avatar-two-line@3",class:"mx-auto"})]),_:1})]),_:1})):b("",!0),!a.loading&&a.configs.length>0?(v(),x(M,{key:3,class:"my-4",elevation:"1"},{default:n(()=>[l(B,{class:"d-flex align-center pa-4 bg-primary-lighten-5"},{default:n(()=>[l(C,{class:"mr-2"},{default:n(()=>[...e[13]||(e[13]=[r("mdi-format-list-bulleted",-1)])]),_:1}),e[14]||(e[14]=g("span",{class:"font-weight-bold"},"配置列表",-1))]),_:1}),l(Ce,null,{default:n(()=>[(v(!0),P(te,null,le(a.configs,m=>(v(),x(pe,{key:m.id,class:"border-b",style:{cursor:"pointer"},onClick:f=>o.showEditDialog(m)},{prepend:n(()=>[l(ot,{color:"primary",class:"mr-2"},{default:n(()=>[l(C,{color:"white"},{default:n(()=>[...e[15]||(e[15]=[r("mdi-calendar-text",-1)])]),_:1})]),_:1})]),append:n(()=>[g("div",Xt,[l(y,{icon:"mdi-pencil",size:"small",color:"primary",variant:"text",class:"mr-1",onClick:f=>o.showEditDialog(m)},{default:n(()=>[l(C,null,{default:n(()=>[...e[18]||(e[18]=[r("mdi-pencil",-1)])]),_:1})]),_:2},1032,["onClick"]),l(y,{icon:"mdi-eye",size:"small",color:"info",variant:"text",class:"mr-1",onClick:f=>o.showEditDialog(m)},{default:n(()=>[l(C,null,{default:n(()=>[...e[19]||(e[19]=[r("mdi-eye",-1)])]),_:1})]),_:2},1032,["onClick"])])]),default:n(()=>[l(Oe,{class:"font-weight-medium"},{default:n(()=>[r(D(m.examName||`配置 ${m.id}`),1)]),_:2},1024),l(it,{class:"text-caption mt-1"},{default:n(()=>[g("div",Wt,[l(C,{size:"small",class:"mr-1"},{default:n(()=>[...e[16]||(e[16]=[r("mdi-information-outline",-1)])]),_:1}),r(" "+D(m.message||"无描述"),1)]),g("div",Gt,[l(C,{size:"small",class:"mr-1"},{default:n(()=>[...e[17]||(e[17]=[r("mdi-book-multiple",-1)])]),_:1}),r(" "+D(m.examInfos?m.examInfos.length:0)+" 堂考试 ",1)])]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1})):b("",!0),!a.loading&&a.configs.length===0?(v(),x(M,{key:4,class:"my-4",elevation:"1"},{default:n(()=>[l(E,{class:"text-center py-8"},{default:n(()=>[l(C,{size:"64",color:"grey-lighten-1",class:"mb-4"},{default:n(()=>[...e[20]||(e[20]=[r(" mdi-calendar-blank ",-1)])]),_:1}),e[22]||(e[22]=g("h3",{class:"text-h6 mb-2 text-grey-darken-1"},"暂无配置",-1)),e[23]||(e[23]=g("p",{class:"text-body-2 text-grey-darken-1 mb-4"},' 点击"新建配置"按钮创建您的第一个考试配置 ',-1)),l(y,{color:"primary","prepend-icon":"mdi-plus",onClick:o.createNewConfig},{default:n(()=>[...e[21]||(e[21]=[r(" 新建配置 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})):b("",!0)]),_:1})]),_:1})]),_:1})]),_:1}),l(we,{modelValue:a.renameDialog,"onUpdate:modelValue":e[4]||(e[4]=m=>a.renameDialog=m),"max-width":"500"},{default:n(()=>[l(M,null,{default:n(()=>[l(B,{class:"d-flex align-center"},{default:n(()=>[l(C,{color:"primary",class:"mr-2"},{default:n(()=>[...e[24]||(e[24]=[r("mdi-rename-box",-1)])]),_:1}),e[25]||(e[25]=r(" 重命名配置 ",-1))]),_:1}),l(E,null,{default:n(()=>[l(Z,{modelValue:a.newConfigName,"onUpdate:modelValue":e[2]||(e[2]=m=>a.newConfigName=m),label:"配置名称","prepend-inner-icon":"mdi-calendar-text",variant:"outlined",rules:[m=>!!m||"配置名称不能为空"],onKeyup:st(o.renameConfig,["enter"])},null,8,["modelValue","rules","onKeyup"])]),_:1}),l(ae,null,{default:n(()=>[l(q),l(y,{color:"grey",variant:"text",onClick:e[3]||(e[3]=m=>a.renameDialog=!1)},{default:n(()=>[...e[26]||(e[26]=[r(" 取消 ",-1)])]),_:1}),l(y,{color:"primary",variant:"outlined",loading:a.renaming,onClick:o.renameConfig,disabled:!a.newConfigName},{default:n(()=>[...e[27]||(e[27]=[r(" 确认 ",-1)])]),_:1},8,["loading","onClick","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),l(we,{modelValue:a.editDialog,"onUpdate:modelValue":e[5]||(e[5]=m=>a.editDialog=m),"max-width":"1200",persistent:""},{default:n(()=>[l(M,null,{default:n(()=>[l(B,{class:"d-flex align-center primary lighten-1 white--text py-3 px-4"},{default:n(()=>[l(C,{color:"white",class:"mr-2"},{default:n(()=>[...e[28]||(e[28]=[r("mdi-pencil",-1)])]),_:1}),e[30]||(e[30]=r(" 编辑考试配置 ",-1)),l(q),a.editingConfig?(v(),x(ve,{key:0,color:"white","text-color":"primary",size:"small",class:"mr-2"},{default:n(()=>[r(" ID: "+D(a.editingConfig.id),1)]),_:1})):b("",!0),l(y,{icon:"mdi-close",color:"white",variant:"text",onClick:o.closeEditDialog},{default:n(()=>[l(C,null,{default:n(()=>[...e[29]||(e[29]=[r("mdi-close",-1)])]),_:1})]),_:1},8,["onClick"])]),_:1}),l(E,{class:"pa-4",style:{"max-height":"70vh","overflow-y":"auto"}},{default:n(()=>[a.editingConfig?(v(),x(s,{key:0,"config-id":a.editingConfig.id,ref:"configEditor","dialog-mode":!0,onSaved:o.onConfigSaved,onError:o.onConfigError,onOpened:o.onConfigOpened,onDeleted:o.onConfigDeleted},null,8,["config-id","onSaved","onError","onOpened","onDeleted"])):b("",!0)]),_:1}),l(ae,{class:"pa-4"},{default:n(()=>[l(y,{color:"grey",variant:"outlined","prepend-icon":"mdi-close",onClick:o.closeEditDialog},{default:n(()=>[...e[31]||(e[31]=[r(" 关闭 ",-1)])]),_:1},8,["onClick"]),l(q),l(y,{color:"success",variant:"outlined","prepend-icon":"mdi-content-save",loading:a.saving,onClick:o.saveConfigInDialog},{default:n(()=>[...e[32]||(e[32]=[r(" 保存配置 ",-1)])]),_:1},8,["loading","onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})}const ul=Fe(Jt,[["render",Qt],["__scopeId","data-v-87e82d7e"]]);export{ul as default};