2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
import{d as T,e as z,a as R,f as B,g as q,h as H,i as O}from"./LearningQuery-COiYAMTQ.js";import{_ as G,y as A,b as h,G as M,c as p,d as b,e as d,f as i,w as o,F as N,x as F,q as v,i as D,D as j,H as U,T as W,n as Z,t as J,p as K,j as Q}from"./index-DjgxJhni.js";import{_ as X,a as Y}from"./reset-C9wGeSio.js";import{_ as $}from"./Increased-DVYM0f5Q.js";import"./request-B06qJ2Sm.js";const ee={name:"NewLearning",data(){return{uploading:!1,uploadingFile:!1,tableHeight:"500px",dialogImageUrl:"",dialogVisible:!1,titleForm:"新建学习",fileListVideo:[],fileListFile:[],paramStudyId:"",indexMethod:1,fileList:[],visible:!1,action:"action",tableData:[],formInline:{StudyName:"",StudyClass:"",Status:""},InlineForm:{PageIndex:1,PageSize:10},dialogFormVisible:!1,ruleForm:[],formData:{StudyName:"",StudyClass:"",StudySynopsis:"",VideoData:[],FileData:[]},StudyNameset:"",total:0,totalstudy:"",showTip:!1,list:[]}},props:{value:[String,Object,Array],fileSize:{type:Number,default:2},isShowTip:{type:Boolean,default:!0},billId:{type:Number,require:!0},billType:{type:Number,required:!0}},created(){this.onload()},mounted(){this.tableHeight=window.innerHeight-390,this.screenHeight=window.innerHeight},methods:{handleSuccess(t,e,n){console.log("File uploaded successfully:",t)},handleRemove(t,e){console.log(this.formData.VideoData,"data"),this.formData.VideoData.forEach((n,r)=>{t.name==n.FileName&&this.formData.VideoData.splice(r,1)})},handleRemoveFile(t,e){console.log(this.formData.FileData,"data"),this.formData.FileData.forEach((n,r)=>{t.name==n.FileName&&this.formData.FileData.splice(r,1)})},handleVSuccess(t,e,n){},handleVPreview(t){t.url=t.name,this.formData.VideoData.forEach((e,n)=>{if(t.url==e.FileName){const r=window.location.href,l=/^https?:\/\/([^/:]+):?(\d+)?/i,a=r.match(l);console.log("match",a),this.dialogImageUrl=a[0]+e.FilePath,console.log("this.dialogImageUrl",this.dialogImageUrl)}}),this.dialogVisible=!0},handleFormPreview(t){console.log("预览文件",t.name);let e="";this.formData.FileData.forEach((n,r)=>{if(t.name==n.FileName){const l=window.location.href,a=/^https?:\/\/([^/:]+):?(\d+)?/i,u=l.match(a);console.log("match",u),e=u[0]+n.FilePath}}),new Blob([e],{type:"application/msword"}),window.open(e,"_block"),console.log(e,"文件")},Release(t){this.$confirm("确定要发布吗?",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{this.handleReleaseForm(t.StudyId)})},async handleReleaseForm(t){await T({StudyId:t}).then(n=>{this.$message.success(n.data),this.onload()})},delItem(t){t.StudyId,this.$confirm("确定要删除吗?",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{this.handledeleteForm(t.StudyId)})},async handledeleteForm(t){await z({id:t}).then(n=>{this.$message.success(n.data),this.onload()})},handleCurrentChange(t){this.InlineForm.PageIndex=t,this.onload()},handleFileChange(t){const e=this.$refs.inputer;this.file=e.files[0]},async onload(t,e){const n={StudyName:this.formInline.StudyName,StudyClass:this.formInline.StudyClass,Status:this.formInline.Status,PageIndex:this.InlineForm.PageIndex,PageSize:10};await R(n).then(r=>{r.code==null?(this.tableData=[],this.total=0):(this.tableData=r.data.list,this.total=r.data.total)})},handleSet(t){this.formInline.StudyName="",this.formInline.StudyClass="",this.formInline.Status="",this.onload()},handleLook(t){this.onload()},handleCreate(){this.titleForm="新建学习",this.dialogFormVisible=!0,this.paramStudyId="",this.formData={StudyName:"",StudyClass:"",StudySynopsis:"",VideoData:[],FileData:[]},this.fileListVideo=[],this.fileListFile=[]},async handleUpdate(t){this.titleForm="编辑学习",this.fileListVideo=[],this.fileListFile=[],this.dialogFormVisible=!0,this.paramStudyId=t.StudyId;const e={Id:t.StudyId};await B(e).then(n=>{this.formData=n.data;const r=n.data.VideoData,l=n.data.FileData;r.forEach(a=>{const u={name:a.FileName};this.fileListVideo.push(u)}),l.forEach(a=>{const u={name:a.FileName};this.fileListFile.push(u)})})},async createForm(){const t={StudyName:this.formData.StudyName,StudyClass:this.formData.StudyClass,StudySynopsis:this.formData.StudySynopsis,VideoData:this.formData.VideoData,FileData:this.formData.FileData};await q(t).then(e=>{if(e.state=="Fail"){this.$message.warning(e.data);return}else this.$message.success(e.data),this.onload();this.dialogFormVisible=!1})},async updateForm(){const t={StudyId:this.paramStudyId,StudyName:this.formData.StudyName,StudyClass:this.formData.StudyClass,StudySynopsis:this.formData.StudySynopsis,VideoData:this.formData.VideoData,FileData:this.formData.FileData};await H(t).then(e=>{if(e.state=="Fail"){this.$message.warning(e.data);return}else this.$message.success(e.data),this.onload();this.dialogFormVisible=!1})},saveItem(){this.paramStudyId==""?this.createForm():this.updateForm()},handleExceed(){this.$message.error("只允许上传3个文件")},handleUploadError(t){this.$message.error("上传失败, 请重试")},handleVSuccess(t,e){this.$message.success("上传成功"),this.cancel(),this.dialogImageUrl="PATH_TO_DOCUMENT_PREVIEW_PAGE?file="+encodeURIComponent(t.fileUrl)},handleUploadSuccess(t,e){this.$message.success("上传成功"),this.cancel(),this.previewUrl="PATH_TO_DOCUMENT_PREVIEW_PAGE?file="+encodeURIComponent(t.fileUrl)},handChangeFile(t,e){this.fileList=e,this.file=t.raw,this.loadSize("File")},handChangeVideo(t,e){this.file=t.raw,this.loadSize("Video")},S4(){return((1+Math.random())*65536|0).toString(16).substring(1)},guid(){return this.S4()+this.S4()+"-"+this.S4()+"-"+this.S4()+"-"+this.S4()+"-"+this.S4()+this.S4()+this.S4()},loadSize(t){const e=this.file.size,r=8*(1024*1024);let l=0,a=r;const u=[];for(;l<e;){const f={File:this.file.slice(l,a),Start:l,End:a};u.push(f),l=a,a=l+r}const m=u.length,c=this.file.name+"~"+this.guid(),g=this.file.name;this.test2(m,c,r,u,e,t,g)},async test2(t,e,n,r,l,a,u){for(let m=0;m<t;m++){const c=new FormData;c.append("file",r[m].File);const g="?Name="+e+"&Number="+m+"&BufferSize="+n+"&Count="+t+"&Start="+r[m].Start+"&End="+r[m].End+"&Size="+l+"&FolderName="+a;a=="File"?this.uploadingFile=!0:a=="Video"&&(this.uploading=!0),await O(g,c).then(f=>{a=="File"&&f!="成功"?this.formData.FileData.push({FileName:u,FilePath:f}):a=="Video"&&f!="成功"&&this.formData.VideoData.push({FileName:u,FilePath:f}),f.indexOf("Upload")&&f!="成功"&&(A({message:"上传成功",type:"success"}),a=="File"?this.uploadingFile=!1:a=="Video"&&(this.uploading=!1)),console.log(f,"res")})}},handleDelete(t){this.fileList.splice(t,1)},getFileName(t){return alert(1),t.lastIndexOf("/")>-1?t.slice(t.lastIndexOf("/")+1).toLowerCase():""},submitUpload(){if(this.fileList.length<=0)return!1;this.$refs.upload.submit()},cancel(){this.fileList=[],this.visible=!1},httpRequest(t){const e=new FormData;e.append("billId",this.billId),e.append("formType",this.billType),e.append("file",t.file),uploadFormFile(e).then(n=>{n.code===200&&(t.onSuccess(),this.$refs.upload.clearFiles(),this.msgSuccess("上传成功"),this.$emit("input",n.data))}).catch(n=>{})}}},y=t=>(K("data-v-f1e5eea1"),t=t(),Q(),t),te={class:"PageContent"},le={class:"WebToolbar"},ae={class:"FormComponent"},ie={class:"ButtonAssembly"},se=y(()=>d("img",{src:X,alt:""},null,-1)),oe=y(()=>d("span",null,"查询",-1)),ne=y(()=>d("img",{src:Y,alt:""},null,-1)),re=y(()=>d("span",null,"重置",-1)),de={class:"Tabulation"},ue={class:"actionBar"},me=y(()=>d("h1",null,"学习列表",-1)),he={class:"Worktop"},ce=y(()=>d("img",{src:$,alt:""},null,-1)),fe=y(()=>d("span",null,"新增",-1)),pe={class:"ExaminationForm"},ge=["onClick"],_e=["onClick"],ye=["onClick"],Se=["src"],be={key:0},Fe={class:"el-icon-document"},De={class:"ele-upload-list__item-content-action"},Ve={class:"dialog-footer"};function ve(t,e,n,r,l,a){const u=h("el-input"),m=h("el-form-item"),c=h("el-option"),g=h("el-select"),f=h("el-form"),_=h("el-button"),S=h("el-table-column"),I=h("el-divider"),k=h("el-table"),E=h("el-pagination"),w=h("el-dialog"),C=h("el-upload"),P=h("el-progress"),x=h("el-link"),L=M("loading");return p(),b(N,null,[d("div",te,[d("div",le,[d("div",ae,[i(f,{inline:!0,model:l.formInline},{default:o(()=>[i(m,{label:"学习名称:",class:"demo-form-city"},{default:o(()=>[i(u,{modelValue:l.formInline.StudyName,"onUpdate:modelValue":e[0]||(e[0]=s=>l.formInline.StudyName=s),maxlength:"30",placeholder:"请输入学习名称",clearable:""},null,8,["modelValue"])]),_:1}),i(m,{label:"学习分类:"},{default:o(()=>[i(g,{modelValue:l.formInline.StudyClass,"onUpdate:modelValue":e[1]||(e[1]=s=>l.formInline.StudyClass=s),placeholder:"请选择学习分类",clearable:""},{default:o(()=>[i(c,{label:"变压器台架",value:"变压器台架"}),i(c,{label:"杆塔",value:"杆塔"}),i(c,{label:"线档",value:"线档"})]),_:1},8,["modelValue"])]),_:1}),i(m,{label:"状态:"},{default:o(()=>[i(g,{modelValue:l.formInline.Status,"onUpdate:modelValue":e[2]||(e[2]=s=>l.formInline.Status=s),placeholder:"请选择状态",clearable:""},{default:o(()=>[i(c,{label:"已发布",value:"已发布"}),i(c,{label:"未发布",value:"未发布"})]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])]),d("div",ie,[i(_,{style:{color:"#fff"},onClick:e[3]||(e[3]=s=>a.handleLook())},{default:o(()=>[se,oe]),_:1}),i(_,{style:{color:"#1d2129"},onClick:e[4]||(e[4]=s=>a.handleSet())},{default:o(()=>[ne,re]),_:1})])]),d("div",de,[d("div",ue,[me,d("div",he,[i(_,{class:"BlueBack",onClick:e[5]||(e[5]=s=>a.handleCreate())},{default:o(()=>[ce,fe]),_:1})])]),d("div",pe,[i(k,{ref:"multipconstableRef",data:l.tableData,height:l.tableHeight,style:{width:"100%"}},{default:o(()=>[i(S,{property:"StudyName",label:"学习名称"}),i(S,{property:"StudyClass",label:"学习分类"}),i(S,{property:"StudySynopsis",label:"学习内容简介"}),i(S,{property:"CreateTime",label:"发布时间"}),i(S,{property:"Status",label:"状态"}),i(S,{property:"",label:"操作"},{default:o(s=>[s.row.Status=="未发布"?(p(),b("span",{key:0,class:"user-name",onClick:V=>a.Release(s.row)},"发布",8,ge)):F("",!0),s.row.Status=="未发布"?(p(),v(I,{key:1,direction:"vertical"})):F("",!0),s.row.Status=="未发布"?(p(),b("span",{key:2,class:"user-name",onClick:V=>a.handleUpdate(s.row)},"编辑",8,_e)):F("",!0),s.row.Status=="未发布"?(p(),v(I,{key:3,direction:"vertical"})):F("",!0),d("span",{class:"register",onClick:V=>a.delItem(s.row)},"删除",8,ye)]),_:1})]),_:1},8,["data","height"]),i(E,{"current-page":l.InlineForm.PageIndex,"onUpdate:currentPage":e[6]||(e[6]=s=>l.InlineForm.PageIndex=s),"page-size":l.InlineForm.PageSize,layout:"total, prev, pager, next",total:l.total,onCurrentChange:a.handleCurrentChange},null,8,["current-page","page-size","total","onCurrentChange"])])])]),i(w,{modelValue:l.dialogFormVisible,"onUpdate:modelValue":e[13]||(e[13]=s=>l.dialogFormVisible=s),title:l.titleForm,width:"600",center:"",style:{"margin-top":"17vh !important"}},{footer:o(()=>[d("div",Ve,[i(_,{onClick:e[11]||(e[11]=s=>l.dialogFormVisible=!1)},{default:o(()=>[D("取消")]),_:1}),i(_,{type:"primary",onClick:e[12]||(e[12]=j(s=>a.saveItem(),["stop"]))},{default:o(()=>[D(" 保存 ")]),_:1})])]),default:o(()=>[i(f,{model:l.formData},{default:o(()=>[i(m,{label:"学习分类",rules:[{required:!0,message:"学习分类不能为空"}]},{default:o(()=>[i(g,{modelValue:l.formData.StudyClass,"onUpdate:modelValue":e[7]||(e[7]=s=>l.formData.StudyClass=s),placeholder:"请选择学习分类"},{default:o(()=>[i(c,{label:"变压器台架",value:"变压器台架"}),i(c,{label:"杆塔",value:"杆塔"}),i(c,{label:"线档",value:"线档"})]),_:1},8,["modelValue"])]),_:1}),i(m,{label:"学习名称",rules:[{required:!0,message:"学习名称不能为空"}]},{default:o(()=>[i(u,{modelValue:l.formData.StudyName,"onUpdate:modelValue":e[8]||(e[8]=s=>l.formData.StudyName=s),maxlength:"30"},null,8,["modelValue"])]),_:1}),i(m,{label:"简介",prop:"savinger","label-width":"69",style:{"margin-bottom":"120px","margin-left":"10px"}},{default:o(()=>[i(u,{type:"textarea",rows:6,placeholder:"请输入简介",modelValue:l.formData.StudySynopsis,"onUpdate:modelValue":e[9]||(e[9]=s=>l.formData.StudySynopsis=s),maxlength:"500"},null,8,["modelValue"])]),_:1}),i(m,{label:"视频资源",rules:[{required:!0,message:"视频路径不能为空"}]},{default:o(()=>[U((p(),v(C,{action:l.action,"before-remove":a.handleRemove,"file-list":l.fileListVideo,multiple:"",accept:"video/mp4,video/ogg,video/*","on-error":a.handleUploadError,"on-exceed":a.handleExceed,"on-success":a.handleVSuccess,"on-preview":a.handleVPreview,"on-change":a.handChangeVideo,"http-request":a.httpRequest,"show-file-list":!0,"auto-upload":!1,class:"upload-file-uploader horizontal-list",ref:"upload"},{trigger:o(()=>[i(_,{size:"mini",type:"primary"},{default:o(()=>[D("上传视频")]),_:1})]),default:o(()=>[i(w,{modelValue:l.dialogVisible,"onUpdate:modelValue":e[10]||(e[10]=s=>l.dialogVisible=s)},{default:o(()=>[d("video",{src:l.dialogImageUrl,controls:"controls",style:{width:"100%",height:"500px"}},null,8,Se)]),_:1},8,["modelValue"])]),_:1},8,["action","before-remove","file-list","on-error","on-exceed","on-success","on-preview","on-change","http-request"])),[[L,l.uploading]]),t.progressVisible?(p(),b("div",be,[i(P,{percentage:t.progressPercentage},null,8,["percentage"])])):F("",!0)]),_:1}),i(m,{label:"学习文档",style:{"margin-top":"20%","margin-left":"10px"}},{default:o(()=>[U((p(),v(C,{action:l.action,"before-remove":a.handleRemoveFile,"file-list":l.fileListFile,multiple:"",accept:".pdf,.doc,.docx,.excel,.ppt,.pptx,.word,.xlsx,.RTF, .xls","on-error":a.handleUploadError,"on-exceed":a.handleExceed,"on-success":a.handleUploadSuccess,"on-change":a.handChangeFile,"on-preview":a.handleFormPreview,"http-request":a.httpRequest,"show-file-list":!0,"auto-upload":!1,class:"upload-file-uploader horizontal-list",ref:"upload"},{trigger:o(()=>[i(_,{size:"mini",type:"primary"},{default:o(()=>[D("上传文件")]),_:1})]),_:1},8,["action","before-remove","file-list","on-error","on-exceed","on-success","on-change","on-preview","http-request"])),[[L,l.uploadingFile]]),i(W,{class:"upload-file-list el-upload-list el-upload-list--text",name:"el-fade-in-linear",tag:"ul"},{default:o(()=>[(p(!0),b(N,null,Z(l.list,(s,V)=>(p(),b("li",{key:s.uid,class:"el-upload-list__item ele-upload-list__item-content"},[i(x,{href:s.url,underline:!1,target:"_blank"},{default:o(()=>[d("span",Fe,J(a.getFileName(s.name)),1)]),_:2},1032,["href"]),d("div",De,[i(x,{underline:!1,onClick:Ie=>a.handleDelete(V),type:"danger"},{default:o(()=>[D("删除")]),_:2},1032,["onClick"])])]))),128))]),_:1})]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])],64)}const Ue=G(ee,[["render",ve],["__scopeId","data-v-f1e5eea1"]]);export{Ue as default};
|