neo-cmp-cli 1.2.12 → 1.2.15

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/package.json +1 -1
  2. package/src/module/main.js +4 -4
  3. package/src/plugins/AddNeoRequirePlugin.js +3 -12
  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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.2.12",
3
+ "version": "1.2.15",
4
4
  "description": "前端脚手架:自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -110,9 +110,9 @@ module.exports = {
110
110
  curConfig.webpack.plugins &&
111
111
  Array.isArray(curConfig.webpack.plugins)
112
112
  ) {
113
- curConfig.webpack.plugins.push(new AddNeoRequirePlugin());
113
+ curConfig.webpack.plugins.push(new AddNeoRequirePlugin({verbose: true}));
114
114
  } else {
115
- curConfig.webpack.plugins = [new AddNeoRequirePlugin()];
115
+ curConfig.webpack.plugins = [new AddNeoRequirePlugin({verbose: true})];
116
116
  }
117
117
 
118
118
  // 添加 内置 Neo 的 externals 配置
@@ -230,9 +230,9 @@ module.exports = {
230
230
  curConfig.webpack.plugins &&
231
231
  Array.isArray(curConfig.webpack.plugins)
232
232
  ) {
233
- curConfig.webpack.plugins.push(new AddNeoRequirePlugin());
233
+ curConfig.webpack.plugins.push(new AddNeoRequirePlugin({verbose: true}));
234
234
  } else {
235
- curConfig.webpack.plugins = [new AddNeoRequirePlugin()];
235
+ curConfig.webpack.plugins = [new AddNeoRequirePlugin({verbose: true})];
236
236
  }
237
237
 
238
238
  // 添加 内置 Neo 的 externals 配置
@@ -5,6 +5,8 @@ const { ConcatSource } = require('webpack-sources');
5
5
  * 备注:用于实现和 Neo 平台共享依赖
6
6
  */
7
7
  class AddNeoRequirePlugin {
8
+ key = 'AddNeoRequirePlugin';
9
+
8
10
  constructor(options = {}) {
9
11
  this.options = {
10
12
  // 是否启用详细日志
@@ -17,9 +19,6 @@ class AddNeoRequirePlugin {
17
19
  skipPatterns: options.skipPatterns || [/\.map$/, /\.LICENSE\.txt$/, /\.html$/],
18
20
  ...options
19
21
  };
20
-
21
- // 记录已处理的文件,避免重复处理
22
- this.processedFiles = new Set();
23
22
  }
24
23
 
25
24
  /**
@@ -78,7 +77,7 @@ class AddNeoRequirePlugin {
78
77
  log(message, level = 'info') {
79
78
  if (this.options.verbose || level === 'error') {
80
79
  const prefix = `[AddNeoRequirePlugin]`;
81
- console[level](`${prefix} ${message}`);
80
+ console[level](`/n${prefix} ${message}`);
82
81
  }
83
82
  }
84
83
 
@@ -106,13 +105,6 @@ class AddNeoRequirePlugin {
106
105
  continue;
107
106
  }
108
107
 
109
- // 检查是否已经处理过
110
- if (this.processedFiles.has(filename)) {
111
- this.log(`跳过文件: ${filename} (已处理过)`);
112
- skippedCount++;
113
- continue;
114
- }
115
-
116
108
  // 获取文件内容
117
109
  const source = asset.source();
118
110
  const content = typeof source === 'string' ? source : source.toString();
@@ -133,7 +125,6 @@ class AddNeoRequirePlugin {
133
125
 
134
126
  // 执行注入
135
127
  this.injectNeoRequire(compilation, filename, content);
136
- this.processedFiles.add(filename);
137
128
  processedCount++;
138
129
 
139
130
  this.log(`成功处理文件: ${filename}`);
@@ -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.12",
50
+ "neo-cmp-cli": "^1.2.15",
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.12",
54
+ "neo-cmp-cli": "^1.2.15",
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.12",
50
+ "neo-cmp-cli": "^1.2.15",
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.12",
55
+ "neo-cmp-cli": "^1.2.15",
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
+ - 支持响应式布局