import{b as n}from"./index.51e15757.js";import{R as f}from"./rich-text-editor.3ce9cac2.js";import{d as c}from"./utils.068fedb0.js";import{d as m}from"./data-report.1a365133.js";import{n as p}from"./vueComponentNormalizer.9ef17bb1.js";import"./index.70d38b82.js";const g=t=>n({url:"course-notes",method:"post",data:t}),l=t=>n({url:`course-notes?page=${t.page}&pageSize=${t.pageSize}`,method:"get"}),N=t=>n({url:"course-notes/"+t,method:"get"}),I=t=>n({url:"course-notes/"+t,method:"delete"}),h=t=>n({url:"course-notes/"+t.id,method:"patch",data:t});var k=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}],staticClass:"course-notes v-page"},[e("div",{staticClass:"catalog-box"},[e("h2",{staticClass:"v-title"},[t._v("\u6211\u7684\u7B14\u8BB0")]),e("div",{staticStyle:{width:"100%",padding:"10px 5px"}},[e("el-button",{staticClass:"add-note-button",staticStyle:{width:"100%"},attrs:{size:"small",round:"",type:"primary",icon:"el-icon-plus"},on:{click:t.addNote}},[t._v("\u65B0\u5EFA\u7B14\u8BB0")])],1),e("div",{directives:[{name:"infinite-scroll",rawName:"v-infinite-scroll",value:t.getNewData,expression:"getNewData"}],staticClass:"note-list",attrs:{id:"note-list"}},t._l(t.noteList,function(s,a){return e("div",{key:s.id,class:`note-box ${t.checkNoteInfo.id==s.id?"now-check-box":""}`,on:{click:function(o){return t.checkNote(s,a)}}},[e("div",{staticClass:"note-header"},[e("span",{staticClass:"note-title"},[t._v(t._s(s.title))])]),e("div",{staticClass:"note-explain",domProps:{innerHTML:t._s(s.explain)}}),e("div",{staticClass:"note-manage"},[e("span",{staticClass:"note-time"},[e("i",{staticClass:"el-icon-time"}),t._v(" "+t._s(new Date(s.updateTime).format("yyyy/MM/dd")))]),e("div",{staticClass:"note-manage-button"},[e("i",{staticClass:"el-icon-delete",on:{click:function(o){return o.stopPropagation(),t.deleteNote(s.id)}}})])])])}),0)]),e("div",{staticClass:"right-content"},[e("div",{staticClass:"content-header"},[e("div",{staticClass:"note-title-input"},[e("span",{staticStyle:{width:"130px"}},[t._v("\u7B14\u8BB0\u540D\u79F0\uFF1A")]),e("el-input",{attrs:{maxlength:"20",size:"mini","show-word-limit":"",disabled:!t.checkNoteInfo.updateTime,placeholder:"\u8BF7\u8F93\u5165\u7B14\u8BB0\u540D\u79F0"},on:{blur:t.saveTitleChange},model:{value:t.checkNoteInfo.title,callback:function(s){t.$set(t.checkNoteInfo,"title",s)},expression:"checkNoteInfo.title"}})],1),t.checkNoteInfo.updateTime?e("div",{staticClass:"note-update-time"},[t._v(" \u6700\u540E\u66F4\u65B0\u65E5\u671F\uFF1A"+t._s(new Date(t.checkNoteInfo.updateTime).format("yyyy.MM.dd"))+" ")]):t._e()]),e("RichTextEditor",{ref:"RichTextEditor",attrs:{checkNoteInfo:t.checkNoteInfo},on:{change:t.editorChange}})],1)])},v=[];const _={data(){return{noteList:[],checkNoteInfo:{},checkNoteInfoBase:{},loading:!1,pageInfo:{page:0,pageSize:10,total:0},submitTimeout:null,isCheckFirst:!0}},components:{RichTextEditor:f},created(){},methods:{async getCourseNotesList(){this.loading=!0;const{data:t}=await l(this.pageInfo);this.noteList=t[0],t[0][0]?this.getOneNoteInfo(t[0][0],0).then(i=>{this.pageInfo.total=t[1],this.loading=!1}):this.loading=!1},async addNote(){const{data:t}=await g({title:"\u65B0\u589E\u7B14\u8BB0",content:"",explain:"\u65B0\u589E\u7B14\u8BB0"});this.noteList.push(t),this.checkNoteInfoBase=t,this.checkNoteInfo=c(t),this.checkNoteInfo.title="";const i=document.getElementById("note-list");this.$nextTick(()=>{i.scrollTo(0,i.scrollHeight)})},async getNewData(t){if(this.pageInfo.page++,this.pageInfo.page*this.pageInfo.pageSize<=this.noteList.length){this.$message.warning("\u5230\u5E95\u5566");return}if(this.pageInfo.page===1){this.getCourseNotesList();return}this.loading=!0;const{data:i}=await l(this.pageInfo);this.pageInfo.total=i[1],this.noteList.push(...i[0]),this.loading=!1},async deleteNote(t){this.$confirm("\u6B64\u64CD\u4F5C\u5C06\u6C38\u4E45\u5220\u9664\u8BE5\u7B14\u8BB0, \u662F\u5426\u7EE7\u7EED?","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}).then(async()=>{this.loading=!0,await I(t),this.pageInfo.page=1,await this.getCourseNotesList(),this.$message({type:"success",message:"\u5220\u9664\u6210\u529F!"}),this.loading=!1}).catch(()=>{this.loading=!1})},async checkNote(t,i){if(!this.checkNoteInfo.title.trim())return this.$message.warning("\u7B14\u8BB0\u540D\u79F0\u4E0D\u53EF\u4E3A\u7A7A");this.loading=!0;let e=!1;const s=this.checkNoteInfoBase,a=this.checkNoteInfo;this.submitTimeout&&(clearTimeout(this.submitTimeout),this.submitTimeout=null);for(const o in s)o!=="id"&&s[o]!==a[o]&&(e=!0);if(e){const{data:o}=await this.submitValue(),d=this.noteList.findIndex(u=>u.id===o.id);this.noteList[d]=o}this.getOneNoteInfo(t,i).then(()=>{this.loading=!1})},editorChange(t){this.checkNoteInfo.content=t,this.antiShakeSubmit()},async saveTitleChange(){if(!this.checkNoteInfo.title.trim()){this.checkNoteInfo.title=this.checkNoteInfoBase.title;return}if(this.checkNoteInfo.title!==this.checkNoteInfoBase.title){const{data:t}=await h({id:this.checkNoteInfo.id,title:this.checkNoteInfo.title});this.checkNoteInfoBase.title=t.title,this.checkNoteInfoBase.updateTime=t.updateTime,this.checkNoteInfo.updateTime=t.updateTime}},antiShakeSubmit(){this.submitTimeout&&(clearTimeout(this.submitTimeout),this.submitTimeout=null),this.submitTimeout=setTimeout(async()=>{const{data:t}=await this.submitValue(),i=this.noteList.findIndex(e=>e.id===t.id);this.noteList[i]=t,clearTimeout(this.submitTimeout),this.submitTimeout=null},200)},async getOneNoteInfo(t,i){this.$refs.RichTextEditor.editor.destroy();const{data:e}=await N(t.id);return this.noteList[i]=e,this.checkNoteInfoBase=e,this.checkNoteInfo=c(e),this.$refs.RichTextEditor.seteditor(),e},async submitValue(){return await h({id:this.checkNoteInfo.id,explain:this.checkNoteInfo.explain,title:this.checkNoteInfo.title,content:this.checkNoteInfo.content})}},mixins:[m("CLASS_NOTE")]},r={};var x=p(_,k,v,!1,T,"0ba6182c",null,null);function T(t){for(let i in r)this[i]=r[i]}const B=function(){return x.exports}();export{B as default};