neo-cmp-cli 1.12.7 → 1.12.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.
- package/README.md +204 -6
- package/dist/index2.js +1 -1
- package/dist/neo/env.js +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +1 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/{neo-bi-cmps → asset-manage-template}/README.md +65 -10
- package/template/asset-manage-template/docs/README.md +244 -0
- package/template/asset-manage-template/neo.config.js +60 -0
- package/template/{neo-bi-cmps → asset-manage-template}/package.json +28 -16
- 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 +0 -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/{neo-bi-cmps → asset-manage-template}/tsconfig.json +1 -1
- 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 +2 -2
- package/template/neo-custom-cmp-template/src/components/entityTable__c/index.tsx +62 -6
- package/template/neo-h5-cmps/neo.config.js +34 -76
- package/template/neo-h5-cmps/package.json +7 -3
- package/template/neo-h5-cmps/src/components/entityList__c/index.tsx +0 -4
- package/template/neo-h5-cmps/src/components/entityList__c/model.ts +10 -5
- package/template/neo-h5-cmps/src/components/entityTabs__c/index.tsx +29 -17
- package/template/neo-h5-cmps/src/components/entityTabs__c/model.ts +25 -5
- package/template/neo-h5-cmps/src/components/entityTabs__c/style.scss +11 -22
- package/template/neo-h5-cmps/src/components/openChatPageBtn__c/index.tsx +3 -1
- package/template/neo-h5-cmps/src/utils/xobjects.ts +8 -3
- package/template/neo-h5-cmps/tsconfig.json +1 -1
- package/template/neo-order-cmps/package.json +2 -2
- 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/src/utils/xobjects.ts +0 -203
- 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/neo-bi-cmps/.prettierrc.js +0 -12
- package/template/neo-bi-cmps/commitlint.config.js +0 -59
- package/template/neo-bi-cmps/neo.config.js +0 -124
- package/template/neo-bi-cmps/public/css/base.css +0 -283
- package/template/neo-bi-cmps/public/scripts/app/bluebird.js +0 -6679
- package/template/neo-bi-cmps/public/template.html +0 -13
- package/template/neo-bi-cmps/src/assets/css/common.scss +0 -127
- package/template/neo-bi-cmps/src/assets/css/mixin.scss +0 -47
- package/template/neo-bi-cmps/src/assets/img/NeoCRM.jpg +0 -0
- package/template/neo-bi-cmps/src/assets/img/custom-widget.svg +0 -1
- package/template/neo-bi-cmps/src/assets/img/favicon.png +0 -0
- package/template/neo-bi-cmps/src/assets/img/table.svg +0 -1
- 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/neo-h5-cmps/src/components/simpleTable__c/README.md +0 -90
- package/template/neo-h5-cmps/src/components/simpleTable__c/index.tsx +0 -277
- package/template/neo-h5-cmps/src/components/simpleTable__c/model.ts +0 -91
- package/template/neo-h5-cmps/src/components/simpleTable__c/style.scss +0 -116
- /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
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import { FormItem, RendererProps } from 'amis';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { Input, Button, Modal, message } from 'antd';
|
|
5
|
-
import { SettingOutlined } from '@ant-design/icons';
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
import JSONEditor from '@wibetter/json-editor';
|
|
8
|
-
import '@wibetter/json-editor/lib/index.css';
|
|
9
|
-
|
|
10
|
-
import { configSchema } from './configSchema';
|
|
11
|
-
import './index.scss';
|
|
12
|
-
|
|
13
|
-
interface ICustomStyleConfigProps {
|
|
14
|
-
onChange?: Function;
|
|
15
|
-
value?: any;
|
|
16
|
-
name: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface ICustomStyleConfigState {
|
|
20
|
-
isModalVisible: boolean;
|
|
21
|
-
editorValue: any;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@FormItem({
|
|
25
|
-
type: 'customStyleConfig',
|
|
26
|
-
detectProps: ['data'],
|
|
27
|
-
})
|
|
28
|
-
export default class CustomStyleConfigRenderer extends React.Component<
|
|
29
|
-
RendererProps & ICustomStyleConfigProps,
|
|
30
|
-
ICustomStyleConfigState
|
|
31
|
-
> {
|
|
32
|
-
constructor(props: RendererProps & ICustomStyleConfigProps) {
|
|
33
|
-
super(props);
|
|
34
|
-
|
|
35
|
-
this.state = {
|
|
36
|
-
isModalVisible: false,
|
|
37
|
-
editorValue: props.value || {},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
this.showModal = this.showModal.bind(this);
|
|
41
|
-
this.handleModalOk = this.handleModalOk.bind(this);
|
|
42
|
-
this.handleModalCancel = this.handleModalCancel.bind(this);
|
|
43
|
-
this.handleEditorChange = this.handleEditorChange.bind(this);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
handleEditorChange = (value: any) => {
|
|
47
|
-
this.setState({ editorValue: value });
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
handleModalOk = () => {
|
|
51
|
-
const { editorValue } = this.state;
|
|
52
|
-
const { onChange } = this.props;
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
onChange && onChange(editorValue);
|
|
56
|
-
this.setState({ isModalVisible: false });
|
|
57
|
-
} catch (error) {
|
|
58
|
-
message.error('保存配置失败');
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
handleModalCancel = () => {
|
|
63
|
-
// 取消时恢复原始值
|
|
64
|
-
const value = this.props.value || {};
|
|
65
|
-
this.setState({
|
|
66
|
-
isModalVisible: false,
|
|
67
|
-
editorValue: value,
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
showModal = () => {
|
|
72
|
-
const value = this.props.value || {};
|
|
73
|
-
this.setState({
|
|
74
|
-
isModalVisible: true,
|
|
75
|
-
editorValue: value,
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
getDisplayValue = () => {
|
|
80
|
-
const { value } = this.props;
|
|
81
|
-
|
|
82
|
-
if (!value || Object.keys(value).length === 0) {
|
|
83
|
-
return '';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return '已配置自定义样式';
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
render() {
|
|
90
|
-
const { disabled, viewStyle, wideScreen, value } = this.props;
|
|
91
|
-
const { isModalVisible } = this.state;
|
|
92
|
-
console.log('customStyleConfig:', this.props);
|
|
93
|
-
console.log('test1:', this.props.data['__NeoPageInfo']);
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<div className="properties-panel-custom-style-config">
|
|
97
|
-
<div className="custom-style-config-input-container">
|
|
98
|
-
<Input
|
|
99
|
-
value={this.getDisplayValue()}
|
|
100
|
-
placeholder="请配置自定义样式"
|
|
101
|
-
disabled={disabled}
|
|
102
|
-
readOnly
|
|
103
|
-
className="custom-style-config-input"
|
|
104
|
-
/>
|
|
105
|
-
<Button
|
|
106
|
-
type="text"
|
|
107
|
-
icon={<SettingOutlined />}
|
|
108
|
-
onClick={this.showModal}
|
|
109
|
-
disabled={disabled}
|
|
110
|
-
className="custom-style-config-setting-btn"
|
|
111
|
-
/>
|
|
112
|
-
</div>
|
|
113
|
-
<Modal
|
|
114
|
-
title="自定义样式配置"
|
|
115
|
-
visible={isModalVisible}
|
|
116
|
-
onOk={this.handleModalOk}
|
|
117
|
-
onCancel={this.handleModalCancel}
|
|
118
|
-
width={800}
|
|
119
|
-
centered={true}
|
|
120
|
-
okText="确定"
|
|
121
|
-
cancelText="取消"
|
|
122
|
-
destroyOnClose={false}
|
|
123
|
-
>
|
|
124
|
-
<div className="custom-style-config-modal-content">
|
|
125
|
-
{isModalVisible && (
|
|
126
|
-
<JSONEditor
|
|
127
|
-
schemaData={configSchema}
|
|
128
|
-
jsonData={value}
|
|
129
|
-
onChange={this.handleEditorChange}
|
|
130
|
-
viewStyle={viewStyle || 'tabs'}
|
|
131
|
-
tabPosition="left"
|
|
132
|
-
wideScreen={wideScreen ?? false}
|
|
133
|
-
/>
|
|
134
|
-
)}
|
|
135
|
-
</div>
|
|
136
|
-
</Modal>
|
|
137
|
-
</div>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/*
|
|
143
|
-
// 通过 普通方式进行
|
|
144
|
-
FormItem({
|
|
145
|
-
type: 'customStyleConfig',
|
|
146
|
-
detectProps: ['data'],
|
|
147
|
-
})(CustomStyleConfigRenderer);
|
|
148
|
-
*/
|
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file 数值指标组件
|
|
3
|
-
* @description 基于 Neo 平台的 XObject 实体对象数值指标组件,用于展示多个关键数值指标
|
|
4
|
-
*/
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
import { xObject } from 'neo-open-api'; // Neo Open API
|
|
8
|
-
|
|
9
|
-
// 引入 neo-ui-common / NeoEvent
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
import { BaseCmp, StatusHoc, NeoEvent } from 'neo-ui-common';
|
|
12
|
-
|
|
13
|
-
import './style.scss';
|
|
14
|
-
|
|
15
|
-
interface EntityApiKey {
|
|
16
|
-
xObjectApiKey: string;
|
|
17
|
-
objectId: string;
|
|
18
|
-
fieldDescList?: any[];
|
|
19
|
-
fields?: string[];
|
|
20
|
-
autoFetchData?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 字段描述信息接口
|
|
25
|
-
*/
|
|
26
|
-
interface FieldDesc {
|
|
27
|
-
value: string;
|
|
28
|
-
label: string;
|
|
29
|
-
type?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 自定义样式配置接口
|
|
34
|
-
*/
|
|
35
|
-
interface TargetNumberStyle {
|
|
36
|
-
baseStyle?: {
|
|
37
|
-
backgroundColor?: string;
|
|
38
|
-
paddingMargin?: {
|
|
39
|
-
margin?: string;
|
|
40
|
-
padding?: string;
|
|
41
|
-
quantity?: string;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
layoutStyle?: {
|
|
45
|
-
alignClass?: string;
|
|
46
|
-
legendOrient?: string;
|
|
47
|
-
};
|
|
48
|
-
titleStyle?: {
|
|
49
|
-
show?: boolean;
|
|
50
|
-
text?: string;
|
|
51
|
-
fontSize?: number;
|
|
52
|
-
fontWeight?: number;
|
|
53
|
-
color?: string;
|
|
54
|
-
backgroundColor?: string;
|
|
55
|
-
};
|
|
56
|
-
numberStyle?: {
|
|
57
|
-
fontSize?: number;
|
|
58
|
-
fontWeight?: number;
|
|
59
|
-
color?: string;
|
|
60
|
-
linkHref?: string;
|
|
61
|
-
};
|
|
62
|
-
numberTitleStyle?: {
|
|
63
|
-
fontSize?: number;
|
|
64
|
-
fontWeight?: number;
|
|
65
|
-
color?: string;
|
|
66
|
-
linkHref?: string;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 组件属性接口
|
|
72
|
-
*/
|
|
73
|
-
interface TargetNumberProps {
|
|
74
|
-
/** 实体对象的 API Key */
|
|
75
|
-
entityApiKey?: EntityApiKey;
|
|
76
|
-
/** 绑定的字段描述信息数组 */
|
|
77
|
-
selectFieldDesc?: FieldDesc[];
|
|
78
|
-
/** 自定义样式配置 */
|
|
79
|
-
targetNumberStyle?: TargetNumberStyle;
|
|
80
|
-
/** 数值格式化函数 */
|
|
81
|
-
formatter?: (value: any, fieldDesc?: FieldDesc) => string;
|
|
82
|
-
/** Neo 平台传递的数据 */
|
|
83
|
-
data?: any;
|
|
84
|
-
/** 组件类名 */
|
|
85
|
-
className?: string;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 字段值接口
|
|
90
|
-
*/
|
|
91
|
-
interface FieldValue {
|
|
92
|
-
fieldDesc: FieldDesc;
|
|
93
|
-
value: any;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 组件状态接口
|
|
98
|
-
*/
|
|
99
|
-
interface TargetNumberState {
|
|
100
|
-
recordData: any; // 数据列表
|
|
101
|
-
/** 当前字段值数组 */
|
|
102
|
-
targetNumbers: FieldValue[];
|
|
103
|
-
/** 加载状态 */
|
|
104
|
-
loading: boolean;
|
|
105
|
-
/** 错误信息 */
|
|
106
|
-
error: string | null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* 数值指标组件
|
|
111
|
-
* 用于展示多个关键数值指标,支持从 XObject 实体对象获取动态数据
|
|
112
|
-
* 每个字段都会显示为一个独立的数值块,包含字段标签和数值
|
|
113
|
-
*/
|
|
114
|
-
class TargetNumber extends BaseCmp<TargetNumberProps, TargetNumberState> {
|
|
115
|
-
constructor(props: TargetNumberProps) {
|
|
116
|
-
super(props);
|
|
117
|
-
|
|
118
|
-
// 初始化组件状态
|
|
119
|
-
this.state = {
|
|
120
|
-
recordData: {},
|
|
121
|
-
targetNumbers: [],
|
|
122
|
-
loading: false,
|
|
123
|
-
error: null,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// 绑定方法上下文
|
|
127
|
-
this.loadData = this.loadData.bind(this);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
componentDidMount() {
|
|
131
|
-
const { entityApiKey, selectFieldDesc } = this.props;
|
|
132
|
-
|
|
133
|
-
if (entityApiKey && this.hasValidFieldDesc(selectFieldDesc)) {
|
|
134
|
-
// 加载数据
|
|
135
|
-
this.loadData();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// 监听一个广播事件
|
|
139
|
-
console.log('TargetNumber 注册了一个广播事件 SavePageEvent');
|
|
140
|
-
NeoEvent.listen('SavePageEvent', (eventData: any) => {
|
|
141
|
-
console.log(
|
|
142
|
-
'TargetNumber 监听到了一个广播事件 SavePageEvent: ',
|
|
143
|
-
eventData,
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* 检查字段描述是否有效
|
|
150
|
-
*/
|
|
151
|
-
hasValidFieldDesc(selectFieldDesc?: FieldDesc[]): boolean {
|
|
152
|
-
return Array.isArray(selectFieldDesc);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
componentWillReceiveProps(nextProps: TargetNumberProps) {
|
|
156
|
-
const { selectFieldDesc } = nextProps;
|
|
157
|
-
if (selectFieldDesc && this.hasValidFieldDesc(selectFieldDesc)) {
|
|
158
|
-
this.getTargetNumbers(selectFieldDesc);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* 组件更新后执行
|
|
164
|
-
* 当 entityApiKey 或 selectFieldDesc 发生变化时重新加载数据
|
|
165
|
-
*/
|
|
166
|
-
async componentDidUpdate(prevProps: TargetNumberProps) {
|
|
167
|
-
const { entityApiKey, selectFieldDesc } = this.props;
|
|
168
|
-
const { entityApiKey: prevEntityApiKey } = prevProps;
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
entityApiKey?.xObjectApiKey !== prevEntityApiKey?.xObjectApiKey ||
|
|
172
|
-
entityApiKey?.objectId !== prevEntityApiKey?.objectId
|
|
173
|
-
) {
|
|
174
|
-
if (entityApiKey?.xObjectApiKey && entityApiKey?.objectId) {
|
|
175
|
-
this.loadData();
|
|
176
|
-
} else {
|
|
177
|
-
this.setState({
|
|
178
|
-
recordData: {},
|
|
179
|
-
targetNumbers: [],
|
|
180
|
-
error: null,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* 提取数值指标数据
|
|
188
|
-
* 根据配置的 selectFieldDesc 数组,提取数据列表中的字段值
|
|
189
|
-
*/
|
|
190
|
-
getTargetNumbers(selectFieldDesc: FieldDesc[]) {
|
|
191
|
-
const { recordData } = this.state;
|
|
192
|
-
|
|
193
|
-
let fieldValues: FieldValue[] = [];
|
|
194
|
-
if (selectFieldDesc && selectFieldDesc.length > 0) {
|
|
195
|
-
fieldValues = selectFieldDesc.map((fieldDesc: FieldDesc) => ({
|
|
196
|
-
fieldDesc,
|
|
197
|
-
value: recordData[fieldDesc.value],
|
|
198
|
-
}));
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
this.setState({
|
|
202
|
-
targetNumbers: fieldValues,
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* 加载数据
|
|
208
|
-
* 从 Neo 平台获取 XObject 实体数据,直接使用查询结果的第一条记录
|
|
209
|
-
*/
|
|
210
|
-
@NeoEvent.function
|
|
211
|
-
async loadData() {
|
|
212
|
-
const { entityApiKey, selectFieldDesc } = this.props;
|
|
213
|
-
this.setState({ loading: true, error: null });
|
|
214
|
-
|
|
215
|
-
try {
|
|
216
|
-
// 查询数据
|
|
217
|
-
const result = await xObject.get(entityApiKey);
|
|
218
|
-
|
|
219
|
-
if (result && result.status) {
|
|
220
|
-
const recordData = result.data || {};
|
|
221
|
-
let fieldValues: FieldValue[] = [];
|
|
222
|
-
|
|
223
|
-
if (selectFieldDesc && selectFieldDesc.length > 0) {
|
|
224
|
-
fieldValues = selectFieldDesc.map((fieldDesc) => ({
|
|
225
|
-
fieldDesc,
|
|
226
|
-
value: recordData[fieldDesc.value],
|
|
227
|
-
}));
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
this.setState({
|
|
231
|
-
recordData: recordData,
|
|
232
|
-
targetNumbers: fieldValues,
|
|
233
|
-
loading: false,
|
|
234
|
-
});
|
|
235
|
-
} else {
|
|
236
|
-
this.setState({
|
|
237
|
-
recordData: {},
|
|
238
|
-
error: result?.msg || '获取数据失败',
|
|
239
|
-
loading: false,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
} catch (error: any) {
|
|
243
|
-
this.setState({
|
|
244
|
-
recordData: {},
|
|
245
|
-
error: error.message || '获取数据失败',
|
|
246
|
-
loading: false,
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* 格式化数值
|
|
253
|
-
*/
|
|
254
|
-
formatValue(value: any, fieldDesc?: FieldDesc): string {
|
|
255
|
-
const { formatter } = this.props;
|
|
256
|
-
|
|
257
|
-
if (value === null || value === undefined) {
|
|
258
|
-
return '-';
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// 如果提供了自定义格式化函数,使用自定义格式化
|
|
262
|
-
if (formatter) {
|
|
263
|
-
return formatter(value, fieldDesc);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// 根据字段类型进行格式化
|
|
267
|
-
if (
|
|
268
|
-
fieldDesc &&
|
|
269
|
-
(fieldDesc.type === 'number' || fieldDesc.type === 'currency')
|
|
270
|
-
) {
|
|
271
|
-
// 数字类型,添加千分位
|
|
272
|
-
const numValue = Number(value);
|
|
273
|
-
if (!isNaN(numValue)) {
|
|
274
|
-
return numValue.toLocaleString('zh-CN');
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return String(value);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* 渲染组件
|
|
283
|
-
*/
|
|
284
|
-
render() {
|
|
285
|
-
const { targetNumbers, loading, error } = this.state;
|
|
286
|
-
const { className, targetNumberStyle = {} } = this.props;
|
|
287
|
-
|
|
288
|
-
console.log('TargetNumber:', this.props);
|
|
289
|
-
|
|
290
|
-
// 从 targetNumberStyle 中获取样式配置
|
|
291
|
-
const {
|
|
292
|
-
baseStyle = {},
|
|
293
|
-
layoutStyle = {},
|
|
294
|
-
titleStyle: titleStyleConfig = {},
|
|
295
|
-
numberStyle: numberStyleConfig = {},
|
|
296
|
-
numberTitleStyle: numberTitleStyleConfig = {},
|
|
297
|
-
} = targetNumberStyle;
|
|
298
|
-
|
|
299
|
-
// 获取布局方式,默认为 flex-col
|
|
300
|
-
// 兼容 configSchema 中的值映射:horizontal -> flex-col
|
|
301
|
-
let alignClass = layoutStyle?.alignClass || 'flex-col';
|
|
302
|
-
if (alignClass === 'horizontal') {
|
|
303
|
-
alignClass = 'flex-col';
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// 获取基础样式
|
|
307
|
-
const baseStyleObj: React.CSSProperties = {
|
|
308
|
-
backgroundColor: baseStyle?.backgroundColor || '#ffffff',
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
// 处理内外边距
|
|
312
|
-
const paddingMargin = baseStyle?.paddingMargin || {};
|
|
313
|
-
const margin = paddingMargin.margin || '0';
|
|
314
|
-
const padding = paddingMargin.padding || '0';
|
|
315
|
-
const quantity = paddingMargin.quantity || 'px';
|
|
316
|
-
|
|
317
|
-
// 应用单位到 margin 和 padding
|
|
318
|
-
const formatSpacing = (value: string, unit: string) => {
|
|
319
|
-
if (!value || value === '0') return '0';
|
|
320
|
-
// 如果值已经包含单位,直接返回;否则添加单位
|
|
321
|
-
if (/\d+(px|rem|em|%)$/.test(value.trim())) {
|
|
322
|
-
return value;
|
|
323
|
-
}
|
|
324
|
-
return `${value}${unit}`;
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
baseStyleObj.margin = formatSpacing(margin, quantity);
|
|
328
|
-
// 如果 padding 为 0,使用默认的 16px(保持原有样式)
|
|
329
|
-
const finalPadding =
|
|
330
|
-
padding === '0' ? '16px' : formatSpacing(padding, quantity);
|
|
331
|
-
baseStyleObj.padding = finalPadding;
|
|
332
|
-
|
|
333
|
-
// 数值样式
|
|
334
|
-
const numberStyle: React.CSSProperties = {
|
|
335
|
-
fontSize: numberStyleConfig?.fontSize
|
|
336
|
-
? `${numberStyleConfig.fontSize}px`
|
|
337
|
-
: '32px',
|
|
338
|
-
fontWeight: numberStyleConfig?.fontWeight || 600,
|
|
339
|
-
color: numberStyleConfig?.color || '#262626',
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
// 数值标题样式(字段标签)
|
|
343
|
-
const numberTitleStyle: React.CSSProperties = {
|
|
344
|
-
fontSize: numberTitleStyleConfig?.fontSize
|
|
345
|
-
? `${numberTitleStyleConfig.fontSize}px`
|
|
346
|
-
: '14px',
|
|
347
|
-
fontWeight: numberTitleStyleConfig?.fontWeight || 400,
|
|
348
|
-
color: numberTitleStyleConfig?.color || '#8c8c8c',
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
// 组件标题样式(根据 titleStyle 配置,仅当 show 为 true 时展示)
|
|
352
|
-
const showTitle = titleStyleConfig?.show === true;
|
|
353
|
-
const titleStyle: React.CSSProperties = {
|
|
354
|
-
fontSize:
|
|
355
|
-
titleStyleConfig?.fontSize != null
|
|
356
|
-
? `${titleStyleConfig.fontSize}px`
|
|
357
|
-
: '24px',
|
|
358
|
-
fontWeight: titleStyleConfig?.fontWeight ?? 400,
|
|
359
|
-
color: titleStyleConfig?.color || '#000000',
|
|
360
|
-
backgroundColor: titleStyleConfig?.backgroundColor || '#eaf3fc',
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
// 渲染单个数值块
|
|
364
|
-
const renderFieldValue = (fieldValue: FieldValue, index: number) => {
|
|
365
|
-
const fieldLabel = fieldValue.fieldDesc?.label || '数值指标';
|
|
366
|
-
const formattedValue = this.formatValue(
|
|
367
|
-
fieldValue.value,
|
|
368
|
-
fieldValue.fieldDesc,
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
// 处理数值链接
|
|
372
|
-
const numberLinkHref = numberStyleConfig?.linkHref;
|
|
373
|
-
const numberContent = numberLinkHref ? (
|
|
374
|
-
<a
|
|
375
|
-
href={numberLinkHref}
|
|
376
|
-
style={{ ...numberStyle, textDecoration: 'none' }}
|
|
377
|
-
>
|
|
378
|
-
{formattedValue}
|
|
379
|
-
</a>
|
|
380
|
-
) : (
|
|
381
|
-
formattedValue
|
|
382
|
-
);
|
|
383
|
-
|
|
384
|
-
// 处理标题链接
|
|
385
|
-
const titleLinkHref = numberTitleStyleConfig?.linkHref;
|
|
386
|
-
const titleContent = titleLinkHref ? (
|
|
387
|
-
<a
|
|
388
|
-
href={titleLinkHref}
|
|
389
|
-
style={{ ...numberTitleStyle, textDecoration: 'none' }}
|
|
390
|
-
>
|
|
391
|
-
{fieldLabel}
|
|
392
|
-
</a>
|
|
393
|
-
) : (
|
|
394
|
-
fieldLabel
|
|
395
|
-
);
|
|
396
|
-
|
|
397
|
-
return (
|
|
398
|
-
<div key={index} className={`target-number-item ${alignClass}`}>
|
|
399
|
-
<div className="target-number-value" style={numberStyle}>
|
|
400
|
-
{numberContent}
|
|
401
|
-
</div>
|
|
402
|
-
<div className="target-number-label" style={numberTitleStyle}>
|
|
403
|
-
{titleContent}
|
|
404
|
-
</div>
|
|
405
|
-
</div>
|
|
406
|
-
);
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
return (
|
|
410
|
-
<div
|
|
411
|
-
className={`targetNumber__c ${className || ''}`}
|
|
412
|
-
style={baseStyleObj}
|
|
413
|
-
>
|
|
414
|
-
{showTitle && (titleStyleConfig?.text ?? '') !== '' && (
|
|
415
|
-
<div className="target-number-title" style={titleStyle}>
|
|
416
|
-
{titleStyleConfig?.text}
|
|
417
|
-
</div>
|
|
418
|
-
)}
|
|
419
|
-
<div className="target-number-block multiple-fields">
|
|
420
|
-
{loading ? (
|
|
421
|
-
<div className="target-number-loading">加载中...</div>
|
|
422
|
-
) : error ? (
|
|
423
|
-
<div className="target-number-error">{error}</div>
|
|
424
|
-
) : targetNumbers.length > 0 ? (
|
|
425
|
-
<div className="target-number-list">
|
|
426
|
-
{targetNumbers.map((fieldValue, index) =>
|
|
427
|
-
renderFieldValue(fieldValue, index),
|
|
428
|
-
)}
|
|
429
|
-
</div>
|
|
430
|
-
) : (
|
|
431
|
-
<div className="target-number-empty">暂无数据</div>
|
|
432
|
-
)}
|
|
433
|
-
</div>
|
|
434
|
-
</div>
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// 使用 StatusHoc 包裹组件,用于支持组件显示隐藏控制
|
|
440
|
-
export default StatusHoc(TargetNumber);
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// 导入自定义配置项(用于对接复杂自定义配置)
|
|
2
|
-
// import './customStyleConfig';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @file 数值指标组件对接编辑器的描述文件
|
|
6
|
-
* @description 定义组件在 Neo 平台编辑器中的配置信息
|
|
7
|
-
* @author Neo Custom Widget CLI
|
|
8
|
-
* @version 1.0.0
|
|
9
|
-
*/
|
|
10
|
-
export class TargetNumberModel {
|
|
11
|
-
/**
|
|
12
|
-
* 组件类型标识
|
|
13
|
-
* 用于标识组件的唯一性,在构建时根据当前组件目录名称自动生成
|
|
14
|
-
* 注意:此字段在构建时会被自动替换,不需要手动设置
|
|
15
|
-
*/
|
|
16
|
-
// cmpType: string = 'targetNumber';
|
|
17
|
-
|
|
18
|
-
/** 组件名称,用于设置在编辑器左侧组件面板中展示的名称 */
|
|
19
|
-
label: string = '数值指标';
|
|
20
|
-
|
|
21
|
-
/** 组件描述,用于设置在编辑器左侧组件面板中展示的描述 */
|
|
22
|
-
description: string =
|
|
23
|
-
'用于展示关键数值指标,支持从 XObject 实体对象获取动态数据,支持绑定多个字段进行展示';
|
|
24
|
-
|
|
25
|
-
/** 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示 */
|
|
26
|
-
// tags: string[] = ['自定义组件'];
|
|
27
|
-
|
|
28
|
-
/** 组件图标,用于设置在编辑器左侧组件面板中展示的图标 */
|
|
29
|
-
iconUrl: string = 'https://custom-widgets.bj.bcebos.com/TargetNumber.svg';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 用于设置组件支持的页面类型
|
|
33
|
-
*
|
|
34
|
-
* 当前 NeoCRM 平台存在的页面类型:
|
|
35
|
-
* all: 1 全页面
|
|
36
|
-
* entityFormPage: 4 实体表单页
|
|
37
|
-
* customPage: 6 自定义页面
|
|
38
|
-
*/
|
|
39
|
-
targetPage: string[] = ['all'];
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 用于设置组件支持的终端类型
|
|
43
|
-
*
|
|
44
|
-
* 当前 NeoCRM 平台存在的终端类型:
|
|
45
|
-
* web: 网页端
|
|
46
|
-
* mobile: 移动端
|
|
47
|
-
*/
|
|
48
|
-
targetDevice: string = 'all';
|
|
49
|
-
|
|
50
|
-
/** 初次插入页面的默认属性数据 */
|
|
51
|
-
defaultComProps = {
|
|
52
|
-
entityApiKey: '',
|
|
53
|
-
targetNumberStyle: {
|
|
54
|
-
baseStyle: {
|
|
55
|
-
backgroundColor: '#ffffff',
|
|
56
|
-
paddingMargin: {
|
|
57
|
-
margin: '0',
|
|
58
|
-
padding: '0',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
layoutStyle: {
|
|
62
|
-
alignClass: 'flex-col',
|
|
63
|
-
},
|
|
64
|
-
titleStyle: {
|
|
65
|
-
show: true,
|
|
66
|
-
text: '>> 关键数据',
|
|
67
|
-
fontSize: 18,
|
|
68
|
-
fontWeight: 700,
|
|
69
|
-
color: '#333',
|
|
70
|
-
backgroundColor: '#eaf3fc',
|
|
71
|
-
},
|
|
72
|
-
numberStyle: {
|
|
73
|
-
fontSize: 32,
|
|
74
|
-
fontWeight: 600,
|
|
75
|
-
color: '#262626',
|
|
76
|
-
},
|
|
77
|
-
numberTitleStyle: {
|
|
78
|
-
fontSize: 14,
|
|
79
|
-
fontWeight: 400,
|
|
80
|
-
color: '#8c8c8c',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// 当前组件支持的函数列表(其他组件可触发当前组件的函数)
|
|
86
|
-
functions = [
|
|
87
|
-
{
|
|
88
|
-
apiKey: 'loadData',
|
|
89
|
-
label: '刷新BI看板数据',
|
|
90
|
-
helpTextKey: '刷新BI看板组件数据',
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 组件属性配置模式
|
|
96
|
-
* 支持静态配置:propsSchema,优先级比 propsSchemaCreator 低
|
|
97
|
-
* 定义组件在编辑器中可配置的属性
|
|
98
|
-
*/
|
|
99
|
-
propsSchema = [
|
|
100
|
-
{
|
|
101
|
-
type: 'xObjectDetailApi',
|
|
102
|
-
name: 'entityApiKey',
|
|
103
|
-
label: '绑定实体业务数据',
|
|
104
|
-
placeholder: '绑定实体业务数据源',
|
|
105
|
-
disabledFieldSelect: true,
|
|
106
|
-
disabledAutoFetchData: true,
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
type: 'selectFieldDescApi',
|
|
110
|
-
name: 'selectFieldDesc',
|
|
111
|
-
xObjectApiKey: 'entityApiKey.xObjectApiKey',
|
|
112
|
-
mode: 'tags', // 多选,必填
|
|
113
|
-
label: '绑定字段',
|
|
114
|
-
placeholder: '请至少选择一个要显示的字段',
|
|
115
|
-
},
|
|
116
|
-
/*
|
|
117
|
-
{
|
|
118
|
-
type: 'customStyleConfig',
|
|
119
|
-
name: 'targetNumberStyle',
|
|
120
|
-
label: '自定义样式配置',
|
|
121
|
-
viewStyle: 'tabs', // 'tabs'、'fold'
|
|
122
|
-
wideScreen: false, // 是否开启宽屏展示模式
|
|
123
|
-
},
|
|
124
|
-
*/
|
|
125
|
-
];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export default TargetNumberModel;
|