@jiangood/open-admin 1.0.0
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/config/dist/common-plugin.js +148 -0
- package/config/dist/config.js +45 -0
- package/config/dist/index.js +18 -0
- package/package.json +41 -0
- package/src/app.js +1 -0
- package/src/asserts/welcome.png +0 -0
- package/src/forms/demoForm.jsx +16 -0
- package/src/framework/components/DownloadFileButton.d.ts +11 -0
- package/src/framework/components/DownloadFileButton.jsx +33 -0
- package/src/framework/components/Ellipsis.jsx +39 -0
- package/src/framework/components/Ellipsis.less +8 -0
- package/src/framework/components/Gap/index.d.ts +23 -0
- package/src/framework/components/Gap/index.jsx +46 -0
- package/src/framework/components/LinkButton.d.ts +14 -0
- package/src/framework/components/LinkButton.jsx +10 -0
- package/src/framework/components/NamedIcon.tsx +15 -0
- package/src/framework/components/Page/index.d.ts +17 -0
- package/src/framework/components/Page/index.jsx +30 -0
- package/src/framework/components/Page/index.less +10 -0
- package/src/framework/components/PageLoading.tsx +27 -0
- package/src/framework/components/ProModal/index.tsx +66 -0
- package/src/framework/components/ProTable/components/ToolBar/index.jsx +123 -0
- package/src/framework/components/ProTable/components/ToolBar/index.less +53 -0
- package/src/framework/components/ProTable/index.d.ts +42 -0
- package/src/framework/components/ProTable/index.jsx +260 -0
- package/src/framework/components/ProTable/index.less +14 -0
- package/src/framework/components/ProTable/utils/index.js +43 -0
- package/src/framework/components/ValueType/index.jsx +34 -0
- package/src/framework/components/ValueType/registry.jsx +27 -0
- package/src/framework/components/index.ts +17 -0
- package/src/framework/components/system/ButtonList.d.ts +8 -0
- package/src/framework/components/system/ButtonList.jsx +42 -0
- package/src/framework/components/system/HasPerm.tsx +14 -0
- package/src/framework/components/system/index.tsx +29 -0
- package/src/framework/components/view/ViewBooleanEnableDisable.tsx +20 -0
- package/src/framework/components/view/ViewEllipsis.d.ts +11 -0
- package/src/framework/components/view/ViewEllipsis.jsx +30 -0
- package/src/framework/components/view/ViewFile.d.ts +10 -0
- package/src/framework/components/view/ViewFile.jsx +49 -0
- package/src/framework/components/view/ViewFileButton.d.ts +10 -0
- package/src/framework/components/view/ViewFileButton.jsx +0 -0
- package/src/framework/components/view/ViewImage.d.ts +9 -0
- package/src/framework/components/view/ViewImage.jsx +60 -0
- package/src/framework/components/view/ViewRange/index.d.ts +16 -0
- package/src/framework/components/view/ViewRange/index.jsx +20 -0
- package/src/framework/components/view/ViewText.tsx +16 -0
- package/src/framework/components/view/index.ts +10 -0
- package/src/framework/field-components/FieldBoolean.d.ts +13 -0
- package/src/framework/field-components/FieldBoolean.jsx +76 -0
- package/src/framework/field-components/FieldDate.d.ts +27 -0
- package/src/framework/field-components/FieldDate.jsx +114 -0
- package/src/framework/field-components/FieldDateRange.d.ts +6 -0
- package/src/framework/field-components/FieldDateRange.jsx +104 -0
- package/src/framework/field-components/FieldDictSelect.d.ts +13 -0
- package/src/framework/field-components/FieldDictSelect.jsx +16 -0
- package/src/framework/field-components/FieldEditor.d.ts +10 -0
- package/src/framework/field-components/FieldEditor.jsx +58 -0
- package/src/framework/field-components/FieldNumberRange.d.ts +13 -0
- package/src/framework/field-components/FieldNumberRange.jsx +59 -0
- package/src/framework/field-components/FieldPercent.d.ts +12 -0
- package/src/framework/field-components/FieldPercent.jsx +27 -0
- package/src/framework/field-components/FieldRemoteSelect.d.ts +13 -0
- package/src/framework/field-components/FieldRemoteSelect.jsx +87 -0
- package/src/framework/field-components/FieldRemoteSelectMultiple.d.ts +13 -0
- package/src/framework/field-components/FieldRemoteSelectMultiple.jsx +86 -0
- package/src/framework/field-components/FieldRemoteSelectMultipleInline.d.ts +20 -0
- package/src/framework/field-components/FieldRemoteSelectMultipleInline.jsx +86 -0
- package/src/framework/field-components/FieldRemoteTree.d.ts +21 -0
- package/src/framework/field-components/FieldRemoteTree.jsx +45 -0
- package/src/framework/field-components/FieldRemoteTreeCascader.d.ts +23 -0
- package/src/framework/field-components/FieldRemoteTreeCascader.jsx +61 -0
- package/src/framework/field-components/FieldRemoteTreeSelect.d.ts +17 -0
- package/src/framework/field-components/FieldRemoteTreeSelect.jsx +67 -0
- package/src/framework/field-components/FieldRemoteTreeSelectMultiple.d.ts +17 -0
- package/src/framework/field-components/FieldRemoteTreeSelectMultiple.jsx +72 -0
- package/src/framework/field-components/FieldSysOrgTree.d.ts +12 -0
- package/src/framework/field-components/FieldSysOrgTree.jsx +23 -0
- package/src/framework/field-components/FieldSysOrgTreeSelect.d.ts +12 -0
- package/src/framework/field-components/FieldSysOrgTreeSelect.jsx +23 -0
- package/src/framework/field-components/FieldTable.d.ts +17 -0
- package/src/framework/field-components/FieldTable.jsx +108 -0
- package/src/framework/field-components/FieldTable.less +29 -0
- package/src/framework/field-components/FieldTableSelect.d.ts +19 -0
- package/src/framework/field-components/FieldTableSelect.jsx +59 -0
- package/src/framework/field-components/FieldUploadFile.d.ts +34 -0
- package/src/framework/field-components/FieldUploadFile.jsx +141 -0
- package/src/framework/field-components/index.ts +21 -0
- package/src/framework/field-components/system/OrgTree.tsx +61 -0
- package/src/framework/field-components/system/RoleTree.tsx +53 -0
- package/src/framework/field-components/system/index.ts +2 -0
- package/src/framework/index.ts +5 -0
- package/src/framework/pages/LoginPage.d.ts +16 -0
- package/src/framework/pages/LoginPage.jsx +135 -0
- package/src/framework/pages/LoginPage.less +53 -0
- package/src/framework/pages/LoginPageUtils.ts +36 -0
- package/src/framework/pages/index.ts +2 -0
- package/src/framework/utils/ArrUtils.ts +229 -0
- package/src/framework/utils/ColorsUtils.ts +378 -0
- package/src/framework/utils/DateUtils.ts +187 -0
- package/src/framework/utils/DeviceUtils.ts +46 -0
- package/src/framework/utils/DomUtils.ts +50 -0
- package/src/framework/utils/EventBusUtils.ts +144 -0
- package/src/framework/utils/Logger.ts +40 -0
- package/src/framework/utils/MessageUtils.tsx +170 -0
- package/src/framework/utils/ObjectUtils.ts +118 -0
- package/src/framework/utils/StorageUtils.ts +50 -0
- package/src/framework/utils/StringUtils.ts +436 -0
- package/src/framework/utils/TreeUtils.ts +251 -0
- package/src/framework/utils/UrlUtils.ts +152 -0
- package/src/framework/utils/UuidUtils.ts +88 -0
- package/src/framework/utils/ValidateUtils.ts +28 -0
- package/src/framework/utils/index.ts +16 -0
- package/src/framework/utils/system/DictUtils.ts +97 -0
- package/src/framework/utils/system/FormRegistryUtils.ts +77 -0
- package/src/framework/utils/system/HttpUtils.ts +247 -0
- package/src/framework/utils/system/PageUtils.ts +163 -0
- package/src/framework/utils/system/PermUtils.ts +79 -0
- package/src/framework/utils/system/SysUtils.ts +97 -0
- package/src/framework/utils/system/ThemeUtils.ts +27 -0
- package/src/framework/utils/system/index.ts +7 -0
- package/src/framework/view-components/ViewApproveStatus.tsx +26 -0
- package/src/framework/view-components/ViewBoolean.tsx +6 -0
- package/src/framework/view-components/ViewFlowableInstanceProgress.d.ts +12 -0
- package/src/framework/view-components/ViewFlowableInstanceProgress.jsx +97 -0
- package/src/framework/view-components/ViewFlowableInstanceProgressButton.tsx +26 -0
- package/src/framework/view-components/ViewPassword.tsx +25 -0
- package/src/framework/view-components/ViewProps.ts +11 -0
- package/src/framework/view-components/index.ts +6 -0
- package/src/index.ts +2 -0
- package/src/layouts/PageRender.d.ts +22 -0
- package/src/layouts/PageRender.jsx +90 -0
- package/src/layouts/admin/HeaderRight.jsx +104 -0
- package/src/layouts/admin/TabPageRender.jsx +158 -0
- package/src/layouts/admin/index.jsx +161 -0
- package/src/layouts/admin/index.less +65 -0
- package/src/layouts/index.jsx +165 -0
- package/src/layouts/index.less +24 -0
- package/src/loading.jsx +18 -0
- package/src/pages/404.jsx +13 -0
- package/src/pages/about.jsx +14 -0
- package/src/pages/index.jsx +25 -0
- package/src/pages/login.jsx +21 -0
- package/src/pages/system/api/ApiDoc.jsx +144 -0
- package/src/pages/system/api/index.jsx +268 -0
- package/src/pages/system/api/perm.jsx +69 -0
- package/src/pages/system/dict/Dict.jsx +72 -0
- package/src/pages/system/dict/DictItem.jsx +177 -0
- package/src/pages/system/dict/index.jsx +25 -0
- package/src/pages/system/file/index.jsx +160 -0
- package/src/pages/system/job/index.jsx +324 -0
- package/src/pages/system/log/index.jsx +78 -0
- package/src/pages/system/org/index.jsx +262 -0
- package/src/pages/system/role/index.jsx +308 -0
- package/src/pages/system/role/perm.jsx +108 -0
- package/src/pages/system/sysManual/index.jsx +127 -0
- package/src/pages/system/user/UserPerm.jsx +97 -0
- package/src/pages/system/user/index.jsx +258 -0
- package/src/pages/test.jsx +200 -0
- package/src/pages/ureport/index.jsx +16 -0
- package/src/pages/userCenter/ChangePassword.jsx +63 -0
- package/src/pages/userCenter/index.jsx +90 -0
- package/src/pages/userCenter/manual.jsx +59 -0
- package/src/pages/userCenter/message.jsx +105 -0
- package/src/style/global.less +51 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {FieldRemoteSelect, FieldRemoteSelectMultiple, FieldRemoteTreeSelect} from "../../field-components";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
export * from './ButtonList'
|
|
5
|
+
export * from './HasPerm'
|
|
6
|
+
|
|
7
|
+
export function FieldUserSelect(props) {
|
|
8
|
+
return <FieldRemoteSelect url="admin/sysUser/options" {...props} />;
|
|
9
|
+
}
|
|
10
|
+
export function FieldUserSelectMultiple(props) {
|
|
11
|
+
return <FieldRemoteSelectMultiple url="admin/sysUser/options" {...props} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function FieldUnitTreeSelect(props) {
|
|
15
|
+
return <FieldRemoteTreeSelect url="admin/sysOrg/unitTree" {...props} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function FieldDeptTreeSelect(props) {
|
|
19
|
+
return <FieldRemoteTreeSelect url="admin/sysOrg/deptTree" {...props} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function FieldOrgTreeSelect(props) {
|
|
23
|
+
return <FieldRemoteTreeSelect url="admin/sysOrg/deptTree" {...props} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function FieldOrgTreeMultipleSelect(props) {
|
|
27
|
+
return <FieldRemoteSelectMultiple url="/sysOrg/deptTree" {...props} />;
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tag } from 'antd';
|
|
3
|
+
|
|
4
|
+
// 定义组件的 Props 接口
|
|
5
|
+
interface ViewBooleanEnableDisableProps {
|
|
6
|
+
value: boolean | null | undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class ViewBooleanEnableDisable extends React.Component<ViewBooleanEnableDisableProps, any> {
|
|
10
|
+
|
|
11
|
+
render() {
|
|
12
|
+
const { value } = this.props;
|
|
13
|
+
|
|
14
|
+
if (value == null) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return value ? <Tag color={"green"}>启用</Tag> : <Tag color={"red"}>禁用</Tag>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Button, Modal, Popover} from 'antd';
|
|
3
|
+
import {StringUtils} from "../../utils";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class ViewEllipsis extends React.Component {
|
|
7
|
+
|
|
8
|
+
static defaultProps = {maxLength: 15}
|
|
9
|
+
|
|
10
|
+
render() {
|
|
11
|
+
let {maxLength, value} = this.props;
|
|
12
|
+
|
|
13
|
+
const short = StringUtils.ellipsis(value, maxLength)
|
|
14
|
+
return <Popover placement="topLeft" title={'长文本'} content={<Button onClick={this.showModal}>点击查看全部内容</Button>}>
|
|
15
|
+
{short}
|
|
16
|
+
</Popover>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
showModal = () => {
|
|
21
|
+
let {maxLength, value} = this.props;
|
|
22
|
+
Modal.info({
|
|
23
|
+
icon:null,
|
|
24
|
+
title:'长文本内容',
|
|
25
|
+
content: <div style={{height:500,overflowY:'auto'}}>{value}</div>,
|
|
26
|
+
width:700
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Carousel, Empty} from 'antd';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class ViewFile extends React.Component {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
render() {
|
|
9
|
+
let fileId = this.props.value
|
|
10
|
+
|
|
11
|
+
if (!fileId) {
|
|
12
|
+
return <Empty/>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let arr = fileId.split(',');
|
|
16
|
+
|
|
17
|
+
let urlList = arr.map(id => 'admin/sysFile/preview/' + id);
|
|
18
|
+
let height = this.props.height;
|
|
19
|
+
|
|
20
|
+
if(urlList.length === 1){
|
|
21
|
+
const url = urlList[0]
|
|
22
|
+
return <iframe
|
|
23
|
+
src={url}
|
|
24
|
+
width='99%'
|
|
25
|
+
frameBorder={0}
|
|
26
|
+
style={{height}}
|
|
27
|
+
/>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 多个文件则用走马灯
|
|
31
|
+
const iframeList = urlList.map((url) => {
|
|
32
|
+
return <div style={{height}}>
|
|
33
|
+
<iframe
|
|
34
|
+
key={url}
|
|
35
|
+
src={url}
|
|
36
|
+
width='99%'
|
|
37
|
+
frameBorder={0}
|
|
38
|
+
style={{height}}
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return <div style={{height}}>
|
|
44
|
+
<Carousel dotPosition={"top"}>
|
|
45
|
+
{iframeList}
|
|
46
|
+
</Carousel>
|
|
47
|
+
</div>
|
|
48
|
+
}
|
|
49
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Modal} from 'antd';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class ViewImage extends React.Component {
|
|
6
|
+
|
|
7
|
+
render() {
|
|
8
|
+
let vs = this.props.value
|
|
9
|
+
|
|
10
|
+
if (!vs) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (typeof vs === 'string') {
|
|
15
|
+
vs = vs.split(',');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let urlList = [];
|
|
19
|
+
for (let v of vs) {
|
|
20
|
+
let isId = v.indexOf('/') === -1;
|
|
21
|
+
let isAbsUrl = v.startsWith('http');
|
|
22
|
+
if (isAbsUrl) {
|
|
23
|
+
urlList.push(v);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (isId) {
|
|
28
|
+
urlList.push( 'admin/sysFile/preview/' + v);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
urlList.push( v);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const imgs = urlList.map((url) => (
|
|
36
|
+
<img
|
|
37
|
+
style={{ display: 'inline-block' }}
|
|
38
|
+
key={url}
|
|
39
|
+
src={url}
|
|
40
|
+
onClick={() => this.preview(url)}
|
|
41
|
+
width={60}
|
|
42
|
+
height={60}
|
|
43
|
+
/>
|
|
44
|
+
));
|
|
45
|
+
|
|
46
|
+
return imgs;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
preview = (url) => {
|
|
50
|
+
Modal.info({
|
|
51
|
+
title: '预览图片',
|
|
52
|
+
width: '70vw',
|
|
53
|
+
content: <div style={{maxHeight:'70vh',overflow:'auto'}}>
|
|
54
|
+
<img src={url} style={{maxWidth: '100%'}}/>
|
|
55
|
+
</div>,
|
|
56
|
+
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export class ViewRange extends React.Component {
|
|
4
|
+
|
|
5
|
+
static defaultProps = {
|
|
6
|
+
min : '未知',max : '未知'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
render() {
|
|
10
|
+
let {min,max} = this.props
|
|
11
|
+
if(min == null && max == null){
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
min = min == null ? '未知': min;
|
|
15
|
+
max = max == null ? '未知': max;
|
|
16
|
+
|
|
17
|
+
return min + ' - ' + max;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {Typography} from "antd";
|
|
3
|
+
|
|
4
|
+
interface ViewTextProps {
|
|
5
|
+
value?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class ViewText extends React.Component<ViewTextProps, any>{
|
|
9
|
+
|
|
10
|
+
render() {
|
|
11
|
+
if(this.props.value == null){
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return <Typography.Text> {this.props.value}</Typography.Text>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SelectProps } from 'antd/es/select';
|
|
3
|
+
|
|
4
|
+
export interface FieldBooleanProps {
|
|
5
|
+
|
|
6
|
+
type?:'select' | 'radio' | 'checkbox' | 'switch'; // 默认 select
|
|
7
|
+
value?: boolean;
|
|
8
|
+
onChange?: (value: boolean) => void;
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class FieldBoolean extends React.Component<FieldBooleanProps, any> {}
|
|
13
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* antd 自带的checkbox 未选择时不会返回false, 和form配合时还得设置 valuePropName
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* 本组件改成布尔值的输入
|
|
6
|
+
*
|
|
7
|
+
* 选中 true, 反选 false
|
|
8
|
+
*
|
|
9
|
+
* 注意:null 会转为false
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import {Checkbox, Radio, Select, Switch} from 'antd';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export class FieldBoolean extends React.Component {
|
|
18
|
+
|
|
19
|
+
static defaultProps = {
|
|
20
|
+
type: 'select'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
render() {
|
|
24
|
+
let {value, onChange, type} = this.props
|
|
25
|
+
|
|
26
|
+
const v = this.parseBoolean(value);
|
|
27
|
+
|
|
28
|
+
switch (type) {
|
|
29
|
+
case 'radio':
|
|
30
|
+
return <Radio.Group value={v} onChange={onChange}>
|
|
31
|
+
<Radio value={true}>是</Radio>
|
|
32
|
+
<Radio value={false}>否</Radio>
|
|
33
|
+
<Radio value={undefined}>不确定</Radio>
|
|
34
|
+
</Radio.Group>;
|
|
35
|
+
case 'checkbox':
|
|
36
|
+
return <Checkbox
|
|
37
|
+
checked={v}
|
|
38
|
+
onChange={(e) => {
|
|
39
|
+
onChange(e.target.checked);
|
|
40
|
+
}}
|
|
41
|
+
/>;
|
|
42
|
+
case 'select':
|
|
43
|
+
return <Select options={[
|
|
44
|
+
{value: true, label: '是'},
|
|
45
|
+
{value: false, label: '否'},
|
|
46
|
+
]}
|
|
47
|
+
value={v}
|
|
48
|
+
onChange={onChange}
|
|
49
|
+
style={{width: '100%'}}
|
|
50
|
+
allowClear={true}
|
|
51
|
+
placeholder={'请选择'}
|
|
52
|
+
/>
|
|
53
|
+
case 'switch':
|
|
54
|
+
return <Switch
|
|
55
|
+
checked={v}
|
|
56
|
+
onChange={onChange}
|
|
57
|
+
/>;
|
|
58
|
+
default:
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
parseBoolean(v) {
|
|
65
|
+
if (v === null || v === undefined) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof v === 'boolean') {
|
|
70
|
+
return v;
|
|
71
|
+
}
|
|
72
|
+
return v === 1 || v === 'true' || v === 'Y';
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface FieldDateProps {
|
|
4
|
+
|
|
5
|
+
type: 'YYYY-MM-DD' | 'DAY'|
|
|
6
|
+
'YYYY-MM-DD HH:mm:ss' |
|
|
7
|
+
// 年
|
|
8
|
+
'YYYY' | 'YEAR' |
|
|
9
|
+
// 年月
|
|
10
|
+
'YYYY-MM' | 'YEAR_MONTH'|
|
|
11
|
+
// 季度
|
|
12
|
+
'YYYY-QQ' | 'YEAR_QUARTER'|
|
|
13
|
+
|
|
14
|
+
'YYYY-MM-DD HH:mm' |
|
|
15
|
+
|
|
16
|
+
// 时间
|
|
17
|
+
'HH:mm' |
|
|
18
|
+
'HH:mm:ss';
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class FieldDate extends React.Component<FieldDateProps, any> {
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 根据时间类型自动渲染时间选择组件
|
|
3
|
+
*/
|
|
4
|
+
import React from "react";
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
import {DatePicker, TimePicker} from "antd";
|
|
7
|
+
import {DateUtils} from "../utils";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class FieldDate extends React.Component {
|
|
11
|
+
static defaultProps = {
|
|
12
|
+
type: 'YYYY-MM-DD'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
render() {
|
|
18
|
+
let {type, value, onChange, ...rest} = this.props;
|
|
19
|
+
type = DateUtils.convertTypeToFormat(type)
|
|
20
|
+
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'YYYY':
|
|
23
|
+
return <DatePicker
|
|
24
|
+
value={this.strToDate(value, type)}
|
|
25
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY'))}
|
|
26
|
+
picker="year"
|
|
27
|
+
{...rest}
|
|
28
|
+
/>;
|
|
29
|
+
case 'YYYY-MM':
|
|
30
|
+
return <DatePicker
|
|
31
|
+
value={this.strToDate(value, 'YYYY-MM')}
|
|
32
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-MM'))}
|
|
33
|
+
picker="month"
|
|
34
|
+
{...rest}
|
|
35
|
+
/>;
|
|
36
|
+
case 'YYYY-QQ':
|
|
37
|
+
return <DatePicker
|
|
38
|
+
value={this.strToDate(value, 'YYYY-QQ')}
|
|
39
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-QQ'))}
|
|
40
|
+
picker="quarter"
|
|
41
|
+
{...rest}
|
|
42
|
+
/>;
|
|
43
|
+
case 'YYYY-MM-DD':
|
|
44
|
+
return <DatePicker
|
|
45
|
+
value={this.strToDate(value, 'YYYY-MM-DD')}
|
|
46
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-MM-DD'))}
|
|
47
|
+
{...rest}
|
|
48
|
+
></DatePicker>;
|
|
49
|
+
case 'YYYY-MM-DD HH:mm':
|
|
50
|
+
return <DatePicker
|
|
51
|
+
value={this.strToDate(value, 'YYYY-MM-DD HH:mm')}
|
|
52
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-MM-DD HH:mm'))}
|
|
53
|
+
format='YYYY-MM-DD HH:mm'
|
|
54
|
+
showTime
|
|
55
|
+
{...rest}
|
|
56
|
+
></DatePicker>;
|
|
57
|
+
case 'YYYY-MM-DD HH:mm:ss':
|
|
58
|
+
return <DatePicker
|
|
59
|
+
value={this.strToDate(value, 'YYYY-MM-DD HH:mm:ss')}
|
|
60
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-MM-DD HH:mm:ss'))}
|
|
61
|
+
showTime
|
|
62
|
+
{...rest}
|
|
63
|
+
></DatePicker>;
|
|
64
|
+
case 'HH:mm':
|
|
65
|
+
return <TimePicker
|
|
66
|
+
format='HH:mm'
|
|
67
|
+
value={this.strToDate(value, 'HH:mm')}
|
|
68
|
+
onChange={v => onChange(this.dateToStr(v,'HH:mm'))}
|
|
69
|
+
{...rest}
|
|
70
|
+
></TimePicker>;
|
|
71
|
+
case 'HH:mm:ss':
|
|
72
|
+
return <TimePicker
|
|
73
|
+
value={this.strToDate(value, 'HH:mm:ss')}
|
|
74
|
+
onChange={v => onChange(this.dateToStr(v,'HH:mm:ss'))}
|
|
75
|
+
{...rest}
|
|
76
|
+
></TimePicker>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return <div>未知组件 {type}</div>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static getDefaultValue(type) {
|
|
83
|
+
let year = dayjs().format("YYYY");
|
|
84
|
+
let month = dayjs().format("YYYY-MM");
|
|
85
|
+
let quarter = dayjs().format("YYYY-QQ");
|
|
86
|
+
|
|
87
|
+
switch (type) {
|
|
88
|
+
case 'YYYY':
|
|
89
|
+
return year;
|
|
90
|
+
case 'YYYY-MM':
|
|
91
|
+
return month;
|
|
92
|
+
case 'YYYY-QQ':
|
|
93
|
+
return quarter;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
strToDate(value, fmt) {
|
|
100
|
+
if (value != null && value !== '') {
|
|
101
|
+
let type = typeof value;
|
|
102
|
+
if (type === 'string' || type === 'number') {
|
|
103
|
+
value = dayjs(value, fmt);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
dateToStr(date, fmt) {
|
|
111
|
+
return date ? date.format(fmt) : null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 根据时间类型自动渲染时间选择组件
|
|
3
|
+
*/
|
|
4
|
+
import React from "react";
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
import {DatePicker, TimePicker} from "antd";
|
|
7
|
+
import {DateUtils, StringUtils} from "../utils";
|
|
8
|
+
|
|
9
|
+
const SP = StringUtils.ISO_SPLITTER;
|
|
10
|
+
|
|
11
|
+
export class FieldDateRange extends React.Component {
|
|
12
|
+
static defaultProps = {
|
|
13
|
+
type: 'YYYY-MM-DD'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
render() {
|
|
17
|
+
let {type, value, onChange, ...rest} = this.props;
|
|
18
|
+
type = DateUtils.convertTypeToFormat(type)
|
|
19
|
+
switch (type) {
|
|
20
|
+
case 'YYYY':
|
|
21
|
+
return <DatePicker.RangePicker
|
|
22
|
+
value={this.strToDate(value, 'YYYY')}
|
|
23
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY'))}
|
|
24
|
+
picker="year"
|
|
25
|
+
{...rest}
|
|
26
|
+
/>;
|
|
27
|
+
case 'YYYY-MM':
|
|
28
|
+
return <DatePicker.RangePicker
|
|
29
|
+
value={this.strToDate(value, 'YYYY-MM')}
|
|
30
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-MM'))}
|
|
31
|
+
picker="month"
|
|
32
|
+
{...rest}
|
|
33
|
+
/>;
|
|
34
|
+
case 'YYYY-QQ':
|
|
35
|
+
return <DatePicker.RangePicker
|
|
36
|
+
value={this.strToDate(value, 'YYYY-QQ')}
|
|
37
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-QQ'))}
|
|
38
|
+
picker="quarter"
|
|
39
|
+
{...rest}
|
|
40
|
+
/>;
|
|
41
|
+
case 'YYYY-MM-DD':
|
|
42
|
+
return <DatePicker.RangePicker
|
|
43
|
+
value={this.strToDate(value, 'YYYY-MM-DD')}
|
|
44
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-MM-DD'))}
|
|
45
|
+
{...rest}
|
|
46
|
+
/>;
|
|
47
|
+
case 'YYYY-MM-DD HH:mm':
|
|
48
|
+
return <DatePicker.RangePicker
|
|
49
|
+
value={this.strToDate(value, 'YYYY-MM-DD HH:mm')}
|
|
50
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-MM-DD HH:mm'))}
|
|
51
|
+
format='YYYY-MM-DD HH:mm'
|
|
52
|
+
showTime
|
|
53
|
+
{...rest}
|
|
54
|
+
/>;
|
|
55
|
+
case 'YYYY-MM-DD HH:mm:ss':
|
|
56
|
+
return <DatePicker.RangePicker
|
|
57
|
+
value={this.strToDate(value, 'YYYY-MM-DD HH:mm:ss')}
|
|
58
|
+
onChange={v => onChange(this.dateToStr(v,'YYYY-MM-DD HH:mm:ss'))}
|
|
59
|
+
showTime
|
|
60
|
+
{...rest}
|
|
61
|
+
/>;
|
|
62
|
+
case 'HH:mm':
|
|
63
|
+
return <TimePicker.RangePicker
|
|
64
|
+
format='HH:mm'
|
|
65
|
+
value={this.strToDate(value, 'HH:mm')}
|
|
66
|
+
onChange={v => onChange(this.dateToStr(v,'HH:mm'))}
|
|
67
|
+
{...rest}
|
|
68
|
+
/>;
|
|
69
|
+
case 'HH:mm:ss':
|
|
70
|
+
return <TimePicker.RangePicker
|
|
71
|
+
value={this.strToDate(value, 'HH:mm:ss')}
|
|
72
|
+
onChange={v => onChange(this.dateToStr(v,'HH:mm:ss'))}
|
|
73
|
+
{...rest}
|
|
74
|
+
/>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return <div>未知组件 {type}</div>
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
strToDate(v, fmt) {
|
|
83
|
+
console.log('调用转换')
|
|
84
|
+
if (!v) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const arr = v.split(SP)
|
|
89
|
+
let s1 = arr[0];
|
|
90
|
+
let s2 = arr[1];
|
|
91
|
+
return [dayjs(s1), dayjs(s2)]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
dateToStr(dateArr, fmt) {
|
|
95
|
+
const d1 = dateArr[0]
|
|
96
|
+
const d2 = dateArr[1]
|
|
97
|
+
|
|
98
|
+
const s1 = d1 ? d1.format(fmt) : ""
|
|
99
|
+
const s2 = d2 ? d2.format(fmt) : "";
|
|
100
|
+
|
|
101
|
+
return s1 + SP + s2
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SelectProps } from 'antd/es/select';
|
|
3
|
+
|
|
4
|
+
export interface FieldDictSelectProps extends Omit<SelectProps, 'options' | 'children'|'mode'> {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 请求地址
|
|
8
|
+
*/
|
|
9
|
+
typeCode: string ;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class FieldDictSelect extends React.Component<FieldDictSelectProps, any> {}
|
|
13
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {Select} from "antd";
|
|
3
|
+
import {DictUtils} from "../utils";
|
|
4
|
+
|
|
5
|
+
export function FieldDictSelect(props) {
|
|
6
|
+
const {value, onChange, typeCode, ...rest} = props
|
|
7
|
+
const options = DictUtils.dictOptions(typeCode)
|
|
8
|
+
|
|
9
|
+
return <Select value={value}
|
|
10
|
+
onChange={onChange}
|
|
11
|
+
style={{width: '100%', minWidth: 200}}
|
|
12
|
+
options={options}
|
|
13
|
+
{...rest}>
|
|
14
|
+
|
|
15
|
+
</Select>
|
|
16
|
+
}
|