1 line
4.2 KiB
JavaScript
1 line
4.2 KiB
JavaScript
|
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0baa4b"],{"37a2":function(e,t,l){"use strict";l.r(t);var s=function(){var e=this,t=e.$createElement,l=e._self._c||t;return l("div",{staticClass:"app-container"},[l("el-alert",{attrs:{title:"注意: 支持上传.txt .docx .pdf .xlsx文档! pdf文档不能是图片扫描生成的,读取不到数据!",type:"info","show-icon":""}}),l("el-form",{staticStyle:{margin:"10px 0px"}},[l("el-upload",{staticStyle:{margin:"10px 0px"},attrs:{action:e.uloadUrl,"on-success":e.uploadDocSuccess,"on-error":e.uploadError,"before-upload":e.beforeUpload}},[l("el-button",{attrs:{type:"primary",icon:"el-icon-upload"}},[e._v("上传文档")])],1),l("el-form-item",[l("el-input",{staticStyle:{width:"800px"},attrs:{placeholder:"网页地址"},model:{value:e.learnUrl,callback:function(t){e.learnUrl=t},expression:"learnUrl"}})],1),l("el-form-item",[l("el-button",{attrs:{icon:"el-icon-upload",type:"primary"},on:{click:e.uploadUrl}},[e._v("上传网址")])],1)],1),l("el-table",{attrs:{data:e.list,border:"",fit:"","highlight-current-row":""}},[l("el-table-column",{attrs:{align:"center",label:"ID",width:"95"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.id)+" ")]}}])}),l("el-table-column",{attrs:{label:"文件名"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.file_name)+" ")]}}])}),l("el-table-column",{attrs:{align:"center",prop:"created_at",label:"上传时间",width:"400"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(e.formatTime(t.row.created_at))+" ")]}}])}),l("el-table-column",{attrs:{prop:"id",label:"操作"},scopedSlots:e._u([{key:"default",fn:function(t){return[l("el-button",{attrs:{type:"danger",size:"small",icon:"el-icon-delete",circle:""},on:{click:function(l){return e.delFile(t.row.id)}}})]}}])})],1)],1)},a=[],o=l("a78e"),n=l.n(o);function r(e,t){if(0===arguments.length||!e)return null;const l=t||"{y}-{m}-{d} {h}:{i}:{s}";let s;"object"===typeof e?s=e:("string"===typeof e&&(e=/^[0-9]+$/.test(e)?parseInt(e):e.replace(new RegExp(/-/gm),"/")),"number"===typeof e&&10===e.toString().length&&(e*=1e3),s=new Date(e));const a={y:s.getFullYear(),m:s.getMonth()+1,d:s.getDate(),h:s.getHours(),i:s.getMinutes(),s:s.getSeconds(),a:s.getDay()},o=l.replace(/{([ymdhisa])+}/g,(e,t)=>{const l=a[t];return"a"===t?["日","一","二","三","四","五","六"][l]:l.toString().padStart(2,"0")});return o}var i={data(){return{list:null,listLoading:!0,baseUrl:"",uloadUrl:"",colletName:"",learnUrl:""}},methods:{getFileList(){let e=this,t=this.colletName;fetch(this.baseUrl+`/${t}/fileList`,{method:"GET"}).then(e=>e.json()).then(t=>{t.result&&(e.list=t.result,e.listLoading=!1)})},formatTime(e){return r(new Date(e),"{y}-{m}-{d} {h}:{i}")},uploadDocSuccess(e,t,l){this.listLoading.close(),200==e.code?(this.$message({message:"上传成功",type:"success"}),this.getFileList()):this.$message({message:e.msg,type:"error"})},uploadError(){this.listLoading.close()},beforeUpload(e){this.listLoading=this.$loading({lock:!0,text:"上传中"});let t=e.name.substring(e.name.lastIndexOf(".")+1);if("txt"!=t&&"docx"!=t&&"xlsx"!=t&&"pdf"!=t)return this.$message.error("上传文件只能是 .txt .docx .xlsx .pdf 格式!"),this.listLoading.close(),!1},delFile(e){let t=this;this.$confirm("是否删除","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((function(){let l=t.baseUrl+`/${t.colletName}/delFile?id=`+e;fetch(l,{method:"GET"}).then(e=>e.json()).then(e=>{t.getFileList()})})).catch((function(){}))},uploadUrl(){let e=this,t={url:this.learnUrl};const l=new URLSearchParams(t).toString();this.listLoading=this.$loading({lock:!0,text:"上传中"});let s=e.baseUrl+`/${e.colletName}/uploadUrl`;fetch(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:l}).then(e=>e.json()).then(t=>{this.listLoading.close(),200==t.code?(e.$message({message:"success",type:"success"}),e.getFileList()):e.$message({message:t.msg,type:"error"})})}},created(){let e=n.a.get("collectName");this.colletName=e,this
|