lilei 3 лет назад
Родитель
Сommit
a4a698ff43

+ 48 - 22
src/components/MultiTab/MultiTab.vue

@@ -5,10 +5,10 @@ export default {
   name: 'MultiTab',
   data () {
     return {
-      fullPathList: [],
-      tabsList: [],
-      pages: [],
-      activeKey: '',
+      pagesRecordList: [], // 记录打开过的页面
+      tabsList: [], // 已打开页签
+      pages: [], // 已打开页面
+      activeKey: '', // 当前页面
       newTabIndex: 0
     }
   },
@@ -38,6 +38,7 @@ export default {
 
     this.pages.push(this.$route)
     this.tabsList.push(this.$route.name)
+    this.pagesRecordList.push(this.$route.name)
     this.selectedLastPath()
   },
   methods: {
@@ -66,6 +67,11 @@ export default {
     selectedLastPath () {
       this.activeKey = this.tabsList[this.tabsList.length - 1]
     },
+    replaceTab (newtab, oldtab) {
+      const index = this.pages.findIndex(item => item.name == oldtab.name)
+      this.pages.splice(index, 1, newtab)
+      this.tabsList.splice(index, 1, newtab.name)
+    },
     // content menu
     refashThat (e) {
       this.reloadView()
@@ -143,35 +149,55 @@ export default {
   },
   watch: {
     '$route': function (newVal, oldVal) {
-      const index = this.tabsList.indexOf(newVal.name)
+      console.log(newVal, oldVal)
       if (newVal.name == oldVal.name) { return }
       // 解决页面地址相同参数不同时打开多个页签问题(例 详情页id或sn不同时)
+      const index = this.tabsList.indexOf(newVal.name)
       if (index < 0) { // 不存在
-        this.tabsList.push(newVal.name)
-        this.pages.push(newVal)
-        this.$store.state.app.isNewTab = true
+        console.log(1, '不存在')
+        // 判断是否是新增,编辑,详情页
+        const na = newVal.meta.title.indexOf('详情') >= 0
+        const nb = newVal.meta.title.indexOf('新增') >= 0
+        const nc = newVal.meta.title.indexOf('编辑') >= 0
+        const oa = oldVal.meta.title.indexOf('详情') >= 0
+        const ob = oldVal.meta.title.indexOf('新增') >= 0
+        const oc = oldVal.meta.title.indexOf('编辑') >= 0
+        if (na || nb || nc || oa || ob || oc) {
+          // 替换当前页签
+          this.replaceTab(newVal, oldVal)
+        } else {
+          this.tabsList.push(newVal.name)
+          this.pages.push(newVal)
+          this.pagesRecordList.push(newVal.name)
+        }
+        // 从列表打开新增,编辑
+        this.$store.state.app.isNewTab = na || nb || nc
+        // 从编辑,新增返回列表
+        this.$store.state.app.updateList = ob || oc
       } else { // 已存在
         this.pages.splice(index, 1, newVal)
+        this.tabsList.splice(index, 1, newVal.name)
         this.$store.state.app.isNewTab = false
+        console.log(1, '已存在')
       }
       // 父页面(列表)进入子页面(编辑、详情)再返回至父页面时关闭子页面页签   子页面点击“返回列表”
-      if (oldVal && oldVal.name && newVal.query.closeLastOldTab) {
-        if (oldVal.name.indexOf('List') == -1) { // 要关闭的页面不能是列表页
-          this.remove(oldVal.name) // 关闭子页面
-          this.$store.state.app.isNewTab = !(oldVal.meta.title.indexOf('详情') >= 0)
-        }
-      }
+      // if (oldVal && oldVal.name && newVal.query.closeLastOldTab) {
+      //   if (oldVal.name.indexOf('List') == -1) { // 要关闭的页面不能是列表页
+      //     this.remove(oldVal.name) // 关闭子页面
+      //     this.$store.state.app.isNewTab = !(oldVal.meta.title.indexOf('详情') >= 0)
+      //   }
+      // }
       this.activeKey = newVal.name
     },
     activeKey: function (newPathKey) {
-      console.log(newPathKey, 'newVal')
-      const row = this.pages.find(item => item.name == newPathKey)
-      if (row.fullPath.indexOf('/list') == -1) {
-        this.$router.push({ path: row.fullPath })
-      } else {
-        // this.$router.push({ path: row.fullPath, query: { closeLastOldTab: true } })  //  需求:切换页签需关掉子页面
-        this.$router.push({ path: row.path }) //  需求:切换页签不需关掉子页面
-      }
+      this.$router.push({ name: newPathKey })
+      // const row = this.pages.find(item => item.name == newPathKey)
+      // if (row.fullPath.indexOf('/list') == -1) {
+      //   this.$router.push({ path: row.fullPath })
+      // } else {
+      //   // this.$router.push({ path: row.fullPath, query: { closeLastOldTab: true } })  //  需求:切换页签需关掉子页面
+      //   this.$router.push({ path: row.path }) //  需求:切换页签不需关掉子页面
+      // }
     }
   },
   render () {

+ 1 - 1
src/config/router.config.js

@@ -660,7 +660,7 @@ export const asyncRouterMap = [
                 name: 'companyReceivablePayableCollectionPayment',
                 component: () => import(/* webpackChunkName: "financialManagement" */ '@/views/financialManagement/companyReceivablePayable/collectionPayment.vue'),
                 meta: {
-                  title: '单位应收应付',
+                  title: '编辑单位应收应付',
                   icon: 'transaction',
                   hidden: true,
                   permission: 'M_collectionPayment'

+ 2 - 1
src/store/modules/app.js

@@ -28,7 +28,8 @@ const app = {
     nowRoute: '', // 当前路由
     isShowVideo: false, // 是否显示视频弹窗
     isNewTab: false,
-    isNewSubTab: false
+    isNewSubTab: false,
+    updateList: false
   },
   mutations: {
     SET_SIDEBAR_TYPE: (state, type) => {

+ 5 - 0
src/views/allocationManagement/chainTransferIn/list.vue

@@ -263,6 +263,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/allocationManagement/chainTransferOut/list.vue

@@ -325,6 +325,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/allocationManagement/storeTransferOut/list.vue

@@ -310,6 +310,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/allocationManagement/warehouseAllocation/list.vue

@@ -267,6 +267,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/bulkManagement/bulkReturnGoods/list.vue

@@ -338,6 +338,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/bulkManagement/bulkWarehousingOrder/list.vue

@@ -368,6 +368,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/customerManagement/customerInfo/list.vue

@@ -357,6 +357,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/financialManagement/companyReceivablePayable/list.vue

@@ -165,6 +165,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/financialManagement/expenseManagement/list.vue

@@ -335,6 +335,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/inventoryManagement/inventoryChecking/list.vue

@@ -297,6 +297,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/inventoryManagement/inventoryQuery/list.vue

@@ -367,6 +367,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/inventoryManagement/warehouse/list.vue

@@ -177,6 +177,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/productManagement/productInfo/list.vue

@@ -354,6 +354,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/purchasingManagement/purchaseOrder/list.vue

@@ -325,6 +325,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/purchasingManagement/purchaseReturn/list.vue

@@ -290,6 +290,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 1
src/views/salesManagement/salesQuery/list.vue

@@ -441,12 +441,16 @@ export default {
     }
   },
   activated () {
-    console.log(this.$store.state.app.isNewTab)
     // 如果是新页签打开,则重置当前页面
     if (this.$store.state.app.isNewTab) {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 5 - 0
src/views/salesManagement/salesReturn/list.vue

@@ -298,6 +298,11 @@ export default {
       this.pageInit()
       this.resetSearchForm()
     }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})