ソースを参照

切换公司功能挪到外边来

fubin 1 年間 前
コミット
56e96f7d4b
2 ファイル変更89 行追加60 行削除
  1. 46 46
      src/components/main/components/user/user.vue
  2. 43 14
      src/components/main/main.vue

+ 46 - 46
src/components/main/components/user/user.vue

@@ -9,19 +9,19 @@
       <!--      <Icon :size="18" type="md-arrow-dropdown"></Icon>-->
       <DropdownMenu slot="list" style="line-height: 0;" class="dropDownCp">
         <!--切换公司-->
-        <Dropdown placement="left">
-          <DropdownItem name="changeCp">
-            {{ $t('changeCp') }}
-            <Icon type="ios-arrow-forward"></Icon>
-          </DropdownItem>
+<!--        <Dropdown placement="left">-->
+<!--          <DropdownItem name="changeCp">-->
+<!--            {{ $t('changeCp') }}-->
+<!--            <Icon type="ios-arrow-forward"></Icon>-->
+<!--          </DropdownItem>-->
 
-          <DropdownMenu slot="list">
-            <DropdownItem v-for="(item,index) in joinedCpList" :key="index+'l'" :name="'changeCp_' + item.cpId"
-                          :selected="item.cpId === $store.state.user.cpId">
-              {{ (item.cpId === $store.state.user.cpId ? '●' : '\u00A0\u00A0') + "\u3000" + item.cpName }}
-            </DropdownItem>
-          </DropdownMenu>
-        </Dropdown>
+<!--          <DropdownMenu slot="list">-->
+<!--            <DropdownItem v-for="(item,index) in joinedCpList" :key="index+'l'" :name="'changeCp_' + item.cpId"-->
+<!--                          :selected="item.cpId === $store.state.user.cpId">-->
+<!--              {{ (item.cpId === $store.state.user.cpId ? '●' : '\u00A0\u00A0') + "\u3000" + item.cpName }}-->
+<!--            </DropdownItem>-->
+<!--          </DropdownMenu>-->
+<!--        </Dropdown>-->
         <Dropdown placement="left">
           <DropdownItem name="lang">
             {{ $t('languageSetting') }}
@@ -250,7 +250,7 @@ export default {
       imageViewerFlag: false,
       dkLogo: dk_logo,
       personalFlag: false,
-      joinedCpList: self.$store.state.user.joinedCpList,// 加入公司
+      // joinedCpList: self.$store.state.user.joinedCpList,// 加入公司
       imagePathType: null, /* WXQY AL-OSS */
       personalInfo: {},
       langList: self.$config.languages,   // 语言包
@@ -681,39 +681,39 @@ export default {
         location.reload();
       }
     },
-    /**
-     * @desc   : 切换公司
-     * @author : 周兴
-     * @date   : 2024/3/19 14:18
-     */
-    async chooseCp(cpId) {
-      if (cpId) {
-        let item = this.joinedCpList.filter(it=>it.cpId == cpId);
-        if(!item || item.length == 0){
-          return;
-        }
-        await this.updateCompany(item[0]);
-        // 点击切换公司
-        this.changeCp(this.joinedCps).then(res => {
-          // 更新token
-          this.updateToken(res.data);
-          setTimeout(() => {
-            // 登录后获取信息
-            this.getInfoAfterLogin().then(r => {
-              if (r.code == this.$config.SUCCESS_CODE) {
-                this.handleAfterLoginInfo(r.data);
-                // 关闭所有的窗体
-                if (this.dkMain) {
-                  this.dkMain.handleAllClose();
-                }
-                // 刷新页面
-                location.reload();
-              }
-            });
-          }, 50)
-        })
-      }
-    },
+    // /**
+    //  * @desc   : 切换公司
+    //  * @author : 周兴
+    //  * @date   : 2024/3/19 14:18
+    //  */
+    // async chooseCp(cpId) {
+    //   if (cpId) {
+    //     let item = this.joinedCpList.filter(it=>it.cpId == cpId);
+    //     if(!item || item.length == 0){
+    //       return;
+    //     }
+    //     await this.updateCompany(item[0]);
+    //     // 点击切换公司
+    //     this.changeCp(this.joinedCps).then(res => {
+    //       // 更新token
+    //       this.updateToken(res.data);
+    //       setTimeout(() => {
+    //         // 登录后获取信息
+    //         this.getInfoAfterLogin().then(r => {
+    //           if (r.code == this.$config.SUCCESS_CODE) {
+    //             this.handleAfterLoginInfo(r.data);
+    //             // 关闭所有的窗体
+    //             if (this.dkMain) {
+    //               this.dkMain.handleAllClose();
+    //             }
+    //             // 刷新页面
+    //             location.reload();
+    //           }
+    //         });
+    //       }, 50)
+    //     })
+    //   }
+    // },
     /**
      * @desc   : 下拉点击
      * @author : 洪旭东

+ 43 - 14
src/components/main/main.vue

@@ -51,19 +51,8 @@
                         @click="exitFullscreen"></icon>
                 </Tooltip>
               </p>
-              <Select v-model="type" style="width:200px;margin-right: 10px">
-                <Option value="New York" label="New York">
-                  <span>New York</span>
-                  <span style="float:right;color:#ccc">America</span>
-                </Option>
-                <Option value="London" label="London">
-                  <span>London</span>
-                  <span style="float:right;color:#ccc">U.K.</span>
-                </Option>
-                <Option value="Sydney" label="Sydney">
-                  <span>Sydney</span>
-                  <span style="float:right;color:#ccc">Australian</span>
-                </Option>
+              <Select v-model="type" style="width:200px;margin-right: 10px" default-label="东科" @on-change="cpChange" >
+                <Option v-for="item in joinedCpList" :value="item.cpId" :key="item.cpId">{{ item.cpName }}</Option>
               </Select>
             </header-bar>
           </div>
@@ -133,6 +122,7 @@ export default {
     }
   },
   data() {
+    let self = this
     return {
       type:'',
       logo,
@@ -152,7 +142,8 @@ export default {
       dragging: false,
       siderWidth: 200,
       minSiderWidth:200,
-      maxSiderWidth:300
+      maxSiderWidth:300,
+      joinedCpList:self.$store.state.user.joinedCpList,
     }
   },
   computed: {
@@ -226,6 +217,11 @@ export default {
     ]),
     ...mapActions([
       'handleLogin',
+      'updateCompany',
+      'updateToken',
+      'changeCp',
+      'getInfoAfterLogin',
+      'handleAfterLoginInfo'
     ]),
     /**
      * @desc   : 开始拖动
@@ -548,6 +544,39 @@ export default {
         }
       })
     },
+    /**
+     * @desc   : 公司改变
+     * @author : 付斌
+     * @date   : 2024-06-13 17:14
+     */
+    async cpChange(cpId){
+      if (cpId) {
+        let item = this.joinedCpList.filter(it=>it.cpId == cpId);
+        if(!item || item.length == 0){
+          return;
+        }
+        await this.updateCompany(item[0]);
+        // 点击切换公司
+        this.changeCp(this.joinedCps).then(res => {
+          // 更新token
+          this.updateToken(res.data);
+          setTimeout(() => {
+            // 登录后获取信息
+            this.getInfoAfterLogin().then(r => {
+              if (r.code == this.$config.SUCCESS_CODE) {
+                this.handleAfterLoginInfo(r.data);
+                // 关闭所有的窗体
+                if (this.dkMain) {
+                  this.dkMain.handleAllClose();
+                }
+                // 刷新页面
+                location.reload();
+              }
+            });
+          }, 50)
+        })
+      }
+    }
   },
   watch: {
     '$route'(newRoute, oldRoute) {