| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <template>
- <ul class="nav navbar-nav navbar-right">
- <li class="dropdown">
- <a
- v-if="loginInfo"
-
- class="dropdown-toggle"
- data-toggle="dropdown"
- role="button"
- aria-haspopup="true"
- aria-expanded="false"
- >
- {{ loginClientName }}
- <span class="caret" />
- </a>
- <ul
- v-if="clientCanAccessList != null && clientCanAccessList.length > 0"
- class="dropdown-menu"
- >
- <li
- v-for="clientCanAccess in clientCanAccessList"
- :key="clientCanAccess.id"
- >
- <a @click="changeTokenClient(clientCanAccess.id)">{{ clientCanAccess.name }}</a>
- </li>
- </ul>
- </li>
- </ul>
- <a-modal v-model:open="visible" title="新用户未设置所属部门或岗位">
- <p>
- 尊敬的用户,
- </p>
- <p>
- 您好,
- 您的账号还未设置所属部门或岗位,因此您可能看不到任何数据。请联系您公司的管理员为您分配权限。
- </p>
- <template #footer>
- <a-button @click="visible = false">确定</a-button>
- <a-button @click="goHome">退出</a-button>
- </template>
- </a-modal>
- </template>
- <script>
- import Common from '../common/Common.js';
- import ClientResourceV2 from '../api/base/ClientResourceV2.js';
- import TokenClientResource from '../api/base/TokenClientResource.js';
- import { Notify, Uuid } from 'pc-component-v3';
- export default {
- props: {
- loginInfo: {
- type: Object,
- default: function(){
- return null;
- },
- },
- },
- data: function () {
- return {
- clientCanAccessList: [],
- loginClientName:'',
- visible: false,
- };
- },
- mounted: function () {
- this.listClientCanAccess();
- this.queryTokenClient();
- },
- methods: {
- /**
- * 获取可以访问的公司
- */
- listClientCanAccess: function () {
- var _self = this;
- ClientResourceV2.listClientCanAccess().then(baseListResponse => {
- if (baseListResponse.errorCode == 0) {
- _self.clientCanAccessList = baseListResponse.datas;
- } else if(baseListResponse.errorCode == -1){
- _self.visible = true;
- } else {
- Notify.error(_self.$t('lang.Notify.error'), baseListResponse.errorMessage, false);
- }
- }, errorData => {
- Common.processException(errorData);
- });
- },
- /**
- * 切换公司
- */
- changeTokenClient: function (clientId) {
- var _self = this;
- console.log(_self.loginInfo);
- const tokenClientChangeRequest = {
- userId: _self.loginInfo.userId,
- clientId: clientId,
- token: _self.loginInfo.token,
- };
- TokenClientResource.changeTokenClient(tokenClientChangeRequest).then(baseObjectResponse => {
- if (baseObjectResponse.errorCode == 0) {
- // Notify.success('正确','公司切换成功',true);
- _self.queryTokenClient();
- window.location.reload();
- }else{
- Notify.error(_self.$t('lang.Notify.companySwitchFailed'), baseObjectResponse.errorMessage, false);
- }
- }, errorData => {
- Common.processException(errorData);
- });
- },
- /**
- * 查询设置的公司
- */
- queryTokenClient: function () {
- var _self = this;
- TokenClientResource.queryTokenClient().then(baseObjectResponse => {
- if (baseObjectResponse.errorCode == 0) {
- _self.loginClientName = baseObjectResponse.data.clientName;
- }else if (baseObjectResponse.errorCode == -1){
- // add by jack 2024-04-09
- // see http://wuzhixin.vip:8080/#/knowledge/1/markdown/viewer/1239
- _self.visible = true;
- }else{
- Notify.error(_self.$t('lang.Notify.error'), baseObjectResponse.errorMessage, false);
- }
- }, errorData => {
- Common.processException(errorData);
- });
- },
- goHome: function(){
- window.location.href = Common.getRootPath() + '/';
- },
- },
- };
- </script>
|