瀏覽代碼

Merge branch 'deploy' of jianguan-web/qpls-it-html into master

陈瑞 3 年之前
父節點
當前提交
3d2b573ecd
共有 6 個文件被更改,包括 81 次插入53 次删除
  1. 39 21
      src/components/MultiTab/MultiTab.vue
  2. 1 1
      src/config/defaultSettings.js
  3. 6 3
      src/permission.js
  4. 2 2
      src/utils/mixin.js
  5. 31 24
      src/views/power/menuMould/setModal.vue
  6. 2 2
      vue.config.js

+ 39 - 21
src/components/MultiTab/MultiTab.vue

@@ -6,6 +6,7 @@ export default {
   data () {
     return {
       fullPathList: [],
+      tabsList: [],
       pages: [],
       activeKey: '',
       newTabIndex: 0
@@ -25,7 +26,7 @@ export default {
       }
       this.closeThat(val)
     }).$on('rename', ({ key, name }) => {
-      console.log('rename', key, name)
+      // console.log('rename', key, name)
       try {
         const item = this.pages.find(item => item.path === key)
         item.meta.customTitle = name
@@ -35,7 +36,7 @@ export default {
     })
 
     this.pages.push(this.$route)
-    this.fullPathList.push(this.$route.fullPath)
+    this.tabsList.push(this.$route.name)
     this.selectedLastPath()
   },
   methods: {
@@ -43,30 +44,30 @@ export default {
       this[action](targetKey)
     },
     remove (targetKey) {
-      this.pages = this.pages.filter(page => page.fullPath !== targetKey)
-      this.fullPathList = this.fullPathList.filter(path => path !== targetKey)
+      this.pages = this.pages.filter(page => page.name !== targetKey)
+      this.tabsList = this.tabsList.filter(name => name !== targetKey)
       // 判断当前标签是否关闭,若关闭则跳转到最后一个还存在的标签页
-      if (!this.fullPathList.includes(this.activeKey)) {
+      if (!this.tabsList.includes(this.activeKey)) {
         this.selectedLastPath()
       }
     },
     selectedLastPath () {
-      this.activeKey = this.fullPathList[this.fullPathList.length - 1]
+      this.activeKey = this.tabsList[this.tabsList.length - 1]
     },
 
     // content menu
     closeThat (e) {
       // 判断是否为最后一个标签页,如果是最后一个,则无法被关闭
-      if (this.fullPathList.length > 1) {
+      if (this.tabsList.length > 1) {
         this.remove(e)
       } else {
         this.$message.info('这是最后一个标签了, 无法被关闭')
       }
     },
     closeLeft (e) {
-      const currentIndex = this.fullPathList.indexOf(e)
+      const currentIndex = this.tabsList.indexOf(e)
       if (currentIndex > 0) {
-        this.fullPathList.forEach((item, index) => {
+        this.tabsList.forEach((item, index) => {
           if (index < currentIndex) {
             this.remove(item)
           }
@@ -76,9 +77,9 @@ export default {
       }
     },
     closeRight (e) {
-      const currentIndex = this.fullPathList.indexOf(e)
-      if (currentIndex < (this.fullPathList.length - 1)) {
-        this.fullPathList.forEach((item, index) => {
+      const currentIndex = this.tabsList.indexOf(e)
+      if (currentIndex < (this.tabsList.length - 1)) {
+        this.tabsList.forEach((item, index) => {
           if (index > currentIndex) {
             this.remove(item)
           }
@@ -88,8 +89,8 @@ export default {
       }
     },
     closeAll (e) {
-      const currentIndex = this.fullPathList.indexOf(e)
-      this.fullPathList.forEach((item, index) => {
+      const currentIndex = this.tabsList.indexOf(e)
+      this.tabsList.forEach((item, index) => {
         if (index !== currentIndex) {
           this.remove(item)
         }
@@ -120,15 +121,32 @@ export default {
     }
   },
   watch: {
-    '$route': function (newVal) {
-      this.activeKey = newVal.fullPath
-      if (this.fullPathList.indexOf(newVal.fullPath) < 0) {
-        this.fullPathList.push(newVal.fullPath)
+    '$route': function (newVal, oldVal) {
+      // 父页面(列表)进入子页面(编辑、详情)再返回至父页面时关闭子页面页签   子页面点击“返回列表”
+      if (oldVal && oldVal.name && newVal.query.closeLastOldTab) {
+        if (oldVal.name.indexOf('List') == -1) { // 要关闭的页面不能是列表页
+          this.remove(oldVal.name) // 关闭子页面
+        }
+      }
+      this.activeKey = newVal.name
+      const index = this.tabsList.indexOf(newVal.name)
+      // 解决页面地址相同参数不同时打开多个页签问题(例 详情页id或sn不同时)
+      if (index < 0) { // 不存在
+        this.tabsList.push(newVal.name)
         this.pages.push(newVal)
+      } else { // 已存在
+        this.pages.splice(index, 1, newVal)
       }
     },
     activeKey: function (newPathKey) {
-      this.$router.push({ path: newPathKey })
+      const row = this.pages.find(item => item.name == newPathKey)
+      // console.log(row, '+++', row.fullPath)
+      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 () {
@@ -137,10 +155,10 @@ export default {
       return (
         <a-tab-pane
           style={{ height: 0 }}
-          key={page.fullPath} closable={pages.length > 1}
+          key={page.name} closable={pages.length > 1}
         >
           <span slot="tab">
-            {this.renderTabPane(page.meta.customTitle || page.meta.title, page.fullPath)}
+            {this.renderTabPane(page.meta.customTitle || page.meta.title, page.name)}
           </span>
         </a-tab-pane>)
     })

+ 1 - 1
src/config/defaultSettings.js

@@ -28,6 +28,6 @@ export default {
   storageOptions: {
     namespace: 'pro__', // key prefix
     name: 'ls', // name variable Vue.[ls] or this.[$ls],
-    storage: 'local' // storage name session, local, memory
+    storage: 'session' // storage name session, local, memory
   }
 }

+ 6 - 3
src/permission.js

@@ -32,7 +32,8 @@ router.beforeEach((to, from, next) => {
         store.dispatch('SetInfo', userInfo)
       } else {
         store.dispatch('Logout').then(() => {
-          next({ path: '/user/login', query: { redirect: to.fullPath } })
+          // next({ path: '/user/login', query: { redirect: to.fullPath } })
+          next({ path: '/user/login' })
         })
       }
       console.log(store.getters.roles)
@@ -45,7 +46,8 @@ router.beforeEach((to, from, next) => {
             if (roles.permissionList.length == 0 || !roles) {
               store.dispatch('Logout').then(() => {
                 store.dispatch('ResetRoutes').then(() => {
-                  next({ path: '/user/login', query: { redirect: to.fullPath } })
+                  // next({ path: '/user/login', query: { redirect: to.fullPath } })
+                  next({ path: '/user/login' })
                 })
               })
             } else {
@@ -70,7 +72,8 @@ router.beforeEach((to, from, next) => {
               description: '请求用户信息失败,请重试'
             })
             store.dispatch('Logout').then(() => {
-              next({ path: '/user/login', query: { redirect: to.fullPath } })
+              // next({ path: '/user/login', query: { redirect: to.fullPath } })
+              next({ path: '/user/login' })
             })
           })
       } else {

+ 2 - 2
src/utils/mixin.js

@@ -57,9 +57,9 @@ const AppDeviceEnquire = {
       switch (deviceType) {
         case DEVICE_TYPE.DESKTOP:
           $store.commit('TOGGLE_DEVICE', 'desktop')
-          // $store.dispatch('setSidebar', true)
+          $store.dispatch('setSidebar', true)
           // 默认收起侧边栏
-          $store.dispatch('setSidebar', false)
+          // $store.dispatch('setSidebar', false)
           break
         case DEVICE_TYPE.TABLET:
           $store.commit('TOGGLE_DEVICE', 'tablet')

+ 31 - 24
src/views/power/menuMould/setModal.vue

@@ -8,31 +8,33 @@
     v-model="isShow"
     @cancle="isShow=false"
     :width="800">
-    <!-- 表单 -->
-    <div>
-      <a-form-model
-        id="customerTypeEdit-form"
-        ref="ruleForm"
-        :model="form"
-        :rules="rules"
-        :label-col="formItemLayout.labelCol"
-        :wrapper-col="formItemLayout.wrapperCol"
-      >
-        <a-tree
-          checkable
-          @check="onCheck"
-          @expand="onExpand"
-          :expandedKeys="expandedKeys"
-          :autoExpandParent="autoExpandParent"
-          v-model="checkedKeys"
-          :treeData="treeData"
-        />
-      </a-form-model>
-      <div class="btn-cont">
-        <a-button type="primary" id="customer-type-edit-modal-save" @click="handleSave">保存</a-button>
-        <a-button id="customer-type-edit-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
+    <a-spin :spinning="spinning" tip="Loading...">
+      <!-- 表单 -->
+      <div>
+        <a-form-model
+          id="customerTypeEdit-form"
+          ref="ruleForm"
+          :model="form"
+          :rules="rules"
+          :label-col="formItemLayout.labelCol"
+          :wrapper-col="formItemLayout.wrapperCol"
+        >
+          <a-tree
+            checkable
+            @check="onCheck"
+            @expand="onExpand"
+            :expandedKeys="expandedKeys"
+            :autoExpandParent="autoExpandParent"
+            v-model="checkedKeys"
+            :treeData="treeData"
+          />
+        </a-form-model>
+        <div class="btn-cont">
+          <a-button type="primary" id="customer-type-edit-modal-save" @click="handleSave">保存</a-button>
+          <a-button id="customer-type-edit-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
+        </div>
       </div>
-    </div>
+    </a-spin>
   </a-modal>
 </template>
 
@@ -61,6 +63,7 @@ export default {
   },
   data () {
     return {
+      spinning: false,
       isShow: this.openModal, //  是否打开弹框
       detailData: null, //  数据
       formItemLayout: {
@@ -108,6 +111,7 @@ export default {
     },
     // 详情
     getDetail () {
+      this.spinning = true
       findMouldMenuDetail({ id: this.itemId, appType: 2 }).then(res => {
         if (res.status == 200) {
           this.treeData = res.data.menuList
@@ -117,6 +121,9 @@ export default {
             // 找出叶子节点
             this.findLeaf(this.treeData, arr)
           }
+          this.spinning = false
+        } else {
+          this.spinning = false
         }
       })
     },

+ 2 - 2
vue.config.js

@@ -108,8 +108,8 @@ const vueConfig = {
     // If you want to turn on the proxy, please remove the mockjs /src/main.jsL11
     proxy: {
       '/api': {
-        target: 'http://192.168.16.103:8501/qpls-it',
-        // target: 'http://qpls-it.360arrow.com.cn/qpls-it',
+        // target: 'http://192.168.16.103:8501/qpls-it',
+        target: 'http://qpls-it.360arrow.com.cn/qpls-it',
         // target: 'https://it.test.qiubcar.com/zyit',
         ws: false,
         changeOrigin: true,