neo-cmp-cli 1.3.7 → 1.3.9

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 (33) hide show
  1. package/README.md +5 -5
  2. package/package.json +1 -1
  3. package/src/module/neoInit.js +2 -0
  4. package/src/module/neoInitByCopy.js +3 -0
  5. package/src/template/antd-custom-cmp-template/package.json +1 -1
  6. package/src/template/echarts-custom-cmp-template/package.json +1 -1
  7. package/src/template/{react-ts-custom-cmp-template → echarts-custom-cmp-template}/src/components/map-widget/index.tsx +56 -18
  8. package/src/template/echarts-custom-cmp-template/src/utils/url.ts +82 -0
  9. package/src/template/neo-custom-cmp-template/neo.config.js +4 -4
  10. package/src/template/neo-custom-cmp-template/package.json +1 -1
  11. package/src/template/react-custom-cmp-template/package.json +1 -1
  12. package/src/template/react-ts-custom-cmp-template/neo.config.js +4 -4
  13. package/src/template/react-ts-custom-cmp-template/package.json +2 -2
  14. package/src/template/vue2-custom-cmp-template/package.json +1 -1
  15. package/src/utils/resetPackageVersion.js +115 -0
  16. package/src/template/echarts-custom-cmp-template/src/components/info-card/index.tsx +0 -69
  17. package/src/template/echarts-custom-cmp-template/src/components/info-card/model.ts +0 -78
  18. package/src/template/echarts-custom-cmp-template/src/components/info-card/style.scss +0 -105
  19. package/src/template/neo-custom-cmp-template/src/components/contact-card-list/README.md +0 -61
  20. package/src/template/neo-custom-cmp-template/src/components/contact-card-list/index.tsx +0 -191
  21. package/src/template/neo-custom-cmp-template/src/components/contact-card-list/model.ts +0 -56
  22. package/src/template/neo-custom-cmp-template/src/components/contact-card-list/style.scss +0 -260
  23. package/src/template/neo-custom-cmp-template/src/components/contact-form/README.md +0 -94
  24. package/src/template/neo-custom-cmp-template/src/components/contact-form/index.tsx +0 -249
  25. package/src/template/neo-custom-cmp-template/src/components/contact-form/model.ts +0 -63
  26. package/src/template/neo-custom-cmp-template/src/components/contact-form/style.scss +0 -120
  27. package/src/template/react-ts-custom-cmp-template/src/components/info-card/index.tsx +0 -69
  28. package/src/template/react-ts-custom-cmp-template/src/components/info-card/model.ts +0 -78
  29. package/src/template/react-ts-custom-cmp-template/src/components/info-card/style.scss +0 -105
  30. /package/src/template/{react-ts-custom-cmp-template → echarts-custom-cmp-template}/src/components/map-widget/README.md +0 -0
  31. /package/src/template/{react-ts-custom-cmp-template → echarts-custom-cmp-template}/src/components/map-widget/USAGE.md +0 -0
  32. /package/src/template/{react-ts-custom-cmp-template → echarts-custom-cmp-template}/src/components/map-widget/model.ts +0 -0
  33. /package/src/template/{react-ts-custom-cmp-template → echarts-custom-cmp-template}/src/components/map-widget/style.scss +0 -0
@@ -1,260 +0,0 @@
1
- .contact-card-list-container {
2
- position: relative;
3
- box-sizing: border-box;
4
- height: 100%;
5
- display: flex;
6
- flex-direction: column;
7
- margin: 6px 12px;
8
- padding: 12px;
9
- background-color: #fff;
10
- border-radius: 8px;
11
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
12
-
13
- .card-list-header {
14
- flex-shrink: 0;
15
- margin-bottom: 16px;
16
- border-bottom: 1px solid #f0f0f0;
17
- padding-bottom: 12px;
18
-
19
- .header-content {
20
- display: flex;
21
- justify-content: space-between;
22
- align-items: center;
23
- gap: 16px;
24
- }
25
-
26
- .header-title {
27
- margin: 0;
28
- font-family: PingFangSC-Medium, -apple-system, BlinkMacSystemFont,
29
- 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
30
- font-size: 18px;
31
- font-weight: 500;
32
- line-height: 1.4;
33
- color: #262626;
34
- flex: 1;
35
- }
36
-
37
- .refresh-button {
38
- flex-shrink: 0;
39
- border-radius: 6px;
40
- font-size: 13px;
41
- height: 32px;
42
- padding: 4px 12px;
43
- box-shadow: 0 2px 4px rgba(24, 144, 255, 0.2);
44
- transition: all 0.3s ease;
45
-
46
- &:hover {
47
- box-shadow: 0 4px 8px rgba(24, 144, 255, 0.3);
48
- transform: translateY(-1px);
49
- }
50
-
51
- &:active {
52
- transform: translateY(0);
53
- }
54
-
55
- .anticon {
56
- font-size: 12px;
57
- }
58
- }
59
- }
60
-
61
- .card-list-content {
62
- flex: 1;
63
- overflow-y: auto;
64
-
65
- .error-container {
66
- display: flex;
67
- justify-content: center;
68
- align-items: center;
69
- min-height: 300px;
70
- padding: 20px;
71
-
72
- .retry-button {
73
- padding: 8px 16px;
74
- background-color: #1890ff;
75
- color: white;
76
- border: none;
77
- border-radius: 4px;
78
- cursor: pointer;
79
- font-size: 14px;
80
- transition: background-color 0.3s;
81
-
82
- &:hover {
83
- background-color: #40a9ff;
84
- }
85
-
86
- &:active {
87
- background-color: #096dd9;
88
- }
89
- }
90
- }
91
- }
92
-
93
- .contact-card {
94
- height: 100%;
95
- border-radius: 12px;
96
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
97
- transition: all 0.3s ease;
98
- border: 1px solid #f0f0f0;
99
-
100
- &:hover {
101
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
102
- transform: translateY(-2px);
103
- border-color: #d9d9d9;
104
- }
105
-
106
- .ant-card-body {
107
- padding: 16px;
108
- height: 100%;
109
- display: flex;
110
- align-items: center;
111
- }
112
-
113
- .contact-card-content {
114
- display: flex;
115
- align-items: center;
116
- width: 100%;
117
- gap: 12px;
118
-
119
- .contact-avatar {
120
- flex-shrink: 0;
121
-
122
- .avatar-icon {
123
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
124
- border: 2px solid #fff;
125
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
126
- }
127
- }
128
-
129
- .contact-info {
130
- flex: 1;
131
- min-width: 0;
132
-
133
- .contact-name,
134
- .contact-phone {
135
- display: flex;
136
- align-items: center;
137
- margin-bottom: 4px;
138
- gap: 6px;
139
-
140
- &:last-child {
141
- margin-bottom: 0;
142
- }
143
-
144
- .info-icon {
145
- font-size: 12px;
146
- color: #8c8c8c;
147
- flex-shrink: 0;
148
- }
149
-
150
- .name-text,
151
- .phone-text {
152
- font-size: 14px;
153
- line-height: 1.4;
154
- overflow: hidden;
155
- text-overflow: ellipsis;
156
- white-space: nowrap;
157
- }
158
-
159
- .name-text {
160
- color: #262626;
161
- font-weight: 500;
162
- }
163
-
164
- .phone-text {
165
- color: #595959;
166
- font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo,
167
- Courier, monospace;
168
- }
169
- }
170
-
171
- .contact-name {
172
- margin-bottom: 8px;
173
- }
174
- }
175
- }
176
- }
177
-
178
- // 响应式设计
179
- @media (max-width: 768px) {
180
- margin: 4px 8px;
181
- padding: 8px;
182
-
183
- .card-list-header {
184
- margin-bottom: 12px;
185
- padding-bottom: 8px;
186
-
187
- .header-content {
188
- gap: 12px;
189
- }
190
-
191
- .header-title {
192
- font-size: 16px;
193
- }
194
-
195
- .refresh-button {
196
- height: 28px;
197
- padding: 2px 8px;
198
- font-size: 12px;
199
-
200
- .anticon {
201
- font-size: 11px;
202
- }
203
- }
204
- }
205
-
206
- .contact-card {
207
- .ant-card-body {
208
- padding: 12px;
209
- }
210
-
211
- .contact-card-content {
212
- gap: 8px;
213
-
214
- .contact-avatar {
215
- .avatar-icon {
216
- width: 40px !important;
217
- height: 40px !important;
218
- line-height: 40px !important;
219
- }
220
- }
221
-
222
- .contact-info {
223
- .contact-name,
224
- .contact-phone {
225
- .name-text,
226
- .phone-text {
227
- font-size: 13px;
228
- }
229
- }
230
- }
231
- }
232
- }
233
- }
234
-
235
- @media (max-width: 480px) {
236
- .contact-card {
237
- .contact-card-content {
238
- flex-direction: column;
239
- text-align: center;
240
- gap: 8px;
241
-
242
- .contact-info {
243
- .contact-name,
244
- .contact-phone {
245
- justify-content: center;
246
- }
247
- }
248
- }
249
- }
250
- }
251
- }
252
-
253
- // 全局样式覆盖
254
- .ant-spin-container {
255
- min-height: 200px;
256
- }
257
-
258
- .ant-empty {
259
- padding: 40px 20px;
260
- }
@@ -1,94 +0,0 @@
1
- # 联系人表单组件
2
- 基于 Ant Design 的联系人表单组件,支持姓名、所有人、业务类型、所属部门、手机号等字段的输入和提交。
3
- 【备注】使用 cursor 生成的自定义组件。
4
-
5
- ## 功能特性
6
-
7
- - ✅ 基于 Ant Design 4.x 组件库
8
- - ✅ 表单字段验证(姓名和手机号为必填项)
9
- - ✅ 手机号格式验证
10
- - ✅ 数据提交到 Neo 平台 API
11
- - ✅ 加载状态显示
12
- - ✅ 成功/错误消息提示
13
- - ✅ 响应式设计
14
- - ✅ 使用 React state 管理表单数据
15
-
16
- ## 表单字段
17
-
18
- | 字段名 | 类型 | 必填 | 说明 |
19
- |--------|------|------|------|
20
- | 姓名 | text | ✅ | 联系人姓名 |
21
- | 所有人 | number | ❌ | 联系人用户ID (userId) |
22
- | 业务类型 | select | ❌ | 销售/市场/客服/技术/其他 (entityType) |
23
- | 所属部门 | number | ❌ | 联系人所属部门ID (dimDepart) |
24
- | 手机号 | number | ✅ | 联系人手机号(格式验证)(phone__c) |
25
-
26
- ## API 接口
27
-
28
- 组件会将表单数据提交到以下接口:
29
-
30
- ```
31
- POST /rest/data/v2.0/xobjects/customContact__c
32
- ```
33
-
34
- ### 请求数据格式
35
-
36
- ```json
37
- {
38
- "name": "张三",
39
- "userId": 12345,
40
- "entityType": 3998003734470119,
41
- "dimDepart": 67890,
42
- "phone__c": "13800138000"
43
- }
44
- ```
45
-
46
- ## 组件属性
47
-
48
- | 属性名 | 类型 | 默认值 | 说明 |
49
- |--------|------|--------|------|
50
- | title | string | '创建联系人' | 表单标题 |
51
- | data | object | {} | Neo 平台数据(包含用户信息和系统信息) |
52
-
53
- ## 使用示例
54
-
55
- ```tsx
56
- import ContactForm from './components/contact-form';
57
-
58
- // 在页面中使用
59
- <ContactForm
60
- title="创建新联系人"
61
- data={amisData}
62
- />
63
- ```
64
-
65
- ## 技术栈
66
-
67
- - React 16.9.0
68
- - TypeScript
69
- - Ant Design 4.x
70
- - SCSS
71
-
72
- ## 样式定制
73
-
74
- 组件基于 Ant Design 设计规范,支持通过 SCSS 进行样式定制:
75
-
76
- ```scss
77
- .contact-form-container {
78
- .contact-form-card {
79
- // 卡片样式定制
80
- }
81
-
82
- .contact-form {
83
- // 表单样式定制
84
- }
85
- }
86
- ```
87
-
88
- ## 注意事项
89
-
90
- 1. 确保 Neo 平台已正确配置 `customContact__c` 对象
91
- 2. 组件依赖 `antd` 和 `axios` 进行 UI 渲染和 API 调用
92
- 3. 需要确保用户有创建联系人的权限
93
- 4. 手机号格式验证仅支持中国大陆手机号(1开头的11位数字)
94
- 5. 组件使用 React state 管理表单数据,无需手动处理 ref
@@ -1,249 +0,0 @@
1
- import * as React from 'react';
2
- import { Form, Input, Select, Button, message, Card } from 'antd';
3
- // @ts-ignore
4
- import { xObject } from 'neo-open-api'; // Neo Open API
5
- const { Option } = Select;
6
-
7
- import './style.scss';
8
-
9
- interface ContactFormProps {
10
- title: string;
11
- showSubmitButton?: boolean;
12
- data?: any;
13
- }
14
-
15
- interface ContactFormState {
16
- formData: {
17
- name: string;
18
- entityType?: number;
19
- phone__c: string;
20
- };
21
- entityTypeList: any[];
22
- loading: boolean;
23
- }
24
-
25
- export default class ContactForm extends React.PureComponent<
26
- ContactFormProps,
27
- ContactFormState
28
- > {
29
- private formRef: any;
30
-
31
- constructor(props: ContactFormProps) {
32
- super(props);
33
-
34
- this.state = {
35
- formData: {
36
- name: 'wibetter',
37
- phone__c: '15900000003',
38
- },
39
- entityTypeList: [],
40
- loading: false,
41
- };
42
-
43
- // 获取业务类型列表
44
- xObject.getEntityTypeList('customContact__c').then((res: any) => {
45
- if (res && res.status) {
46
- this.setState({
47
- entityTypeList: res.data || [],
48
- });
49
- }
50
- });
51
-
52
- this.handleInputChange = this.handleInputChange.bind(this);
53
- this.handleSubmit = this.handleSubmit.bind(this);
54
- this.resetForm = this.resetForm.bind(this);
55
- }
56
-
57
- handleInputChange(
58
- field: keyof ContactFormState['formData'],
59
- value: string | number,
60
- ) {
61
- this.setState((prevState) => ({
62
- formData: {
63
- ...prevState.formData,
64
- [field]: value,
65
- },
66
- }));
67
- }
68
-
69
- validateForm() {
70
- const { formData } = this.state;
71
-
72
- if (!formData.name.trim()) {
73
- message.error('请输入联系人姓名');
74
- return false;
75
- }
76
-
77
- if (!formData.phone__c.trim()) {
78
- message.error('请输入手机号');
79
- return false;
80
- }
81
-
82
- // 手机号格式验证
83
- const phoneRegex = /^1[3-9]\d{9}$/;
84
- if (!phoneRegex.test(formData.phone__c)) {
85
- message.error('请输入正确的手机号格式');
86
- return false;
87
- }
88
-
89
- return true;
90
- }
91
-
92
- async handleSubmit() {
93
- if (!this.validateForm()) {
94
- return;
95
- }
96
- this.setState({ loading: true });
97
-
98
- try {
99
- const { formData } = this.state;
100
- // 获取当前用户信息
101
- const curAmisData = this.props.data || {};
102
- const userInfo = curAmisData.__NeoCurrentUser;
103
-
104
- // 准备提交的数据
105
- let submitData = {
106
- name: formData.name.trim(),
107
- phone__c: formData.phone__c.trim(),
108
- entityType: formData.entityType,
109
- };
110
-
111
- if (userInfo && userInfo.id) {
112
- submitData = Object.assign(submitData, {
113
- userId: userInfo.id, // 当前用户ID,非必填
114
- dimDepart: userInfo.departId, // 当前用户所属部门ID,非必填
115
- });
116
- }
117
-
118
- // 调用 API 提交数据
119
- const response: any = await xObject.create('customContact__c', {
120
- data: submitData,
121
- });
122
-
123
- if (response && response.status) {
124
- message.success('联系人创建成功!');
125
- // 成功后重置表单
126
- setTimeout(() => {
127
- this.resetForm();
128
- }, 1000);
129
- } else {
130
- message.error('创建联系人失败:', response.msg);
131
- }
132
- } catch (error: any) {
133
- message.error('创建联系人失败:', error);
134
- } finally {
135
- this.setState({ loading: false });
136
- }
137
- }
138
-
139
- resetForm() {
140
- this.setState({
141
- formData: {
142
- name: '',
143
- phone__c: '',
144
- },
145
- });
146
-
147
- // 重置 Ant Design 表单
148
- if (this.formRef) {
149
- this.formRef.resetFields();
150
- }
151
- }
152
-
153
- render() {
154
- const { title, showSubmitButton } = this.props;
155
- const { formData, loading, entityTypeList } = this.state;
156
- const curAmisData = this.props.data || {};
157
- const systemInfo = curAmisData.__NeoSystemInfo || {};
158
-
159
- return (
160
- <div className="contact-form-container">
161
- <Card
162
- title={title || '创建联系人'}
163
- extra={systemInfo.tenantName ? `【${systemInfo.tenantName}】` : ''}
164
- className="contact-form-card"
165
- >
166
- <Form
167
- ref={(ref) => {
168
- this.formRef = ref;
169
- }}
170
- layout="vertical"
171
- className="contact-form"
172
- initialValues={formData}
173
- >
174
- <Form.Item
175
- label="姓名"
176
- required
177
- rules={[{ required: true, message: '请输入联系人姓名' }]}
178
- >
179
- <Input
180
- value={formData.name}
181
- onChange={(e) => this.handleInputChange('name', e.target.value)}
182
- placeholder="请输入联系人姓名"
183
- disabled={loading}
184
- />
185
- </Form.Item>
186
-
187
- <Form.Item
188
- label="手机号"
189
- required
190
- rules={[
191
- { required: true, message: '请输入手机号' },
192
- { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号格式' },
193
- ]}
194
- >
195
- <Input
196
- value={formData.phone__c}
197
- onChange={(e) =>
198
- this.handleInputChange('phone__c', e.target.value)
199
- }
200
- placeholder="请输入手机号"
201
- disabled={loading}
202
- />
203
- </Form.Item>
204
-
205
- <Form.Item label="业务类型">
206
- <Select
207
- value={formData.entityType}
208
- onChange={(value) =>
209
- this.handleInputChange('entityType', value)
210
- }
211
- placeholder="请选择业务类型"
212
- disabled={loading}
213
- >
214
- {entityTypeList.map((item) => (
215
- <Option
216
- key={item.apiKey}
217
- value={item.id}
218
- disabled={!item.active}
219
- >
220
- {item.label}
221
- </Option>
222
- ))}
223
- </Select>
224
- </Form.Item>
225
-
226
- {showSubmitButton && (
227
- <Form.Item className="form-actions">
228
- <Button
229
- onClick={this.resetForm}
230
- disabled={loading}
231
- style={{ marginRight: 8 }}
232
- >
233
- 重置
234
- </Button>
235
- <Button
236
- type="primary"
237
- onClick={this.handleSubmit}
238
- loading={loading}
239
- >
240
- 保存联系人
241
- </Button>
242
- </Form.Item>
243
- )}
244
- </Form>
245
- </Card>
246
- </div>
247
- );
248
- }
249
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * @file 自定义组件对接编辑器的描述文件
3
- */
4
- export class ContactFormModel {
5
- /**
6
- * cmpType 为自定义组件名称,用于标识组件的唯一性
7
- * 在构建时根据当前组件目录名称自动生成
8
- */
9
- // cmpType: string = 'contact-form';
10
-
11
- // 组件名称,用于设置在编辑器左侧组件面板中展示的名称
12
- label: string = '联系人表单';
13
-
14
- // 组件描述,用于设置在编辑器左侧组件面板中展示的描述
15
- description: string =
16
- '基于 Ant Design 的联系人表单组件,支持姓名、所有人、业务类型、所属部门、手机号等字段';
17
-
18
- // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
19
- tags: string[] = ['自定义组件'];
20
-
21
- // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
22
- iconSrc: string = 'https://custom-widgets.bj.bcebos.com/contact-form.svg';
23
-
24
- // 初次插入页面的默认属性数据
25
- defaultComProps = {
26
- title: '创建联系人',
27
- label: '联系人表单',
28
- showSubmitButton: true,
29
- };
30
-
31
- // 设计器端预览时展示的默认数据
32
- previewComProps = {
33
- label: '联系人表单',
34
- };
35
-
36
- /**
37
- * 组件面板配置,用于生成编辑器右侧属性配置面板内容
38
- */
39
- propsSchema = [
40
- {
41
- type: 'textarea',
42
- name: 'title',
43
- label: '表单标题',
44
- value: '创建联系人',
45
- placeholder: '请输入表单标题',
46
- },
47
- {
48
- type: 'switch',
49
- name: 'showSubmitButton',
50
- label: '显示提交按钮',
51
- value: true,
52
- },
53
- ];
54
-
55
- // 支持 函数式写法:propsSchemaCreator,com 为组件实例。优先级比 propsSchema 高
56
- /*
57
- propsSchemaCreator = (com: any) => {
58
- return [];
59
- };
60
- */
61
- }
62
-
63
- export default ContactFormModel;