@yeeyoon/library 3.6.9 → 3.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -337,6 +337,9 @@ const Header = (props) => {
337
337
  <span
338
338
  className={styles['comp-header__icon']}
339
339
  onClick={() => {
340
+ if (productName === 'wms' || productName === 'bpm') {
341
+ window.location.href = `${HOST_PROFILE_TASK}?token=${token}&source=${productName}&tenantId=${tenantId}`;
342
+ }
340
343
  setRedirectUrl(HOST_PROFILE_TASK);
341
344
  setPlatformsModalShow(true);
342
345
  }}
@@ -1,86 +1,73 @@
1
- import React, { useState, useEffect } from 'react';
1
+ import { AutoComplete } from 'antd';
2
2
  import PropTypes from 'prop-types';
3
- import { Select } from 'antd';
3
+ import React, { useEffect, useState } from 'react';
4
+ import { fetchTenantList } from './service';
4
5
 
5
- import { fetchUserInfo } from './service';
6
-
7
- const { Option } = Select;
6
+ let defaultTenantName;
8
7
 
9
8
  const TenantSelector = (props) => {
10
9
  const {
11
10
  tenantId,
12
11
  tenantIdChangeCb,
13
12
  appId,
14
- handleException,
15
- shareTenantIdList = [],
16
- isSharePlatform = false,
13
+ // handleException,
17
14
  } = props;
18
- const [tenantList, setTenantList] = useState([]);
19
- const [currentTenantId, setCurrentTenantId] = useState('');
15
+ const [options, setOptions] = useState([]);
16
+ const [value, setValue] = useState('');
17
+ const [placeholder, setPlaceholder] = useState('');
20
18
 
21
- useEffect(async () => {
22
- const resp = await fetchUserInfo();
23
- const { data, success } = resp;
24
- let id;
25
- let name;
19
+ const searchTenant = async (value = '', tenantId) => {
20
+ setValue(value);
21
+ const resp = await fetchTenantList({
22
+ applicationId: appId,
23
+ key: value.trim(),
24
+ });
25
+ const { success, data } = resp;
26
26
  if (success) {
27
- let { tenants } = data;
28
- if (appId) {
29
- tenants = tenants.filter((item) => {
30
- const { applications } = item;
31
- return applications?.filter((item) => item.id === appId).length;
27
+ let tenantList = [];
28
+ data.forEach((item) => {
29
+ if (tenantId && tenantId === item.id) {
30
+ defaultTenantName = item.name;
31
+ setValue(item.name);
32
+ }
33
+ tenantList.push({
34
+ label: item.name,
35
+ value: item.id,
32
36
  });
33
- }
34
- if (!tenants.length) {
35
- handleException && handleException();
36
- return;
37
- }
38
- const result = tenants.filter((item) => item.id === tenantId);
39
- if (result.length) {
40
- id = tenantId;
41
- name = result[0].name;
42
- } else {
43
- id = tenants[0].id;
44
- name = tenants[0].name;
45
- }
46
- // if (!isSharePlatform) {
47
- // tenants = tenants.filter(
48
- // (item) => !shareTenantIdList.includes(item.id)
49
- // );
50
- // } else {
51
- // tenants = tenants.filter((item) => shareTenantIdList.includes(item.id));
52
- // }
53
- if (isSharePlatform) {
54
- tenants = tenants.filter((item) => shareTenantIdList.includes(item.id));
55
- }
56
- setTenantList(tenants);
57
- setCurrentTenantId(id);
58
- tenantIdChangeCb && tenantIdChangeCb(id, name);
37
+ });
38
+ setOptions(tenantList);
59
39
  }
40
+ };
41
+
42
+ useEffect(async () => {
43
+ searchTenant('', tenantId);
60
44
  }, []);
61
45
 
62
46
  return (
63
- <Select
64
- getPopupContainer={(triggerNode) => triggerNode.parentNode}
65
- showSearch
66
- optionFilterProp="children"
47
+ <AutoComplete
67
48
  bordered={false}
68
- value={currentTenantId}
49
+ placeholder={placeholder}
50
+ getPopupContainer={(triggerNode) => triggerNode.parentNode}
51
+ value={value}
69
52
  style={{ width: '215px' }}
70
- onChange={(value, option) => {
71
- const { children } = option;
72
- setCurrentTenantId(value);
73
- tenantIdChangeCb && tenantIdChangeCb(value, children);
53
+ options={options}
54
+ onChange={(value) => {
55
+ searchTenant(value);
56
+ }}
57
+ onFocus={() => {
58
+ setValue('');
59
+ setPlaceholder(defaultTenantName);
60
+ }}
61
+ onBlur={() => {
62
+ // if (value.trim() === '') {
63
+ setValue(defaultTenantName);
64
+ // }
65
+ }}
66
+ onSelect={(value, option) => {
67
+ setValue(option.label);
68
+ tenantIdChangeCb && tenantIdChangeCb(value, option);
74
69
  }}
75
- >
76
- {tenantList.map((item) => {
77
- return (
78
- <Option value={item.id} key={item.id}>
79
- {item.name}
80
- </Option>
81
- );
82
- })}
83
- </Select>
70
+ />
84
71
  );
85
72
  };
86
73
 
@@ -89,8 +76,6 @@ TenantSelector.propTypes = {
89
76
  appId: PropTypes.string,
90
77
  tenantIdChangeCb: PropTypes.func,
91
78
  handleException: PropTypes.func,
92
- shareTenantIdList: PropTypes.array,
93
- isSharePlatform: PropTypes.bool,
94
79
  };
95
80
 
96
81
  export default TenantSelector;
@@ -9,3 +9,14 @@ export async function fetchUserInfo() {
9
9
  data: {},
10
10
  });
11
11
  }
12
+
13
+ export async function fetchTenantList(params) {
14
+ return request(`/findOidcUserTenantList`, {
15
+ prefix: `${API_IAM}/api/oidc/v1/oidcuser`,
16
+ method: 'post',
17
+ data: {
18
+ paging: false,
19
+ ...params,
20
+ },
21
+ });
22
+ }
@@ -43,12 +43,12 @@ rest && ls.set(REST_KEY, JSON.stringify(rest));
43
43
  /** 异常处理程序 */
44
44
 
45
45
  const backToIam = () => {
46
- // const { origin, pathname } = window.location;
47
- // if (origin.indexOf(HOST_HUASHAN_BPM) > -1) {
48
- // window.location.href = HOST_HUASHAN_LOGIN;
49
- // } else {
50
- // window.location.href = `${HOST_IAM}?redirect=${origin}${pathname}`;
51
- // }
46
+ const { origin, pathname } = window.location;
47
+ if (origin.indexOf(HOST_HUASHAN_BPM) > -1) {
48
+ window.location.href = HOST_HUASHAN_LOGIN;
49
+ } else {
50
+ window.location.href = `${HOST_IAM}?redirect=${origin}${pathname}`;
51
+ }
52
52
  };
53
53
 
54
54
  const errorHandler = (error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeeyoon/library",
3
- "version": "3.6.9",
3
+ "version": "3.7.2",
4
4
  "description": "宜云前端组件库和通用服务",
5
5
  "main": "index.js",
6
6
  "repository": {