neo-cmp-cli 1.2.11 → 1.2.13

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.
Files changed (30) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
  3. package/src/module/index.js +2 -2
  4. package/src/template/antd-custom-cmp-template/package.json +1 -1
  5. package/src/template/develop/neo-custom-cmp-template/package.json +1 -1
  6. package/src/template/echarts-custom-cmp-template/package.json +1 -1
  7. package/src/template/neo-custom-cmp-template/README.md +1 -1
  8. package/src/template/neo-custom-cmp-template/package.json +2 -2
  9. package/src/template/neo-custom-cmp-template/src/assets/img/detail.svg +1 -0
  10. package/src/template/neo-custom-cmp-template/src/components/contact-card-list/README.md +2 -7
  11. package/src/template/neo-custom-cmp-template/src/components/contact-card-list/index.tsx +13 -1
  12. package/src/template/neo-custom-cmp-template/src/components/contact-form/index.tsx +2 -3
  13. package/src/template/neo-custom-cmp-template/src/components/entity-detail/README.md +193 -0
  14. package/src/template/neo-custom-cmp-template/src/components/entity-detail/index.tsx +325 -0
  15. package/src/template/neo-custom-cmp-template/src/components/entity-detail/model.ts +125 -0
  16. package/src/template/neo-custom-cmp-template/src/components/entity-detail/style.scss +292 -0
  17. package/src/template/neo-custom-cmp-template/src/components/object-card-list/README.md +61 -0
  18. package/src/template/neo-custom-cmp-template/src/components/object-card-list/index.tsx +201 -0
  19. package/src/template/neo-custom-cmp-template/src/components/object-card-list/model.ts +66 -0
  20. package/src/template/neo-custom-cmp-template/src/components/object-card-list/style.scss +260 -0
  21. package/src/template/neo-custom-cmp-template/src/components/xobject-table/README.md +3 -11
  22. package/src/template/neo-custom-cmp-template/src/components/xobject-table/index.tsx +76 -58
  23. package/src/template/neo-custom-cmp-template/src/components/xobject-table/model.ts +21 -3
  24. package/src/template/react-custom-cmp-template/package.json +1 -1
  25. package/src/template/react-ts-custom-cmp-template/package.json +1 -1
  26. package/src/template/vue2-custom-cmp-template/package.json +1 -1
  27. package/src/template/neo-custom-cmp-template/src/components/xobject-table-v2/README.md +0 -108
  28. package/src/template/neo-custom-cmp-template/src/components/xobject-table-v2/index.tsx +0 -729
  29. package/src/template/neo-custom-cmp-template/src/components/xobject-table-v2/model.ts +0 -122
  30. package/src/template/neo-custom-cmp-template/src/components/xobject-table-v2/style.scss +0 -304
package/README.md CHANGED
@@ -34,16 +34,16 @@ neo init -t=react-ts
34
34
  3) 安装依赖并运行
35
35
  ```bash
36
36
  # 预览自定义组件内容
37
- npm run preview
37
+ neo preview
38
38
 
39
39
  # 外链调试(在平台线上预览与调试)
40
- npm run linkDebug
40
+ neo linkDebug
41
41
 
42
42
  # 构建库产物(默认输出到 dist)
43
- npm run build2lib
43
+ neo build2lib
44
44
 
45
45
  # 构建并发布到 OSS(确保 package.json 的 name 唯一、version 不重复)
46
- npm run publish2oss
46
+ neo publish2oss
47
47
  ```
48
48
 
49
49
  ### 方法二:在现有项目中使用
@@ -82,13 +82,13 @@ npm run publish2oss
82
82
  - **自动生成相关注册文件并注入**: 自动生成自定义组件注册文件和模型注册文件,并注入到构建脚本中,无需用户关注 [neo-register](https://www.npmjs.com/package/neo-register)。
83
83
 
84
84
  ## 发布到对象存储(OSS)
85
- 执行 `npm run publish2oss` 即可构建并上传到对象存储。发布前请确保:
85
+ 执行 `neo publish2oss` 即可构建并上传到对象存储。发布前请确保:
86
86
  - **package.json 的 name 唯一**
87
87
  - **version 不重复**
88
88
  - 已按需配置对象存储参数(支持自定义)
89
89
 
90
90
  支持发布指定自定义组件:
91
- 执行 `npm run publish2oss --cmpType=xxCmp`
91
+ 执行 `neo publish2oss --cmpType=xxCmp`
92
92
 
93
93
  ## 配置说明(neo.config.js)
94
94
  neo-cmp-cli 默认提供完整配置;如需自定义,使用 `neo config init` 生成 `neo.config.js` 并按需修改。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.2.11",
3
+ "version": "1.2.13",
4
4
  "description": "前端脚手架:自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -154,7 +154,7 @@ yargs
154
154
  (yargs) => {
155
155
  yargs
156
156
  .reset()
157
- .usage(titleTip('Usage') + ': $0 init [options]')
157
+ .usage(titleTip('Usage') + ': $0 preview [options]')
158
158
  .option('cmpType', {
159
159
  alias: 't',
160
160
  describe: '自定义组件项目名称'
@@ -198,7 +198,7 @@ yargs
198
198
  (yargs) => {
199
199
  yargs
200
200
  .reset()
201
- .usage(titleTip('Usage') + ': $0 dev')
201
+ .usage(titleTip('Usage') + ': $0 linkDebug')
202
202
  .alias('h', 'help');
203
203
  },
204
204
  (argv) => {
@@ -47,7 +47,7 @@
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
48
  "@types/react": "^16.9.11",
49
49
  "@types/react-dom": "^16.9.15",
50
- "neo-cmp-cli": "^1.2.9",
50
+ "neo-cmp-cli": "^1.2.13",
51
51
  "husky": "^4.2.5",
52
52
  "lint-staged": "^10.2.9",
53
53
  "prettier": "^2.0.5"
@@ -51,7 +51,7 @@
51
51
  "@types/react": "^16.9.11",
52
52
  "@types/react-dom": "^16.9.15",
53
53
  "@types/axios": "^0.14.0",
54
- "neo-cmp-cli": "^1.2.9",
54
+ "neo-cmp-cli": "^1.2.13",
55
55
  "husky": "^4.2.5",
56
56
  "lint-staged": "^10.2.9",
57
57
  "prettier": "^2.0.5"
@@ -47,7 +47,7 @@
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
48
  "@types/react": "^16.9.11",
49
49
  "@types/react-dom": "^16.9.15",
50
- "neo-cmp-cli": "^1.2.9",
50
+ "neo-cmp-cli": "^1.2.13",
51
51
  "husky": "^4.2.5",
52
52
  "lint-staged": "^10.2.9",
53
53
  "prettier": "^2.0.5",
@@ -44,5 +44,5 @@ $ npm run linkDebug
44
44
  $ npm run publish2oss
45
45
  ```
46
46
 
47
- ### 配置项说明(neo-cmp-cli)
47
+ ### 前端工程配置项说明(neo-cmp-cli)
48
48
  [请查看neo-cmp-cli](https://github.com/wibetter/neo-cmp-cli)
@@ -44,7 +44,7 @@
44
44
  "axios": "^0.27.2",
45
45
  "antd": "^4.9.4",
46
46
  "lodash": "^4.17.21",
47
- "neo-open-api": "^1.0.2"
47
+ "neo-open-api": "^1.0.8"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@commitlint/cli": "^8.3.5",
@@ -52,7 +52,7 @@
52
52
  "@types/react": "^16.9.11",
53
53
  "@types/react-dom": "^16.9.15",
54
54
  "@types/axios": "^0.14.0",
55
- "neo-cmp-cli": "^1.2.9",
55
+ "neo-cmp-cli": "^1.2.13",
56
56
  "husky": "^4.2.5",
57
57
  "lint-staged": "^10.2.9",
58
58
  "prettier": "^2.0.5"
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1759211982910" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2424" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M1024 1024H0V0h768v20.608l19.84-19.904 235.52 235.392-19.84 19.904H1024v768zM768 147.2V256h108.8zM896 384h-256V128H128v768h768V384z m-128 192H256V448h512v128z m0 192H256v-128h512v128z" fill="#0764f5" p-id="2425"></path></svg>
@@ -1,8 +1,4 @@
1
1
  # ContactCardList 联系人卡片列表组件
2
- - 使用 cursor 生成的自定义组件。
3
-
4
- ## 组件描述
5
-
6
2
  联系人卡片列表组件用于展示联系人信息,以卡片形式展示每个联系人的姓名和手机号。组件使用 Ant Design 的 Card 组件,具有良好的视觉效果和交互体验。
7
3
 
8
4
  ## 功能特性
@@ -10,7 +6,7 @@
10
6
  - 📱 响应式设计,支持多种屏幕尺寸
11
7
  - 🎨 美观的卡片布局,支持悬停效果
12
8
  - 🔄 自动加载数据,支持错误重试
13
- - 📊 使用 queryXObjectData 获取 customContact__c 数据
9
+ - 📊 使用 neo-open-api 获取 customContact__c 数据
14
10
  - 🎯 展示联系人姓名和手机号信息
15
11
  - 💫 加载状态和空状态处理
16
12
 
@@ -23,11 +19,10 @@
23
19
 
24
20
  ## 数据源
25
21
 
26
- 组件通过 `queryXObjectData` 工具函数获取数据:
22
+ 组件通过 `neo-open-api` 工具函数获取数据:
27
23
 
28
24
  - **数据表**: `customContact__c`
29
25
  - **字段**: `id`, `name`, `phone__c`
30
- - **API**: `/rest/data/v2/query`
31
26
 
32
27
  ## 样式特性
33
28
 
@@ -76,6 +76,16 @@ export default class ContactCardList extends React.PureComponent<
76
76
  }
77
77
  }
78
78
 
79
+ getDataName = (data: any) => {
80
+ let dataNameKey = 'name';
81
+ Object.keys(data).forEach((nameKey: string) => {
82
+ if (nameKey && /Name$/.test(nameKey)) {
83
+ dataNameKey = nameKey;
84
+ }
85
+ });
86
+ return data[dataNameKey];
87
+ };
88
+
79
89
  renderContactCard(contact: ContactData, index: number) {
80
90
  return (
81
91
  <Col xs={24} sm={12} md={8} lg={6} xl={6} key={contact.id || index}>
@@ -96,7 +106,9 @@ export default class ContactCardList extends React.PureComponent<
96
106
  <div className="contact-info">
97
107
  <div className="contact-name">
98
108
  <UserOutlined className="info-icon" />
99
- <span className="name-text">{contact.name || '未知姓名'}</span>
109
+ <span className="name-text">
110
+ {contact.name || this.getDataName(contact) || '未知姓名'}
111
+ </span>
100
112
  </div>
101
113
  <div className="contact-phone">
102
114
  <PhoneOutlined className="info-icon" />
@@ -109,14 +109,13 @@ export default class ContactForm extends React.PureComponent<
109
109
 
110
110
  if (userInfo && userInfo.id) {
111
111
  submitData = Object.assign(submitData, {
112
- userId: userInfo.id,
113
- dimDepart: userInfo.departId,
112
+ userId: userInfo.id, // 当前用户ID,非必填
113
+ dimDepart: userInfo.departId, // 当前用户所属部门ID,非必填
114
114
  });
115
115
  }
116
116
 
117
117
  // 调用 API 提交数据
118
118
  const response: any = await xObject.create('customContact__c', {
119
- method: 'POST',
120
119
  data: submitData,
121
120
  });
122
121
 
@@ -0,0 +1,193 @@
1
+ # 实体数据详情组件
2
+ 实体数据详情组件(entity-detail)是一个用于展示实体数据详细信息的自定义组件。它通过 Neo Open API 获取数据,支持多列布局展示,自动识别字段类型并进行格式化显示。
3
+
4
+ ## 功能特性
5
+
6
+ - ✅ **数据获取**:基于 Neo Open API 获取实体数据详情
7
+ - ✅ **多列布局**:支持 1-4 列的灵活布局配置
8
+ - ✅ **字段类型识别**:自动识别并格式化不同类型的字段(布尔值、日期、数字、URL、邮箱、电话等)
9
+ - ✅ **可视化配置**:在编辑器中可视化配置实体类型、数据ID、列数等属性
10
+ - ✅ **响应式设计**:支持不同屏幕尺寸的自适应布局
11
+ - ✅ **刷新功能**:支持手动刷新数据
12
+ - ✅ **错误处理**:完善的错误提示和重试机制
13
+
14
+ ## 使用场景
15
+
16
+ - 实体记录详情页展示
17
+ - 数据详情弹窗
18
+ - 审批流程中的数据展示
19
+ - 仪表盘中的详细信息卡片
20
+
21
+ ## 组件属性配置
22
+
23
+ | 属性名 | 类型 | 默认值 | 说明 |
24
+ |--------|------|--------|------|
25
+ | title | string | '实体数据详情' | 组件标题 |
26
+ | showTitle | boolean | true | 是否显示标题栏和刷新按钮 |
27
+ | xObjectDetailApi | object | { xObjectApiKey: 'account', objectId: '' } | 业务详情数据配置,包含实体对象API Key和数据ID |
28
+ | xObjectDetailApi.xObjectApiKey | string | 'account' | 实体对象的 API Key |
29
+ | xObjectDetailApi.objectId | string | '' | 要展示的数据记录ID,支持变量如 ${recordId} |
30
+ | columnCount | number | 3 | 详情页面的列数布局(1-4列) |
31
+
32
+ ## 字段类型支持
33
+
34
+ 组件会根据字段类型自动格式化显示:
35
+
36
+ - **boolean**:显示为带图标的标签(是/否)
37
+ - **date/datetime**:格式化为本地日期时间
38
+ - **number/currency/percent**:使用千分位格式化
39
+ - **url**:显示为可点击的链接
40
+ - **email**:显示为邮箱链接
41
+ - **phone**:显示为电话链接
42
+ - **text**:普通文本显示
43
+ - **空值**:显示为 "-"
44
+
45
+ ## 使用示例
46
+
47
+ ### 基础用法
48
+
49
+ ```jsx
50
+ <EntityDetail
51
+ title="客户详情"
52
+ xObjectDetailApi={{
53
+ xObjectApiKey: "account",
54
+ objectId: "12345"
55
+ }}
56
+ columnCount={3}
57
+ />
58
+ ```
59
+
60
+ ### 使用变量
61
+
62
+ 在 Neo 平台中,可以使用上下文变量:
63
+
64
+ ```jsx
65
+ <EntityDetail
66
+ title="当前记录详情"
67
+ xObjectDetailApi={{
68
+ xObjectApiKey: "customContact__c",
69
+ objectId: "${recordId}"
70
+ }}
71
+ columnCount={2}
72
+ />
73
+ ```
74
+
75
+ ### 隐藏标题栏
76
+
77
+ ```jsx
78
+ <EntityDetail
79
+ showTitle={false}
80
+ xObjectDetailApi={{
81
+ xObjectApiKey: "account",
82
+ objectId: "12345"
83
+ }}
84
+ columnCount={1}
85
+ />
86
+ ```
87
+
88
+ ## 技术实现
89
+
90
+ ### 数据获取
91
+
92
+ 组件使用以下 API 获取数据:
93
+
94
+ 1. **xObject.get**:获取单条实体数据
95
+ 2. **xObject.getDesc**:获取实体字段描述信息
96
+
97
+ ```typescript
98
+ // 获取详情数据
99
+ const result = await xObject.get(xObjectDetailApi.xObjectApiKey, xObjectDetailApi.objectId);
100
+
101
+ // 获取字段描述
102
+ const descResult = await xObject.getDesc(xObjectDetailApi.xObjectApiKey);
103
+ ```
104
+
105
+ ### 布局方案
106
+
107
+ 组件采用 Ant Design 的 Row/Col 栅格系统,根据 `columnCount` 属性动态分配字段到不同的列中:
108
+
109
+ - 1列:每列占 24 格(100%宽度)
110
+ - 2列:每列占 12 格(50%宽度)
111
+ - 3列:每列占 8 格(33.3%宽度)
112
+ - 4列:每列占 6 格(25%宽度)
113
+
114
+ ### 响应式适配
115
+
116
+ - **桌面端**(>1200px):按配置的列数显示
117
+ - **平板端**(768px-1200px):3列及以上自动调整为2列
118
+ - **移动端**(<768px):自动调整为单列显示
119
+
120
+ ## 样式定制
121
+
122
+ 组件提供了丰富的 CSS 类名,可以通过自定义样式进行个性化定制:
123
+
124
+ ```scss
125
+ .entity-detail-container {
126
+ // 容器样式
127
+
128
+ .detail-header {
129
+ // 头部样式
130
+ }
131
+
132
+ .detail-content {
133
+ // 内容区域样式
134
+
135
+ .detail-column-card {
136
+ // 列卡片样式
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
142
+ ## 注意事项
143
+
144
+ 1. **xObjectDetailApi 参数必填**:必须提供有效的 `xObjectDetailApi` 对象,包含 `xObjectApiKey` 和 `objectId` 才能正常展示
145
+ 2. **权限要求**:确保当前用户有权限访问指定的实体对象
146
+ 3. **字段过滤**:组件会自动过滤以下划线开头的系统字段
147
+ 4. **性能优化**:大量字段时建议使用2-3列布局以保证用户体验
148
+ 5. **属性结构**:使用 `xObjectDetailApi` 对象结构,提供更清晰的数据配置方式
149
+
150
+ ## 开发说明
151
+
152
+ ### 目录结构
153
+
154
+ ```
155
+ entity-detail/
156
+ ├── index.tsx # 组件主文件
157
+ ├── model.ts # 编辑器配置文件
158
+ ├── style.scss # 样式文件
159
+ └── README.md # 组件文档
160
+ ```
161
+
162
+ ### 依赖包
163
+
164
+ - react: ^16.9.0
165
+ - antd: ^4.9.4
166
+ - neo-open-api: ^1.0.2
167
+
168
+ ### 本地开发
169
+
170
+ ```bash
171
+ # 预览组件
172
+ npm run preview --cmpType=entity-detail
173
+
174
+ # 构建组件
175
+ npm run build
176
+ ```
177
+
178
+ ## 更新日志
179
+
180
+ ### v1.1.0 (2024-12-19)
181
+
182
+ - **重大更新**:重构属性结构,使用 `xObjectDetailApi` 对象替代分离的 `xObjectApiKey` 和 `objectId` 属性
183
+ - 优化组件属性配置,提供更清晰的数据结构
184
+ - 更新编辑器配置,支持 `xObjectDetailApi` 类型的属性配置
185
+ - 保持向后兼容性,现有功能完全保留
186
+
187
+ ### v1.0.0 (2024-09-30)
188
+
189
+ - 初始版本发布
190
+ - 支持基础的实体数据详情展示
191
+ - 支持多列布局配置
192
+ - 支持字段类型识别和格式化
193
+ - 支持响应式布局