From 15a59707c6a5552c65146c4cabdfbb984742d1b1 Mon Sep 17 00:00:00 2001
From: pan <380711010@qq.com>
Date: Thu, 29 Aug 2024 22:02:09 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=8F=91=E5=B8=83=E5=B7=A5=E5=85=B7?=
=?UTF-8?q?=E6=B5=81=E7=A8=8B-=E5=85=B3=E8=81=94=E5=B7=A5=E5=85=B7?=
=?UTF-8?q?=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4=202=E3=80=81=E6=96=87?=
=?UTF-8?q?=E6=A1=A3=E8=B5=84=E6=BA=90=E7=AE=A1=E7=90=86=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/css/tool.css | 1 -
src/api/document/document.js | 10 +
src/components/FileUpload/optimizeUpload.vue | 131 +++-----
src/plugins/download.js | 2 +-
src/views/document/editDocument.vue | 299 ++++++++++--------
src/views/document/index.vue | 119 +++++--
src/views/tool/AddDoc.vue | 18 +-
src/views/tool/toolDetail.vue | 115 +++++--
.../workflowList/addWorkflow/tool_release.vue | 119 ++++++-
9 files changed, 526 insertions(+), 288 deletions(-)
diff --git a/public/css/tool.css b/public/css/tool.css
index faf15b3..f4c3733 100644
--- a/public/css/tool.css
+++ b/public/css/tool.css
@@ -876,7 +876,6 @@ body .el-form-border .el-form-item .el-cascader ,
body .el-form-border .el-form-item .el-select,
body .el-form-border .el-form-item .el-date-editor{
width: 100%;
- max-width: 340px;
}
body .el-form-border .el-form-item .el-checkbox-group .el-checkbox{
min-width: 200px;
diff --git a/src/api/document/document.js b/src/api/document/document.js
index 0eebd3d..080e497 100644
--- a/src/api/document/document.js
+++ b/src/api/document/document.js
@@ -42,3 +42,13 @@ export function delDocument(id) {
method: 'delete'
})
}
+
+
+
+// 发布文档
+export function pushDoc(id) {
+ return request({
+ url: '/document/pushDoc/' + id,
+ method: 'put'
+ })
+}
diff --git a/src/components/FileUpload/optimizeUpload.vue b/src/components/FileUpload/optimizeUpload.vue
index bc99cf4..7ff90ae 100644
--- a/src/components/FileUpload/optimizeUpload.vue
+++ b/src/components/FileUpload/optimizeUpload.vue
@@ -33,22 +33,6 @@ export default {
type: String,
required: true
},
- headers: {
- type: Object,
- default: () => ({})
- },
- extraData: {
- type: Object,
- default: () => ({})
- },
- onSuccess: {
- type: Function,
- default: () => {}
- },
- onError: {
- type: Function,
- default: () => {}
- },
// 是否多选
isMultiple: {
type: Boolean,
@@ -75,6 +59,13 @@ export default {
return 1
}
},
+ // 文件
+ dataFile: {
+ type: [Object, Array, String],
+ default() {
+ return ''
+ }
+ },
},
data() {
return {
@@ -86,6 +77,18 @@ export default {
partSize: 5 * 1024 * 1024,
};
},
+ watch: {
+ dataFile: {
+ handler(newValue, oldValue) {
+ if (newValue) {
+ this.fileList = Array.isArray(newValue) ? newValue : [newValue]
+ } else {
+ this.fileList = []
+ }
+ },
+ immediate: true
+ }
+ },
methods: {
// 上传前
beforeUpload(file) {
@@ -99,67 +102,6 @@ export default {
return false
}*/
},
- /* //上传函数
- submitUpload(file) {
- //重新命名 方便setTimeout函数 --因为setTimeout函数在vue内部中无效
- var that = this;
- // that.$refs.upload.submit();
- //判断上传文件数量
- if (this.fileList.length == 0) {
- that.$message({
- message: '请选择导入的文件',
- type: 'warning',
- duration: '2000'
- });
- return;
- }
- //创建FormData();主要用于发送表单数据
- let paramFormData = new FormData();
- //遍历 fileList
- that.fileList.forEach(file => {
- paramFormData.append("file", file.raw);
- });
- //修改progressFlag值
- that.progressFlag = true;
- //axios 发出请求
- axios({
- url: that.uploadUrl,
- method: 'post',
- data: paramFormData,
- headers: {
- 'Authorization': 'Bearer ' + getToken(),
- 'Content-Type': 'multipart/form-data'
- },
- onUploadProgress: progressEvent => {
- // progressEvent.loaded:已上传文件大小
- // progressEvent.total:被上传文件的总大小
- //进度条
- that.progressPercent = ((progressEvent.loaded / progressEvent.total) * 100) | 0;
- }
- }).then(res => {
- console.info("res===========", res)
- if (res.data.code == 200 && that.progressPercent === 100) {
- setTimeout(function () {
- that.$message({
- message: '上传成功!',
- type: 'success',
- duration: '2000'
- });
- that.progressFlag = false;
- that.progressPercent = 0
- }, 500);
- }
- }).catch(error => {
- that.progressFlag = false;
- that.progressPercent = 0
- that.$refs.upload.clearFiles();
- that.$message({
- message: '上传失败!',
- type: 'error',
- duration: '2000'
- });
- })
- },*/
//文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
onChange(file, fileList) {
this.fileList = fileList;
@@ -205,6 +147,7 @@ export default {
});
self.progressFlag = false;
self.progressPercent = 0
+ self.handleResult(res,file);
}, 500);
} else {
self.$message({
@@ -227,7 +170,6 @@ export default {
});
})
} else {
- console.info("111111111111")
file._shardCount = Math.ceil(file.size / this.partSize) //总片数
file.uploaded = 0
let formData = new FormData()
@@ -244,7 +186,6 @@ export default {
'Content-Type': 'multipart/form-data'
},
}).then(function (res) {
- console.info("res=====initUpload=======", res)
if (res.status == 200) {
//从第0块开始上传
file.uploadId = res.data.uploadId
@@ -272,12 +213,6 @@ export default {
//获取文件块MD5
let reader = new FileReader()
reader.readAsBinaryString(fileData)
- // 读取成功后的回调
- // reader.onloadend = function(e) {
- // 用hex_md5生成md5值,与OSS的算法对应,并转换为大写,不是直接md5-js的算法
- // self.md5Str[index] = (CryptoJS(this.result)).toLocaleUpperCase()
- // self.md5Str[index] = CryptoJS.MD5(e.target.result)
- // }
let form1 = new FormData()//new一个form的实例,可以进行键值对的添加,
form1.append('chunkFile', fileData) //slice方法用于切出文件的一部分
form1.append('uploadId', file.uploadId)
@@ -300,7 +235,6 @@ export default {
self.progressPercent = ((progressEvent.loaded / progressEvent.total) * 100) | 0;
}
}).then(response => {
- console.info("response=======uploadChunk=====", response)
if (response.status == 200) {
//判断返回的MD5值是否一致,一致继续传下一块,否则重传本块(这里目前前后端MD5一直不一致,暂时先注释掉,有时间了我再研究一下)
// self.md5Str[index] === response.msg ||
@@ -345,9 +279,8 @@ export default {
'Authorization': 'Bearer ' + getToken(),
'Content-Type': 'multipart/form-data'
},
- }).then(response => {
- console.info("response====mergeFile========", response)
- if (response.status == 200) {
+ }).then(res => {
+ if (res.status == 200) {
setTimeout(function () {
self.$message({
message: '上传成功!',
@@ -356,6 +289,7 @@ export default {
});
self.progressFlag = false;
self.progressPercent = 0
+ self.handleResult(res,file);
}, 500);
} else {
self.$message({
@@ -364,13 +298,30 @@ export default {
duration: '2000'
});
}
- console.info("file===============", file)
})
}
},
resetData() {
this.progress = 0;
},
+ handleResult(res, file) {
+ let self = this
+ const data = {
+ fileName: file.name,
+ fileSize: file.size,
+ fileUrl: res.data.url,
+ filePath: res.data.filePath,
+ fileOldName: res.data.originalFilename,
+ fileNewName: res.data.newFileName,
+ suffixType: res.data.suffixType
+ }
+ self.$emit("handleSuccess", data)
+ },
+ /** 清空文件 **/
+ clearFile(){
+ this.$refs.upload.clearFiles();
+ this.fileList = []
+ }
}
};
diff --git a/src/plugins/download.js b/src/plugins/download.js
index 42acd00..5dcfac3 100644
--- a/src/plugins/download.js
+++ b/src/plugins/download.js
@@ -9,7 +9,7 @@ const baseURL = process.env.VUE_APP_BASE_API
let downloadLoadingInstance;
export default {
- name(name, isDelete = true) {
+ downloadByName(name, isDelete) {
var url = baseURL + "/common/download?fileName=" + encodeURIComponent(name) + "&delete=" + isDelete
axios({
method: 'get',
diff --git a/src/views/document/editDocument.vue b/src/views/document/editDocument.vue
index 9427eca..2090b05 100644
--- a/src/views/document/editDocument.vue
+++ b/src/views/document/editDocument.vue
@@ -3,8 +3,8 @@