weaver-e10-builder 1.0.11-beta → 1.0.12-beta
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/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +13 -0
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/form-list-permission.d.ts.map +1 -1
- package/dist/commands/form-list-permission.js +130 -15
- package/dist/commands/form-list-permission.js.map +1 -1
- package/dist/commands/form-nlist.d.ts +22 -0
- package/dist/commands/form-nlist.d.ts.map +1 -0
- package/dist/commands/form-nlist.js +179 -0
- package/dist/commands/form-nlist.js.map +1 -0
- package/dist/commands/form-serial-mark.d.ts +0 -15
- package/dist/commands/form-serial-mark.d.ts.map +1 -1
- package/dist/commands/form-serial-mark.js +604 -137
- package/dist/commands/form-serial-mark.js.map +1 -1
- package/dist/commands/form.d.ts.map +1 -1
- package/dist/commands/form.js +91 -0
- package/dist/commands/form.js.map +1 -1
- package/dist/commands/skill.d.ts +3 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +112 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/workflow-condition.d.ts.map +1 -1
- package/dist/commands/workflow-condition.js +3 -1
- package/dist/commands/workflow-condition.js.map +1 -1
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +11 -7
- package/dist/commands/workflow.js.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/services/condition-rules.d.ts.map +1 -1
- package/dist/services/condition-rules.js +3 -1
- package/dist/services/condition-rules.js.map +1 -1
- package/dist/services/form-create.d.ts.map +1 -1
- package/dist/services/form-create.js +4 -1
- package/dist/services/form-create.js.map +1 -1
- package/dist/services/form-nlist.d.ts +42 -0
- package/dist/services/form-nlist.d.ts.map +1 -0
- package/dist/services/form-nlist.js +332 -0
- package/dist/services/form-nlist.js.map +1 -0
- package/dist/services/skill-provision.d.ts +18 -0
- package/dist/services/skill-provision.d.ts.map +1 -0
- package/dist/services/skill-provision.js +86 -0
- package/dist/services/skill-provision.js.map +1 -0
- package/dist/services/workflow-initiator.js +3 -3
- package/dist/services/workflow-initiator.js.map +1 -1
- package/package.json +4 -2
- package/skill-docs/SKILL.md +348 -0
- package/skill-docs/actionflows/references/components/calendar/MeetingCreate.md +17 -0
- package/skill-docs/actionflows/references/components/calendar/ScheduleCreate.md +17 -0
- package/skill-docs/actionflows/references/components/document/AttachmentCopy.md +17 -0
- package/skill-docs/actionflows/references/components/document/AttachmentMove.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentCopy.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentDelete.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentEdit.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentMove.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentPermissionChange.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentRenewal.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentRevert.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentSave.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentSubscription.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentSubscriptionApprove.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentSubscriptionSendBack.md +17 -0
- package/skill-docs/actionflows/references/components/document/DocumentSubscriptionWithdraw.md +17 -0
- package/skill-docs/actionflows/references/components/document/FileFolderSave.md +17 -0
- package/skill-docs/actionflows/references/components/document/GetAttachmentInfo.md +17 -0
- package/skill-docs/actionflows/references/components/document/GetDocumentInfo.md +17 -0
- package/skill-docs/actionflows/references/components/document/ModifyDocumentStatus.md +17 -0
- package/skill-docs/actionflows/references/components/document/ReplaceAttachment.md +17 -0
- package/skill-docs/actionflows/references/components/document/UpdatePrintNum.md +17 -0
- package/skill-docs/actionflows/references/components/ebuilder/ActionEbAdd.md +39 -0
- package/skill-docs/actionflows/references/components/ebuilder/ActionEbDelete.md +21 -0
- package/skill-docs/actionflows/references/components/ebuilder/ActionEbRecover.md +17 -0
- package/skill-docs/actionflows/references/components/ebuilder/ActionEbSaveVersion.md +17 -0
- package/skill-docs/actionflows/references/components/ebuilder/ActionEbUpdate.md +21 -0
- package/skill-docs/actionflows/references/components/ebuilder/DateTrigger.md +17 -0
- package/skill-docs/actionflows/references/components/ebuilder/EbGetDataById.md +17 -0
- package/skill-docs/actionflows/references/components/ebuilder/EnquiryForm.md +75 -0
- package/skill-docs/actionflows/references/components/ebuilder/EventFormData.md +17 -0
- package/skill-docs/actionflows/references/components/ebuilder/TimeBatchTrigger.md +17 -0
- package/skill-docs/actionflows/references/components/logic/Condition.md +23 -0
- package/skill-docs/actionflows/references/components/logic/LogicFlowSet.md +17 -0
- package/skill-docs/actionflows/references/components/logic/MultipleExecution.md +38 -0
- package/skill-docs/actionflows/references/components/logic/Output.md +17 -0
- package/skill-docs/actionflows/references/components/message/SendMessage.md +17 -0
- package/skill-docs/actionflows/references/components/personnel/AlterPersonStatus.md +30 -0
- package/skill-docs/actionflows/references/components/personnel/HrmEmployeeUpdate.md +32 -0
- package/skill-docs/actionflows/references/components/personnel/PersonnelOnboarding.md +34 -0
- package/skill-docs/actionflows/references/components/trigger/SimpleScheduler.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveAddSign.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveAgreeRejectApply.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveCommit.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveCompletelyDelete.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveConsulTurnTodo.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveCreate.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveDelete.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveDoCirculate.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveDoForward.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveDoTurnTodo.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveEntrust.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveIntervention.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveMandatoryArchiving.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveManualCC.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveRefuseRejectApply.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveRejectApply.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveSave.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveSendBack.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveShareEntry.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveTrigger.md +49 -0
- package/skill-docs/actionflows/references/components/workflow/ApproveWithdraw.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/WorkFlowDocEmpowerment.md +17 -0
- package/skill-docs/actionflows/references/components/workflow/WorkflowToDoc.md +17 -0
- package/skill-docs/actionflows/references/condition_rules.md +97 -0
- package/skill-docs/actionflows/references/examples/enquiry-form-batch-insert-scene2.json +1046 -0
- package/skill-docs/actionflows/references/function_rules.md +13 -0
- package/skill-docs/actionflows/references/trigger_runtime_notes.md +51 -0
- package/skill-docs/assets/sample/.claude/settings.local.json +8 -0
- package/skill-docs/assets/sample/api/formApi.js +510 -0
- package/skill-docs/assets/sample/config/config.js +0 -0
- package/skill-docs/assets/sample/config/configLoad.js +0 -0
- package/skill-docs/assets/sample/config/configLoad_default.js +0 -0
- package/skill-docs/assets/sample/config/config_default.js +0 -0
- package/skill-docs/assets/sample/entry.js +22 -0
- package/skill-docs/assets/sample/eslint.config.cjs +48 -0
- package/skill-docs/assets/sample/memo.md +0 -0
- package/skill-docs/assets/sample/readme.js +8 -0
- package/skill-docs/references/auth/guide-auth.md +88 -0
- package/skill-docs/references/coding/guide-edit-backfill.md +189 -0
- package/skill-docs/references/coding/guide-form-crud.md +262 -0
- package/skill-docs/references/coding/guide-page-code.md +224 -0
- package/skill-docs/references/coding/guide-page-export.md +119 -0
- package/skill-docs/references/coding/ref-compile-rules.md +106 -0
- package/skill-docs/references/common/ref-cli-commands.md +286 -0
- package/skill-docs/references/components/@weapp-Button.md +104 -0
- package/skill-docs/references/components/base-Badge.md +100 -0
- package/skill-docs/references/components/base-Dialog.md +358 -0
- package/skill-docs/references/components/base-Empty.md +58 -0
- package/skill-docs/references/components/base-Tag.md +112 -0
- package/skill-docs/references/components/display-Alert.md +64 -0
- package/skill-docs/references/components/display-Avatar.md +150 -0
- package/skill-docs/references/components/display-Calendar.md +263 -0
- package/skill-docs/references/components/display-Carousel.md +115 -0
- package/skill-docs/references/components/display-Collapse.md +299 -0
- package/skill-docs/references/components/display-FilePreview.md +49 -0
- package/skill-docs/references/components/display-Icon.md +66 -0
- package/skill-docs/references/components/display-List.md +320 -0
- package/skill-docs/references/components/display-Pagination.md +41 -0
- package/skill-docs/references/components/display-Spin.md +34 -0
- package/skill-docs/references/components/display-Steps.md +89 -0
- package/skill-docs/references/components/display-Table.md +160 -0
- package/skill-docs/references/components/display-Title.md +117 -0
- package/skill-docs/references/components/form-Checkbox.md +161 -0
- package/skill-docs/references/components/form-DepartmentBrowser-api.md +52 -0
- package/skill-docs/references/components/form-EmployeeBrowser-api.md +51 -0
- package/skill-docs/references/components/form-EmployeeBrowser.md +51 -0
- package/skill-docs/references/components/form-Input.md +123 -0
- package/skill-docs/references/components/form-Radio.md +145 -0
- package/skill-docs/references/components/form-Select.md +191 -0
- package/skill-docs/references/components/form-Switch.md +46 -0
- package/skill-docs/references/components/form-Upload.md +53 -0
- package/skill-docs/references/components/generic-Echarts.md +102 -0
- package/skill-docs/references/form/guide-create-form.md +407 -0
- package/skill-docs/references/form/guide-ebuilder-filter.md +73 -0
- package/skill-docs/references/form/guide-ebuilder-scope.md +82 -0
- package/skill-docs/references/form/guide-form-data.md +48 -0
- package/skill-docs/references/form/guide-form-formula-functions.md +297 -0
- package/skill-docs/references/form/guide-form-linkage.md +185 -0
- package/skill-docs/references/form/guide-form-view-permission.md +38 -0
- package/skill-docs/references/form/guide-form-view.md +267 -0
- package/skill-docs/references/form/style-templates.md +44 -0
- package/skill-docs/references/hrm/guide-matrix.md +103 -0
- package/skill-docs/references/menu/system-menus.md +63 -0
- package/skill-docs/references/workflow/guide-workflow-action.md +168 -0
- package/skill-docs/references/workflow/guide-workflow-condition.md +405 -0
- package/skill-docs/references/workflow/guide-workflow.md +388 -0
- package/skill-docs/references/workflow/operator-matrix.md +74 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# 页面编码指南
|
|
2
|
+
|
|
3
|
+
> 本文件为 SKILL.md 的子模块,在需要写页面代码时加载。
|
|
4
|
+
> 页面是搭建流程的最后一步,写代码前确保应用、表单、流程都已建好。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 项目结构(从sample拷贝过来)
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
├── entry.js ← 路由注册入口
|
|
12
|
+
├── pages/ ← 页面组件
|
|
13
|
+
├── api/
|
|
14
|
+
│ └── formApi.js ← 表单数据 API
|
|
15
|
+
└── config/ ← 配置文件(不用管)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- entry.js 只完成入口注册,不要写入业务逻辑。
|
|
19
|
+
- formApi.js 默认自带。
|
|
20
|
+
- 该项目只能在泛微云运行,其他环境缺少依赖都会报错。
|
|
21
|
+
- 只能支持 js 编码,**不支持 jsx 或 ts**。
|
|
22
|
+
- 尽量使用原生 React 编码。
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## entry.js 路由注册模板(严格照抄)
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import { Route } from 'react-router-dom';
|
|
31
|
+
import { regOvProps, appInfo, regReactChildren } from '@weapp/utils';
|
|
32
|
+
import { asyncImport } from '@weapp/ecodesdk';
|
|
33
|
+
|
|
34
|
+
var { publicUrl } = appInfo('@weapp/ecodesdk');
|
|
35
|
+
|
|
36
|
+
// 1. 异步引入页面组件 — asyncImport 第一个参数固定为 '${appId}',不允许留空
|
|
37
|
+
var MyPage = React.lazy(function () {
|
|
38
|
+
return asyncImport('${appId}', 'pages/MyPage');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// 2. 路由 path 写死字符串,
|
|
42
|
+
var ROUTE_PATH = '/sp/custom/ecode/my-page';
|
|
43
|
+
|
|
44
|
+
var extract = (
|
|
45
|
+
<Route path={publicUrl + ROUTE_PATH}>
|
|
46
|
+
<React.Suspense fallback={<div>Loading...</div>}>
|
|
47
|
+
<MyPage />
|
|
48
|
+
</React.Suspense>
|
|
49
|
+
</Route>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
regOvProps('weappEcodesdk', 'Switch', function (props) {
|
|
53
|
+
regReactChildren(props, extract);
|
|
54
|
+
return props;
|
|
55
|
+
}, 0);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**铁律**:
|
|
59
|
+
- `asyncImport('${appId}', 'pages/xxx')` — 第一个参数**固定**是 `'${appId}'`,不能写空字符串、不能写别的值
|
|
60
|
+
- `React.Suspense` **只包裹一层**,不要双层嵌套
|
|
61
|
+
- 路由 path 写死字符串(如 `/sp/custom/ecode/my-page`),**不拼接 `${appId}` 变量**
|
|
62
|
+
|
|
63
|
+
**一个项目可以包含多个页面**,在 entry.js 中按同样模式注册:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
var MeetingList = React.lazy(function () {
|
|
67
|
+
return asyncImport('${appId}', 'pages/MeetingList');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var MeetingForm = React.lazy(function () {
|
|
71
|
+
return asyncImport('${appId}', 'pages/MeetingForm');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
var extract = (
|
|
75
|
+
<>
|
|
76
|
+
<Route path={publicUrl + '/sp/custom/ecode/meeting-list'}>
|
|
77
|
+
<React.Suspense fallback={<div>Loading...</div>}>
|
|
78
|
+
<MeetingList />
|
|
79
|
+
</React.Suspense>
|
|
80
|
+
</Route>
|
|
81
|
+
<Route path={publicUrl + '/sp/custom/ecode/meeting-form'}>
|
|
82
|
+
<React.Suspense fallback={<div>Loading...</div>}>
|
|
83
|
+
<MeetingForm />
|
|
84
|
+
</React.Suspense>
|
|
85
|
+
</Route>
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
> 新页面导出和路由注册详见 `references/coding/guide-page-export.md`
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 引用规则
|
|
95
|
+
|
|
96
|
+
- **前置加载文件(entry.js)**可以直接 import:`import { getSimpleData } from './api/formApi.js'`
|
|
97
|
+
- **非前置加载文件(pages/ 下的所有文件)**只能通过 `React.lazy(() => asyncImport('${appId}', 'pages/xxx'))` 引用
|
|
98
|
+
- entry.js 中只能使用 `React`、`ReactDOM`、`@weapp/utils`、`@weapp/ecodesdk`、`axios`,**不能使用 `@weapp/ui` 组件**
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## @weapp/ui 可用组件清单
|
|
103
|
+
|
|
104
|
+
**只能使用以下明确列出的组件**,不要从 `@weapp/ui` 里编造任何不在此列表中的组件名。
|
|
105
|
+
|
|
106
|
+
| 组件 | import 方式 | 参考文档 |
|
|
107
|
+
|------|-----------|---------|
|
|
108
|
+
| Table | `import { Table } from '@weapp/ui'` | `references/components/display-Table.md` |
|
|
109
|
+
| Avatar | `import { Avatar } from '@weapp/ui'` | `references/components/display-Avatar.md` |
|
|
110
|
+
| List | `import { List } from '@weapp/ui'` | `references/components/display-List.md` |
|
|
111
|
+
| Pagination | `import { Pagination } from '@weapp/ui'` | `references/components/display-Pagination.md` |
|
|
112
|
+
| Icon | `import { Icon } from '@weapp/ui'` | `references/components/display-Icon.md` |
|
|
113
|
+
| Button | `import { Button } from '@weapp/ui'` | `references/components/@weapp-Button.md` |
|
|
114
|
+
| EChart | `import { EChart } from '@weapp/ui'` | `references/components/generic-Echarts.md` |
|
|
115
|
+
| CorsComponent | `import { CorsComponent } from '@weapp/ui'` | `references/components/display-FilePreview.md` |
|
|
116
|
+
| Browser(人员) | `import { Browser } from '@weapp/ui'`<br>`type="resource"` | `references/components/form-EmployeeBrowser-api.md` |
|
|
117
|
+
| Browser(部门) | `import { Browser } from '@weapp/ui'`<br>`type="department"` | `references/components/form-DepartmentBrowser-api.md` |
|
|
118
|
+
| Upload | `import { Upload } from '@weapp/ui'` | `references/components/form-Upload.md` |
|
|
119
|
+
| Badge | `import { Badge } from '@weapp/ui'` | `references/components/base-Badge.md` |
|
|
120
|
+
| Tag | `import { Tag } from '@weapp/ui'` | `references/components/base-Tag.md` |
|
|
121
|
+
|
|
122
|
+
表单输入控件(文本框、下拉框、日期选择等)用原生 HTML:
|
|
123
|
+
```js
|
|
124
|
+
<input type="text" value={form[F.name]} onChange={...} />
|
|
125
|
+
<input type="date" value={form[F.date]} onChange={...} />
|
|
126
|
+
<select value={form[F.status]} onChange={...}>
|
|
127
|
+
{options.map(function (opt) {
|
|
128
|
+
return <option key={opt.valueKey} value={opt.valueKey}>{opt.name}</option>;
|
|
129
|
+
})}
|
|
130
|
+
</select>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 表单数据操作(核心模式)
|
|
136
|
+
|
|
137
|
+
**四个 API 各有分工,不要混用:**
|
|
138
|
+
|
|
139
|
+
| API | 用途 | 返回内容 |
|
|
140
|
+
|-----|------|---------|
|
|
141
|
+
| `getSimpleData(objId, userId)` | 读 ID、写回 formToSave | 所有特殊字段统一返回 `fieldOptionId`(纯数字串) |
|
|
142
|
+
| `getAllData(objId, userId)` | 提取名称、编辑回显 | 含 `fieldOptionName`,mainTable key 是随机哈希 |
|
|
143
|
+
| `withDisplayNames(rows, map)` | 表格展示:ID → 名称 | 把 Select 的 `valueKey` 映射为中文名 |
|
|
144
|
+
| `getFieldOptions(fieldId, objId)` | 拿下拉选项 | `[{valueKey, name}]` |
|
|
145
|
+
|
|
146
|
+
**不同字段类型,名称来源不同(写在墙上):**
|
|
147
|
+
|
|
148
|
+
| 字段类型 | getSimpleData 返回 | 展示时名称来源 |
|
|
149
|
+
|---------|-------------------|--------------|
|
|
150
|
+
| Text / Number / Date | `"值"` / `123` / `"2026-01-01"` | 直接展示 |
|
|
151
|
+
| Select / RadioBox / CheckBox | `"1283421826353889337"`(选项 ID) | `getFieldOptions` → `withDisplayNames` 映射 |
|
|
152
|
+
| **Employee** | `"2765550234448235905"`(用户 ID) | `getAllData` 的 `fieldOptionName`,**不是** getFieldOptions |
|
|
153
|
+
| **Department** | `"2765550234448235905"`(部门 ID) | 同上 |
|
|
154
|
+
| FileComponent | `"fileid1,fileid2"`(文件 ID 串) | 上传组件的 `name` |
|
|
155
|
+
|
|
156
|
+
**表格页面标准加载模式:**
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
var [data, setData] = useState([]);
|
|
160
|
+
|
|
161
|
+
useEffect(function () {
|
|
162
|
+
Promise.all([
|
|
163
|
+
getSimpleData(OBJ_ID, USER_ID),
|
|
164
|
+
getFieldOptions(F.status, OBJ_ID), // Select 字段拿选项
|
|
165
|
+
]).then(function ([rows, statusOpts]) {
|
|
166
|
+
// 加载时为每个需要展示名称的 Select/Employee 字段做映射
|
|
167
|
+
// Employee/Department 的名称要另外从 getAllData 提取!
|
|
168
|
+
var displayRows = withDisplayNames(rows, {
|
|
169
|
+
[F.status]: statusOpts,
|
|
170
|
+
});
|
|
171
|
+
// Employee 字段需要额外用 getAllData 构建 ID→名称 map
|
|
172
|
+
setData(displayRows);
|
|
173
|
+
});
|
|
174
|
+
}, []);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**写入 / 更新:**
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
// form 中所有值已经是 ID,直接拼入 formToSave
|
|
181
|
+
var formToSave = {};
|
|
182
|
+
Object.keys(form).forEach(function (key) {
|
|
183
|
+
if (form[key] !== '' && form[key] !== null && form[key] !== undefined) {
|
|
184
|
+
formToSave[key] = form[key];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
// 选择器新值覆盖
|
|
188
|
+
if (selectedPerson.length > 0) formToSave[F.person] = selectedPerson[0].id;
|
|
189
|
+
|
|
190
|
+
if (editingId) {
|
|
191
|
+
updateFormData(OBJ_ID, formToSave, editingId, USER_ID);
|
|
192
|
+
} else {
|
|
193
|
+
saveFormData(OBJ_ID, formToSave, USER_ID);
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
> 完整的数据读写指南见 `references/coding/guide-form-crud.md`,编辑回显见 `references/coding/guide-edit-backfill.md`(前端代码)。
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 编译规则(简要)
|
|
202
|
+
|
|
203
|
+
- `ecodecmd build {project-dir} --target=e10` 打包(cd 到项目前一级)
|
|
204
|
+
- 所有变量用 `var` 声明
|
|
205
|
+
- 不支持的语法:`catch{}` 无参数 catch、`??`、`import()` 动态导入、`BigInt`
|
|
206
|
+
- 详见 `references/coding/ref-compile-rules.md`(编译配置)、`references/coding/guide-page-export.md`(引用规范)
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## 代码质量检查清单
|
|
211
|
+
|
|
212
|
+
生成代码后逐项检查:
|
|
213
|
+
|
|
214
|
+
1. [ ] 变量用 `var` 声明,非 `const`/`let`
|
|
215
|
+
2. [ ] 非前置加载文件引用使用 `React.lazy(() => asyncImport(...))`
|
|
216
|
+
3. [ ] **表格中没有任何裸 ID 展示**:Employee/Department 用 `fieldOptionName`,Select 用 `withDisplayNames`,用户看到的必须是中文名称
|
|
217
|
+
4. [ ] `getSimpleData` 返回值直接 `item[字段ID]`,没有 `_raw` 层
|
|
218
|
+
5. [ ] Select 字段读写统一用选项 ID(`valueKey`),不是显示名称
|
|
219
|
+
6. [ ] React state 不直接修改,创建新对象 `var newForm = {}; Object.keys(form).forEach(...)`
|
|
220
|
+
7. [ ] entry.js 不引入 `@weapp/ui` 组件
|
|
221
|
+
8. [ ] 没有 `forEach/map/filter(fn, this)` 传 context 的写法,用 `var self = this;` 替代
|
|
222
|
+
9. [ ] 表单数据 key 用字段 ID(纯数字字符串),对照 `form read --out fields.json`
|
|
223
|
+
10. [ ] Employee/Department 字段写入前已转为 ID
|
|
224
|
+
11. [ ] 写完代码后运行 `e10-cli check <项目目录>` 逐条自检
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# 页面导出与路由注册指南
|
|
2
|
+
|
|
3
|
+
## 引用规范
|
|
4
|
+
|
|
5
|
+
### 前置加载文件(entry.js)
|
|
6
|
+
|
|
7
|
+
只有前置加载的文件才可以直接 import:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { getSimpleData } from './api/formApi.js'; // entry.js 中可以直接引用
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- entry.js 中只能使用 `React`、`ReactDOM`、`@weapp/utils`、`@weapp/ecodesdk`、`axios`
|
|
14
|
+
- **不能使用 `@weapp/ui` 组件**
|
|
15
|
+
- entry 只完成入口的注册,不要写入业务逻辑
|
|
16
|
+
|
|
17
|
+
### 非前置加载文件(pages/ 目录)
|
|
18
|
+
|
|
19
|
+
**非常关键!!!** 非前置加载的文件(新增的所有文件),只能通过以下方式引用:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { asyncImport } from '@weapp/ecodesdk';
|
|
23
|
+
const AgentSxxx = React.lazy(() => asyncImport('${appId}', 'pages/AgentSxxx'));
|
|
24
|
+
// '${appId}' 是固定写法,是内置的ecode应用ID,不用管
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
引用路径要根据文件相对位置判断:
|
|
28
|
+
- entry.js 中引用 `api/formApi.js`:`'./api/formApi.js'`
|
|
29
|
+
- pages/ 目录下引用 `api/formApi.js`:`'../api/formApi.js'`
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 页面导出(路由注册)
|
|
34
|
+
|
|
35
|
+
在 `entry.js` 中通过 `regOvProps` + `regReactChildren` 注册路由:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { regOvProps, appInfo, regReactChildren } from '@weapp/utils';
|
|
39
|
+
const { publicUrl } = appInfo('@weapp/ecodesdk');
|
|
40
|
+
const extract = (
|
|
41
|
+
<Route path={`${publicUrl}/sp/custom/abc123123/abc123`}> // 导出页面的具体路径
|
|
42
|
+
<React.Suspense fallback={<div>Loading...</div>}>
|
|
43
|
+
<Test /> // 导出页面的组件
|
|
44
|
+
</React.Suspense>
|
|
45
|
+
</Route>
|
|
46
|
+
);
|
|
47
|
+
regOvProps('weappEcodesdk', 'Switch', (props) => {
|
|
48
|
+
regReactChildren(props, extract);
|
|
49
|
+
return props;
|
|
50
|
+
}, 0);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 路由规范
|
|
56
|
+
|
|
57
|
+
> **核心规则:entry.js 中的路由 path 不要拼接变量,直接写死字符串。**
|
|
58
|
+
|
|
59
|
+
| 端 | 路由前缀 |
|
|
60
|
+
|----|---------|
|
|
61
|
+
| PC 端 | `/sp/custom/...` |
|
|
62
|
+
| 移动端 | `/mobile/custom/...` |
|
|
63
|
+
|
|
64
|
+
- path 写固定字符串,如 `/sp/custom/ecode/onboarding`,不拼接 `${appId}`
|
|
65
|
+
- 使用 `appInfo('@weapp/ecodesdk').publicUrl` 处理二级路径兼容(`publicUrl` 本身已包含二级路径前缀)
|
|
66
|
+
- 页面跳转使用 `Link` 或 `withRouter` 的 `history.push`,需拼接 `publicUrl`
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## ecodInfo.json
|
|
71
|
+
|
|
72
|
+
项目根目录下的 `ecodInfo.json` 记录项目元信息:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"ecodeProjId": "",
|
|
77
|
+
"ecodeAppId": "",
|
|
78
|
+
"ebuilderAppId": "",
|
|
79
|
+
"mainUrl": ""
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- 如果文件不存在或内容为空,说明项目还未上传到 Ecode 平台
|
|
84
|
+
- **导入 Ecode 成功后,必须将主页面路径写入 `mainUrl` 字段**,格式如 `/sp/custom/......`,和 entry.js 里必须完全相同
|
|
85
|
+
- **如果当前 Ecode 项目关联了 Ebuilder 应用,必须将 Ebuilder 应用 ID 写入 `ebuilderAppId`**。注意:`ebuilderAppId` 是 Ebuilder 应用的 ID,与 `ecodeAppId`(Ecode 应用文件夹 ID)不同
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## entry.js 完整模板
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
import React from 'react';
|
|
93
|
+
import { regOvProps, appInfo, regReactChildren } from '@weapp/utils';
|
|
94
|
+
import { asyncImport } from '@weapp/ecodesdk';
|
|
95
|
+
|
|
96
|
+
const { publicUrl } = appInfo('@weapp/ecodesdk');
|
|
97
|
+
const appId = '${appId}';
|
|
98
|
+
|
|
99
|
+
// 异步引入页面组件
|
|
100
|
+
const MyPage = React.lazy(() => asyncImport('${appId}', 'pages/MyPage'));
|
|
101
|
+
|
|
102
|
+
// 注册路由 — path 写死固定字符串,和
|
|
103
|
+
var ROUTE_PATH = '/sp/custom/ecode/my-page';
|
|
104
|
+
const myRoute = (
|
|
105
|
+
<Route path={`${publicUrl}${ROUTE_PATH}`}>
|
|
106
|
+
<React.Suspense fallback={<div>Loading...</div>}>
|
|
107
|
+
<MyPage />
|
|
108
|
+
</React.Suspense>
|
|
109
|
+
</Route>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
regOvProps('weappEcodesdk', 'Switch', (props) => {
|
|
113
|
+
regReactChildren(props, myRoute);
|
|
114
|
+
return props;
|
|
115
|
+
}, 0);
|
|
116
|
+
```
|
|
117
|
+
> `ROUTE_PATH` 不要在这里拼接 `appId` 变量,`publicUrl` 已包含二级路径前缀。
|
|
118
|
+
|
|
119
|
+
> 完成后记得告诉用户哪些页面对应哪些 URL。
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# 编译规则参考
|
|
2
|
+
|
|
3
|
+
## 编译命令
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
ecodecmd build {project-dir} --target=e10
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
- 其中 `{project-dir}` 为代码项目的目录
|
|
10
|
+
- 打包会在项目产生一个 `.target` 文件夹,包含一个 `.zip` 文件
|
|
11
|
+
- **打包得 cd 到项目的前一级**,要不然传的目录里面没有名称
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 编译配置
|
|
16
|
+
|
|
17
|
+
ecodecmd 内部使用 `@babel/standalone` v7.5.5 编译代码,E10 模式下调用 `compileJsE10`。
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
presets: ['es2015', 'react', ['stage-2', {decoratorsLegacy: true, loose: true}]]
|
|
21
|
+
plugins: ['proposal-object-rest-spread', 'proposal-optional-chaining']
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 支持的语法
|
|
27
|
+
|
|
28
|
+
| 语法 | 示例 |
|
|
29
|
+
|------|------|
|
|
30
|
+
| JSX | `<div className="app">{content}</div>` |
|
|
31
|
+
| 箭头函数 | `(x) => x + 1` |
|
|
32
|
+
| async/await | `const data = await getSimpleData(...)` |
|
|
33
|
+
| 模板字符串 | `` `Hello ${name}` `` |
|
|
34
|
+
| 对象展开 `...` | `{ ...oldObj, newKey: val }` |
|
|
35
|
+
| 可选链 `?.` | `obj?.nested?.value` |
|
|
36
|
+
| Class 组件 | `class MyPage extends React.Component {}` |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Babel 编译陷阱(语法合法但编译后行为异常)
|
|
41
|
+
|
|
42
|
+
| 陷阱 | 说明 | 解决方案 |
|
|
43
|
+
|------|------|---------|
|
|
44
|
+
| `forEach(fn, this)` 传 context | `this` 在 Babel 编译后丢失,回调内的 `this` 变成 `undefined` | 提前 `var self = this;`,回调内用 `self` |
|
|
45
|
+
| `map/filter/find` 同样受影响 | 所有数组方法只要传了第二个参数 `this`,编译后都失效 | 一律用 `var self = this;` 模式 |
|
|
46
|
+
| 漏写 `var` 直接赋值 | `x = {}` 未经声明直接赋值,Babel 编译后严格模式报 `ReferenceError: x is not defined` | **所有变量必须先 `var x = ...` 再使用** |
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// ❌ Babel 编译后 this 丢失,setState 报错
|
|
50
|
+
data.forEach(function (item) {
|
|
51
|
+
this.setState({ ... });
|
|
52
|
+
}, this);
|
|
53
|
+
|
|
54
|
+
// ✅ 提前捕获 this
|
|
55
|
+
var self = this;
|
|
56
|
+
|
|
57
|
+
// ❌ 漏写 var,Babel 编译后报 ReferenceError
|
|
58
|
+
priorityColorCache = {};
|
|
59
|
+
priorityOpts.forEach(function(opt) { ... });
|
|
60
|
+
|
|
61
|
+
// ✅ 先声明再赋值
|
|
62
|
+
var priorityColorCache = {};
|
|
63
|
+
priorityOpts.forEach(function(opt) { ... });
|
|
64
|
+
data.forEach(function (item) {
|
|
65
|
+
self.setState({ ... });
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 不支持的语法(会编译报错)
|
|
72
|
+
|
|
73
|
+
| 语法 | 解决方案 |
|
|
74
|
+
|------|---------|
|
|
75
|
+
| `catch { }` 无参数 catch | 必须写成 `catch(e) {}` |
|
|
76
|
+
| `??` 空值合并运算符 | 用 `||` 或三元表达式替代 |
|
|
77
|
+
| `import()` 动态导入 | 必须用 `asyncImport` |
|
|
78
|
+
| `private class fields #` | 不用 class fields,用普通方法 |
|
|
79
|
+
| `globalThis` | 用 `window` |
|
|
80
|
+
| `BigInt` | 不用 |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 打包 & 上传流程
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# 1. 编译检查
|
|
88
|
+
e10-cli check <项目目录>
|
|
89
|
+
|
|
90
|
+
# 2. 打包(cd 到项目前一级)
|
|
91
|
+
cd /path/to/parent && ecodecmd build project-dir --target=e10
|
|
92
|
+
|
|
93
|
+
# 3. 上传(先删旧应用)
|
|
94
|
+
e10-cli project tree <projectId> # 找旧应用 folderId
|
|
95
|
+
e10-cli project delete-folder <folderId>
|
|
96
|
+
e10-cli project import <projectId> .target/xxx.zip --main-url /sp/custom/...
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 关键注意事项
|
|
102
|
+
|
|
103
|
+
1. **所有变量用 var 声明**,非前置加载文件引用确保使用 `React.lazy(() => asyncImport...)`
|
|
104
|
+
2. `${appId}` 是占位符,运行时由 ecode SDK 替换
|
|
105
|
+
3. 写完代码后运行 `e10-cli check <项目目录>` 逐条自检,全部确认通过后再 build
|
|
106
|
+
4. 本地修改后一定要及时 `ecodecmd build` + `import` 上传,否则用户无法验证(用户看不到本地代码)
|