fix: 修正图片上传和显示路径并添加本地存储状态保持
- 将图片上传接口从 `/open/file/upload` 改为 `/work-presentation/upload`
- 统一图片显示路径,添加 `/project/download/` 前缀
- 添加上传失败的错误处理
- 使用 localStorage 保持首页标签页的激活状态
- 修正编辑时图片路径的拼接逻辑
| | |
| | | > |
| | | <el-carousel-item v-for="item in workListData" :key="item.id"> |
| | | <div @click="toWorkDetail(item)" class="cursor-pointer"> |
| | | <img :src="item.img.split(',')[0]" class="w100 h--290" /> |
| | | <img :src="VUE_APP_IMAGE_BASE_URL + item.img.split(',')[0]" class="w100 h--290" /> |
| | | <div |
| | | class="fs--18 lh--24 SHSBold py--10 pl--20 pr--14 c-fff" |
| | | > |
| | |
| | | searchTabs: ["本周", "本月", "本季度", "本年"], |
| | | activeTabs: "本周", |
| | | workListData: [], |
| | | VUE_APP_IMAGE_BASE_URL: process.env.VUE_APP_IMAGE_BASE_URL, |
| | | VUE_APP_IMAGE_BASE_URL: process.env.VUE_APP_IMAGE_BASE_URL + "/project/download/", |
| | | projectList: [], |
| | | tooltipVisible: false, |
| | | tooltipPos: { left: 0, top: 0 }, |
| | |
| | | }, |
| | | }, |
| | | created() { |
| | | if (localStorage.getItem("activeTab")) { |
| | | this.activeTab = Number(localStorage.getItem("activeTab")); |
| | | } |
| | | this.mapPromise = AMapLoader.load({ |
| | | key: "232929db1cb31f26d42b3645a7456154", |
| | | version: "2.0", |
| | |
| | | }); |
| | | }, |
| | | beforeDestroy() { |
| | | localStorage.setItem("activeTab", this.activeTab); |
| | | this.stopAutoScroll(); |
| | | }, |
| | | methods: { |
| | |
| | | <img |
| | | v-for="(item, index) in detailData.img.split(',')" |
| | | :key="index" |
| | | style="width: 100%; height: 100%" |
| | | :src="item" |
| | | :src="VUE_APP_IMAGE_BASE_URL + item" |
| | | /> |
| | | </div> |
| | | </div> |
| | |
| | | data() { |
| | | return { |
| | | detailData: {}, |
| | | VUE_APP_IMAGE_BASE_URL: process.env.VUE_APP_IMAGE_BASE_URL + '/project/download/' |
| | | }; |
| | | }, |
| | | computed: {}, |
| | |
| | | <div class="SHSR fs--16 lh--16 mb--17 color1">工作图片:</div> |
| | | <div class=""> |
| | | <el-upload |
| | | :action="VUE_APP_BASE_URL + '/open/file/upload'" |
| | | :action="VUE_APP_BASE_URL + '/work-presentation/upload'" |
| | | :headers="uploadHeaders" |
| | | :before-upload="beforeUpload" |
| | | :limit="5" |
| | |
| | | ...this.formData, |
| | | clientId: localStorage.getItem("clientId"), |
| | | }; |
| | | obj.img = this.fileList.map((item) => item.url).join(","); |
| | | obj.img = this.fileList |
| | | .map((item) => item.url.substring(item.url.lastIndexOf("/") + 1)) |
| | | .join(","); |
| | | let api = obj.id ? updateWorkPresentation : addWorkPresentation; |
| | | api(obj).then((res) => { |
| | | this.closeForm(); |
| | |
| | | }, |
| | | |
| | | handleSuccess(response, file, fileList) { |
| | | this.fileList.push({ |
| | | url: process.env.VUE_APP_IMAGE_BASE_URL + response.data, |
| | | }); |
| | | this.$message.success("上传成功"); |
| | | if (response.code == 200) { |
| | | this.fileList.push({ |
| | | url: |
| | | process.env.VUE_APP_IMAGE_BASE_URL + |
| | | "/project/download/" + |
| | | response.data.split(".")[0], |
| | | }); |
| | | this.$message.success("上传成功"); |
| | | } else { |
| | | this.$message.error(response.msg); |
| | | } |
| | | }, |
| | | |
| | | beforeUpload(file) { |
| | |
| | | this.formData = { ...row }; |
| | | this.fileList = row.img.split(",").map((item) => { |
| | | return { |
| | | url: item, |
| | | url: process.env.VUE_APP_IMAGE_BASE_URL + "/project/download/" + item, |
| | | }; |
| | | }); |
| | | this.formVisible = true; |