@bit-sun/business-component 2.3.28 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +592 -456
- package/dist/index.js +592 -456
- package/dist/utils/CustomLoginInfo.d.ts +10 -0
- package/dist/utils/requestUtils.d.ts +28 -0
- package/dist/utils/utils.d.ts +0 -6
- package/package.json +1 -1
- package/src/components/Business/AddSelectBusiness/index.tsx +3 -2
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +9 -7
- package/src/components/Business/BsSulaQueryTable/index.tsx +11 -8
- package/src/components/Business/BsSulaQueryTable/setting.tsx +7 -5
- package/src/components/Business/JsonQueryTable/components/Formula.tsx +3 -2
- package/src/components/Business/JsonQueryTable/index.tsx +8 -6
- package/src/components/Business/SearchSelect/utils.ts +2 -1
- package/src/components/Business/columnSettingTable/columnSetting.tsx +5 -4
- package/src/components/Business/columnSettingTable/index.tsx +3 -2
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +3 -2
- package/src/components/Functional/AddSelect/helps.ts +2 -1
- package/src/components/Functional/AddSelect/index.tsx +3 -2
- package/src/components/Functional/BillEntry/index.tsx +3 -2
- package/src/components/Functional/DataImport/index.tsx +2 -1
- package/src/components/Functional/DataValidation/index.tsx +2 -1
- package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +2 -1
- package/src/components/Functional/SearchSelect/index.tsx +10 -9
- package/src/components/Functional/TreeSearchSelect/index.tsx +2 -1
- package/src/components/Solution/RuleComponent/ruleFiled.js +2 -1
- package/src/plugin/TableColumnSetting/index.tsx +4 -3
- package/src/utils/CustomLoginInfo.ts +39 -0
- package/src/utils/requestUtils.ts +139 -7
- package/src/utils/utils.ts +0 -21
|
@@ -3,7 +3,8 @@ import { Select, Input, InputNumber, DatePicker, TimePicker } from 'antd';
|
|
|
3
3
|
import styles from './index.less';
|
|
4
4
|
import { getRegularThresholdRange } from './services';
|
|
5
5
|
import moment from 'moment';
|
|
6
|
-
import {
|
|
6
|
+
import { judgeIsEmpty } from '../../../utils/utils';
|
|
7
|
+
import { handleError } from '../../../utils/requestUtils';
|
|
7
8
|
import { queryIdentityInfo, findChangedThresholdQuery, setParams, dateFormat, fullDateFormat } from './util';
|
|
8
9
|
import { request as SulaRequest } from 'bssula';
|
|
9
10
|
import { stringify } from 'querystring';
|
|
@@ -19,6 +19,7 @@ import fixedLeftActive from '../../assets/fixed-left-active.svg';
|
|
|
19
19
|
import fixedRight from '../../assets/fixed-right.svg';
|
|
20
20
|
import fixedRightActive from '../../assets/fixed-right-active.svg';
|
|
21
21
|
import './index.less';
|
|
22
|
+
import { handleRequestUrl, judgeIsRequestSuccess } from '@/utils/requestUtils';
|
|
22
23
|
|
|
23
24
|
interface TableColumnSettingProps {
|
|
24
25
|
/** tableCode必填,做用户存储关键key,*/
|
|
@@ -54,7 +55,7 @@ class TableColumnSetting extends React.Component<TableColumnSettingProps> {
|
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
patchUserColumnConfig = (config: any) => {
|
|
57
|
-
const { tableCode }: any = this.props;
|
|
58
|
+
const { tableCode, appRequestConfig }: any = this.props;
|
|
58
59
|
if (!tableCode) return;
|
|
59
60
|
let configvalue = config.map((item:any) => ({
|
|
60
61
|
key: item.key,
|
|
@@ -65,14 +66,14 @@ class TableColumnSetting extends React.Component<TableColumnSettingProps> {
|
|
|
65
66
|
}))
|
|
66
67
|
|
|
67
68
|
axios({
|
|
68
|
-
url: '/user/appConfig/saveUserOrder',
|
|
69
|
+
url: handleRequestUrl('/user','/appConfig/saveUserOrder',appRequestConfig),
|
|
69
70
|
method:'POST',
|
|
70
71
|
data: {
|
|
71
72
|
"code": tableCode,
|
|
72
73
|
"detail": JSON.stringify(configvalue)
|
|
73
74
|
},
|
|
74
75
|
}).then((res:any) => {
|
|
75
|
-
if (res?.data
|
|
76
|
+
if (judgeIsRequestSuccess(res?.data)) {
|
|
76
77
|
setConfigTableColumns(configvalue, tableCode)
|
|
77
78
|
} else {
|
|
78
79
|
message.error('保存表头列自定义失败,请稍后尝试');
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ENUM from '@/utils/enumConfig';
|
|
2
|
+
|
|
3
|
+
const resposne = JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.USER_INFO) || '{}');
|
|
4
|
+
//--------赢家项目登录信息---------
|
|
5
|
+
export function getEekaSessionId() {
|
|
6
|
+
return resposne?.sessionId || '';
|
|
7
|
+
}
|
|
8
|
+
export function getEekaAccountId() {
|
|
9
|
+
return resposne?.personDetailResDto?.accountId || -1;
|
|
10
|
+
}
|
|
11
|
+
export function getEekaEmployeeId() {
|
|
12
|
+
return resposne?.personDetailResDto?.employeeId || 2;
|
|
13
|
+
}
|
|
14
|
+
export function getEekaTenantId() {
|
|
15
|
+
return resposne?.personDetailResDto?.tenantId || 1;
|
|
16
|
+
}
|
|
17
|
+
export function getEekaToken() {
|
|
18
|
+
return resposne?.token;
|
|
19
|
+
}
|
|
20
|
+
//--------赢家项目登录信息---------
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
//--------国药项目登录信息---------
|
|
24
|
+
export function getGuoyaoshukeSessionId() {
|
|
25
|
+
return resposne?.sessionId || '';
|
|
26
|
+
}
|
|
27
|
+
export function getGuoyaoshukeAccountId() {
|
|
28
|
+
return resposne?.accountPersonDetail?.accountId || -1;
|
|
29
|
+
}
|
|
30
|
+
export function getGuoyaoshukeEmployeeId() {
|
|
31
|
+
return resposne?.employeeResVo?.id || 2;
|
|
32
|
+
}
|
|
33
|
+
export function getGuoyaoshukeTenantId() {
|
|
34
|
+
return resposne?.personDetailResDto?.tenantId || 1;
|
|
35
|
+
}
|
|
36
|
+
export function getGuoyaoshukeToken() {
|
|
37
|
+
return resposne?.token || '';
|
|
38
|
+
}
|
|
39
|
+
//--------国药项目登录信息---------
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import ENUM from './enumConfig';
|
|
3
3
|
import { getCurrentTenantId, getEmployeeId, getSessionId, getAccountId } from './LocalstorageUtils';
|
|
4
|
+
import { getEekaSessionId, getEekaAccountId, getEekaEmployeeId, getEekaTenantId, getEekaToken,
|
|
5
|
+
getGuoyaoshukeSessionId, getGuoyaoshukeAccountId, getGuoyaoshukeEmployeeId, getGuoyaoshukeToken,
|
|
6
|
+
} from './CustomLoginInfo';
|
|
4
7
|
|
|
5
8
|
export function handleRequestAuthHeader(config?: any) {
|
|
6
9
|
// https://www.kdocs.cn/l/coNbPpjamr5v这个表格里面涉及的接口,接口请求头里需要添加参数:x-biz-code 值就是列表里的code
|
|
@@ -15,20 +18,149 @@ export function handleRequestAuthHeader(config?: any) {
|
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* 获取当前组件服务项目
|
|
24
|
+
* */
|
|
25
|
+
const getCurrentUseProject = () => {
|
|
26
|
+
let project = 'BitSun';
|
|
27
|
+
const hostname = window.location.hostname;
|
|
28
|
+
if(hostname?.indexOf('omni')>-1 || hostname?.indexOf('eeka')>-1 || hostname?.indexOf('koradior')>-1) {
|
|
29
|
+
project = 'YingJia'
|
|
30
|
+
}
|
|
31
|
+
if(hostname?.indexOf('guoyaoshuke')>-1 || hostname?.indexOf('10.31.249.136')>-1) {
|
|
32
|
+
project = 'GuoYao'
|
|
33
|
+
}
|
|
34
|
+
return project
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* 处理一般请求头
|
|
39
|
+
* @param {*} config 请求参数配置
|
|
40
|
+
* */
|
|
41
|
+
const handleCommonHeader = () => {
|
|
42
|
+
let commonHeaders = {};
|
|
43
|
+
const defaultHeaders = {
|
|
44
|
+
'sso-sessionid': getSessionId(),
|
|
45
|
+
'x-account-id': getAccountId(),
|
|
46
|
+
'x-employee-id': getEmployeeId(),
|
|
47
|
+
'x-tenant-id': getCurrentTenantId()
|
|
48
|
+
};
|
|
49
|
+
const type = getCurrentUseProject()
|
|
50
|
+
switch (type) {
|
|
51
|
+
case 'YingJia':
|
|
52
|
+
commonHeaders = {
|
|
53
|
+
'x-sso-sessionid': getEekaSessionId(),
|
|
54
|
+
'x-account-id': getEekaAccountId(),
|
|
55
|
+
'x-employee-id': getEekaEmployeeId(),
|
|
56
|
+
'x-tenant-id': getEekaTenantId(),
|
|
57
|
+
'x-user-token': getEekaToken()
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case 'GuoYao':
|
|
61
|
+
commonHeaders = {
|
|
62
|
+
'sso-sessionid': getGuoyaoshukeSessionId(),
|
|
63
|
+
'gksk-account-id': getGuoyaoshukeAccountId(),
|
|
64
|
+
'gksk-employee-id': getGuoyaoshukeEmployeeId(),
|
|
65
|
+
'gksk-tenant-id': getCurrentTenantId(),
|
|
66
|
+
'gksk-user-token': getGuoyaoshukeToken()
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
commonHeaders = defaultHeaders
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
return commonHeaders
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* 处理请求头方法-包含一般请求头、权限请求头。组件默认统一处理一遍,若组件使用处需要可以单独在组件处传参进来处理
|
|
79
|
+
* @param {*} config 请求参数配置
|
|
80
|
+
* */
|
|
19
81
|
const handleRequestHeader = (config: any) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
config.headers['x-tenant-id'] = getCurrentTenantId()
|
|
82
|
+
|
|
83
|
+
let commonHeaders = handleCommonHeader();
|
|
84
|
+
|
|
24
85
|
if (localStorage.getItem('x-user-auth-context')) {
|
|
25
|
-
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
commonHeaders['x-user-auth-context'] = localStorage.getItem('x-user-auth-context');
|
|
88
|
+
}
|
|
89
|
+
!!!config.headers['x-biz-code'] && handleRequestAuthHeader(config)
|
|
90
|
+
|
|
91
|
+
config.headers = {
|
|
92
|
+
...commonHeaders,
|
|
93
|
+
...config.headers
|
|
26
94
|
}
|
|
27
|
-
handleRequestAuthHeader(config)
|
|
28
95
|
}
|
|
29
96
|
|
|
97
|
+
|
|
30
98
|
// 拦截器
|
|
31
99
|
axios.interceptors.request.use((config: any) => {
|
|
32
100
|
handleRequestHeader(config)
|
|
33
101
|
return config
|
|
34
102
|
})
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 处理请求路径前缀/请求路径等使用不一的问题
|
|
109
|
+
* @param {*} defaultUrl 默认请求路径
|
|
110
|
+
* @param {*} defaultPreFix 默认请求路径的前缀
|
|
111
|
+
* @param {*} config 更改请求前缀/路径集合
|
|
112
|
+
* 示例:
|
|
113
|
+
* appRequestConfig: {
|
|
114
|
+
* '/appConfig/saveUserOrder': ['/api/user-manage'],
|
|
115
|
+
* '/appConfig/saveQueryCriteria': ['/api/user-manage']
|
|
116
|
+
* }
|
|
117
|
+
*/
|
|
118
|
+
export const handleRequestUrl = (defaultPreFix: string,defaultUrl: string, config: any) => {
|
|
119
|
+
let rUrl = `${defaultPreFix}${defaultUrl}`;
|
|
120
|
+
if(config && Object.keys((config||{}))?.length) {
|
|
121
|
+
const value = config[defaultUrl] || []
|
|
122
|
+
const newPreFix = value[0] || defaultPreFix;
|
|
123
|
+
const newUrl = value[1] || defaultUrl;
|
|
124
|
+
rUrl = `${newPreFix}${newUrl}`;
|
|
125
|
+
}
|
|
126
|
+
return rUrl
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 处理错误请求
|
|
132
|
+
* @param {*} response 返回结果
|
|
133
|
+
* @param {*} needBackError 是否需要将错误回传到页面单独处理
|
|
134
|
+
*/
|
|
135
|
+
export function handleError(response: object, needBackError?: boolean) {
|
|
136
|
+
if (judgeIsRequestError(response)) {
|
|
137
|
+
if (response && !needBackError) {
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
response.msg && message.error(response.msg);
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 判断为请求错误
|
|
149
|
+
* @param {*} res 响应体
|
|
150
|
+
* */
|
|
151
|
+
export const judgeIsRequestError = (res: any) => {
|
|
152
|
+
if (!res || (res?.status && res.status !== '0') || (res?.code && (res.code !== '000000' || res.code !== '0'))) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* 判断为请求成功
|
|
159
|
+
* @param {*} res 响应体
|
|
160
|
+
* */
|
|
161
|
+
export const judgeIsRequestSuccess = (res: any) => {
|
|
162
|
+
if (res?.status === '0' || res?.code === '000000'|| res?.code === '0') {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
166
|
+
};
|
package/src/utils/utils.ts
CHANGED
|
@@ -189,24 +189,3 @@ export const judgeIsEmpty = (value: any) => {
|
|
|
189
189
|
}
|
|
190
190
|
return false;
|
|
191
191
|
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* 处理错误请求
|
|
195
|
-
* @param {*} response 返回结果
|
|
196
|
-
* @param {*} needBackError 是否需要将错误回传到页面单独处理
|
|
197
|
-
*/
|
|
198
|
-
export function handleError(response: object, needBackError?: boolean) {
|
|
199
|
-
// @ts-ignore
|
|
200
|
-
if (
|
|
201
|
-
!response ||
|
|
202
|
-
(response.code ? response.code !== '000000' : response.status !== '0')
|
|
203
|
-
) {
|
|
204
|
-
if (response && !needBackError) {
|
|
205
|
-
// @ts-ignore
|
|
206
|
-
response.msg && message.error(response.msg);
|
|
207
|
-
}
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return true;
|
|
212
|
-
}
|