From 292dce1630442883abff3b63752d16ba15c86f57 Mon Sep 17 00:00:00 2001 From: p71924506 <222@qq.com> Date: Wed, 7 Dec 2022 17:17:54 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AE=8C=E6=88=90=E6=96=87=E4=BB=B6=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E5=88=97=E8=A1=A8=E5=9F=BA=E7=A1=80=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=202.=E5=AE=8C=E6=88=90=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD=203.=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=86=E7=B1=BB=E6=B7=BB=E5=8A=A0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=204.=E5=AE=8C=E6=88=90=E6=8C=89=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD=20TODO:?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=AE=8C=E6=88=90=E6=8C=89=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD=E3=80=82?= =?UTF-8?q?=E9=9C=80=E9=85=8D=E5=90=88=E5=AF=B9=E5=BA=94=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/http/interface.js | 49 +++++++- src/views/fileList/FileList.vue | 195 ++++++++++++++++++++++++++------ 2 files changed, 207 insertions(+), 37 deletions(-) diff --git a/src/utils/http/interface.js b/src/utils/http/interface.js index 6a24851..fd8bdef 100644 --- a/src/utils/http/interface.js +++ b/src/utils/http/interface.js @@ -62,6 +62,50 @@ export const getUserDataByUserId = data => { }) }; +//获取分类 +export const getAllType =()=>{ + return axios({ + headers:{ + "Authorization": localStorage.getItem("systemToken") + }, + url: '/file/getAlltype', + method: 'post' + }) +} + + +export const addType = data =>{ + return axios({ + headers:{ + "Authorization": localStorage.getItem("systemToken") + }, + url: '/file/addType', + method: 'post', + data + }) +} +export const addFileInfo = data =>{ + return axios({ + headers:{ + "Authorization": localStorage.getItem("systemToken") + }, + url: '/file/addFileInfo', + method: 'post', + data + }) +} + +export const getFilesInfoByType = data =>{ + return axios({ + headers:{ + "Authorization": localStorage.getItem("systemToken") + }, + url: '/file/getFilesInfoByType', + method: 'post', + data + }) +} + // 默认全部倒出 @@ -73,5 +117,8 @@ export default { getUserDataByUserId, login, register, - + getAllType, + addType, + addFileInfo, + getFilesInfoByType } diff --git a/src/views/fileList/FileList.vue b/src/views/fileList/FileList.vue index 96eec2e..c2efb0d 100644 --- a/src/views/fileList/FileList.vue +++ b/src/views/fileList/FileList.vue @@ -9,13 +9,14 @@ 分类: - - + + 上传文件 + 添加分类 @@ -27,30 +28,32 @@ width="50%" :before-close="handleClose"> - + - + - - + - + - - - + + + - + - 确 定 + 确 定 + + + + + + + + 确 定 + + { + if (res.status === 0) { + this.filesTypeList =res.data + } + console.log(res) + }) + }, + getAllFiles(){ this.$api.getAllFilesInfo().then((res)=>{ console.log(res) + if (res.status === 0) { + this.list = res.data - this.list = res.data - - console.log(this.list) - this.listLoading = false + console.log(this.list) + this.listLoading = false + }else { + Message.warning("加载失败") + } }).catch(function (res) { alert(res); }); - // getList().then(response => { - // this.list = response.data.items - // this.listLoading = false - // }) + }, + // 获取数据 + fetchData() { + this.listLoading = true + this.getAllFiles() + this.getAllType() + }, downloadFile(link) { - window.location.href = '/api' + link + window.location.href = '/api/' + link // console.log('/api' + link) // pageUtils.openPage(this.$router, '/api' + link) }, @@ -227,8 +277,8 @@ export default { //关闭上传弹窗 handleClose() { this.dialogVisible = false; - this.filesInfo.filesInfoId = 0; - this.filesInfo.filesTypeId = 0; + this.filesInfo.filesInfoId = null; + this.filesInfo.filesTypeId = null; this.filesInfo.location = ""; this.filesInfo.name = ""; this.filesInfo.uploadUserId = ""; @@ -237,6 +287,16 @@ export default { }, + //关闭添加分类弹窗 + typeHandleClose(){ + this.typeDialogVisible = false; + this.fileType.name = "" + + }, + + resetForm(formName) { + this.$refs[formName].resetFields(); + }, //上传文件本身成功调用,信息未上传 uploadSuccess(response){ @@ -245,6 +305,69 @@ export default { //此时会有一个返回的生成随机ID 暂不需要 如之后做成果库可以升级 this.filesInfo.location = response.url } + }, + + //添加fileinfo + fileInfoSubmit(){ + //检查是否有url + if (this.filesInfo.location != null && this.filesInfo.location != '') { + //提交 + console.log(localStorage.getItem("userId")) + this.filesInfo.uploadUserId = localStorage.getItem("userId") + this.$api.addFileInfo(this.filesInfo).then((res)=>{ + console.log(res) + if (res.status == 0) { + Message.success("上传成功") + this.handleClose() + this.getAllFiles() + } + }) + }else{ + Message.warning("请上传文件完善信息") + } + }, + //添加type按钮执行 + addTypeSubmit(){ + if (this.fileType.name != null && this.fileType.name !== '') { + //提交 + this.$api.addType(this.fileType).then((res)=>{ + console.log(res) + if (res.status == 30) { + Message.warning(res.msg) + }else if (res.status == 0){ + Message.success("添加成功") + this.typeHandleClose() + this.getAllType() + //刷新页面 + }else { + Message.warning("系统错误请重试") + } + }) + }else{ + Message.warning("请输入文件分类") + } + }, + + + //分类change + selectByType(){ + // console.log(this.searchInfo.type) + if (this.searchInfo.type != null && this.searchInfo.type != '' && this.searchInfo.type != undefined) { + let filesInfo = { + filesTypeId : this.searchInfo.type + } + this.$api.getFilesInfoByType(filesInfo).then((res)=>{ + if (res.status == 0) { + this.list = res.data + }else { + Message.warning("服务错误") + } + }) + // console.log("非空非默认状态啊") + }else { + this.getAllFiles() + // console.log("默认状态") + } } },