@bit-sun/business-component 2.2.0-alpha.4 → 2.2.0-alpha.6
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/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +59 -0
- package/dist/index.esm.js +872 -214
- package/dist/index.js +871 -213
- package/dist/utils/LocalstorageUtils.d.ts +6 -0
- package/dist/utils/enumConfig.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +538 -0
- package/src/components/Business/BsSulaQueryTable/index.tsx +69 -20
- package/src/components/Business/BsSulaQueryTable/setting.tsx +1 -1
- package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +6 -2
- package/src/components/Business/JsonQueryTable/index.tsx +152 -23
- package/src/components/Functional/DataImport/index.tsx +1 -1
- package/src/components/Functional/DataValidation/index.tsx +1 -1
- package/src/styles/bsDefault.less +6 -0
- package/src/utils/LocalstorageUtils.ts +25 -0
- package/src/utils/enumConfig.ts +1 -0
- package/src/utils/requestUtils.ts +2 -1
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
authFn,
|
|
9
9
|
queryParams,
|
|
10
10
|
} from './utils';
|
|
11
|
-
import { Menu, Tooltip, } from 'antd';
|
|
11
|
+
import { Menu, Tooltip, Dropdown } from 'antd';
|
|
12
12
|
import SortableTable from './setting';
|
|
13
|
+
import SearchItemTable from "./SearchItemSetting";
|
|
13
14
|
import { Resizable } from 'react-resizable';
|
|
14
15
|
import quanping from '../../../assets/icon-quanping.svg';
|
|
15
16
|
import scanning from '../../../assets/scanning.svg';
|
|
17
|
+
import shezhi from '../../../assets/icon-shezhi.svg';
|
|
16
18
|
import { debounce } from 'lodash';
|
|
17
19
|
import ExportIcon from '@/components/Functional/ExportFunctions/ExportIcon';
|
|
18
20
|
import ENUM from '@/utils/enumConfig';
|
|
@@ -52,8 +54,8 @@ export default (props: any) => {
|
|
|
52
54
|
const [isFullScreen, setIsFnllScreen]: any = useState(false);
|
|
53
55
|
// @ts-nocheck
|
|
54
56
|
const [value, setValue]: any = useState(props);
|
|
55
|
-
const [showColumn, setShowColumns] = useState([]);
|
|
56
|
-
|
|
57
|
+
const [showColumn, setShowColumns] = useState([]); // 列字段
|
|
58
|
+
const [showSearchFields, setShowSearchFields] = useState(props.fields || []); //搜索项字段
|
|
57
59
|
const { isPage = true, pagination, tableCode } = props;
|
|
58
60
|
|
|
59
61
|
const [height, setHeight]: any = useState('100vh');
|
|
@@ -96,8 +98,8 @@ export default (props: any) => {
|
|
|
96
98
|
return isFull;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
const getConfigFromlocalstorage = () => {
|
|
100
|
-
let config = localStorage.getItem(
|
|
101
|
+
const getConfigFromlocalstorage = (type: string) => {
|
|
102
|
+
let config = localStorage.getItem(type) || '[]';
|
|
101
103
|
let configArray = JSON.parse(config);
|
|
102
104
|
let configSetting = configArray.filter(
|
|
103
105
|
(item) => item.code === bsTableCode,
|
|
@@ -157,7 +159,7 @@ export default (props: any) => {
|
|
|
157
159
|
columns: [...props.columns],
|
|
158
160
|
});
|
|
159
161
|
const { columns } = props;
|
|
160
|
-
let columnConfig = getConfigFromlocalstorage();
|
|
162
|
+
let columnConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.COLUMN_CONDITION);
|
|
161
163
|
let showColumns = columnConfig.length ? columnConfig.map((item) => {
|
|
162
164
|
let inner = columns.filter(
|
|
163
165
|
(inneritem) => {
|
|
@@ -191,12 +193,35 @@ export default (props: any) => {
|
|
|
191
193
|
});
|
|
192
194
|
});
|
|
193
195
|
setShowColumns([...showColumns]);
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const setInitialSearchFieldsInfo = () =>{
|
|
200
|
+
//获取搜索字段的缓存配置
|
|
201
|
+
const { fields = [] } = props;
|
|
202
|
+
let searchFieldsConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION);
|
|
203
|
+
let showSearchFields = searchFieldsConfig.length ? searchFieldsConfig.map((item) => {
|
|
204
|
+
let inner = fields.filter(
|
|
205
|
+
(inneritem) => {
|
|
206
|
+
let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : inneritem.name;
|
|
207
|
+
let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : item.name;
|
|
208
|
+
return innerKey && innerKey === itemKey;
|
|
209
|
+
}
|
|
210
|
+
)[0];
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
...inner,
|
|
214
|
+
...item,
|
|
215
|
+
};
|
|
216
|
+
}) : fields;
|
|
217
|
+
setShowSearchFields([...showSearchFields])
|
|
194
218
|
}
|
|
195
219
|
|
|
196
220
|
//组件初始挂载
|
|
197
221
|
useEffect(() => {
|
|
198
222
|
getTableHeight();
|
|
199
223
|
setInitialTableInfo();
|
|
224
|
+
setInitialSearchFieldsInfo();
|
|
200
225
|
window.addEventListener('resize', (e) => {
|
|
201
226
|
watchWinResize();
|
|
202
227
|
});
|
|
@@ -212,6 +237,14 @@ export default (props: any) => {
|
|
|
212
237
|
}
|
|
213
238
|
}, [props?.columns])
|
|
214
239
|
|
|
240
|
+
useEffect(() => {
|
|
241
|
+
if (props?.fields && value?.fields) {
|
|
242
|
+
let newKeys = props.fields.map((d: any) => Array.isArray(d.name) ? JSON.stringify(d.name) : (d.name));
|
|
243
|
+
let oldKeys = value.fields.map((d: any) => Array.isArray(d.name) ? JSON.stringify(d.name) : (d.name));
|
|
244
|
+
JSON.stringify(newKeys) !== JSON.stringify(oldKeys) && setInitialSearchFieldsInfo();
|
|
245
|
+
}
|
|
246
|
+
},[props?.fields])
|
|
247
|
+
|
|
215
248
|
useEffect(() => {
|
|
216
249
|
setInitialTableInfo();
|
|
217
250
|
}, [props?.refreshColumns]);
|
|
@@ -326,19 +359,34 @@ export default (props: any) => {
|
|
|
326
359
|
type: 'text',
|
|
327
360
|
props: {
|
|
328
361
|
children: (
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
362
|
+
<span className="ant-dropdown-link">
|
|
363
|
+
<Dropdown overlay={
|
|
364
|
+
<Menu >
|
|
365
|
+
<Menu.Item>
|
|
366
|
+
<SortableTable
|
|
367
|
+
ref={sortTableRef}
|
|
368
|
+
setShowColumns={setShowColumns}
|
|
369
|
+
showColumn={showColumn}
|
|
370
|
+
datasource={value?.columns || []}
|
|
371
|
+
bsTableCode={bsTableCode}
|
|
372
|
+
/>
|
|
373
|
+
</Menu.Item>
|
|
374
|
+
<Menu.Item>
|
|
375
|
+
<SearchItemTable
|
|
376
|
+
ref={sortTableRef}
|
|
377
|
+
setShowSearchFields={setShowSearchFields}
|
|
378
|
+
showSearchFields={showSearchFields}
|
|
379
|
+
datasource={value?.fields || []}
|
|
380
|
+
bsTableCode={bsTableCode}
|
|
381
|
+
/>
|
|
382
|
+
</Menu.Item>
|
|
383
|
+
</Menu>
|
|
384
|
+
} placement="bottom" >
|
|
385
|
+
<span className="ant-dropdown-link">
|
|
386
|
+
<img width={32} src={shezhi} />
|
|
387
|
+
</span>
|
|
388
|
+
</Dropdown>
|
|
389
|
+
</span>
|
|
342
390
|
),
|
|
343
391
|
},
|
|
344
392
|
},
|
|
@@ -441,6 +489,7 @@ export default (props: any) => {
|
|
|
441
489
|
...handleTimeValue(),
|
|
442
490
|
tableProps: setTableProps(),
|
|
443
491
|
columns: [...showColumn],
|
|
492
|
+
fields: [...showSearchFields],
|
|
444
493
|
ref: props.forwardedRef || refs,
|
|
445
494
|
isFullScreen,
|
|
446
495
|
};
|
|
@@ -465,7 +514,7 @@ export default (props: any) => {
|
|
|
465
514
|
summary: props.summary,
|
|
466
515
|
statusMapping: props.statusMapping,
|
|
467
516
|
}),
|
|
468
|
-
[value, checkedList, showColumn, props.statusMapping],
|
|
517
|
+
[value, checkedList, showColumn, props.statusMapping, showSearchFields],
|
|
469
518
|
);
|
|
470
519
|
return <MemoQueryTable {...memoConfig} />;
|
|
471
520
|
};
|
|
@@ -12,6 +12,7 @@ export default (props:any)=>{
|
|
|
12
12
|
codeProps='',
|
|
13
13
|
moduleType,
|
|
14
14
|
moduleRelationId,
|
|
15
|
+
tableFlag = false
|
|
15
16
|
} = props;
|
|
16
17
|
|
|
17
18
|
const ref = useRef(null);
|
|
@@ -95,7 +96,7 @@ export default (props:any)=>{
|
|
|
95
96
|
width: 100
|
|
96
97
|
},
|
|
97
98
|
{
|
|
98
|
-
key: '
|
|
99
|
+
key: 'isUse',
|
|
99
100
|
title: '是否使用',
|
|
100
101
|
width: 70,
|
|
101
102
|
render: ({text}:any) => {
|
|
@@ -105,9 +106,12 @@ export default (props:any)=>{
|
|
|
105
106
|
}
|
|
106
107
|
},
|
|
107
108
|
{
|
|
108
|
-
key: '
|
|
109
|
+
key: 'codeSnippet',
|
|
109
110
|
title: '代码片段',
|
|
110
111
|
render: ({text,record}:any) => {
|
|
112
|
+
if(tableFlag){
|
|
113
|
+
return <div> 列表:{`{"key": "extensionFields,${record.code}","dataIndex": "extensionFields,${record.code}","title": "${record.name}"},`}</div>
|
|
114
|
+
}
|
|
111
115
|
if (!codeProps.columns) {
|
|
112
116
|
return <div>表单:{`{"name": "extensionFields,${record.code}","label": "${record.name}"},`}</div>
|
|
113
117
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
3
|
-
import { message, Button, Table } from 'antd';
|
|
2
|
+
import React, { useState, useRef, useEffect, Fragment } from 'react';
|
|
3
|
+
import { message, Button, Table, Tabs } from 'antd';
|
|
4
4
|
import Drawer from './drawer';
|
|
5
5
|
import ConfigButton from './configButton';
|
|
6
6
|
import Editor from './jsonEditor';
|
|
@@ -205,11 +205,13 @@ const tableStyleList = [
|
|
|
205
205
|
];
|
|
206
206
|
const JsonQueryTable = React.memo(props => {
|
|
207
207
|
const {
|
|
208
|
-
callBack,
|
|
209
|
-
codeProps,
|
|
210
|
-
customerFields,
|
|
211
|
-
initialSetting,
|
|
212
|
-
pageType
|
|
208
|
+
callBack, // 主保存函数回调
|
|
209
|
+
codeProps, // 整体的配置数据
|
|
210
|
+
customerFields, //可选的配置字段
|
|
211
|
+
initialSetting, //上一次添加自定义字段后保存的数据
|
|
212
|
+
pageType, //页面权限code
|
|
213
|
+
detailTablesSetting = [], //详情明细表格列配置数据
|
|
214
|
+
saveTableCallBack, //详情明细保存函数回调
|
|
213
215
|
} = props;
|
|
214
216
|
|
|
215
217
|
let codeFilter = {};
|
|
@@ -229,7 +231,6 @@ const JsonQueryTable = React.memo(props => {
|
|
|
229
231
|
} else {
|
|
230
232
|
codeFilter.fields = iterFileds({fields: codeProps.fields}).fields
|
|
231
233
|
}
|
|
232
|
-
console.log('codeFilter',codeFilter)
|
|
233
234
|
|
|
234
235
|
const styleRef = useRef(null);
|
|
235
236
|
|
|
@@ -238,6 +239,9 @@ const JsonQueryTable = React.memo(props => {
|
|
|
238
239
|
const [init, setInit] = useState(true);
|
|
239
240
|
const [jsonEditorVal, setJsonEditorVal] = useState(initialSetting || codeFilter);
|
|
240
241
|
const [moduleParams, setModuleParams] = useState({});
|
|
242
|
+
const [activeKey, setActiveKey] = useState('main'); //默认详情页配置
|
|
243
|
+
const [tablesConfigParams, setTablesConfigParams] = useState({});
|
|
244
|
+
const [tableJsonEditorValsArr, setTableJsonEditorValsArr] = useState([]);
|
|
241
245
|
|
|
242
246
|
useEffect(()=>{
|
|
243
247
|
Promise.all([
|
|
@@ -258,6 +262,52 @@ const JsonQueryTable = React.memo(props => {
|
|
|
258
262
|
})
|
|
259
263
|
},[]);
|
|
260
264
|
|
|
265
|
+
useEffect(()=>{
|
|
266
|
+
//明细表的配置数据
|
|
267
|
+
const axiosArr = detailTablesSetting.map((item:any) => axios.get(`/basic/flow/businessFieldGroup/one?moduleType=2&layoutPoint=${item.tableCode}`));
|
|
268
|
+
Promise.all(axiosArr).then(([...resArr])=> {
|
|
269
|
+
detailTablesSetting.map((item:any, index:number)=>{
|
|
270
|
+
const { code, data } = resArr[index]?.data || {};
|
|
271
|
+
if(data){
|
|
272
|
+
const { businessType, code:fieldGroup, moduleType } = data;
|
|
273
|
+
setTablesConfigParams({
|
|
274
|
+
...tablesConfigParams,
|
|
275
|
+
[item.tableCode]: {
|
|
276
|
+
businessType,
|
|
277
|
+
fieldGroup,
|
|
278
|
+
moduleType,
|
|
279
|
+
tableFlag: true
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
const detailTableCodeFilter = detailTablesSetting.map(item => {
|
|
287
|
+
if(item?.initialSetting && item?.initialSetting.length){
|
|
288
|
+
return {
|
|
289
|
+
...item,
|
|
290
|
+
columns: item?.initialSetting
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
...item,
|
|
295
|
+
columns: item?.columns.map(childItem => ({
|
|
296
|
+
key: childItem.key || childItem.dataIndex,
|
|
297
|
+
dataIndex: childItem.dataIndex || childItem.key,
|
|
298
|
+
isStaticCode: true,
|
|
299
|
+
title: childItem.title
|
|
300
|
+
}))
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
setTableJsonEditorValsArr([...detailTableCodeFilter]);
|
|
304
|
+
detailTableCodeFilter.map(item => {
|
|
305
|
+
if(item?.initialSetting && item?.initialSetting.length){
|
|
306
|
+
onClickRunDetailTables(item.initialSetting, false, item.tableCode, detailTableCodeFilter);
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
},[detailTablesSetting.length]);
|
|
310
|
+
|
|
261
311
|
const onClickRun = (value, isSave) => {
|
|
262
312
|
setJsonEditorVal(value);
|
|
263
313
|
|
|
@@ -269,6 +319,38 @@ const JsonQueryTable = React.memo(props => {
|
|
|
269
319
|
}
|
|
270
320
|
};
|
|
271
321
|
|
|
322
|
+
//明细表保存
|
|
323
|
+
const onClickRunDetailTables = (value, isSave, tableCode, tableSouce) =>{
|
|
324
|
+
const targetCode = tableCode || activeKey;
|
|
325
|
+
const targetTableSource = tableSouce || tableJsonEditorValsArr;
|
|
326
|
+
const newArr = targetTableSource.map(item => {
|
|
327
|
+
if(item.tableCode == targetCode){
|
|
328
|
+
return {
|
|
329
|
+
...item,
|
|
330
|
+
columns: value
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return item
|
|
334
|
+
});
|
|
335
|
+
setTableJsonEditorValsArr([...newArr]);
|
|
336
|
+
|
|
337
|
+
try {
|
|
338
|
+
const target = targetTableSource.find(item=>item.tableCode == targetCode);
|
|
339
|
+
const codeProps = {
|
|
340
|
+
fields: [],
|
|
341
|
+
columns: target?.columns,
|
|
342
|
+
};
|
|
343
|
+
const newValue = {
|
|
344
|
+
fields: [],
|
|
345
|
+
columns: value
|
|
346
|
+
};
|
|
347
|
+
const result = hanleCallbackValue(codeProps, newValue, target?.customerFields);
|
|
348
|
+
saveTableCallBack({ columns: result.columns, tableCode: targetCode }, isSave, value);
|
|
349
|
+
} catch (e) {
|
|
350
|
+
message.error(e);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
272
354
|
React.useEffect(() => {
|
|
273
355
|
localStorage.setItem('jsonEditorVal',JSON.stringify(jsonEditorVal||{}))
|
|
274
356
|
}, [jsonEditorVal]);
|
|
@@ -292,24 +374,71 @@ const JsonQueryTable = React.memo(props => {
|
|
|
292
374
|
return (
|
|
293
375
|
<div>
|
|
294
376
|
<Drawer visible={visible} width={800} onClose={() => setVisible(false)} className={'customFieldsDrawer'}>
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
377
|
+
{
|
|
378
|
+
detailTablesSetting.length == 0 &&(
|
|
379
|
+
<Fragment>
|
|
380
|
+
{
|
|
381
|
+
isEmpty(moduleParams)?(
|
|
382
|
+
<div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
|
|
383
|
+
提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
|
|
384
|
+
</div>
|
|
385
|
+
):(
|
|
386
|
+
<FieldsSettingsTable {...tableParams}/>
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
<Editor
|
|
390
|
+
type="table"
|
|
391
|
+
onRun={onClickRun}
|
|
392
|
+
value={jsonEditorVal}
|
|
393
|
+
shallowHeight={height}
|
|
394
|
+
/>
|
|
395
|
+
</Fragment>
|
|
396
|
+
)
|
|
397
|
+
}
|
|
298
398
|
{
|
|
299
|
-
|
|
300
|
-
<
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
399
|
+
detailTablesSetting.length > 0 && (
|
|
400
|
+
<Tabs defaultActiveKey={activeKey} onChange={(v: any) => setActiveKey(v)}>
|
|
401
|
+
<Tabs.TabPane tab="详情页配置" key="main">
|
|
402
|
+
{
|
|
403
|
+
isEmpty(moduleParams)?(
|
|
404
|
+
<div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
|
|
405
|
+
提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
|
|
406
|
+
</div>
|
|
407
|
+
):(
|
|
408
|
+
<FieldsSettingsTable {...tableParams}/>
|
|
409
|
+
)
|
|
410
|
+
}
|
|
411
|
+
<Editor
|
|
412
|
+
type="table"
|
|
413
|
+
onRun={onClickRun}
|
|
414
|
+
value={jsonEditorVal}
|
|
415
|
+
shallowHeight={height}
|
|
416
|
+
/>
|
|
417
|
+
</Tabs.TabPane>
|
|
418
|
+
{
|
|
419
|
+
tableJsonEditorValsArr.map((k:any)=>(
|
|
420
|
+
<Tabs.TabPane tab={k.title} key={k.tableCode}>
|
|
421
|
+
{
|
|
422
|
+
!tablesConfigParams[k.tableCode]?(
|
|
423
|
+
<div style={{padding:"10px 0", fontSize:"16px", fontWeight:"bolder"}}>
|
|
424
|
+
提示:业务对象未维护,请在通用单据对应业务类型下维护业务对象
|
|
425
|
+
</div>
|
|
426
|
+
):(
|
|
427
|
+
<FieldsSettingsTable {...tablesConfigParams[k.tableCode]}/>
|
|
428
|
+
)
|
|
429
|
+
}
|
|
430
|
+
<Editor
|
|
431
|
+
type="table"
|
|
432
|
+
onRun={onClickRunDetailTables}
|
|
433
|
+
value={k.columns}
|
|
434
|
+
shallowHeight={height}
|
|
435
|
+
/>
|
|
436
|
+
</Tabs.TabPane>
|
|
437
|
+
))
|
|
438
|
+
}
|
|
439
|
+
</Tabs>
|
|
305
440
|
)
|
|
306
441
|
}
|
|
307
|
-
<Editor
|
|
308
|
-
type="table"
|
|
309
|
-
onRun={onClickRun}
|
|
310
|
-
value={jsonEditorVal}
|
|
311
|
-
shallowHeight={height}
|
|
312
|
-
/>
|
|
313
442
|
</Drawer>
|
|
314
443
|
|
|
315
444
|
{!visible && isAdmin() && <ConfigButton type='primary' onClick={() => setVisible(true)}>setting</ConfigButton>}
|
|
@@ -31,3 +31,28 @@ export const getConfigTableColumns = (tableCode: string) => {
|
|
|
31
31
|
}
|
|
32
32
|
return [];
|
|
33
33
|
};
|
|
34
|
+
|
|
35
|
+
// 登陆租户信息存储、获取、移除
|
|
36
|
+
export const saveTenantList = (data: any) => {
|
|
37
|
+
const list = data?.length && data || [];
|
|
38
|
+
localStorage.setItem('tenant_list', JSON.stringify(list));
|
|
39
|
+
}
|
|
40
|
+
export const getTenantList = () => {
|
|
41
|
+
const list = JSON.parse(localStorage.getItem('tenant_list') || '[]');
|
|
42
|
+
return list
|
|
43
|
+
}
|
|
44
|
+
export const removeTenantList = () => {
|
|
45
|
+
localStorage.removeItem('tenant_list');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 当前租户存储、获取、移除
|
|
49
|
+
export const saveCurrentTenantId = (item: string) => {
|
|
50
|
+
localStorage.setItem('current_tenant_id', String(item));
|
|
51
|
+
}
|
|
52
|
+
export const getCurrentTenantId = () => {
|
|
53
|
+
return localStorage.getItem('current_tenant_id') || '';
|
|
54
|
+
}
|
|
55
|
+
export const removeCurrentTenantId = () => {
|
|
56
|
+
localStorage.removeItem('current_tenant_id');
|
|
57
|
+
}
|
|
58
|
+
|
package/src/utils/enumConfig.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import ENUM from './enumConfig';
|
|
3
|
+
import { getCurrentTenantId } from './LocalstorageUtils';
|
|
3
4
|
|
|
4
5
|
const resposne = JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.USER_INFO) || '{}');
|
|
5
6
|
|
|
@@ -19,7 +20,7 @@ export function handleRequestAuthHeader(config?: any) {
|
|
|
19
20
|
// 处理请求头
|
|
20
21
|
const handleRequestHeader = (config: any) => {
|
|
21
22
|
config.headers['sso-sessionid'] = resposne?.sessionId || ''
|
|
22
|
-
config.headers['x-tenant-id'] =
|
|
23
|
+
config.headers['x-tenant-id'] = getCurrentTenantId() || 1
|
|
23
24
|
if (localStorage.getItem('x-user-auth-context')) {
|
|
24
25
|
config.headers['x-user-auth-context'] = localStorage.getItem('x-user-auth-context');
|
|
25
26
|
}
|