From e02f6923593bd49f87caccd87e063baf312aaa3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=9A=E5=B1=BF?= <1491182878@qq.com> Date: Mon, 22 Aug 2022 06:19:08 +0000 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=B7=B2=E7=9F=A5=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E6=8F=8F=E8=BF=B0=EF=BC=9A=E5=9C=A8=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E7=AE=A1=E7=90=86=E4=B8=8B=EF=BC=8C=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=B8=BA=E8=8F=9C=E5=8D=95=E6=88=96=E8=80=85=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E7=9A=84=E6=9D=A1=E7=9B=AE=E4=B8=8B=E7=82=B9=E5=87=BB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8C=89=E9=92=AE=E3=80=82=20=E6=83=85=E5=86=B51?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=98=AF=E7=B1=BB=E5=9E=8B=E4=B8=BA?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=EF=BC=8C=E7=AC=AC=E4=B8=80=E6=AC=A1=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E4=BF=AE=E6=94=B9=E6=8C=89=E9=92=AE=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=EF=BC=8C=E5=88=99=E7=AC=AC=E4=BA=8C=E6=AC=A1=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=8F=A6=E4=B8=80=E4=B8=AA=E6=9D=A1=E7=9B=AE=E5=90=8E=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9=E6=8C=89=E9=92=AE=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=E9=94=99=EF=BC=81=20=E6=83=85=E5=86=B52=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=98=AF=E7=B1=BB=E5=9E=8B=E4=B8=BA=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=8C=E7=AC=AC=E4=B8=80=E6=AC=A1=E7=82=B9=E5=87=BB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=97=B6=E6=AD=A3=E5=B8=B8=EF=BC=8C=E5=BD=93=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E5=8F=96=E6=B6=88=E6=8C=89=E9=92=AE=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=97=B6=EF=BC=8C=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E6=8A=A5=E9=94=99=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 报错代码:this.resetForm("form") 修复方案:添加遗漏的表单 prop 属性 Signed-off-by: 稚屿 <1491182878@qq.com> --- ruoyi-ui/src/views/system/menu/index.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue index c30be850..57b56e55 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -107,7 +107,7 @@ - + - + @@ -195,7 +195,7 @@ - + @@ -206,7 +206,7 @@ - + @@ -217,7 +217,7 @@ - + @@ -231,7 +231,7 @@ - + @@ -248,7 +248,7 @@ - + From 99d1760b989a57cca8a158fcd29205af211ca46c Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 22 Aug 2022 15:27:58 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/system/SysDeptController.java | 12 +----------- .../common/core/domain/entity/SysDictData.java | 2 +- .../ruoyi/common/core/redis/RedisCache.java | 18 +++--------------- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index 92625493..6dd1756b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -1,6 +1,5 @@ package com.ruoyi.web.controller.system; -import java.util.Iterator; import java.util.List; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -54,16 +53,7 @@ public class SysDeptController extends BaseController public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) { List depts = deptService.selectDeptList(new SysDept()); - Iterator it = depts.iterator(); - while (it.hasNext()) - { - SysDept d = (SysDept) it.next(); - if (d.getDeptId().intValue() == deptId - || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) - { - it.remove(); - } - } + depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); return AjaxResult.success(depts); } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java index 4fa5f0bd..e79eaa20 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java @@ -131,7 +131,7 @@ public class SysDictData extends BaseEntity public boolean getDefault() { - return UserConstants.YES.equals(this.isDefault) ? true : false; + return UserConstants.YES.equals(this.isDefault); } public String getIsDefault() diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java index 03f062ef..d0a6de49 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java @@ -124,9 +124,9 @@ public class RedisCache * @param collection 多个对象 * @return */ - public long deleteObject(final Collection collection) + public boolean deleteObject(final Collection collection) { - return redisTemplate.delete(collection); + return redisTemplate.delete(collection) > 0; } /** @@ -231,18 +231,6 @@ public class RedisCache return opsForHash.get(key, hKey); } - /** - * 删除Hash中的数据 - * - * @param key - * @param hKey - */ - public void delCacheMapValue(final String key, final String hKey) - { - HashOperations hashOperations = redisTemplate.opsForHash(); - hashOperations.delete(key, hKey); - } - /** * 获取多个Hash中的数据 * @@ -264,7 +252,7 @@ public class RedisCache */ public boolean deleteCacheMapValue(final String key, final String hKey) { - return Boolean.TRUE.equals(redisTemplate.opsForHash().delete(key, hKey)); + return redisTemplate.opsForHash().delete(key, hKey) > 0; } /** From 7347cbaedf770def7a33ec925b9daeb7c7d7dc53 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 23 Aug 2022 17:29:09 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=86=85=E5=B5=8Ciframe=E5=88=87=E6=8D=A2tab=E4=B8=8D=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/assets/styles/transition.scss | 5 ++ ruoyi-ui/src/layout/components/AppMain.vue | 10 ++- .../layout/components/IframeToggle/index.vue | 24 +++++++ .../src/layout/components/InnerLink/index.vue | 62 ++++++++++++------- .../src/layout/components/TagsView/index.vue | 6 ++ ruoyi-ui/src/store/modules/tagsView.js | 40 ++++++++---- 6 files changed, 111 insertions(+), 36 deletions(-) create mode 100644 ruoyi-ui/src/layout/components/IframeToggle/index.vue diff --git a/ruoyi-ui/src/assets/styles/transition.scss b/ruoyi-ui/src/assets/styles/transition.scss index 25e7e181..a7129370 100644 --- a/ruoyi-ui/src/assets/styles/transition.scss +++ b/ruoyi-ui/src/assets/styles/transition.scss @@ -12,11 +12,16 @@ } /* fade-transform */ +.fade-transform--move, .fade-transform-leave-active, .fade-transform-enter-active { transition: all .5s; } +.fade-transform-leave-active { + position: absolute; +} + .fade-transform-enter { opacity: 0; transform: translateX(-30px); diff --git a/ruoyi-ui/src/layout/components/AppMain.vue b/ruoyi-ui/src/layout/components/AppMain.vue index 7cc66748..25d5a25a 100644 --- a/ruoyi-ui/src/layout/components/AppMain.vue +++ b/ruoyi-ui/src/layout/components/AppMain.vue @@ -2,15 +2,19 @@
- + +
diff --git a/ruoyi-ui/src/layout/components/InnerLink/index.vue b/ruoyi-ui/src/layout/components/InnerLink/index.vue index 227ff2a7..6edcdec6 100644 --- a/ruoyi-ui/src/layout/components/InnerLink/index.vue +++ b/ruoyi-ui/src/layout/components/InnerLink/index.vue @@ -1,27 +1,47 @@ + + diff --git a/ruoyi-ui/src/layout/components/TagsView/index.vue b/ruoyi-ui/src/layout/components/TagsView/index.vue index 2381d2e0..cbd9a253 100644 --- a/ruoyi-ui/src/layout/components/TagsView/index.vue +++ b/ruoyi-ui/src/layout/components/TagsView/index.vue @@ -133,6 +133,9 @@ export default { const { name } = this.$route if (name) { this.$store.dispatch('tagsView/addView', this.$route) + if (this.$route.meta.link) { + this.$store.dispatch('tagsView/addIframeView', this.$route) + } } return false }, @@ -153,6 +156,9 @@ export default { }, refreshSelectedTag(view) { this.$tab.refreshPage(view); + if (this.$route.meta.link) { + this.$store.dispatch('tagsView/delIframeView', this.$route) + } }, closeSelectedTag(view) { this.$tab.closePage(view).then(({ visitedViews }) => { diff --git a/ruoyi-ui/src/store/modules/tagsView.js b/ruoyi-ui/src/store/modules/tagsView.js index 9acf5dc5..39c70cba 100644 --- a/ruoyi-ui/src/store/modules/tagsView.js +++ b/ruoyi-ui/src/store/modules/tagsView.js @@ -1,9 +1,17 @@ const state = { visitedViews: [], - cachedViews: [] + cachedViews: [], + iframeViews: [] } const mutations = { + ADD_IFRAME_VIEW: (state, view) => { + if (state.iframeViews.some(v => v.path === view.path)) { + return + } else { + state.iframeViews.push(view) + } + }, ADD_VISITED_VIEW: (state, view) => { if (state.visitedViews.some(v => v.path === view.path)) return state.visitedViews.push( @@ -18,7 +26,6 @@ const mutations = { state.cachedViews.push(view.name) } }, - DEL_VISITED_VIEW: (state, view) => { for (const [i, v] of state.visitedViews.entries()) { if (v.path === view.path) { @@ -26,6 +33,10 @@ const mutations = { break } } + state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) + }, + DEL_IFRAME_VIEW: (state, view) => { + state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) }, DEL_CACHED_VIEW: (state, view) => { const index = state.cachedViews.indexOf(view.name) @@ -36,6 +47,7 @@ const mutations = { state.visitedViews = state.visitedViews.filter(v => { return v.meta.affix || v.path === view.path }) + state.iframeViews = state.iframeViews.filter(item => item.path === view.path) }, DEL_OTHERS_CACHED_VIEWS: (state, view) => { const index = state.cachedViews.indexOf(view.name) @@ -45,16 +57,15 @@ const mutations = { state.cachedViews = [] } }, - DEL_ALL_VISITED_VIEWS: state => { // keep affix tags const affixTags = state.visitedViews.filter(tag => tag.meta.affix) state.visitedViews = affixTags + state.iframeViews = [] }, DEL_ALL_CACHED_VIEWS: state => { state.cachedViews = [] }, - UPDATE_VISITED_VIEW: (state, view) => { for (let v of state.visitedViews) { if (v.path === view.path) { @@ -63,7 +74,6 @@ const mutations = { } } }, - DEL_RIGHT_VIEWS: (state, view) => { const index = state.visitedViews.findIndex(v => v.path === view.path) if (index === -1) { @@ -79,8 +89,9 @@ const mutations = { } return false }) + const iframeIndex = state.iframeViews.findIndex(v => v.path === view.path) + state.iframeViews = state.iframeViews.filter((item, idx) => idx <= iframeIndex) }, - DEL_LEFT_VIEWS: (state, view) => { const index = state.visitedViews.findIndex(v => v.path === view.path) if (index === -1) { @@ -96,6 +107,8 @@ const mutations = { } return false }) + const iframeIndex = state.iframeViews.findIndex(v => v.path === view.path) + state.iframeViews = state.iframeViews.filter((item, idx) => idx >= iframeIndex) } } @@ -104,13 +117,15 @@ const actions = { dispatch('addVisitedView', view) dispatch('addCachedView', view) }, + addIframeView({ commit }, view) { + commit('ADD_IFRAME_VIEW', view) + }, addVisitedView({ commit }, view) { commit('ADD_VISITED_VIEW', view) }, addCachedView({ commit }, view) { commit('ADD_CACHED_VIEW', view) }, - delView({ dispatch, state }, view) { return new Promise(resolve => { dispatch('delVisitedView', view) @@ -127,13 +142,18 @@ const actions = { resolve([...state.visitedViews]) }) }, + delIframeView({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_IFRAME_VIEW', view) + resolve([...state.iframeViews]) + }) + }, delCachedView({ commit, state }, view) { return new Promise(resolve => { commit('DEL_CACHED_VIEW', view) resolve([...state.cachedViews]) }) }, - delOthersViews({ dispatch, state }, view) { return new Promise(resolve => { dispatch('delOthersVisitedViews', view) @@ -156,7 +176,6 @@ const actions = { resolve([...state.cachedViews]) }) }, - delAllViews({ dispatch, state }, view) { return new Promise(resolve => { dispatch('delAllVisitedViews', view) @@ -179,18 +198,15 @@ const actions = { resolve([...state.cachedViews]) }) }, - updateVisitedView({ commit }, view) { commit('UPDATE_VISITED_VIEW', view) }, - delRightTags({ commit }, view) { return new Promise(resolve => { commit('DEL_RIGHT_VIEWS', view) resolve([...state.visitedViews]) }) }, - delLeftTags({ commit }, view) { return new Promise(resolve => { commit('DEL_LEFT_VIEWS', view) From 9a895763d55e147be355a2198ecfd33f66c2e746 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 23 Aug 2022 20:59:26 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=86=85=E5=B5=8Ciframe=E5=88=87=E6=8D=A2tab=E4=B8=8D=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/constant/Constants.java | 5 ++++ .../service/impl/SysMenuServiceImpl.java | 4 ++-- ruoyi-ui/src/store/modules/tagsView.js | 23 +++++++++++-------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java index 2dbdbe64..87fa40fc 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -19,6 +19,11 @@ public class Constants */ public static final String GBK = "GBK"; + /** + * www主域 + */ + public static final String WWW = "www."; + /** * http请求 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java index 604d60e6..481a9ec9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java @@ -529,7 +529,7 @@ public class SysMenuServiceImpl implements ISysMenuService */ public String innerLinkReplaceEach(String path) { - return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS }, - new String[] { "", "" }); + return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, "." }, + new String[] { "", "", "", "/" }); } } diff --git a/ruoyi-ui/src/store/modules/tagsView.js b/ruoyi-ui/src/store/modules/tagsView.js index 39c70cba..9a88c2bc 100644 --- a/ruoyi-ui/src/store/modules/tagsView.js +++ b/ruoyi-ui/src/store/modules/tagsView.js @@ -6,11 +6,12 @@ const state = { const mutations = { ADD_IFRAME_VIEW: (state, view) => { - if (state.iframeViews.some(v => v.path === view.path)) { - return - } else { - state.iframeViews.push(view) - } + if (state.iframeViews.some(v => v.path === view.path)) return + state.iframeViews.push( + Object.assign({}, view, { + title: view.meta.title || 'no-name' + }) + ) }, ADD_VISITED_VIEW: (state, view) => { if (state.visitedViews.some(v => v.path === view.path)) return @@ -87,10 +88,12 @@ const mutations = { if (i > -1) { state.cachedViews.splice(i, 1) } + if(item.meta.link) { + const fi = state.iframeViews.findIndex(v => v.path === item.path) + state.iframeViews.splice(fi, 1) + } return false }) - const iframeIndex = state.iframeViews.findIndex(v => v.path === view.path) - state.iframeViews = state.iframeViews.filter((item, idx) => idx <= iframeIndex) }, DEL_LEFT_VIEWS: (state, view) => { const index = state.visitedViews.findIndex(v => v.path === view.path) @@ -105,10 +108,12 @@ const mutations = { if (i > -1) { state.cachedViews.splice(i, 1) } + if(item.meta.link) { + const fi = state.iframeViews.findIndex(v => v.path === item.path) + state.iframeViews.splice(fi, 1) + } return false }) - const iframeIndex = state.iframeViews.findIndex(v => v.path === view.path) - state.iframeViews = state.iframeViews.filter((item, idx) => idx >= iframeIndex) } } From 39efed17102745750cd339c19b06e01b2e9d798d Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 24 Aug 2022 11:18:52 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E6=8A=A5=E9=94=99=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/components/FileUpload/index.vue | 28 ++++++--- ruoyi-ui/src/components/ImageUpload/index.vue | 58 ++++++++++++------- 2 files changed, 56 insertions(+), 30 deletions(-) diff --git a/ruoyi-ui/src/components/FileUpload/index.vue b/ruoyi-ui/src/components/FileUpload/index.vue index aa2296b9..4e94cb0c 100644 --- a/ruoyi-ui/src/components/FileUpload/index.vue +++ b/ruoyi-ui/src/components/FileUpload/index.vue @@ -12,7 +12,7 @@ :show-file-list="false" :headers="headers" class="upload-file-uploader" - ref="upload" + ref="fileUpload" > 选取文件 @@ -151,14 +151,16 @@ export default { this.$modal.closeLoading() }, // 上传成功回调 - handleUploadSuccess(res) { - this.uploadList.push({ name: res.fileName, url: res.fileName }); - if (this.uploadList.length === this.number) { - this.fileList = this.fileList.concat(this.uploadList); - this.uploadList = []; - this.number = 0; - this.$emit("input", this.listToString(this.fileList)); + handleUploadSuccess(res, file) { + if (res.code === 200) { + this.uploadList.push({ name: res.fileName, url: res.fileName }); + this.uploadedSuccessfully(); + } else { + this.number--; this.$modal.closeLoading(); + this.$modal.msgError(res.msg); + this.$refs.fileUpload.handleRemove(file); + this.uploadedSuccessfully(); } }, // 删除文件 @@ -166,6 +168,16 @@ export default { this.fileList.splice(index, 1); this.$emit("input", this.listToString(this.fileList)); }, + // 上传结束处理 + uploadedSuccessfully() { + if (this.number > 0 && this.uploadList.length === this.number) { + this.fileList = this.fileList.concat(this.uploadList); + this.uploadList = []; + this.number = 0; + this.$emit("input", this.listToString(this.fileList)); + this.$modal.closeLoading(); + } + }, // 获取文件名称 getFileName(name) { if (name.lastIndexOf("/") > -1) { diff --git a/ruoyi-ui/src/components/ImageUpload/index.vue b/ruoyi-ui/src/components/ImageUpload/index.vue index 71172c1f..e0140f5f 100644 --- a/ruoyi-ui/src/components/ImageUpload/index.vue +++ b/ruoyi-ui/src/components/ImageUpload/index.vue @@ -9,8 +9,8 @@ :limit="limit" :on-error="handleUploadError" :on-exceed="handleExceed" - name="file" - :on-remove="handleRemove" + ref="imageUpload" + :on-remove="handleDelete" :show-file-list="true" :headers="headers" :file-list="fileList" @@ -117,25 +117,6 @@ export default { }, }, methods: { - // 删除图片 - handleRemove(file, fileList) { - const findex = this.fileList.map(f => f.name).indexOf(file.name); - if(findex > -1) { - this.fileList.splice(findex, 1); - this.$emit("input", this.listToString(this.fileList)); - } - }, - // 上传成功回调 - handleUploadSuccess(res) { - this.uploadList.push({ name: res.fileName, url: res.fileName }); - if (this.uploadList.length === this.number) { - this.fileList = this.fileList.concat(this.uploadList); - this.uploadList = []; - this.number = 0; - this.$emit("input", this.listToString(this.fileList)); - this.$modal.closeLoading(); - } - }, // 上传前loading加载 handleBeforeUpload(file) { let isImg = false; @@ -171,11 +152,42 @@ export default { handleExceed() { this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`); }, + // 上传成功回调 + handleUploadSuccess(res, file) { + if (res.code === 200) { + this.uploadList.push({ name: res.fileName, url: res.fileName }); + this.uploadedSuccessfully(); + } else { + this.number--; + this.$modal.closeLoading(); + this.$modal.msgError(res.msg); + this.$refs.imageUpload.handleRemove(file); + this.uploadedSuccessfully(); + } + }, + // 删除图片 + handleDelete(file) { + const findex = this.fileList.map(f => f.name).indexOf(file.name); + if(findex > -1) { + this.fileList.splice(findex, 1); + this.$emit("input", this.listToString(this.fileList)); + } + }, // 上传失败 handleUploadError() { this.$modal.msgError("上传图片失败,请重试"); this.$modal.closeLoading(); }, + // 上传结束处理 + uploadedSuccessfully() { + if (this.number > 0 && this.uploadList.length === this.number) { + this.fileList = this.fileList.concat(this.uploadList); + this.uploadList = []; + this.number = 0; + this.$emit("input", this.listToString(this.fileList)); + this.$modal.closeLoading(); + } + }, // 预览 handlePictureCardPreview(file) { this.dialogImageUrl = file.url; @@ -186,7 +198,9 @@ export default { let strs = ""; separator = separator || ","; for (let i in list) { - strs += list[i].url.replace(this.baseUrl, "") + separator; + if (list[i].url) { + strs += list[i].url.replace(this.baseUrl, "") + separator; + } } return strs != '' ? strs.substr(0, strs.length - 1) : ''; }