From f1c6f571f841df4dc775433b875f3fbbf66a87ff Mon Sep 17 00:00:00 2001
From: yujialong <479214531@qq.com>
Date: Wed, 22 Nov 2023 17:14:09 +0800
Subject: [PATCH] fix
---
src/components/upload/index.vue | 10 +++++--
src/views/match/add/step1.vue | 2 +-
src/views/parnerOperation/learnMg.vue | 43 +++++++++++++--------------
src/views/shop/addProduct/index.vue | 39 ++++++++----------------
4 files changed, 42 insertions(+), 52 deletions(-)
diff --git a/src/components/upload/index.vue b/src/components/upload/index.vue
index 55b951c..8e3ae47 100644
--- a/src/components/upload/index.vue
+++ b/src/components/upload/index.vue
@@ -52,6 +52,11 @@ export default {
type: Array,
default: () => []
},
+ // 是否要更新fileList(如果要使用自己的fileList,则这个值传false,一般情况不用给这个值)
+ changeFileList: {
+ type: Boolean,
+ default: true
+ },
// 已上传文件列表
onRemove: {
type: Function,
@@ -70,6 +75,7 @@ export default {
this.initOss()
},
methods: {
+ // 初始化oss
initOss () {
this.client = new OSS({
region: 'oss-cn-shenzhen',
@@ -99,14 +105,14 @@ export default {
this.uploadProgress = 0
this.uploading = true
this.showFiles = false
- // 先传到阿里云oss,再把url传给后端
+ // 上传到阿里云oss
const { name } = await this.client.multipartUpload(file.name, file, {
progress: this.handleProgress
});
this.uploading = false
const url = 'http://huoran.oss-cn-shenzhen.aliyuncs.com/' + name
- this.$emit('update:fileList', [
+ this.changeFileList && this.$emit('update:fileList', [
...this.fileList,
{
name: name,
diff --git a/src/views/match/add/step1.vue b/src/views/match/add/step1.vue
index 90b6e15..d67c20b 100644
--- a/src/views/match/add/step1.vue
+++ b/src/views/match/add/step1.vue
@@ -223,7 +223,7 @@
+ @onSuccess="uploadAnnexSuccess" />
diff --git a/src/views/parnerOperation/learnMg.vue b/src/views/parnerOperation/learnMg.vue
index e1abbf7..cddcd46 100644
--- a/src/views/parnerOperation/learnMg.vue
+++ b/src/views/parnerOperation/learnMg.vue
@@ -147,14 +147,11 @@
-
- 上传
-
+
@@ -294,10 +291,11 @@ import Setting from '@/setting'
import Util from '@/libs/util'
import { mapState } from 'vuex'
import Editor from '@tinymce/tinymce-vue'
-// import t from "tinymce-plugin/plugins/tpImportword/plugin.js";
import editorConfig from '@/utils/editor'
import Cropper from '@/components/img-upload/Cropper'
import Axios from 'axios'
+import Upload from '@/components/upload';
+
export default {
data () {
return {
@@ -357,7 +355,8 @@ export default {
},
components: {
Editor,
- Cropper
+ Cropper,
+ Upload
},
watch: {
// 监听信息是否有更改,有的话页面离开的时候要询问是否要保存
@@ -641,29 +640,29 @@ export default {
this.uploading++
},
// 附件上传成功
- uploadSuccessFile (res) {
- const { originalFileName, fileUrl } = res.filesResult
+ uploadSuccessFile (file) {
+ const { name, url } = file
this.uploading--
this.form.id ?
this.$post(this.api.saveParnerFile, {
contentId: this.form.id,
id: '',
- fileName: originalFileName,
- filePath: fileUrl
+ fileName: name,
+ filePath: url
}).then(({ data }) => {
this.form.fileList.push({
- fileName: originalFileName,
- filePath: fileUrl,
- name: originalFileName,
- url: fileUrl,
+ fileName: name,
+ filePath: url,
+ name: name,
+ url,
id: data
})
}).catch(res => { }) :
this.form.fileList.push({
- fileName: originalFileName,
- filePath: fileUrl,
- name: originalFileName,
- url: fileUrl
+ fileName: name,
+ filePath: url,
+ name: name,
+ url
})
},
// 预览
diff --git a/src/views/shop/addProduct/index.vue b/src/views/shop/addProduct/index.vue
index 8a26ca9..6862bfc 100644
--- a/src/views/shop/addProduct/index.vue
+++ b/src/views/shop/addProduct/index.vue
@@ -529,14 +529,11 @@
-
- 上传文件
-
+
@@ -748,6 +745,7 @@ import quill from "@/components/quill";
import Editor from '@tinymce/tinymce-vue'
import editorConfig from '@/utils/editor'
import Cropper from '@/components/img-upload/Cropper'
+import Upload from '@/components/upload';
import Axios from 'axios'
export default {
data () {
@@ -914,7 +912,8 @@ export default {
},
components: {
Editor,
- Cropper
+ Cropper,
+ Upload
},
methods: {
getData () {
@@ -1503,13 +1502,12 @@ export default {
uploadSuccessInterface (res) { // 文件上传成功时的钩子
this.form.mall.interfaceDiagrams.push(res.data.filesResult.fileUrl)
},
- uploadSuccessFile (res) { // 文件上传成功时的钩子
- const e = res.filesResult
+ uploadSuccessFile (file) { // 文件上传成功时的钩子
this.form.mallAnnex.push({
mallId: this.id,
- filePath: e.fileUrl,
- fileName: e.originalFileName,
- name: e.originalFileName,
+ filePath: file.url,
+ fileName: file.name,
+ name: file.name
})
},
beforeRemove (file, fileList) {
@@ -1662,19 +1660,6 @@ $avatar-width: 104px;
}
}
}
-/deep/.el-upload__tip {
- margin-top: 0;
-
- p {
- font-size: 14px;
- color: rgba(0, 0, 0, 0.45);
- line-height: 1;
-
- &:first-child {
- margin-bottom: 5px;
- }
- }
-}
.pics {
display: flex;
margin-top: 10px;