@zgfe/business-lib 1.2.10 → 1.2.11-data.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.
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BizCycleTime } from '@zgfe/business-lib';
|
|
3
|
+
import { CycleTimeUnit } from '..';
|
|
4
|
+
export default (function () {
|
|
5
|
+
var options = [{
|
|
6
|
+
label: '每小时',
|
|
7
|
+
value: CycleTimeUnit.hour
|
|
8
|
+
}, {
|
|
9
|
+
label: '每日',
|
|
10
|
+
value: CycleTimeUnit.day
|
|
11
|
+
}, {
|
|
12
|
+
label: '每周',
|
|
13
|
+
value: CycleTimeUnit.week
|
|
14
|
+
}, {
|
|
15
|
+
label: '每月',
|
|
16
|
+
value: CycleTimeUnit.month
|
|
17
|
+
}];
|
|
18
|
+
var onChange = function onChange(data) {
|
|
19
|
+
console.log('change:', data);
|
|
20
|
+
};
|
|
21
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("b", null, "\u9ED8\u8BA4\u503C")), /*#__PURE__*/React.createElement(BizCycleTime, {
|
|
22
|
+
value: {
|
|
23
|
+
unit: 3,
|
|
24
|
+
day: [1, 23, 4],
|
|
25
|
+
time: '12:00:00'
|
|
26
|
+
},
|
|
27
|
+
multiple: true,
|
|
28
|
+
showHour: true,
|
|
29
|
+
options: options,
|
|
30
|
+
onChange: onChange
|
|
31
|
+
}), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("b", null, "\u65E0\u9ED8\u8BA4\u503C")), /*#__PURE__*/React.createElement(BizCycleTime, {
|
|
32
|
+
multiple: true,
|
|
33
|
+
showHour: true,
|
|
34
|
+
options: options,
|
|
35
|
+
format: "HH",
|
|
36
|
+
onChange: onChange
|
|
37
|
+
}));
|
|
38
|
+
});
|
package/es/cycleTime/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { BaseOption } from '../utils/type';
|
|
3
4
|
import './styles/index.less';
|
|
4
5
|
export declare enum CycleTimeUnit {
|
|
6
|
+
hour = 0,
|
|
5
7
|
day = 1,
|
|
6
8
|
week = 2,
|
|
7
9
|
month = 3
|
|
@@ -18,5 +20,8 @@ declare const BizCycleTime: React.FC<{
|
|
|
18
20
|
onChange?: (val: Value) => void;
|
|
19
21
|
size?: SizeType;
|
|
20
22
|
disable?: boolean;
|
|
23
|
+
showHour?: boolean;
|
|
24
|
+
format?: string;
|
|
25
|
+
options?: BaseOption<CycleTimeUnit>[];
|
|
21
26
|
}>;
|
|
22
27
|
export default BizCycleTime;
|
package/es/cycleTime/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import MonthDay from './month';
|
|
|
12
12
|
import './styles/index.less';
|
|
13
13
|
export var CycleTimeUnit;
|
|
14
14
|
(function (CycleTimeUnit) {
|
|
15
|
+
CycleTimeUnit[CycleTimeUnit["hour"] = 0] = "hour";
|
|
15
16
|
CycleTimeUnit[CycleTimeUnit["day"] = 1] = "day";
|
|
16
17
|
CycleTimeUnit[CycleTimeUnit["week"] = 2] = "week";
|
|
17
18
|
CycleTimeUnit[CycleTimeUnit["month"] = 3] = "month";
|
|
@@ -19,9 +20,11 @@ export var CycleTimeUnit;
|
|
|
19
20
|
var BizCycleTime = function BizCycleTime(props) {
|
|
20
21
|
var multiple = props.multiple,
|
|
21
22
|
size = props.size,
|
|
22
|
-
disable = props.disable
|
|
23
|
+
disable = props.disable,
|
|
24
|
+
showHour = props.showHour,
|
|
25
|
+
options = props.options;
|
|
23
26
|
var classPrefix = 'biz-cycle-time';
|
|
24
|
-
var unitList = [{
|
|
27
|
+
var unitList = options || [{
|
|
25
28
|
label: '每日',
|
|
26
29
|
value: CycleTimeUnit.day
|
|
27
30
|
}, {
|
|
@@ -59,6 +62,9 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
59
62
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
60
63
|
initing = _useState10[0],
|
|
61
64
|
setIniting = _useState10[1];
|
|
65
|
+
var _useState11 = useState(props.format || 'hh:mm:ss'),
|
|
66
|
+
_useState12 = _slicedToArray(_useState11, 1),
|
|
67
|
+
format = _useState12[0];
|
|
62
68
|
useEffect(function () {
|
|
63
69
|
if (!props.value) {
|
|
64
70
|
setIniting(false);
|
|
@@ -85,6 +91,7 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
85
91
|
} else {
|
|
86
92
|
setDay(valList[0]);
|
|
87
93
|
}
|
|
94
|
+
if (showHour) setTime(props.value.time);
|
|
88
95
|
break;
|
|
89
96
|
case CycleTimeUnit.month:
|
|
90
97
|
setDay(props.value.day.map(function (v) {
|
|
@@ -93,6 +100,7 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
93
100
|
value: v
|
|
94
101
|
};
|
|
95
102
|
}));
|
|
103
|
+
if (showHour) setTime(props.value.time);
|
|
96
104
|
break;
|
|
97
105
|
}
|
|
98
106
|
}
|
|
@@ -111,9 +119,12 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
111
119
|
}) : [day.value],
|
|
112
120
|
time: time
|
|
113
121
|
};
|
|
114
|
-
if (unit.value === CycleTimeUnit.
|
|
122
|
+
if (unit.value === CycleTimeUnit.hour) {
|
|
115
123
|
delete res.day;
|
|
116
|
-
|
|
124
|
+
delete res.time;
|
|
125
|
+
} else if (unit.value === CycleTimeUnit.day) {
|
|
126
|
+
delete res.day;
|
|
127
|
+
} else if (!showHour) {
|
|
117
128
|
delete res.time;
|
|
118
129
|
}
|
|
119
130
|
if (props.onChange) props.onChange(res);
|
|
@@ -138,15 +149,6 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
138
149
|
setTime(undefined);
|
|
139
150
|
setUnit(v);
|
|
140
151
|
}
|
|
141
|
-
}), unit.value === CycleTimeUnit.day && /*#__PURE__*/React.createElement(DatePicker.TimePicker, {
|
|
142
|
-
className: "".concat(classPrefix, "-hour"),
|
|
143
|
-
size: size,
|
|
144
|
-
placeholder: props.placeholder,
|
|
145
|
-
defaultValue: time ? moment(time, 'hh:mm:ss') : undefined,
|
|
146
|
-
onChange: function onChange(time) {
|
|
147
|
-
setTime(time === null || time === void 0 ? void 0 : time.format('hh:mm:ss'));
|
|
148
|
-
},
|
|
149
|
-
disabled: disable
|
|
150
152
|
}), unit.value === CycleTimeUnit.week && /*#__PURE__*/React.createElement(BizSelect, {
|
|
151
153
|
options: days,
|
|
152
154
|
labelField: "label",
|
|
@@ -166,7 +168,17 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
166
168
|
defaultValue: day,
|
|
167
169
|
onChange: setDayList,
|
|
168
170
|
disable: disable
|
|
169
|
-
})
|
|
171
|
+
}), unit.value === CycleTimeUnit.day || unit.value && showHour ? /*#__PURE__*/React.createElement(DatePicker.TimePicker, {
|
|
172
|
+
className: "".concat(classPrefix, "-hour"),
|
|
173
|
+
size: size,
|
|
174
|
+
placeholder: props.placeholder,
|
|
175
|
+
value: time ? moment(time, format) : undefined,
|
|
176
|
+
format: format,
|
|
177
|
+
onChange: function onChange(time) {
|
|
178
|
+
setTime(time === null || time === void 0 ? void 0 : time.format(format));
|
|
179
|
+
},
|
|
180
|
+
disabled: disable
|
|
181
|
+
}) : null);
|
|
170
182
|
};
|
|
171
183
|
BizCycleTime.defaultProps = {
|
|
172
184
|
multiple: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@import '../../assets//styles/inner.less';
|
|
2
2
|
.biz-cycle-time {
|
|
3
|
-
display:
|
|
3
|
+
display: flex;
|
|
4
|
+
gap: 12px;
|
|
4
5
|
&-unit {
|
|
5
6
|
width: 129px;
|
|
6
7
|
}
|
|
@@ -15,7 +16,6 @@
|
|
|
15
16
|
&-day,
|
|
16
17
|
&-hour {
|
|
17
18
|
display: inline-block;
|
|
18
|
-
margin-right: @margin-xs;
|
|
19
19
|
}
|
|
20
20
|
&-hour {
|
|
21
21
|
width: 220px;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgfe/business-lib",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11-data.0",
|
|
4
4
|
"module": "es/index.js",
|
|
5
5
|
"typings": "es/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"react": "^16.12.0 || ^17.0.0",
|
|
56
56
|
"yorkie": "^2.0.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "dd0fcae68835a8dfbc1bacd80ed6a06c7f7a7e4c",
|
|
59
59
|
"gitHooks": {
|
|
60
60
|
"pre-commit": "lint-staged"
|
|
61
61
|
}
|