index.b83d22e8.js 12 KB

1
  1. import{C as x}from"./index.98009975.js";import{bg as h,d as C,c as t,a as c,bd as j,be as f,aZ as y,b as g,bi as E,aM as N,F as v,bb as I,bc as p,E as _,b1 as O,bf as k}from"./index.25c29239.js";import{v as M}from"./toolsValidate.add49407.js";import{c as H,i as P}from"./isSameOrBefore.98035e6a.js";import{E as b,a as F}from"./index2.fcf14428.js";import{E as V,a as w}from"./index2.025aff2f.js";import"./index2.32ff5740.js";const B="_timer_t2oca_1",D="_tips_t2oca_5",L="_tipsTitle_t2oca_11",A="_tipsTime_t2oca_17",J="_timerContainer_t2oca_26",q="_tag_t2oca_34",U="_active_t2oca_45",$="_select_t2oca_49",l={timer:B,tips:D,tipsTitle:L,tipsTime:A,timerContainer:J,tag:q,active:U,select:$};h.extend(H);h.extend(P);const R=C({name:"practice-timer",props:{timerObject:{type:Object,default:{}},onClose:{type:Function,default:()=>{}},onChoice:{type:Function,default:e=>{}},courseMinutes:{type:Number,default:25},freeMinutes:{type:Number,default:5},startSetting:{type:String,default:"08:00"},endSetting:{type:String,default:"18:00"}},data(){return{timerList:[],list:[],weekList:["\u5468\u4E00","\u5468\u4E8C","\u5468\u4E09","\u5468\u56DB","\u5468\u4E94","\u5468\u516D","\u5468\u65E5"],weekType:["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]}},mounted(){this.list=this.timerInit(this.startSetting,this.endSetting,this.courseMinutes+this.freeMinutes||30)},methods:{timerInit(e,i,r){let s=h(e,"HH:mm");const a=h(i,"HH:mm"),u=[];for(;s.add(r,"minute").isSameOrBefore(h(a));){const o={startTime:s.format("HH:mm"),endTime:s.add(r,"minute").format("HH:mm"),status:!1};u.push(o),s=s.add(r,"minute")}const n=[];return u.forEach(o=>{const m=[];for(let S=0;S<7;S++)m.push({...o});n.push(m)}),this._initData(n)},_initData(e){const i=this.weekType,r=this.timerObject;return e.forEach(s=>{s.forEach((a,u)=>{const n=r[i[u]],d=h(a.startTime,"HH:mm").format("HH:mm:ss");(n==null?void 0:n.some(m=>m.startTime===d))&&(a.status=!0)})}),e},btnStatus(e,i){if(i==="row")return this.list.every(r=>r[e].status);if(i=="col")return this.list[e].every(r=>r.status)},choice(e,i,r){i==="row"&&this.list.forEach((s,a)=>{const u=!r;s[e].status=u}),i=="col"&&this.list[e].forEach((s,a)=>{const u=!r;s.status=u})},onSubmit(){const e=this.list,i={monday:[],tuesday:[],wednesday:[],thursday:[],friday:[],saturday:[],sunday:[]},r=this.weekType;let s=!1;e.forEach((a,u)=>{a.forEach((n,d)=>{n.status&&(s=!0,i[r[d]].push({startTime:h(n.startTime,"HH:mm").format("HH:mm:ss"),endTime:h(n.endTime,"HH:mm").subtract(this.freeMinutes,"minute").format("HH:mm:ss")}))})}),this.onChoice&&this.onChoice(i,s)}},render(){return t("div",{class:l.timer},[t("div",{class:l.tips},[t("div",{class:l.tipsTitle},[c("\u8BF7\u9009\u62E9\u966A\u7EC3\u5F00\u59CB\u65F6\u95F4")]),t("div",{class:l.tipsTime},[c("\u966A\u7EC3\u8BFE\u5355\u8BFE\u65F6\u65F6\u957F\u4E3A "),t("span",null,[this.courseMinutes]),c(" \u5206\u949F")])]),t("div",{class:[l.timerContainer,"mb12"]},[t(j,{gutter:5,class:"pr-2"},{default:()=>[t(f,{span:3},null),this.weekList.map(e=>t(f,{span:3},{default:()=>[t("span",{class:l.tag},[e])]}))]}),t(j,{gutter:5,class:"pt-1 pr-2"},{default:()=>[t(f,{span:3},null),this.weekList.map((e,i)=>t(f,{span:3},{default:()=>[t("span",{class:[l.tag,"cursor-pointer",this.btnStatus(i,"row")&&l.active],onClick:()=>this.choice(i,"row",this.btnStatus(i,"row"))},[c("\u5168\u9009")])]}))]}),t("div",{class:"h-72 overflow-y-auto overflow-x-hidden"},[this.list.map((e,i)=>t(j,{gutter:5,class:"pt-1"},{default:()=>[t(f,{span:3},{default:()=>[t("span",{class:[l.tag,"cursor-pointer",this.btnStatus(i,"col")&&l.active],onClick:()=>this.choice(i,"col",this.btnStatus(i,"col"))},[c("\u5168\u9009")])]}),e.map(r=>t(f,{span:3},{default:()=>[t("span",{class:[l.tag,"cursor-pointer",r.status&&l.select],style:{color:"#333333"},onClick:()=>r.status=!r.status},[r.startTime])]}))]}))])]),t("div",{class:"text-center pt-3 pb-5"},[t(y,{class:"!w-40 !h-[48px] !text-base",round:!0,onClick:()=>{this.onClose()}},{default:()=>[c("\u53D6\u6D88")]}),t(y,{type:"primary",class:"!w-40 !h-[48px] !text-base",onClick:this.onSubmit,round:!0},{default:()=>[c("\u4FDD\u5B58\u8BBE\u7F6E")]})])])}}),z="_setting_1il54_1",G={setting:z};function T(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!k(e)}const et=C({name:"practice-setting",data(){return{subjectList:[],chargeTypeArr:{0:"\u5426",1:"\u662F"},classTimeStatus:!1,subjectStatus:!1,timerStatus:!1,timeSetting:{courseMinutes:25,freeMinutes:5,startSetting:"08:00",endSetting:"18:00"},timerObject:{},form:{enableFlag:1,courseMinutes:null,freeMinutes:0,subjectIdTemp:"",subjectId:[],subjectPrice:[],skipHolidayFlag:1,setting:"\u672A\u8BBE\u7F6E"},minutes:[],rate:0}},async mounted(){try{((await g.get("/api-website/sysConfig/queryByParamNameList",{params:{paramNames:"practice_times_setting,practice_service_fee,course_start_setting,course_end_setting"}})).data||[]).forEach(u=>{if(u.paramName==="practice_times_setting"){const n=u.paramValue?JSON.parse(u.paramValue):[],d=[];n.forEach(o=>{d.push({...o,name:o.courseMinutes})}),this.minutes=[...d]}u.paramName==="practice_service_fee"&&(this.rate=u.paramValue),u.paramName==="course_start_setting"&&(this.timeSetting.startSetting=u.paramValue),u.paramName==="course_end_setting"&&(this.timeSetting.endSetting=u.paramValue)});const r=await g.post("/api-website/teacher/querySubject");this.subjectList=r.data||[];const a=(await g.post("/api-website/teacherFreeTime/getDetail",{data:{defaultFlag:1}})).data;if(a){this.timeSetting.courseMinutes=a.courseMinutes,this.timeSetting.freeMinutes=a.freeMinutes,this.timerObject={monday:a.monday?JSON.parse(a.monday):[],tuesday:a.tuesday?JSON.parse(a.tuesday):[],wednesday:a.wednesday?JSON.parse(a.wednesday):[],thursday:a.thursday?JSON.parse(a.thursday):[],friday:a.friday?JSON.parse(a.friday):[],saturday:a.saturday?JSON.parse(a.saturday):[],sunday:a.sunday?JSON.parse(a.sunday):[]};const u=[],n=[];(a.subjectPrice||[]).forEach(m=>{u.push(m.subjectId),n.push({subjectId:m.subjectId,subjectPrice:m.subjectPrice,subjectName:m.subjectName})});const o=this.timerObject;this.form={enableFlag:a.enableFlag?1:0,courseMinutes:a.courseMinutes,freeMinutes:a.freeMinutes,subjectIdTemp:u.join(","),subjectId:u,subjectPrice:n,skipHolidayFlag:a.skipHolidayFlag?1:0,setting:o.monday.length>0||o.tuesday.length>0||o.wednesday.length>0||o.thursday.length>0||o.friday.length>0||o.saturday.length>0||o.sunday.length>0?"\u5DF2\u8BBE\u7F6E":"\u672A\u8BBE\u7F6E"}}}catch{}},methods:{onSelect(e){this.form.courseMinutes!==e.courseMinutes&&(this.timerObject={},this.form.setting="\u672A\u8BBE\u7F6E"),this.form.courseMinutes=e.courseMinutes,this.form.freeMinutes=e.freeMinutes},async onTimer(){try{const e=this.form;if(!e.courseMinutes){E.error("\u8BF7\u9009\u62E9\u5355\u8BFE\u65F6\u65F6\u957F");return}this.timeSetting.courseMinutes=Number(e.courseMinutes),this.timeSetting.freeMinutes=Number(e.freeMinutes),this.timerStatus=!0}catch{}},onChoiceTimer(e,i){this.form.setting=i?"\u5DF2\u8BBE\u7F6E":"",this.timerObject=e,this.timerStatus=!1},onChoice(e){const i=e||[];this.form.subjectId=i,this.form.subjectIdTemp=i.join(",")||"";const r=[...this.form.subjectPrice];i.forEach(a=>{r.findIndex(n=>n.subjectId===a)===-1&&r.push({subjectId:a,subjectPrice:null,subjectName:""})});const s=[];r.forEach(a=>{i.some(n=>n===a.subjectId)&&s.push(a)}),this.form.subjectPrice=s,this.subjectStatus=!1},getSubjectName(e){const i=this.subjectList.find(r=>r.id===e);return i?i.name:""},onFormatter(e,i){M(e)},async onSubmit(){this.$refs.form.validate(async e=>{if(e)try{const i=this.form;i.subjectPrice.forEach(r=>{r.subjectName=this.getSubjectName(r.subjectId)}),i.setting=i.setting==="\u672A\u8BBE\u7F6E"?"":i.setting,await g.post("/api-website/teacherFreeTime/upSet",{data:{...i,...this.timerObject}}),E.success("\u8BBE\u7F6E\u6210\u529F"),setTimeout(()=>{postMessage({api:"back",content:{}})},500)}catch{}else return this.$nextTick(()=>{document.getElementsByClassName("is-error")[0].scrollIntoView({block:"center",behavior:"smooth"})}),!1})}},render(){var r;let e,i;return t("div",{class:G.setting},[t("div",{class:"text-2xl font-semibold text-black leading-none px-6 py-5 "},[c("\u966A\u7EC3\u8BFE\u8BBE\u7F6E")]),(r=N.user.data)!=null&&r.entryFlag?t(v,null,[t(I,{labelPosition:"left",labelWidth:"188px",size:"large",model:this.form,ref:"form",class:"px-6 py-5"},{default:()=>[t(p,{label:"\u662F\u5426\u5F00\u542F\u966A\u7EC3",prop:"enableFlag",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u662F\u5426\u5F00\u542F\u966A\u7EC3"}]},{default:()=>[t(b,{class:"w-full",modelValue:this.form.enableFlag,"onUpdate:modelValue":s=>this.form.enableFlag=s},{default:()=>[t(b.Option,{value:1,label:"\u662F"},{default:()=>[c("\u662F")]}),t(b.Option,{value:0,label:"\u5426"},{default:()=>[c("\u5426")]})]})]}),t(p,{label:"\u53EF\u6559\u6388\u58F0\u90E8",prop:"subjectId",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u53EF\u6559\u6388\u58F0\u90E8",trigger:"change"}]},{default:()=>[t(b,{multiple:!0,filterable:!0,placeholder:"\u8BF7\u9009\u62E9\u53EF\u6559\u6388\u58F0\u90E8",class:"w-full",multipleLimit:5,modelValue:this.form.subjectId,"onUpdate:modelValue":s=>this.form.subjectId=s,onChange:this.onChoice},T(e=this.subjectList.map(s=>t(F,{key:s.id,value:s.id,label:s.name},null)))?e:{default:()=>[e]})]}),t(p,{label:"\u5355\u8BFE\u65F6\u957F",prop:"courseMinutes",rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u5355\u8BFE\u65F6\u957F",trigger:"change"}]},{default:()=>[t(b,{class:"w-full",placeholder:"\u8BF7\u9009\u62E9\u5355\u8BFE\u65F6\u65F6\u957F",modelValue:this.form.courseMinutes,"onUpdate:modelValue":s=>this.form.courseMinutes=s,onChange:s=>{this.timerObject={},this.form.setting="\u672A\u8BBE\u7F6E",this.minutes.forEach(a=>{a.courseMinutes===s&&(this.form.freeMinutes=a.freeMinutes)})}},T(i=this.minutes.map(s=>t(F,{key:s.courseMinutes,value:s.courseMinutes},{default:()=>[s.name]})))?i:{default:()=>[i]})]}),this.form.subjectPrice.map((s,a)=>t(p,{label:`${this.getSubjectName(s.subjectId)}\u966A\u7EC3\u4EF7\u683C`,prop:`subjectPrice.${a}.subjectPrice`,rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u58F0\u90E8\u966A\u7EC3\u4EF7\u683C"}]},{default:()=>[t(_,{onInput:u=>{s.subjectPrice=M(u)},type:"text",placeholder:"\u8BF7\u8F93\u5165\u966A\u7EC3\u4EF7\u683C",modelValue:s.subjectPrice,"onUpdate:modelValue":u=>s.subjectPrice=u,maxlength:8},{suffix:()=>t("span",{class:"text-base text-[#999]"},[c("\u5143")])})]})),t(p,{label:"\u662F\u5426\u8DF3\u8FC7\u8282\u5047\u65E5"},{default:()=>[t(V,{modelValue:this.form.skipHolidayFlag,"onUpdate:modelValue":s=>this.form.skipHolidayFlag=s},{default:()=>[t(w,{label:1,class:"mr-3 w-24"},{default:()=>[c("\u662F")]}),t(w,{label:0,class:"w-24"},{default:()=>[c("\u5426")]})]})]}),t(p,{label:"\u966A\u7EC3\u65F6\u95F4\u6BB5"},{default:()=>[t("div",{onClick:this.onTimer,class:"w-full"},[t(_,{readonly:!0,class:"cursor-pointer",modelValue:this.form.setting,"onUpdate:modelValue":s=>this.form.setting=s,placeholder:"\u8BF7\u9009\u62E9\u966A\u7EC3\u65F6\u95F4\u6BB5",suffixIcon:"ArrowDown"},null)])]})]}),t("div",{class:"text-center pt-6 pb-7"},[t(y,{class:"!w-44 !h-[48px] !text-base",round:!0,onClick:()=>{this.form={enableFlag:1,courseMinutes:null,freeMinutes:0,subjectIdTemp:"",subjectId:[],subjectPrice:[],skipHolidayFlag:1,setting:"\u672A\u8BBE\u7F6E"},this.$refs.form.resetFields()}},{default:()=>[c("\u91CD\u7F6E")]}),t(y,{type:"primary",class:"!w-44 !h-[48px] !text-base",round:!0,onClick:this.onSubmit},{default:()=>[c("\u4FDD\u5B58\u8BBE\u7F6E")]})])]):t(x,{type:"teacherCert",message:"\u60A8\u8FD8\u672A\u5B8C\u6210\u8FBE\u4EBA\u8BA4\u8BC1\uFF0C\u8BA4\u8BC1\u540E\u624D\u53EF\u8BBE\u7F6E\u966A\u7EC3\u8BFE\u54E6~",buttonVisibility:!0,buttonText:"\u53BB\u8BA4\u8BC1",onDetail:()=>{this.$router.push("/teacherAuth")}},null),t(O,{modelValue:this.timerStatus,"onUpdate:modelValue":s=>this.timerStatus=s,showClose:!0,width:"488px"},{default:()=>[this.timerStatus&&t(R,{onChoice:this.onChoiceTimer,onClose:()=>{this.timerStatus=!1},timerObject:this.timerObject,courseMinutes:Number(this.timeSetting.courseMinutes),freeMinutes:Number(this.timeSetting.freeMinutes),startSetting:this.timeSetting.startSetting,endSetting:this.timeSetting.endSetting},null)]})])}});export{et as default};