neo-cmp-cli 1.12.8 → 1.12.10
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 +204 -6
- package/dist/index2.js +1 -1
- package/dist/module/neoInitByCopy.js +1 -1
- package/dist/neo/env.js +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +4 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/asset-manage-template/README.md +154 -0
- package/template/asset-manage-template/docs/README.md +244 -0
- package/template/asset-manage-template/neo.config.js +60 -0
- package/template/asset-manage-template/package.json +74 -0
- package/template/asset-manage-template/src/assets/img/chart.svg +1 -0
- package/template/asset-manage-template/src/components/README.md +3 -0
- package/template/asset-manage-template/src/components/assetManage__c/assetApi.ts +70 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetCreateModal.tsx +260 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetGrid.tsx +48 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetSidebar.tsx +74 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetToolbar.tsx +79 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/assetDisplay.tsx +72 -0
- package/template/asset-manage-template/src/components/assetManage__c/constants.ts +28 -0
- package/template/asset-manage-template/src/components/assetManage__c/index.tsx +258 -0
- package/template/asset-manage-template/src/components/assetManage__c/model.ts +75 -0
- package/template/asset-manage-template/src/components/assetManage__c/style.scss +425 -0
- package/template/asset-manage-template/src/components/assetManage__c/types.ts +60 -0
- package/template/asset-manage-template/src/components/bidList__c/cmps/BidCard.tsx +47 -0
- package/template/asset-manage-template/src/components/bidList__c/constants.ts +6 -0
- package/template/asset-manage-template/src/components/bidList__c/formatUtils.ts +14 -0
- package/template/asset-manage-template/src/components/bidList__c/index.tsx +194 -0
- package/template/asset-manage-template/src/components/bidList__c/model.ts +57 -0
- package/template/asset-manage-template/src/components/bidList__c/style.scss +179 -0
- package/template/asset-manage-template/src/components/bidList__c/types.ts +10 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/BidPackageHeader.tsx +140 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/PackageItemTable.tsx +148 -0
- package/template/asset-manage-template/src/components/bidPackage__c/index.tsx +394 -0
- package/template/asset-manage-template/src/components/bidPackage__c/mainTableColumns.tsx +57 -0
- package/template/asset-manage-template/src/components/bidPackage__c/model.ts +86 -0
- package/template/asset-manage-template/src/components/bidPackage__c/style.scss +256 -0
- package/template/asset-manage-template/src/components/bidPackage__c/types.ts +35 -0
- package/template/asset-manage-template/src/components/bidPackage__c/utils.ts +19 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/axiosFetcher.ts +0 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/queryObjectData.ts +36 -0
- package/template/asset-manage-template/src/utils/url.ts +82 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/xobjects.ts +0 -0
- package/template/asset-manage-template/tsconfig.json +40 -0
- package/template/echarts-custom-cmp-template/package.json +1 -1
- package/template/empty-custom-cmp-template/package.json +2 -2
- package/template/neo-custom-cmp-template/package.json +5 -2
- package/template/neo-custom-cmp-template/src/components/entityTable__c/index.tsx +62 -6
- package/template/neo-custom-cmp-template/src/utils/queryObjectData.ts +36 -0
- package/template/neo-custom-cmp-template/tsconfig.json +1 -2
- package/template/neo-h5-cmps/neo.config.js +1 -6
- package/template/neo-h5-cmps/package.json +7 -4
- package/template/neo-h5-cmps/src/utils/queryObjectData.ts +36 -0
- package/template/neo-h5-cmps/tsconfig.json +3 -4
- package/template/neo-order-cmps/package.json +2 -2
- package/template/neo-order-cmps/src/utils/queryObjectData.ts +36 -0
- package/template/neo-web-cmps/@types/neo-ui-common.d.ts +36 -0
- package/template/neo-web-cmps/neo.config.js +53 -0
- package/template/{neo-bi-cmps → neo-web-cmps}/package.json +10 -7
- package/template/neo-web-cmps/src/assets/img/AIBtn.gif +0 -0
- package/template/neo-web-cmps/src/assets/img/aiLogo.png +0 -0
- package/template/neo-web-cmps/src/assets/img/card-list.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/contact-form.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/custom-form.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/data-list.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/detail.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/map.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/search.svg +1 -0
- package/template/neo-web-cmps/src/components/entityGrid2__c/index.tsx +72 -0
- package/template/neo-web-cmps/src/components/entityGrid2__c/model.ts +195 -0
- package/template/neo-web-cmps/src/components/entityGrid2__c/style.scss +13 -0
- package/template/neo-web-cmps/src/components/entityGrid__c/index.tsx +52 -0
- package/template/neo-web-cmps/src/components/entityGrid__c/model.ts +195 -0
- package/template/neo-web-cmps/src/components/entityGrid__c/style.scss +13 -0
- package/template/neo-web-cmps/src/utils/axiosFetcher.ts +37 -0
- package/template/neo-web-cmps/src/utils/queryObjectData.ts +112 -0
- package/template/{develop/neo-custom-cmp-template → neo-web-cmps}/src/utils/xobjects.ts +28 -64
- package/template/{neo-bi-cmps → neo-web-cmps}/tsconfig.json +2 -3
- package/template/react-custom-cmp-template/package.json +1 -1
- package/template/react-ts-custom-cmp-template/package.json +1 -1
- package/template/vue2-custom-cmp-template/package.json +1 -1
- package/template/develop/BI /351/241/271/347/233/256/345/210/206/346/236/220/346/212/245/345/221/212.md" +0 -562
- package/template/develop/ChatPage /347/273/204/344/273/266/344/275/277/347/224/250/350/257/264/346/230/216/346/226/207/346/241/243.md" +0 -507
- package/template/develop/EntityGrid Web /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -868
- package/template/develop/EntityList H5 /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -1386
- package/template/develop/GlobalSearch/347/273/204/344/273/266/345/257/271/346/257/224/345/210/206/346/236/220.md +0 -866
- package/template/develop/Neo /344/270/255/345/217/257/347/224/250 amis /347/273/204/344/273/266.md" +0 -1490
- package/template/develop/cmpEventFunctions.ts +0 -257
- package/template/develop/cmpEvents.ts +0 -864
- package/template/develop/comTree/347/224/237/346/210/220/350/277/207/347/250/213/345/210/206/346/236/220.md +0 -469
- package/template/develop/commonModules.js +0 -55
- package/template/develop/components-table.md +0 -50
- package/template/develop/neo-custom-cmp-template/README.md +0 -48
- package/template/develop/neo-custom-cmp-template/docs/README.md +0 -13
- package/template/develop/neo-custom-cmp-template/neo.config.js +0 -121
- package/template/develop/neo-custom-cmp-template/package.json +0 -63
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/README.md +0 -65
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/index.tsx +0 -180
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/model.ts +0 -50
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/style.scss +0 -260
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/README.md +0 -94
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/index.tsx +0 -252
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/model.ts +0 -56
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/style.scss +0 -120
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/README.md +0 -115
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/index.tsx +0 -304
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/model.ts +0 -87
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/style.scss +0 -127
- package/template/develop/neo-custom-cmp-template/src/utils/axiosFetcher.ts +0 -29
- package/template/develop/neo-custom-cmp-template/src/utils/queryObjectData.ts +0 -39
- package/template/develop/neo-custom-cmp-template/tsconfig.json +0 -68
- package/template/develop/neo-ui-component-h5.md +0 -105
- package/template/develop/neo-ui-component-web-xregister.md +0 -31
- package/template/develop/neo-ui-component-web.md +0 -292
- package/template/develop/neoCmps.ts +0 -7508
- package/template/develop/neoGlobalSearchInput /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -497
- package/template/develop/pageSchema1.json +0 -744
- package/template/develop//344/272/213/344/273/266/345/212/250/344/275/234/344/277/235/345/255/230/346/265/201/347/250/213/345/210/206/346/236/220.md +0 -390
- package/template/develop//345/215/225/345/205/203/346/265/213/350/257/225/344/275/277/347/224/250/350/257/264/346/230/216.md +0 -1139
- package/template/develop//345/261/236/346/200/247/351/205/215/347/275/256/351/241/271/347/261/273/345/236/213/346/261/207/346/200/273.md +0 -558
- package/template/neo-bi-cmps/neo.config.js +0 -124
- package/template/neo-bi-cmps/src/components/targetNumber__c/README.md +0 -100
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/configSchema.ts +0 -253
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.scss +0 -76
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.tsx +0 -148
- package/template/neo-bi-cmps/src/components/targetNumber__c/index.tsx +0 -440
- package/template/neo-bi-cmps/src/components/targetNumber__c/model.ts +0 -128
- package/template/neo-bi-cmps/src/components/targetNumber__c/style.scss +0 -173
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/.prettierrc.js +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/@types/neo-ui-common.d.ts +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/commitlint.config.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/css/base.css +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/scripts/app/bluebird.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/template.html +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/common.scss +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/mixin.scss +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/AIBtn.gif +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/NeoCRM.jpg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/aiLogo.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/card-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/contact-form.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/custom-form.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/custom-widget.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/data-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/detail.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/favicon.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/map.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/search.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/table.svg +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/.prettierrc.js +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/README.md +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/commitlint.config.js +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/public/css/base.css +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/public/scripts/app/bluebird.js +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/public/template.html +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/css/common.scss +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/css/mixin.scss +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/NeoCRM.jpg +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/custom-widget.svg +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/favicon.png +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/table.svg +0 -0
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
# 组件事件配置面板中添加的事件动作保存到 cmpExt 流程分析
|
|
2
|
-
|
|
3
|
-
## 整体流程概览
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
用户操作 → 事件面板 → 创建/更新事件实例 → 保存到内存 → 序列化时写入 cmpExt
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
## 详细流程分析
|
|
10
|
-
|
|
11
|
-
### 1. 事件配置面板初始化
|
|
12
|
-
|
|
13
|
-
**文件**: `packages/neo-ui-designer-common/src/designerCmps/comConsole/propEditorCmps/events/collection/component.tsx`
|
|
14
|
-
|
|
15
|
-
- `EventCollections` 组件负责渲染事件配置面板
|
|
16
|
-
- 在 `componentDidMount` 时调用 `updateEvents()` 初始化事件列表
|
|
17
|
-
- 从两个数据源获取事件:
|
|
18
|
-
- **事件定义**: `FxAndEvent.getEventDefsByCom(com)` - 从元模型获取组件支持的事件定义
|
|
19
|
-
- **已保存的事件**: 从 `store.frontendExt.cmpExt` 和 `store.frontendExt.layoutExt` 中获取
|
|
20
|
-
|
|
21
|
-
```typescript:47:89:packages/neo-ui-designer-common/src/designerCmps/comConsole/propEditorCmps/events/collection/component.tsx
|
|
22
|
-
updateEvents = () => {
|
|
23
|
-
const com = ComClicker.comSelected;
|
|
24
|
-
const store = com.$pageCom.$store;
|
|
25
|
-
const { cmpExt = [], layoutExt = [] } = store.frontendExt ?? {};
|
|
26
|
-
const netEvents = layoutExt.concat(cmpExt);
|
|
27
|
-
|
|
28
|
-
// 获取事件定义和已保存的事件实例
|
|
29
|
-
const curEvents = FxAndEvent.getEventDefsByCom(com);
|
|
30
|
-
const evtFxs = FxAndEvent.getEventsById(com.keyIdentifier);
|
|
31
|
-
|
|
32
|
-
// 合并数据,优先使用本地更新的事件
|
|
33
|
-
this.setState({
|
|
34
|
-
events: curEvents.map((eve) => {
|
|
35
|
-
const nativeEve = evtFxs.find((_) => _.apiKey === eve.apiKey);
|
|
36
|
-
if (nativeEve) {
|
|
37
|
-
return { ...eve, ...nativeEve };
|
|
38
|
-
}
|
|
39
|
-
const netEve = curNeoEvents.find((_) => _.apiKey === eve.apiKey);
|
|
40
|
-
if (netEve) {
|
|
41
|
-
return { ...eve, id: uuid(16), actions: netEve.actions };
|
|
42
|
-
}
|
|
43
|
-
return { ...eve, id: uuid(16) };
|
|
44
|
-
}),
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### 2. 添加事件动作
|
|
50
|
-
|
|
51
|
-
**文件**: `packages/neo-ui-designer-common/src/designerCmps/comConsole/propEditorCmps/events/event/component.tsx`
|
|
52
|
-
|
|
53
|
-
- `Event` 组件渲染单个事件及其动作列表
|
|
54
|
-
- 点击"添加行为"按钮时,打开动作配置对话框
|
|
55
|
-
|
|
56
|
-
```typescript:17:43:packages/neo-ui-designer-common/src/designerCmps/comConsole/propEditorCmps/events/event/component.tsx
|
|
57
|
-
export const Event: React.FC<IEvent> = (event) => {
|
|
58
|
-
// 创建或获取事件实例
|
|
59
|
-
const eventIns = FxAndEvent.createEvent(event);
|
|
60
|
-
const [actions, setActions] = useState(eventIns.actions);
|
|
61
|
-
|
|
62
|
-
// 当 actions 变化时,同步更新事件实例
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
eventIns.setActions(actions);
|
|
65
|
-
}, [actions]);
|
|
66
|
-
|
|
67
|
-
// 新增 action
|
|
68
|
-
const addAction = () => {
|
|
69
|
-
NeoNavigator.openDialog({
|
|
70
|
-
bodySchema: {
|
|
71
|
-
type: 'neoDesignAction',
|
|
72
|
-
eventName: event.label,
|
|
73
|
-
eventParams: eventIns.eventParams,
|
|
74
|
-
cmpKeyIdentifier: event.cmpKeyIdentifier,
|
|
75
|
-
},
|
|
76
|
-
}).then((action: any) => {
|
|
77
|
-
setActions(actions.concat(action)); // 添加到本地状态
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
**关键点**:
|
|
83
|
-
- `FxAndEvent.createEvent(event)` 创建或获取事件实例,存储在 `FxAndEvent.events` 数组中
|
|
84
|
-
- 通过 `useEffect` 监听 `actions` 变化,调用 `eventIns.setActions(actions)` 更新事件实例
|
|
85
|
-
|
|
86
|
-
### 3. 动作配置对话框
|
|
87
|
-
|
|
88
|
-
**文件**: `packages/neo-ui-designer-common/src/designerCmps/comConsole/propEditorCmps/events/action/component.tsx`
|
|
89
|
-
|
|
90
|
-
- `CmpActionConfig` 组件提供动作配置界面
|
|
91
|
-
- 用户配置动作的各种属性(名称、执行条件、执行操作等)
|
|
92
|
-
- 点击"确认"时,创建动作实例并回调
|
|
93
|
-
|
|
94
|
-
```typescript:359:374:packages/neo-ui-designer-common/src/designerCmps/comConsole/propEditorCmps/events/action/component.tsx
|
|
95
|
-
// 确认回传
|
|
96
|
-
const onConfirm = () => {
|
|
97
|
-
// 先校验,再保存
|
|
98
|
-
if (validate()) return;
|
|
99
|
-
|
|
100
|
-
// 创建动作实例
|
|
101
|
-
const newAction = FxAndEvent.createAction({
|
|
102
|
-
id: props.id ?? uuid(16),
|
|
103
|
-
label,
|
|
104
|
-
execMode,
|
|
105
|
-
actionType,
|
|
106
|
-
assignment,
|
|
107
|
-
condition,
|
|
108
|
-
function: aFunction,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// 回调给父组件(Event组件)
|
|
112
|
-
props.onConfirm(newAction);
|
|
113
|
-
NeoNavigator.goBack();
|
|
114
|
-
};
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### 4. 事件实例管理
|
|
118
|
-
|
|
119
|
-
**文件**: `packages/neo-ui-designer-common/src/marionette/event.fx/index.ts`
|
|
120
|
-
|
|
121
|
-
`__FxAndEvent__` 类管理所有事件实例:
|
|
122
|
-
|
|
123
|
-
```typescript:37:183:packages/neo-ui-designer-common/src/marionette/event.fx/index.ts
|
|
124
|
-
export class __FxAndEvent__ {
|
|
125
|
-
/**
|
|
126
|
-
* 此次布局编辑中新增的事件实例
|
|
127
|
-
*/
|
|
128
|
-
private events: NeoEvent[] = [];
|
|
129
|
-
|
|
130
|
-
// 创建事件实例
|
|
131
|
-
createEvent = (props: INeoEvent): NeoEvent => {
|
|
132
|
-
let event = this.events.find((eve) => {
|
|
133
|
-
if (eve.id && props.id && eve.id === props.id) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
137
|
-
});
|
|
138
|
-
if (event) {
|
|
139
|
-
return event; // 已存在则返回
|
|
140
|
-
}
|
|
141
|
-
event = new NeoEvent(props);
|
|
142
|
-
this.events.push(event); // 添加到内存数组
|
|
143
|
-
return event;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
// 创建动作实例
|
|
147
|
-
createAction = (props: INeoAction) => new NeoAction(props);
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
**关键点**:
|
|
152
|
-
- `events` 数组存储本次编辑会话中所有创建/修改的事件实例
|
|
153
|
-
- `createEvent` 会检查是否已存在,避免重复创建
|
|
154
|
-
- 事件实例包含 `actions` 数组,存储该事件的所有动作
|
|
155
|
-
|
|
156
|
-
### 5. 事件实例更新
|
|
157
|
-
|
|
158
|
-
**文件**: `packages/neo-ui-designer-common/src/marionette/event.fx/event.ts`
|
|
159
|
-
|
|
160
|
-
`NeoEvent` 类提供更新动作的方法:
|
|
161
|
-
|
|
162
|
-
```typescript:40:64:packages/neo-ui-designer-common/src/marionette/event.fx/event.ts
|
|
163
|
-
// 增加 action
|
|
164
|
-
addAction = (action: NeoAction) => {
|
|
165
|
-
this.actions.push(action);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
// 删除 action
|
|
169
|
-
delAction = (id) => {
|
|
170
|
-
this.actions.splice(
|
|
171
|
-
this.actions.findIndex((ac) => ac.id === id),
|
|
172
|
-
1
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
// 更新 action
|
|
177
|
-
updateAction = (action) => {
|
|
178
|
-
this.actions = this.actions.map((ac) => {
|
|
179
|
-
if (ac.id === action.id) {
|
|
180
|
-
return action;
|
|
181
|
-
}
|
|
182
|
-
return ac;
|
|
183
|
-
});
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
setActions = (acs) => {
|
|
187
|
-
this.actions = acs;
|
|
188
|
-
};
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### 6. 保存到 cmpExt
|
|
192
|
-
|
|
193
|
-
**文件**: `packages/neo-ui-designer-common/src/marionette/event.fx/index.ts`
|
|
194
|
-
|
|
195
|
-
当需要保存布局时,调用 `getEventsDataNet()` 方法将内存中的事件实例转换为接口格式:
|
|
196
|
-
|
|
197
|
-
```typescript:232:303:packages/neo-ui-designer-common/src/marionette/event.fx/index.ts
|
|
198
|
-
getEventsDataNet = () => {
|
|
199
|
-
const store = (window as any).$designer.rootCom.$store;
|
|
200
|
-
|
|
201
|
-
// 1. 获取服务端已经保存的 events
|
|
202
|
-
const _frontendExt = store.frontendExt;
|
|
203
|
-
const cmpExt = _frontendExt?.cmpExt ? [..._frontendExt.cmpExt] : [];
|
|
204
|
-
const layoutExt = _frontendExt?.layoutExt ? [..._frontendExt.layoutExt] : [];
|
|
205
|
-
|
|
206
|
-
// 2. 将此次布局编辑中新增的事件,合并到服务端数据中
|
|
207
|
-
for (const evt of this.events) {
|
|
208
|
-
// 根据事件类型决定保存到 cmpExt 还是 layoutExt
|
|
209
|
-
let eventList = [];
|
|
210
|
-
if (evt.isCmpEvent) {
|
|
211
|
-
eventList = cmpExt; // 组件事件保存到 cmpExt
|
|
212
|
-
} else {
|
|
213
|
-
eventList = layoutExt; // 布局事件保存到 layoutExt
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (eventList) {
|
|
217
|
-
// 查找此事件是否已存在
|
|
218
|
-
const index = eventList.findIndex(
|
|
219
|
-
(acc) =>
|
|
220
|
-
evt.cmpKeyIdentifier === acc.cmpKeyIdentifier &&
|
|
221
|
-
evt.apiKey === acc.apiKey
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
// 如果删除了所有 actions,则删除事件
|
|
225
|
-
if (evt.actions.length === 0) {
|
|
226
|
-
if (index !== -1) {
|
|
227
|
-
eventList.splice(index, 1);
|
|
228
|
-
}
|
|
229
|
-
} else {
|
|
230
|
-
// 更新或添加事件
|
|
231
|
-
if (index !== -1) {
|
|
232
|
-
eventList[index] = evt._json(); // 覆盖已存在的事件
|
|
233
|
-
} else {
|
|
234
|
-
eventList.push(evt._json()); // 添加新事件
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return {
|
|
241
|
-
cmpExt: cmpExt.filter((cmp) =>
|
|
242
|
-
NeoApp.getComByKId(`${cmp.cmpKeyIdentifier}`)
|
|
243
|
-
),
|
|
244
|
-
layoutExt: layoutExt.filter((lay) =>
|
|
245
|
-
NeoApp.getComByKId(`${lay.cmpKeyIdentifier}`)
|
|
246
|
-
),
|
|
247
|
-
};
|
|
248
|
-
};
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
**关键点**:
|
|
252
|
-
- `evt.isCmpEvent` 判断事件类型:`eventCategory === 2` 为组件事件,保存到 `cmpExt`
|
|
253
|
-
- `evt._json()` 方法将事件实例序列化为 JSON 格式,只包含必要字段:
|
|
254
|
-
```typescript
|
|
255
|
-
_json = () => {
|
|
256
|
-
return pick({ ...this, actions: this.getActions() }, [
|
|
257
|
-
'cmpKeyIdentifier',
|
|
258
|
-
'apiKey',
|
|
259
|
-
'actions',
|
|
260
|
-
]);
|
|
261
|
-
};
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### 7. 序列化保存
|
|
265
|
-
|
|
266
|
-
**文件**: `packages/neo-ui-designer-common/src/designer/basic.layout.designer.ts`
|
|
267
|
-
|
|
268
|
-
设计器在保存布局时调用 `getSerializeData()`:
|
|
269
|
-
|
|
270
|
-
```typescript:460:476:packages/neo-ui-designer-common/src/designer/basic.layout.designer.ts
|
|
271
|
-
getSerializeData(): any {
|
|
272
|
-
const layoutRoot = this.rootCom.querySelector(':neoLayoutRoot');
|
|
273
|
-
const schema = layoutRoot.$serialize();
|
|
274
|
-
|
|
275
|
-
const rst = {
|
|
276
|
-
layoutInfo: this.layoutInfo,
|
|
277
|
-
layoutCanvas: {
|
|
278
|
-
cmp: schema,
|
|
279
|
-
frontendExt: FxAndEvent.getEventsDataNet(), // 获取事件数据
|
|
280
|
-
},
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
return rst;
|
|
284
|
-
}
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
## 数据流向图
|
|
288
|
-
|
|
289
|
-
```
|
|
290
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
291
|
-
│ 用户操作:在事件配置面板中添加动作 │
|
|
292
|
-
└────────────────────┬────────────────────────────────────────┘
|
|
293
|
-
│
|
|
294
|
-
▼
|
|
295
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
296
|
-
│ Event 组件 │
|
|
297
|
-
│ - FxAndEvent.createEvent(event) 创建/获取事件实例 │
|
|
298
|
-
│ - setActions(actions) 更新事件实例的 actions 数组 │
|
|
299
|
-
└────────────────────┬────────────────────────────────────────┘
|
|
300
|
-
│
|
|
301
|
-
▼
|
|
302
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
303
|
-
│ __FxAndEvent__ 类 │
|
|
304
|
-
│ - events: NeoEvent[] 存储所有事件实例 │
|
|
305
|
-
│ - createEvent() 创建事件实例 │
|
|
306
|
-
│ - createAction() 创建动作实例 │
|
|
307
|
-
└────────────────────┬────────────────────────────────────────┘
|
|
308
|
-
│
|
|
309
|
-
▼
|
|
310
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
311
|
-
│ NeoEvent 类 │
|
|
312
|
-
│ - actions: NeoAction[] 存储动作列表 │
|
|
313
|
-
│ - setActions() 更新动作列表 │
|
|
314
|
-
│ - _json() 序列化为接口格式 │
|
|
315
|
-
└────────────────────┬────────────────────────────────────────┘
|
|
316
|
-
│
|
|
317
|
-
▼
|
|
318
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
319
|
-
│ getEventsDataNet() 方法 │
|
|
320
|
-
│ - 遍历 events 数组 │
|
|
321
|
-
│ - 根据 isCmpEvent 判断保存到 cmpExt 或 layoutExt │
|
|
322
|
-
│ - 调用 evt._json() 序列化 │
|
|
323
|
-
└────────────────────┬────────────────────────────────────────┘
|
|
324
|
-
│
|
|
325
|
-
▼
|
|
326
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
327
|
-
│ getSerializeData() 方法 │
|
|
328
|
-
│ - 调用 FxAndEvent.getEventsDataNet() │
|
|
329
|
-
│ - 返回包含 frontendExt 的序列化数据 │
|
|
330
|
-
└────────────────────┬────────────────────────────────────────┘
|
|
331
|
-
│
|
|
332
|
-
▼
|
|
333
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
334
|
-
│ 保存到后端 │
|
|
335
|
-
│ - frontendExt.cmpExt 包含组件事件配置 │
|
|
336
|
-
│ - frontendExt.layoutExt 包含布局事件配置 │
|
|
337
|
-
└─────────────────────────────────────────────────────────────┘
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
## 关键数据结构
|
|
341
|
-
|
|
342
|
-
### 事件实例 (NeoEvent)
|
|
343
|
-
```typescript
|
|
344
|
-
{
|
|
345
|
-
id: string;
|
|
346
|
-
label: string;
|
|
347
|
-
apiKey: string; // 事件标识
|
|
348
|
-
eventCategory: number; // 2=组件事件, 其他=布局事件
|
|
349
|
-
cmpKeyIdentifier: string; // 组件标识
|
|
350
|
-
actions: NeoAction[]; // 动作列表
|
|
351
|
-
}
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
### 动作实例 (NeoAction)
|
|
355
|
-
```typescript
|
|
356
|
-
{
|
|
357
|
-
id: string;
|
|
358
|
-
label: string;
|
|
359
|
-
execMode: number; // 执行模式:1=总是执行, 2=条件执行
|
|
360
|
-
actionType: number; // 动作类型:1=执行函数, 2=赋值
|
|
361
|
-
assignment: Array<...>; // 赋值规则(当 actionType=2 时)
|
|
362
|
-
condition: string; // 执行条件(当 execMode=2 时)
|
|
363
|
-
function: {...}; // 函数配置(当 actionType=1 时)
|
|
364
|
-
}
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
### cmpExt 中的事件数据格式
|
|
368
|
-
```typescript
|
|
369
|
-
{
|
|
370
|
-
cmpKeyIdentifier: string; // 组件标识
|
|
371
|
-
apiKey: string; // 事件标识
|
|
372
|
-
actions: Array<{ // 动作列表(已序列化)
|
|
373
|
-
id: string;
|
|
374
|
-
label: string;
|
|
375
|
-
execMode: number;
|
|
376
|
-
actionType: number;
|
|
377
|
-
// ... 其他动作属性
|
|
378
|
-
}>;
|
|
379
|
-
}
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
## 总结
|
|
383
|
-
|
|
384
|
-
1. **内存管理**: 事件实例存储在 `FxAndEvent.events` 数组中,只在编辑会话期间存在
|
|
385
|
-
2. **实时更新**: 用户添加/修改/删除动作时,立即更新内存中的事件实例
|
|
386
|
-
3. **延迟保存**: 只有在保存布局时,才调用 `getEventsDataNet()` 将内存数据写入 `cmpExt`
|
|
387
|
-
4. **类型区分**: 根据 `eventCategory` 判断是组件事件(保存到 `cmpExt`)还是布局事件(保存到 `layoutExt`)
|
|
388
|
-
5. **数据合并**: `getEventsDataNet()` 会将内存中的事件与已保存的事件合并,更新或新增
|
|
389
|
-
|
|
390
|
-
|