@jiangood/open-admin 1.0.0-beta.5
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/common-plugin.js +94 -0
- package/config/config.js +58 -0
- package/config/utils.js +73 -0
- package/package.json +42 -0
- package/src/.umi-production/appData.json +2365 -0
- package/src/.umi-production/core/EmptyRoute.tsx +9 -0
- package/src/.umi-production/core/defineApp.ts +16 -0
- package/src/.umi-production/core/helmet.ts +10 -0
- package/src/.umi-production/core/helmetContext.ts +4 -0
- package/src/.umi-production/core/history.ts +72 -0
- package/src/.umi-production/core/historyIntelli.ts +132 -0
- package/src/.umi-production/core/plugin.ts +40 -0
- package/src/.umi-production/core/pluginConfig.ts +324 -0
- package/src/.umi-production/core/pluginConfigJoi.d.ts +7 -0
- package/src/.umi-production/core/polyfill.ts +220 -0
- package/src/.umi-production/core/route.tsx +54 -0
- package/src/.umi-production/core/routeProps.js +5 -0
- package/src/.umi-production/core/routeProps.ts +6 -0
- package/src/.umi-production/core/terminal.ts +37 -0
- package/src/.umi-production/exports.ts +17 -0
- package/src/.umi-production/testBrowser.tsx +90 -0
- package/src/.umi-production/tsconfig.json +44 -0
- package/src/.umi-production/typings.d.ts +136 -0
- package/src/.umi-production/umi.ts +83 -0
- package/src/framework/components/DownloadFileButton/index.d.ts +11 -0
- package/src/framework/components/DownloadFileButton/index.jsx +33 -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/index.d.ts +14 -0
- package/src/framework/components/LinkButton/index.jsx +10 -0
- package/src/framework/components/NamedIcon/index.d.ts +5 -0
- package/src/framework/components/NamedIcon/index.jsx +11 -0
- package/src/framework/components/OrgTree/index.d.ts +4 -0
- package/src/framework/components/OrgTree/index.jsx +58 -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/index.d.ts +1 -0
- package/src/framework/components/PageLoading/index.jsx +25 -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/RoleTree/index.d.ts +4 -0
- package/src/framework/components/RoleTree/index.jsx +50 -0
- package/src/framework/components/ValueType/index.jsx +34 -0
- package/src/framework/components/ValueType/registry.jsx +26 -0
- package/src/framework/components/ViewRange/index.d.ts +14 -0
- package/src/framework/components/ViewRange/index.jsx +20 -0
- package/src/framework/components/index.ts +13 -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/fields/FieldBoolean/index.d.ts +9 -0
- package/src/framework/fields/FieldBoolean/index.jsx +73 -0
- package/src/framework/fields/FieldDate/index.d.ts +23 -0
- package/src/framework/fields/FieldDate/index.jsx +116 -0
- package/src/framework/fields/FieldDateRange/index.d.ts +22 -0
- package/src/framework/fields/FieldDateRange/index.jsx +103 -0
- package/src/framework/fields/FieldDictSelect/index.d.ts +12 -0
- package/src/framework/fields/FieldDictSelect/index.jsx +16 -0
- package/src/framework/fields/FieldEditor/index.d.ts +14 -0
- package/src/framework/fields/FieldEditor/index.jsx +59 -0
- package/src/framework/fields/FieldNumberRange/index.d.ts +10 -0
- package/src/framework/fields/FieldNumberRange/index.jsx +55 -0
- package/src/framework/fields/FieldPercent/index.d.ts +8 -0
- package/src/framework/fields/FieldPercent/index.jsx +30 -0
- package/src/framework/fields/FieldRemoteSelect/index.d.ts +44 -0
- package/src/framework/fields/FieldRemoteSelect/index.jsx +125 -0
- package/src/framework/fields/FieldRemoteSelectMultiple/index.d.ts +20 -0
- package/src/framework/fields/FieldRemoteSelectMultiple/index.jsx +85 -0
- package/src/framework/fields/FieldRemoteSelectMultipleInline/index.d.ts +21 -0
- package/src/framework/fields/FieldRemoteSelectMultipleInline/index.jsx +88 -0
- package/src/framework/fields/FieldRemoteTree/index.d.ts +20 -0
- package/src/framework/fields/FieldRemoteTree/index.jsx +50 -0
- package/src/framework/fields/FieldRemoteTreeCascader/index.d.ts +18 -0
- package/src/framework/fields/FieldRemoteTreeCascader/index.jsx +59 -0
- package/src/framework/fields/FieldRemoteTreeSelect/index.d.ts +19 -0
- package/src/framework/fields/FieldRemoteTreeSelect/index.jsx +57 -0
- package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.d.ts +20 -0
- package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.jsx +62 -0
- package/src/framework/fields/FieldSysOrgTree/index.d.ts +9 -0
- package/src/framework/fields/FieldSysOrgTree/index.jsx +20 -0
- package/src/framework/fields/FieldSysOrgTreeSelect/index.d.ts +9 -0
- package/src/framework/fields/FieldSysOrgTreeSelect/index.jsx +22 -0
- package/src/framework/fields/FieldTable/index.d.ts +14 -0
- package/src/framework/fields/FieldTable/index.jsx +108 -0
- package/src/framework/fields/FieldTable/styles.less +29 -0
- package/src/framework/fields/FieldTableSelect/index.d.ts +19 -0
- package/src/framework/fields/FieldTableSelect/index.jsx +60 -0
- package/src/framework/fields/FieldUploadFile/index.d.ts +31 -0
- package/src/framework/fields/FieldUploadFile/index.jsx +139 -0
- package/src/framework/fields/index.ts +22 -0
- package/src/framework/fields/types.ts +16 -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 +15 -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/views/ViewApproveStatus/index.d.ts +3 -0
- package/src/framework/views/ViewApproveStatus/index.jsx +21 -0
- package/src/framework/views/ViewBoolean/index.d.ts +3 -0
- package/src/framework/views/ViewBoolean/index.jsx +4 -0
- package/src/framework/views/ViewBooleanEnableDisable/index.d.ts +5 -0
- package/src/framework/views/ViewBooleanEnableDisable/index.jsx +15 -0
- package/src/framework/views/ViewFile/index.d.ts +10 -0
- package/src/framework/views/ViewFile/index.jsx +49 -0
- package/src/framework/views/ViewFileButton/index.d.ts +10 -0
- package/src/framework/views/ViewFileButton/index.jsx +22 -0
- package/src/framework/views/ViewImage/index.d.ts +6 -0
- package/src/framework/views/ViewImage/index.jsx +60 -0
- package/src/framework/views/ViewPassword/index.d.ts +5 -0
- package/src/framework/views/ViewPassword/index.jsx +24 -0
- package/src/framework/views/ViewProcessInstanceProgress/index.d.ts +12 -0
- package/src/framework/views/ViewProcessInstanceProgress/index.jsx +97 -0
- package/src/framework/views/ViewProcessInstanceProgressButton/index.d.ts +6 -0
- package/src/framework/views/ViewProcessInstanceProgressButton/index.jsx +24 -0
- package/src/framework/views/ViewText/index.d.ts +16 -0
- package/src/framework/views/ViewText/index.jsx +42 -0
- package/src/framework/views/index.ts +12 -0
- package/src/framework/views/types.ts +26 -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 +159 -0
- package/src/layouts/admin/index.less +65 -0
- package/src/layouts/index.jsx +187 -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 +12 -0
- package/src/pages/index.jsx +10 -0
- package/src/pages/login.jsx +16 -0
- package/src/pages/system/api/ApiDoc.jsx +148 -0
- package/src/pages/system/api/index.jsx +267 -0
- package/src/pages/system/api/perm.jsx +69 -0
- package/src/pages/system/dict/Dict.jsx +67 -0
- package/src/pages/system/dict/DictItem.jsx +175 -0
- package/src/pages/system/dict/index.jsx +25 -0
- package/src/pages/system/file/index.jsx +147 -0
- package/src/pages/system/job/index.jsx +324 -0
- package/src/pages/system/log/index.jsx +77 -0
- package/src/pages/system/org/index.jsx +260 -0
- package/src/pages/system/role/index.jsx +302 -0
- package/src/pages/system/role/perm.jsx +107 -0
- package/src/pages/system/sysManual/index.jsx +126 -0
- package/src/pages/system/user/UserPerm.jsx +94 -0
- package/src/pages/system/user/index.jsx +253 -0
- package/src/pages/test/views.jsx +95 -0
- package/src/pages/ureport/index.jsx +16 -0
- package/src/pages/userCenter/ChangePassword.jsx +64 -0
- package/src/pages/userCenter/index.jsx +90 -0
- package/src/pages/userCenter/manual.jsx +57 -0
- package/src/pages/userCenter/message.jsx +103 -0
- package/src/style/global.less +51 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './ProModal'
|
|
2
|
+
export * from './system'
|
|
3
|
+
export * from './PageLoading'
|
|
4
|
+
export * from './ProTable'
|
|
5
|
+
export * from './DownloadFileButton'
|
|
6
|
+
export * from './NamedIcon'
|
|
7
|
+
export * from './LinkButton'
|
|
8
|
+
export * from './Gap'
|
|
9
|
+
export * from './Page'
|
|
10
|
+
export * from './ValueType'
|
|
11
|
+
export * from './OrgTree'
|
|
12
|
+
export * from './RoleTree'
|
|
13
|
+
export * from './ViewRange'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Space} from 'antd';
|
|
3
|
+
import {PermUtils} from "../../utils";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 带权限的按钮列表
|
|
8
|
+
* @param maxNum: 显示子节点的个数, 超过的为收缩起来
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export class ButtonList extends React.Component {
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
let {children} = this.props;
|
|
16
|
+
|
|
17
|
+
// 单节点的情况
|
|
18
|
+
if (!Array.isArray(children)) {
|
|
19
|
+
if (this.checkPerm(children)) {
|
|
20
|
+
return children;
|
|
21
|
+
}
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const menus = [];
|
|
26
|
+
for (let child of children) {
|
|
27
|
+
if (child === null || child === undefined) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (this.checkPerm(child)) {
|
|
31
|
+
menus.push(child);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return <Space>{menus}</Space>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
checkPerm = element => {
|
|
38
|
+
let props = element.props;
|
|
39
|
+
return props == null || props.perm == null || PermUtils.hasPermission(props.perm);
|
|
40
|
+
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {ReactNode} from "react";
|
|
2
|
+
import {PermUtils} from "../../utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 使用该组件,可以判断权限
|
|
6
|
+
*/
|
|
7
|
+
export function HasPerm(props: { code: string, children: ReactNode }) {
|
|
8
|
+
let {code} = props;
|
|
9
|
+
|
|
10
|
+
if (PermUtils.hasPermission(code)) {
|
|
11
|
+
return props.children;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {FieldRemoteSelect, FieldRemoteSelectMultiple, FieldRemoteTreeSelect} from "../../fields";
|
|
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,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldProps } from '../types';
|
|
3
|
+
|
|
4
|
+
interface FieldBooleanProps extends FieldProps<boolean> {
|
|
5
|
+
type?: 'select' | 'radio' | 'checkbox' | 'switch'; // 默认 select
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class FieldBoolean extends React.Component<FieldBooleanProps, any> {
|
|
9
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* antd 自带的checkbox 未选择时不会返回false, 和form配合时还得设置 valuePropName
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* 本组件改成布尔值的输入
|
|
6
|
+
*
|
|
7
|
+
* 选中 true, 反选 false
|
|
8
|
+
*
|
|
9
|
+
* 注意:null 会转为false
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import {Checkbox, Radio, Select, Switch} from 'antd';
|
|
14
|
+
|
|
15
|
+
export class FieldBoolean extends React.Component {
|
|
16
|
+
|
|
17
|
+
static defaultProps = {
|
|
18
|
+
type: 'select'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
render() {
|
|
22
|
+
const {value, onChange, type} = this.props;
|
|
23
|
+
|
|
24
|
+
const v = this.parseBoolean(value);
|
|
25
|
+
|
|
26
|
+
switch (type) {
|
|
27
|
+
case 'radio':
|
|
28
|
+
return <Radio.Group value={v} onChange={onChange}>
|
|
29
|
+
<Radio value={true}>是</Radio>
|
|
30
|
+
<Radio value={false}>否</Radio>
|
|
31
|
+
<Radio value={undefined}>不确定</Radio>
|
|
32
|
+
</Radio.Group>;
|
|
33
|
+
case 'checkbox':
|
|
34
|
+
return <Checkbox
|
|
35
|
+
checked={v}
|
|
36
|
+
onChange={(e) => {
|
|
37
|
+
onChange && onChange(e.target.checked);
|
|
38
|
+
}}
|
|
39
|
+
/>;
|
|
40
|
+
case 'select':
|
|
41
|
+
return <Select options={[
|
|
42
|
+
{value: true, label: '是'},
|
|
43
|
+
{value: false, label: '否'},
|
|
44
|
+
]}
|
|
45
|
+
value={v}
|
|
46
|
+
onChange={onChange}
|
|
47
|
+
style={{width: '100%'}}
|
|
48
|
+
allowClear={true}
|
|
49
|
+
placeholder={'请选择'}
|
|
50
|
+
/>;
|
|
51
|
+
case 'switch':
|
|
52
|
+
return <Switch
|
|
53
|
+
checked={v}
|
|
54
|
+
onChange={onChange}
|
|
55
|
+
/>;
|
|
56
|
+
default:
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
parseBoolean(v) {
|
|
63
|
+
if (v === null || v === undefined) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (typeof v === 'boolean') {
|
|
68
|
+
return v;
|
|
69
|
+
}
|
|
70
|
+
return v === 1 || v === 'true' || v === 'Y';
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FieldProps } from '../types';
|
|
3
|
+
|
|
4
|
+
interface FieldDateProps extends FieldProps<string | null> {
|
|
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
|
+
export class FieldDate extends React.Component<FieldDateProps, any> {
|
|
22
|
+
static getDefaultValue(type: string): string | null;
|
|
23
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
export class FieldDate extends React.Component {
|
|
10
|
+
static defaultProps = {
|
|
11
|
+
type: 'YYYY-MM-DD'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
const {type, value, onChange, ...rest} = this.props;
|
|
16
|
+
const formattedType = DateUtils.convertTypeToFormat(type);
|
|
17
|
+
|
|
18
|
+
switch (formattedType) {
|
|
19
|
+
case 'YYYY':
|
|
20
|
+
return <DatePicker
|
|
21
|
+
value={this.strToDate(value, formattedType)}
|
|
22
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY'))}
|
|
23
|
+
picker="year"
|
|
24
|
+
{...rest}
|
|
25
|
+
/>;
|
|
26
|
+
case 'YYYY-MM':
|
|
27
|
+
return <DatePicker
|
|
28
|
+
value={this.strToDate(value, 'YYYY-MM')}
|
|
29
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-MM'))}
|
|
30
|
+
picker="month"
|
|
31
|
+
{...rest}
|
|
32
|
+
/>;
|
|
33
|
+
case 'YYYY-QQ':
|
|
34
|
+
return <DatePicker
|
|
35
|
+
value={this.strToDate(value, 'YYYY-QQ')}
|
|
36
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-QQ'))}
|
|
37
|
+
picker="quarter"
|
|
38
|
+
{...rest}
|
|
39
|
+
/>;
|
|
40
|
+
case 'YYYY-MM-DD':
|
|
41
|
+
return <DatePicker
|
|
42
|
+
value={this.strToDate(value, 'YYYY-MM-DD')}
|
|
43
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-MM-DD'))}
|
|
44
|
+
{...rest}
|
|
45
|
+
></DatePicker>;
|
|
46
|
+
case 'YYYY-MM-DD HH:mm':
|
|
47
|
+
return <DatePicker
|
|
48
|
+
value={this.strToDate(value, 'YYYY-MM-DD HH:mm')}
|
|
49
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-MM-DD HH:mm'))}
|
|
50
|
+
format='YYYY-MM-DD HH:mm'
|
|
51
|
+
showTime
|
|
52
|
+
{...rest}
|
|
53
|
+
></DatePicker>;
|
|
54
|
+
case 'YYYY-MM-DD HH:mm:ss':
|
|
55
|
+
return <DatePicker
|
|
56
|
+
value={this.strToDate(value, 'YYYY-MM-DD HH:mm:ss')}
|
|
57
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-MM-DD HH:mm:ss'))}
|
|
58
|
+
showTime
|
|
59
|
+
{...rest}
|
|
60
|
+
></DatePicker>;
|
|
61
|
+
case 'HH:mm':
|
|
62
|
+
return <TimePicker
|
|
63
|
+
format='HH:mm'
|
|
64
|
+
value={this.strToDate(value, 'HH:mm')}
|
|
65
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'HH:mm'))}
|
|
66
|
+
{...rest}
|
|
67
|
+
></TimePicker>;
|
|
68
|
+
case 'HH:mm:ss':
|
|
69
|
+
return <TimePicker
|
|
70
|
+
value={this.strToDate(value, 'HH:mm:ss')}
|
|
71
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'HH:mm:ss'))}
|
|
72
|
+
{...rest}
|
|
73
|
+
></TimePicker>;
|
|
74
|
+
default:
|
|
75
|
+
return <div>未知组件 {formattedType}</div>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static getDefaultValue(type) {
|
|
81
|
+
const year = dayjs().format("YYYY");
|
|
82
|
+
const month = dayjs().format("YYYY-MM");
|
|
83
|
+
const quarter = dayjs().format("YYYY-QQ");
|
|
84
|
+
|
|
85
|
+
switch (type) {
|
|
86
|
+
case 'YYYY':
|
|
87
|
+
case 'YEAR':
|
|
88
|
+
return year;
|
|
89
|
+
case 'YYYY-MM':
|
|
90
|
+
case 'YEAR_MONTH':
|
|
91
|
+
return month;
|
|
92
|
+
case 'YYYY-QQ':
|
|
93
|
+
case 'YEAR_QUARTER':
|
|
94
|
+
return quarter;
|
|
95
|
+
default:
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
strToDate(value, fmt) {
|
|
102
|
+
if (value != null && value !== '') {
|
|
103
|
+
const type = typeof value;
|
|
104
|
+
if (type === 'string' || type === 'number') {
|
|
105
|
+
return dayjs(value, fmt);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
dateToStr(date, fmt) {
|
|
113
|
+
return date ? date.format(fmt) : null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FieldProps } from '../types';
|
|
3
|
+
|
|
4
|
+
interface FieldDateRangeProps extends FieldProps<string> {
|
|
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
|
+
export class FieldDateRange extends React.Component<FieldDateRangeProps, any> {
|
|
22
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
const {type, value, onChange, ...rest} = this.props;
|
|
18
|
+
const formattedType = DateUtils.convertTypeToFormat(type);
|
|
19
|
+
|
|
20
|
+
switch (formattedType) {
|
|
21
|
+
case 'YYYY':
|
|
22
|
+
return <DatePicker.RangePicker
|
|
23
|
+
value={this.strToDate(value, 'YYYY')}
|
|
24
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY'))}
|
|
25
|
+
picker="year"
|
|
26
|
+
{...rest}
|
|
27
|
+
/>;
|
|
28
|
+
case 'YYYY-MM':
|
|
29
|
+
return <DatePicker.RangePicker
|
|
30
|
+
value={this.strToDate(value, 'YYYY-MM')}
|
|
31
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-MM'))}
|
|
32
|
+
picker="month"
|
|
33
|
+
{...rest}
|
|
34
|
+
/>;
|
|
35
|
+
case 'YYYY-QQ':
|
|
36
|
+
return <DatePicker.RangePicker
|
|
37
|
+
value={this.strToDate(value, 'YYYY-QQ')}
|
|
38
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-QQ'))}
|
|
39
|
+
picker="quarter"
|
|
40
|
+
{...rest}
|
|
41
|
+
/>;
|
|
42
|
+
case 'YYYY-MM-DD':
|
|
43
|
+
return <DatePicker.RangePicker
|
|
44
|
+
value={this.strToDate(value, 'YYYY-MM-DD')}
|
|
45
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-MM-DD'))}
|
|
46
|
+
{...rest}
|
|
47
|
+
/>;
|
|
48
|
+
case 'YYYY-MM-DD HH:mm':
|
|
49
|
+
return <DatePicker.RangePicker
|
|
50
|
+
value={this.strToDate(value, 'YYYY-MM-DD HH:mm')}
|
|
51
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-MM-DD HH:mm'))}
|
|
52
|
+
format='YYYY-MM-DD HH:mm'
|
|
53
|
+
showTime
|
|
54
|
+
{...rest}
|
|
55
|
+
/>;
|
|
56
|
+
case 'YYYY-MM-DD HH:mm:ss':
|
|
57
|
+
return <DatePicker.RangePicker
|
|
58
|
+
value={this.strToDate(value, 'YYYY-MM-DD HH:mm:ss')}
|
|
59
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'YYYY-MM-DD HH:mm:ss'))}
|
|
60
|
+
showTime
|
|
61
|
+
{...rest}
|
|
62
|
+
/>;
|
|
63
|
+
case 'HH:mm':
|
|
64
|
+
return <TimePicker.RangePicker
|
|
65
|
+
format='HH:mm'
|
|
66
|
+
value={this.strToDate(value, 'HH:mm')}
|
|
67
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'HH:mm'))}
|
|
68
|
+
{...rest}
|
|
69
|
+
/>;
|
|
70
|
+
case 'HH:mm:ss':
|
|
71
|
+
return <TimePicker.RangePicker
|
|
72
|
+
value={this.strToDate(value, 'HH:mm:ss')}
|
|
73
|
+
onChange={v => onChange && onChange(this.dateToStr(v, 'HH:mm:ss'))}
|
|
74
|
+
{...rest}
|
|
75
|
+
/>;
|
|
76
|
+
default:
|
|
77
|
+
return <div>未知组件 {formattedType}</div>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
strToDate(v, fmt) {
|
|
83
|
+
if (!v) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const arr = v.split(SP);
|
|
88
|
+
const s1 = arr[0];
|
|
89
|
+
const s2 = arr[1];
|
|
90
|
+
return [dayjs(s1), dayjs(s2)];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
dateToStr(dateArr, fmt) {
|
|
94
|
+
const d1 = dateArr[0];
|
|
95
|
+
const d2 = dateArr[1];
|
|
96
|
+
|
|
97
|
+
const s1 = d1 ? d1.format(fmt) : "";
|
|
98
|
+
const s2 = d2 ? d2.format(fmt) : "";
|
|
99
|
+
|
|
100
|
+
return s1 + SP + s2;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {SelectProps} from "antd/es/select";
|
|
3
|
+
import { FieldProps } from '../types';
|
|
4
|
+
|
|
5
|
+
interface FieldDictSelectProps extends Omit<SelectProps, 'options' | 'children'|'mode' | 'value' | 'onChange'>, FieldProps<any> {
|
|
6
|
+
/**
|
|
7
|
+
* 字典类型编码
|
|
8
|
+
*/
|
|
9
|
+
typeCode: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function FieldDictSelect(props: FieldDictSelectProps);
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldProps } from '../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 富文本编辑器
|
|
6
|
+
*
|
|
7
|
+
* 图片上传相关配置 https://www.tiny.cloud/docs/tinymce/7/image/
|
|
8
|
+
*/
|
|
9
|
+
interface FieldEditProps extends FieldProps<string> {
|
|
10
|
+
height?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class FieldEditor extends React.Component<FieldEditProps, any> {
|
|
14
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Editor as TinyMceEditor} from '@tinymce/tinymce-react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 富文本编辑器
|
|
6
|
+
*
|
|
7
|
+
* 图片上传相关配置 https://www.tiny.cloud/docs/tinymce/7/image/
|
|
8
|
+
*/
|
|
9
|
+
export class FieldEditor extends React.Component {
|
|
10
|
+
render() {
|
|
11
|
+
const uploadUrl = 'admin/sysFile/upload';
|
|
12
|
+
const jsUrl = 'admin/tinymce/tinymce.min.js';
|
|
13
|
+
const {value, onChange, height} = this.props;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<TinyMceEditor
|
|
18
|
+
initialValue={value}
|
|
19
|
+
tinymceScriptSrc={jsUrl}
|
|
20
|
+
init={{
|
|
21
|
+
min_height: 300,
|
|
22
|
+
language: 'zh_CN',
|
|
23
|
+
height: height,
|
|
24
|
+
|
|
25
|
+
// 上传图片
|
|
26
|
+
images_upload_url: uploadUrl,
|
|
27
|
+
promotion: false, // 不显示升级按钮(右上角)
|
|
28
|
+
cache_suffix: '?v=v7.7',
|
|
29
|
+
|
|
30
|
+
plugins: [
|
|
31
|
+
'advlist', 'autolink', 'lists', 'link', 'image', 'charmap', 'preview',
|
|
32
|
+
'anchor', 'searchreplace', 'visualblocks', 'code', 'fullscreen',
|
|
33
|
+
'insertdatetime', 'media', 'table', 'code', 'help', 'wordcount',
|
|
34
|
+
'emoticons'
|
|
35
|
+
],
|
|
36
|
+
image_description: false,
|
|
37
|
+
|
|
38
|
+
// 设置图片上传对话框默认选中上传Tab
|
|
39
|
+
setup: function (editor) {
|
|
40
|
+
editor.on('OpenWindow', function(e) {
|
|
41
|
+
const dialog = e.dialog;
|
|
42
|
+
// 包含 dimensions 属性应该就是 上传图片的对话框
|
|
43
|
+
if (dialog && dialog.getData().dimensions) {
|
|
44
|
+
dialog.showTab("upload");
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
}}
|
|
50
|
+
onChange={e => {
|
|
51
|
+
if (onChange) {
|
|
52
|
+
onChange(e.target.getContent());
|
|
53
|
+
}
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {InputNumber} from "antd";
|
|
3
|
+
import {StringUtils} from "../../utils";
|
|
4
|
+
|
|
5
|
+
const SP = StringUtils.ISO_SPLITTER;
|
|
6
|
+
|
|
7
|
+
export class FieldNumberRange extends React.Component {
|
|
8
|
+
onChangeA = (a) => {
|
|
9
|
+
const {b} = this.parse(this.props.value);
|
|
10
|
+
this.props.onChange && this.props.onChange(this.merge(a, b));
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
onChangeB = (b) => {
|
|
14
|
+
const {a} = this.parse(this.props.value);
|
|
15
|
+
this.props.onChange && this.props.onChange(this.merge(a, b));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
merge(a, b) {
|
|
19
|
+
if (a == null) {
|
|
20
|
+
a = '';
|
|
21
|
+
}
|
|
22
|
+
if (b == null) {
|
|
23
|
+
b = '';
|
|
24
|
+
}
|
|
25
|
+
return a + SP + b;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
parse(v) {
|
|
29
|
+
if (v == null) {
|
|
30
|
+
return {a: null, b: null};
|
|
31
|
+
}
|
|
32
|
+
const arr = v.split(SP);
|
|
33
|
+
return {a: arr[0] ? Number(arr[0]) : null, b: arr[1] ? Number(arr[1]) : null};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
componentDidMount() {
|
|
37
|
+
const {value, defaultValue} = this.props;
|
|
38
|
+
if (value == null && defaultValue) {
|
|
39
|
+
this.props.onChange && this.props.onChange(defaultValue);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
let {value, defaultValue} = this.props;
|
|
45
|
+
if (value == null) {
|
|
46
|
+
value = defaultValue;
|
|
47
|
+
}
|
|
48
|
+
const {a, b} = this.parse(value);
|
|
49
|
+
|
|
50
|
+
return <div style={{display: 'flex', alignItems: 'center'}}>
|
|
51
|
+
<InputNumber value={a} onChange={this.onChangeA}/> - <InputNumber value={b} onChange={this.onChangeB}/>
|
|
52
|
+
</div>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {InputNumber, Space} from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 数字的百分数输入框
|
|
6
|
+
*/
|
|
7
|
+
export class FieldPercent extends React.Component {
|
|
8
|
+
render() {
|
|
9
|
+
const {value, onChange, ...rest} = this.props;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Space.Compact>
|
|
13
|
+
<InputNumber
|
|
14
|
+
min={0}
|
|
15
|
+
max={100}
|
|
16
|
+
value={Number((value * 100).toFixed(0))}
|
|
17
|
+
onChange={v => {
|
|
18
|
+
if (v !== null) {
|
|
19
|
+
const percentValue = Number((v / 100).toFixed(2));
|
|
20
|
+
onChange && onChange(percentValue);
|
|
21
|
+
}
|
|
22
|
+
}}
|
|
23
|
+
{...rest}
|
|
24
|
+
/>
|
|
25
|
+
<Space.Addon>%</Space.Addon>
|
|
26
|
+
</Space.Compact>
|
|
27
|
+
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|