@esvndev/es-data-sharing 1.1.0 → 1.2.0
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/README.md +189 -14
- package/dist/component/master-info/master-card.d.ts +1 -0
- package/dist/component/modal/batch-master-card.d.ts +1 -0
- package/dist/component/modal/data-sharing-content.d.ts +18 -0
- package/dist/component/modal/index.d.ts +19 -2
- package/dist/component/modal/modal-sharing.d.ts +3 -2
- package/dist/component/modal/sharing-helpers.d.ts +12 -0
- package/dist/component/org-scope/org-table.d.ts +1 -1
- package/dist/index.d.ts +93 -8
- package/dist/index.js +306 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +299 -88
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +201 -6
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/modal.css +29 -5
- package/dist/styles/modal.css.map +1 -1
- package/dist/types/index.d.ts +22 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,60 +2,235 @@
|
|
|
2
2
|
|
|
3
3
|
Module chia sẻ dữ liệu (Data Sharing) và cấu hình theo đơn vị thành viên dùng chung cho toàn bộ hệ thống ERP Becoxy (PO, SO, WMS, MES, HRM...).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 1. Cài đặt & Build
|
|
8
|
+
|
|
9
|
+
### Cài đặt vào dự án client
|
|
10
|
+
```bash
|
|
11
|
+
yarn add @esvndev/es-data-sharing
|
|
12
|
+
# hoặc
|
|
13
|
+
npm install @esvndev/es-data-sharing
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Build package (khi chỉnh sửa source tại `es-data-sharing`)
|
|
8
17
|
```bash
|
|
9
18
|
cd D:\Becoxy\es-data-sharing
|
|
10
19
|
npm install
|
|
11
20
|
npm run build
|
|
12
21
|
```
|
|
13
22
|
|
|
14
|
-
###
|
|
23
|
+
### Import CSS
|
|
24
|
+
Import trực tiếp trong component hoặc file entry (`index.tsx` / `index.scss`):
|
|
25
|
+
```tsx
|
|
26
|
+
import '@esvndev/es-data-sharing/dist/styles/index.css';
|
|
27
|
+
```
|
|
28
|
+
Hoặc trong SCSS:
|
|
29
|
+
```scss
|
|
30
|
+
@import '../node_modules/@esvndev/es-data-sharing/dist/styles/index.css';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 2. Thành phần Export
|
|
36
|
+
|
|
37
|
+
| Export | Mô tả |
|
|
38
|
+
| :--- | :--- |
|
|
39
|
+
| `default` (`DataSharingComponent`) | Component dạng **Modal** điều khiển qua `ref` (`IFDataSharingRef`). |
|
|
40
|
+
| `DataSharingPanel` | Component dạng **Panel nhúng trực tiếp** (không bọc `<Modal>`), phù hợp đặt bên trong form Thêm mới / Chỉnh sửa. |
|
|
41
|
+
| `OrgTable` | Bảng **Phạm vi chia sẻ xuống đơn vị** độc lập. |
|
|
42
|
+
| `MasterCard`, `BatchMasterCard`, `OverrideTable`, `DetailTabTable` | Các sub-component theo từng phân vùng. |
|
|
43
|
+
| `buildDataSharingPayload` | Helper tạo payload chuẩn (`IDataSharingPayload`) từ state hiện tại khi submit form ngoài. |
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 3. Thuộc tính ẩn/hiện phân vùng (`ISharingSectionVisibility`)
|
|
48
|
+
|
|
49
|
+
Có thể truyền vào **`config` (`ISharingMetadataConfig`)**, **`sharingRef.current?.open({...})`**, **`<DataSharingComponent />`** hoặc **`<DataSharingPanel />`**.
|
|
50
|
+
|
|
51
|
+
**Thứ tự ưu tiên:** `open(...)` > props của component > `config` > mặc định (`true`).
|
|
52
|
+
|
|
53
|
+
| Thuộc tính | Kiểu | Mặc định | Mô tả |
|
|
54
|
+
| :--- | :--- | :--- | :--- |
|
|
55
|
+
| `showMasterCard` | `boolean` | `true` | Hiện/ẩn khối **Thông tin gốc** bên trái *(khi ẩn, khối Phạm vi chia sẻ tự mở rộng full ngang `col-md-12`)*. |
|
|
56
|
+
| `showOrgScope` | `boolean` | `true` | Hiện/ẩn khối **Phạm vi chia sẻ xuống đơn vị** bên phải *(khi ẩn, khối Thông tin gốc tự mở rộng full ngang `col-md-12`)*. |
|
|
57
|
+
| `showConfigTabs` | `boolean` | `true` | Hiện/ẩn toàn bộ **khu vực Tab cấu hình phía dưới** (Cấu hình theo đơn vị, `detailTabs`, Tổng hợp phân quyền). |
|
|
58
|
+
| `showOverrideTab` | `boolean` | `true` | Hiện/ẩn riêng tab **Cấu hình theo đơn vị**. |
|
|
59
|
+
| `showSummaryTab` | `boolean` | `true` | Hiện/ẩn riêng tab **Tổng hợp phân quyền**. |
|
|
60
|
+
| `showGlobalSharedSwitch` | `boolean` | `true` | Hiện/ẩn nút gạt **"Danh mục dùng chung toàn tập đoàn"** trong `MasterCard` / `BatchMasterCard`. |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 4. Cách sử dụng
|
|
65
|
+
|
|
66
|
+
### Cách A: Dùng dạng Modal (`DataSharingComponent`) — Chia sẻ đơn lẻ hoặc hàng loạt
|
|
67
|
+
|
|
15
68
|
```tsx
|
|
16
69
|
import React, { useRef } from 'react';
|
|
17
70
|
import DataSharingComponent, {
|
|
18
71
|
IFDataSharingRef,
|
|
19
72
|
ISharingMetadataConfig
|
|
20
73
|
} from '@esvndev/es-data-sharing';
|
|
74
|
+
import '@esvndev/es-data-sharing/dist/styles/index.css';
|
|
21
75
|
|
|
22
|
-
const
|
|
76
|
+
const vendorSharingConfig: ISharingMetadataConfig = {
|
|
23
77
|
entityType: 'SUPPLIER',
|
|
24
78
|
title: 'Chia sẻ Nhà cung cấp',
|
|
25
79
|
masterCardTitle: 'Thông tin nhà cung cấp gốc',
|
|
26
80
|
masterFields: [
|
|
27
|
-
{ key: '
|
|
28
|
-
{ key: '
|
|
81
|
+
{ key: 'code', label: 'Mã nhà cung cấp', required: true },
|
|
82
|
+
{ key: 'name', label: 'Tên nhà cung cấp', required: true },
|
|
83
|
+
{ key: 'taxCode', label: 'Mã số thuế' }
|
|
29
84
|
],
|
|
30
85
|
overrideColumns: [
|
|
31
|
-
{ key: '
|
|
32
|
-
{ key: '
|
|
86
|
+
{ key: 'oldCustomerCode', label: 'Mã cũ', type: 'text' },
|
|
87
|
+
{ key: 'debtDay', label: 'Số ngày được nợ', type: 'number' },
|
|
88
|
+
{
|
|
89
|
+
key: 'status',
|
|
90
|
+
label: 'Trạng thái',
|
|
91
|
+
type: 'select',
|
|
92
|
+
options: [
|
|
93
|
+
{ label: 'Hoạt động', value: 1 },
|
|
94
|
+
{ label: 'Ngừng hoạt động', value: 0 }
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
detailTabs: [
|
|
99
|
+
{
|
|
100
|
+
key: 'objectBank',
|
|
101
|
+
title: 'Tài khoản ngân hàng',
|
|
102
|
+
icon: '🏦',
|
|
103
|
+
defaultRow: { status: 1, default: false },
|
|
104
|
+
columns: [
|
|
105
|
+
{
|
|
106
|
+
key: 'bankId',
|
|
107
|
+
label: 'Ngân hàng',
|
|
108
|
+
type: 'selectTable',
|
|
109
|
+
options: [], // Danh sách ngân hàng
|
|
110
|
+
fieldLabel: 'label',
|
|
111
|
+
fieldKey: 'value',
|
|
112
|
+
selectTableColumns: [],
|
|
113
|
+
autoFillMap: { bankCode: 'key', name: 'name' }
|
|
114
|
+
},
|
|
115
|
+
{ key: 'accountNumber', label: 'Số tài khoản', type: 'text' },
|
|
116
|
+
{
|
|
117
|
+
key: 'default',
|
|
118
|
+
label: 'Mặc định',
|
|
119
|
+
type: 'checkbox',
|
|
120
|
+
uniqueScopeKey: 'organizationId',
|
|
121
|
+
defaultValue: false
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
33
125
|
]
|
|
34
126
|
};
|
|
35
127
|
|
|
36
|
-
export const
|
|
128
|
+
export const VendorTable = () => {
|
|
37
129
|
const sharingRef = useRef<IFDataSharingRef>(null);
|
|
38
130
|
|
|
39
|
-
|
|
131
|
+
// 1) Chia sẻ 1 bản ghi
|
|
132
|
+
const handleOpenSingle = (rowData: any) => {
|
|
40
133
|
sharingRef.current?.open({
|
|
41
134
|
entityType: 'SUPPLIER',
|
|
42
135
|
entityId: rowData.id,
|
|
43
136
|
masterData: rowData,
|
|
44
|
-
config:
|
|
137
|
+
config: vendorSharingConfig
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// 2) Chia sẻ hàng loạt nhiều bản ghi
|
|
142
|
+
const handleOpenBatch = (selectedRows: any[]) => {
|
|
143
|
+
sharingRef.current?.open({
|
|
144
|
+
entityType: 'SUPPLIER',
|
|
145
|
+
entityId: selectedRows[0].id,
|
|
146
|
+
entityIds: selectedRows.map(r => r.id),
|
|
147
|
+
masterData: selectedRows[0],
|
|
148
|
+
masterDataList: selectedRows,
|
|
149
|
+
config: vendorSharingConfig
|
|
45
150
|
});
|
|
46
151
|
};
|
|
47
152
|
|
|
48
153
|
return (
|
|
49
154
|
<>
|
|
50
|
-
<button onClick={() =>
|
|
155
|
+
<button onClick={() => handleOpenSingle(row)}>Chia sẻ</button>
|
|
51
156
|
<DataSharingComponent
|
|
52
157
|
ref={sharingRef}
|
|
158
|
+
database={process.env.REACT_APP_SHARING_DATABASE}
|
|
159
|
+
fetchSharingData={async (entityType, entityId, database) => {
|
|
160
|
+
// Gọi API lấy dữ liệu chia sẻ theo entityType & entityId
|
|
161
|
+
return {
|
|
162
|
+
isGlobalShared: false,
|
|
163
|
+
orgList: [],
|
|
164
|
+
detailData: {}
|
|
165
|
+
};
|
|
166
|
+
}}
|
|
53
167
|
onSave={async (payload) => {
|
|
54
|
-
// Gọi API Backend lưu
|
|
55
|
-
console.log('
|
|
168
|
+
// Gọi API Backend lưu cấu hình chia sẻ
|
|
169
|
+
console.log('Payload chia sẻ:', payload);
|
|
56
170
|
}}
|
|
57
171
|
/>
|
|
58
172
|
</>
|
|
59
173
|
);
|
|
60
174
|
};
|
|
61
175
|
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### Cách B: Nhúng trực tiếp vào form Thêm mới (`DataSharingPanel`)
|
|
180
|
+
|
|
181
|
+
Phù hợp khi đang ở trong Modal Thêm mới (ví dụ chỉ muốn hiển thị phân vùng **Phạm vi chia sẻ xuống đơn vị**):
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import React, { useState } from 'react';
|
|
185
|
+
import {
|
|
186
|
+
DataSharingPanel,
|
|
187
|
+
IOrgSharingItem,
|
|
188
|
+
ISharingMetadataConfig,
|
|
189
|
+
buildDataSharingPayload
|
|
190
|
+
} from '@esvndev/es-data-sharing';
|
|
191
|
+
import '@esvndev/es-data-sharing/dist/styles/index.css';
|
|
192
|
+
|
|
193
|
+
const addVendorSharingConfig: ISharingMetadataConfig = {
|
|
194
|
+
entityType: 'SUPPLIER',
|
|
195
|
+
title: 'Phạm vi chia sẻ',
|
|
196
|
+
showMasterCard: false,
|
|
197
|
+
showConfigTabs: false
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const VendorAddModalSection = () => {
|
|
201
|
+
const [orgList, setOrgList] = useState<IOrgSharingItem[]>([]);
|
|
202
|
+
const [isGlobalShared, setIsGlobalShared] = useState(false);
|
|
203
|
+
|
|
204
|
+
const handleSubmitAddForm = (createdEntityId: string) => {
|
|
205
|
+
const sharingPayload = buildDataSharingPayload({
|
|
206
|
+
config: addVendorSharingConfig,
|
|
207
|
+
entityId: createdEntityId,
|
|
208
|
+
isGlobalShared,
|
|
209
|
+
orgList,
|
|
210
|
+
detailData: {}
|
|
211
|
+
});
|
|
212
|
+
console.log('Payload gửi lên API:', sharingPayload);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<DataSharingPanel
|
|
217
|
+
config={addVendorSharingConfig}
|
|
218
|
+
orgList={orgList}
|
|
219
|
+
onChangeOrgList={setOrgList}
|
|
220
|
+
isGlobalShared={isGlobalShared}
|
|
221
|
+
onChangeGlobalShared={setIsGlobalShared}
|
|
222
|
+
showMasterCard={false}
|
|
223
|
+
showConfigTabs={false}
|
|
224
|
+
/>
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## 5. Ghi chú cấu hình trường (`ISharingFieldDef`)
|
|
232
|
+
|
|
233
|
+
- `type`: `'text' | 'number' | 'numeric' | 'currency' | 'select' | 'selectTable' | 'user' | 'date' | 'switch' | 'checkbox'`
|
|
234
|
+
- `autoFillMap`: Tự động điền các cột liên quan khi chọn option trong `selectTable` (ví dụ `{ bankCode: 'key', name: 'name' }`).
|
|
235
|
+
- `uniqueScopeKey`: Giới hạn chỉ cho phép chọn tối đa 1 giá trị `true` (cho `checkbox` / `switch`) trong cùng 1 nhóm scope (ví dụ `'organizationId'`).
|
|
236
|
+
- `database`: Truyền tên DB khi test local (ví dụ `process.env.REACT_APP_SHARING_DATABASE`); trên môi trường Cloud để trống để API tự lấy theo JWT claim `"data"`.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ISharingMetadataConfig, ISharingSectionVisibility, IOrgSharingItem } from '../../types';
|
|
3
|
+
export interface DataSharingContentProps extends ISharingSectionVisibility {
|
|
4
|
+
config: ISharingMetadataConfig;
|
|
5
|
+
masterData?: Record<string, any>;
|
|
6
|
+
masterDataList?: Record<string, any>[];
|
|
7
|
+
parentOrgName?: string;
|
|
8
|
+
isBatchMode?: boolean;
|
|
9
|
+
orgList: IOrgSharingItem[];
|
|
10
|
+
setOrgList: React.Dispatch<React.SetStateAction<IOrgSharingItem[]>>;
|
|
11
|
+
detailData: Record<string, Record<string, any>[]>;
|
|
12
|
+
setDetailData: React.Dispatch<React.SetStateAction<Record<string, Record<string, any>[]>>>;
|
|
13
|
+
isGlobalShared: boolean;
|
|
14
|
+
onToggleGlobalShared: (checked: boolean) => void;
|
|
15
|
+
onChangeOverride: (targetOrgId: string, fieldKey: string, value: any) => void;
|
|
16
|
+
onApplyFirstToAll?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const DataSharingContent: React.FC<DataSharingContentProps>;
|
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { IOrgSharingItem, IFDataSharingOpenParams, IDataSharingPayload } from '../../types';
|
|
2
|
+
import { ISharingMetadataConfig, ISharingSectionVisibility, IOrgSharingItem, IFDataSharingOpenParams, IDataSharingPayload } from '../../types';
|
|
3
3
|
export interface IFDataSharingRef {
|
|
4
4
|
open: (params: IFDataSharingOpenParams) => void;
|
|
5
5
|
close: () => void;
|
|
6
6
|
}
|
|
7
|
-
export interface IFDataSharingProps {
|
|
7
|
+
export interface IFDataSharingProps extends ISharingSectionVisibility {
|
|
8
8
|
/** Tên DB dự án cho môi trường Test (ví dụ: process.env.REACT_APP_SHARING_DATABASE). Trên Cloud để trống để API tự lấy theo JWT claim "data". */
|
|
9
9
|
database?: string;
|
|
10
|
+
/** Tên/mã công ty mẹ hiển thị trên thanh tiêu đề của Phạm vi chia sẻ */
|
|
11
|
+
parentOrgName?: string;
|
|
10
12
|
/** Function gọi lấy dữ liệu chia sẻ + cấu hình đơn vị + detailData (như ObjectBank) */
|
|
11
13
|
fetchSharingData?: (entityType: string, entityId: string, database?: string) => Promise<{
|
|
12
14
|
isGlobalShared: boolean;
|
|
13
15
|
orgList: IOrgSharingItem[];
|
|
14
16
|
detailData?: Record<string, Record<string, any>[]>;
|
|
17
|
+
parentOrgName?: string;
|
|
15
18
|
}>;
|
|
16
19
|
/** Function callback lưu dữ liệu */
|
|
17
20
|
onSave?: (payload: IDataSharingPayload) => Promise<void>;
|
|
18
21
|
/** Callback sau khi lưu thành công */
|
|
19
22
|
onSuccess?: () => void;
|
|
20
23
|
}
|
|
24
|
+
export interface IDataSharingPanelProps extends ISharingSectionVisibility {
|
|
25
|
+
config: ISharingMetadataConfig;
|
|
26
|
+
masterData?: Record<string, any>;
|
|
27
|
+
masterDataList?: Record<string, any>[];
|
|
28
|
+
parentOrgName?: string;
|
|
29
|
+
isBatchMode?: boolean;
|
|
30
|
+
orgList: IOrgSharingItem[];
|
|
31
|
+
onChangeOrgList: React.Dispatch<React.SetStateAction<IOrgSharingItem[]>>;
|
|
32
|
+
detailData?: Record<string, Record<string, any>[]>;
|
|
33
|
+
onChangeDetailData?: React.Dispatch<React.SetStateAction<Record<string, Record<string, any>[]>>>;
|
|
34
|
+
isGlobalShared?: boolean;
|
|
35
|
+
onChangeGlobalShared?: (checked: boolean) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare const DataSharingPanel: React.FC<IDataSharingPanelProps>;
|
|
21
38
|
declare const DataSharingComponent: React.ForwardRefExoticComponent<IFDataSharingProps & React.RefAttributes<IFDataSharingRef>>;
|
|
22
39
|
export default DataSharingComponent;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ISharingMetadataConfig, IOrgSharingItem, IDataSharingPayload } from '../../types';
|
|
3
|
-
interface Props {
|
|
2
|
+
import { ISharingMetadataConfig, ISharingSectionVisibility, IOrgSharingItem, IDataSharingPayload } from '../../types';
|
|
3
|
+
interface Props extends ISharingSectionVisibility {
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
toggle: () => void;
|
|
6
6
|
config: ISharingMetadataConfig;
|
|
7
7
|
masterData: Record<string, any>;
|
|
8
8
|
masterDataList?: Record<string, any>[];
|
|
9
|
+
parentOrgName?: string;
|
|
9
10
|
entityId: string;
|
|
10
11
|
entityIds?: string[];
|
|
11
12
|
orgList: IOrgSharingItem[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IDataSharingPayload, IOrgSharingItem, ISharingMetadataConfig } from '../../types';
|
|
2
|
+
export declare function applyGlobalSharedToOrgList(orgList: IOrgSharingItem[], checked: boolean, sharingLabel: string): IOrgSharingItem[];
|
|
3
|
+
export declare function updateOrgOverrideValue(orgList: IOrgSharingItem[], targetOrgId: string, fieldKey: string, value: any): IOrgSharingItem[];
|
|
4
|
+
export declare function applyFirstOverrideToAll(orgList: IOrgSharingItem[]): IOrgSharingItem[];
|
|
5
|
+
export declare function buildDataSharingPayload(params: {
|
|
6
|
+
config: ISharingMetadataConfig;
|
|
7
|
+
entityId: string;
|
|
8
|
+
entityIds?: string[];
|
|
9
|
+
isGlobalShared: boolean;
|
|
10
|
+
orgList: IOrgSharingItem[];
|
|
11
|
+
detailData: Record<string, Record<string, any>[]>;
|
|
12
|
+
}): IDataSharingPayload;
|
|
@@ -3,7 +3,7 @@ import { IOrgSharingItem } from '../../types';
|
|
|
3
3
|
interface Props {
|
|
4
4
|
orgList: IOrgSharingItem[];
|
|
5
5
|
onChangeOrg: (updatedList: IOrgSharingItem[]) => void;
|
|
6
|
-
|
|
6
|
+
parentOrgName?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare const OrgTable: React.FC<Props>;
|
|
9
9
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -37,14 +37,29 @@ interface ISharingDetailTabConfig {
|
|
|
37
37
|
allowDelete?: boolean;
|
|
38
38
|
defaultRow?: Record<string, any>;
|
|
39
39
|
}
|
|
40
|
-
interface
|
|
40
|
+
interface ISharingSectionVisibility {
|
|
41
|
+
/** Hiện/ẩn khối Thông tin gốc bên trái (mặc định: true) */
|
|
42
|
+
showMasterCard?: boolean;
|
|
43
|
+
/** Hiện/ẩn khối Phạm vi chia sẻ xuống đơn vị bên phải (mặc định: true) */
|
|
44
|
+
showOrgScope?: boolean;
|
|
45
|
+
/** Hiện/ẩn toàn bộ khối Tab cấu hình phía dưới (mặc định: true) */
|
|
46
|
+
showConfigTabs?: boolean;
|
|
47
|
+
/** Hiện/ẩn tab Cấu hình theo đơn vị (mặc định: true) */
|
|
48
|
+
showOverrideTab?: boolean;
|
|
49
|
+
/** Hiện/ẩn tab Tổng hợp phân quyền (mặc định: true) */
|
|
50
|
+
showSummaryTab?: boolean;
|
|
51
|
+
/** Hiện/ẩn nút gạt "Danh mục dùng chung toàn tập đoàn" (mặc định: true) */
|
|
52
|
+
showGlobalSharedSwitch?: boolean;
|
|
53
|
+
}
|
|
54
|
+
interface ISharingMetadataConfig extends ISharingSectionVisibility {
|
|
41
55
|
entityType: string;
|
|
42
56
|
title: string;
|
|
43
|
-
masterCardTitle
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
masterCardTitle?: string;
|
|
58
|
+
/** Tên/mã công ty mẹ hiển thị trên thanh tiêu đề của Phạm vi chia sẻ */
|
|
59
|
+
parentOrgName?: string;
|
|
60
|
+
masterFields?: ISharingFieldDef[];
|
|
61
|
+
overrideColumns?: ISharingFieldDef[];
|
|
46
62
|
detailTabs?: ISharingDetailTabConfig[];
|
|
47
|
-
showEffectiveDate?: boolean;
|
|
48
63
|
}
|
|
49
64
|
interface IOrgSharingItem {
|
|
50
65
|
targetOrgId: string;
|
|
@@ -78,12 +93,13 @@ interface IDataSharingPayload {
|
|
|
78
93
|
detailData?: Record<string, Record<string, any>[]>;
|
|
79
94
|
database?: string;
|
|
80
95
|
}
|
|
81
|
-
interface IFDataSharingOpenParams {
|
|
96
|
+
interface IFDataSharingOpenParams extends ISharingSectionVisibility {
|
|
82
97
|
entityType: string;
|
|
83
98
|
entityId?: string;
|
|
84
99
|
entityIds?: string[];
|
|
85
100
|
masterData?: Record<string, any>;
|
|
86
101
|
masterDataList?: Record<string, any>[];
|
|
102
|
+
parentOrgName?: string;
|
|
87
103
|
config: ISharingMetadataConfig;
|
|
88
104
|
initialGlobalShared?: boolean;
|
|
89
105
|
initialDetailData?: Record<string, Record<string, any>[]>;
|
|
@@ -94,20 +110,89 @@ interface IFDataSharingRef {
|
|
|
94
110
|
open: (params: IFDataSharingOpenParams) => void;
|
|
95
111
|
close: () => void;
|
|
96
112
|
}
|
|
97
|
-
interface IFDataSharingProps {
|
|
113
|
+
interface IFDataSharingProps extends ISharingSectionVisibility {
|
|
98
114
|
/** Tên DB dự án cho môi trường Test (ví dụ: process.env.REACT_APP_SHARING_DATABASE). Trên Cloud để trống để API tự lấy theo JWT claim "data". */
|
|
99
115
|
database?: string;
|
|
116
|
+
/** Tên/mã công ty mẹ hiển thị trên thanh tiêu đề của Phạm vi chia sẻ */
|
|
117
|
+
parentOrgName?: string;
|
|
100
118
|
/** Function gọi lấy dữ liệu chia sẻ + cấu hình đơn vị + detailData (như ObjectBank) */
|
|
101
119
|
fetchSharingData?: (entityType: string, entityId: string, database?: string) => Promise<{
|
|
102
120
|
isGlobalShared: boolean;
|
|
103
121
|
orgList: IOrgSharingItem[];
|
|
104
122
|
detailData?: Record<string, Record<string, any>[]>;
|
|
123
|
+
parentOrgName?: string;
|
|
105
124
|
}>;
|
|
106
125
|
/** Function callback lưu dữ liệu */
|
|
107
126
|
onSave?: (payload: IDataSharingPayload) => Promise<void>;
|
|
108
127
|
/** Callback sau khi lưu thành công */
|
|
109
128
|
onSuccess?: () => void;
|
|
110
129
|
}
|
|
130
|
+
interface IDataSharingPanelProps extends ISharingSectionVisibility {
|
|
131
|
+
config: ISharingMetadataConfig;
|
|
132
|
+
masterData?: Record<string, any>;
|
|
133
|
+
masterDataList?: Record<string, any>[];
|
|
134
|
+
parentOrgName?: string;
|
|
135
|
+
isBatchMode?: boolean;
|
|
136
|
+
orgList: IOrgSharingItem[];
|
|
137
|
+
onChangeOrgList: React.Dispatch<React.SetStateAction<IOrgSharingItem[]>>;
|
|
138
|
+
detailData?: Record<string, Record<string, any>[]>;
|
|
139
|
+
onChangeDetailData?: React.Dispatch<React.SetStateAction<Record<string, Record<string, any>[]>>>;
|
|
140
|
+
isGlobalShared?: boolean;
|
|
141
|
+
onChangeGlobalShared?: (checked: boolean) => void;
|
|
142
|
+
}
|
|
143
|
+
declare const DataSharingPanel: React.FC<IDataSharingPanelProps>;
|
|
111
144
|
declare const DataSharingComponent: React.ForwardRefExoticComponent<IFDataSharingProps & React.RefAttributes<IFDataSharingRef>>;
|
|
112
145
|
|
|
113
|
-
|
|
146
|
+
interface Props$4 {
|
|
147
|
+
orgList: IOrgSharingItem[];
|
|
148
|
+
onChangeOrg: (updatedList: IOrgSharingItem[]) => void;
|
|
149
|
+
parentOrgName?: string;
|
|
150
|
+
}
|
|
151
|
+
declare const OrgTable: React.FC<Props$4>;
|
|
152
|
+
|
|
153
|
+
interface Props$3 {
|
|
154
|
+
title: string;
|
|
155
|
+
fields: ISharingFieldDef[];
|
|
156
|
+
data: Record<string, any>;
|
|
157
|
+
isGlobalShared: boolean;
|
|
158
|
+
onToggleGlobalShared: (val: boolean) => void;
|
|
159
|
+
showGlobalSharedSwitch?: boolean;
|
|
160
|
+
}
|
|
161
|
+
declare const MasterCard: React.FC<Props$3>;
|
|
162
|
+
|
|
163
|
+
interface Props$2 {
|
|
164
|
+
title: string;
|
|
165
|
+
items: Record<string, any>[];
|
|
166
|
+
isGlobalShared: boolean;
|
|
167
|
+
onToggleGlobalShared: (val: boolean) => void;
|
|
168
|
+
showGlobalSharedSwitch?: boolean;
|
|
169
|
+
}
|
|
170
|
+
declare const BatchMasterCard: React.FC<Props$2>;
|
|
171
|
+
|
|
172
|
+
interface Props$1 {
|
|
173
|
+
orgList: IOrgSharingItem[];
|
|
174
|
+
overrideColumns: ISharingFieldDef[];
|
|
175
|
+
masterData?: Record<string, any>;
|
|
176
|
+
onChangeOverride: (targetOrgId: string, fieldKey: string, value: any) => void;
|
|
177
|
+
onApplyFirstToAll?: () => void;
|
|
178
|
+
}
|
|
179
|
+
declare const OverrideTable: React.FC<Props$1>;
|
|
180
|
+
|
|
181
|
+
interface Props {
|
|
182
|
+
tabConfig: ISharingDetailTabConfig;
|
|
183
|
+
orgList: IOrgSharingItem[];
|
|
184
|
+
rows: Record<string, any>[];
|
|
185
|
+
onChangeRows: (updatedRows: Record<string, any>[]) => void;
|
|
186
|
+
}
|
|
187
|
+
declare const DetailTabTable: React.FC<Props>;
|
|
188
|
+
|
|
189
|
+
declare function buildDataSharingPayload(params: {
|
|
190
|
+
config: ISharingMetadataConfig;
|
|
191
|
+
entityId: string;
|
|
192
|
+
entityIds?: string[];
|
|
193
|
+
isGlobalShared: boolean;
|
|
194
|
+
orgList: IOrgSharingItem[];
|
|
195
|
+
detailData: Record<string, Record<string, any>[]>;
|
|
196
|
+
}): IDataSharingPayload;
|
|
197
|
+
|
|
198
|
+
export { BatchMasterCard, DataSharingPanel, DetailTabTable, FieldType, IDataSharingPanelProps, IDataSharingPayload, IFDataSharingOpenParams, IFDataSharingProps, IFDataSharingRef, IOrgSharingItem, ISharingDetailTabConfig, ISharingFieldDef, ISharingFieldOption, ISharingMetadataConfig, ISharingSectionVisibility, MasterCard, OrgTable, OverrideTable, buildDataSharingPayload, DataSharingComponent as default };
|