@zgfe/business-lib 1.2.15-data.0 → 1.2.15-data.2

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.
@@ -8,6 +8,7 @@ import React from 'react';
8
8
  import { BizCycleTime } from '@zgfe/business-lib';
9
9
  import { CycleTimeUnit } from '..';
10
10
  import { Button, Form } from 'antd';
11
+ import moment from 'moment';
11
12
  export default (function () {
12
13
  var options = [{
13
14
  label: '每小时',
@@ -24,7 +25,39 @@ export default (function () {
24
25
  }];
25
26
  var customOptions = [].concat(options, [{
26
27
  label: '指定时间',
27
- value: CycleTimeUnit.custom
28
+ value: CycleTimeUnit.custom,
29
+ disabledDate: function disabledDate(current) {
30
+ return current && current < moment().subtract(1, 'day').endOf('day');
31
+ },
32
+ disabledTime: function disabledTime(current) {
33
+ var range = function range(start, end) {
34
+ var result = [];
35
+ for (var i = start; i < end; i++) {
36
+ result.push(i);
37
+ }
38
+ return result;
39
+ };
40
+ var minutes = Number(moment().minutes());
41
+ var hour = Number(moment().hours());
42
+ var disMinutes = 0;
43
+ var disHour = 0;
44
+ if (moment().date() === (current === null || current === void 0 ? void 0 : current.date())) {
45
+ disHour = hour;
46
+ if (current.hour() > hour) {
47
+ disMinutes = 0;
48
+ } else {
49
+ disMinutes = minutes;
50
+ }
51
+ }
52
+ return {
53
+ disabledHours: function disabledHours() {
54
+ return range(0, disHour);
55
+ },
56
+ disabledMinutes: function disabledMinutes() {
57
+ return range(0, disMinutes);
58
+ }
59
+ };
60
+ }
28
61
  }]);
29
62
  var _Form$useForm = Form.useForm(),
30
63
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
@@ -53,6 +86,7 @@ export default (function () {
53
86
  showHour: true,
54
87
  options: customOptions,
55
88
  format: "HH",
89
+ minTime: "Now",
56
90
  onChange: onChange
57
91
  }), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("b", null, "Form")), /*#__PURE__*/React.createElement(Form, {
58
92
  form: form
@@ -1,6 +1,7 @@
1
1
  import { SizeType } from 'antd/es/config-provider/SizeContext';
2
+ import moment from 'moment';
2
3
  import React from 'react';
3
- import { BaseOption } from '../utils/type';
4
+ import { BizSelectTypes } from '..';
4
5
  import './styles/index.less';
5
6
  export declare enum CycleTimeUnit {
6
7
  hour = 0,
@@ -24,6 +25,8 @@ declare const BizCycleTime: React.FC<{
24
25
  disable?: boolean;
25
26
  showHour?: boolean;
26
27
  format?: string;
27
- options?: BaseOption<CycleTimeUnit>[];
28
+ options?: BizSelectTypes.Option[];
29
+ minTime?: moment.Moment | 'Now';
30
+ maxTime?: moment.Moment | 'Now';
28
31
  }>;
29
32
  export default BizCycleTime;
@@ -24,7 +24,9 @@ var BizCycleTime = function BizCycleTime(props) {
24
24
  size = props.size,
25
25
  disable = props.disable,
26
26
  showHour = props.showHour,
27
- options = props.options;
27
+ options = props.options,
28
+ minTime = props.minTime,
29
+ maxTime = props.maxTime;
28
30
  var classPrefix = 'biz-cycle-time';
29
31
  var unitList = options || [{
30
32
  label: '每日',
@@ -74,13 +76,13 @@ var BizCycleTime = function BizCycleTime(props) {
74
76
  }
75
77
  setIniting(true);
76
78
  unitList.forEach(function (item) {
77
- var _props$value;
79
+ var _props$value, _props$value2, _props$value3, _props$value4;
78
80
  if (item.value === ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.unit)) {
79
81
  setUnit(item);
80
82
  switch (item.value) {
81
83
  case CycleTimeUnit.day:
82
84
  case CycleTimeUnit.custom:
83
- setTime(props.value.time);
85
+ setTime((_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.time);
84
86
  break;
85
87
  case CycleTimeUnit.week:
86
88
  var valList = [];
@@ -94,7 +96,7 @@ var BizCycleTime = function BizCycleTime(props) {
94
96
  } else {
95
97
  setDay(valList[0]);
96
98
  }
97
- if (showHour) setTime(props.value.time);
99
+ if (showHour) setTime((_props$value3 = props.value) === null || _props$value3 === void 0 ? void 0 : _props$value3.time);
98
100
  break;
99
101
  case CycleTimeUnit.month:
100
102
  setDay(props.value.day.map(function (v) {
@@ -103,7 +105,7 @@ var BizCycleTime = function BizCycleTime(props) {
103
105
  value: v
104
106
  };
105
107
  }));
106
- if (showHour) setTime(props.value.time);
108
+ if (showHour) setTime((_props$value4 = props.value) === null || _props$value4 === void 0 ? void 0 : _props$value4.time);
107
109
  break;
108
110
  }
109
111
  }
@@ -187,8 +189,20 @@ var BizCycleTime = function BizCycleTime(props) {
187
189
  disabled: disable,
188
190
  placeholder: props.placeholder,
189
191
  onChange: function onChange(time) {
190
- setTime(time === null || time === void 0 ? void 0 : time.format('YYYY-MM-DD HH:mm:ss'));
191
- }
192
+ var _currentTime;
193
+ var currentTime = time;
194
+ if (minTime) {
195
+ var minData = minTime === 'Now' ? moment() : moment(minTime);
196
+ currentTime = minData < moment(time) ? time : minData;
197
+ }
198
+ if (maxTime) {
199
+ var maxData = maxTime === 'Now' ? moment() : moment(minTime);
200
+ currentTime = maxData > moment(time) ? time : maxData;
201
+ }
202
+ setTime((_currentTime = currentTime) === null || _currentTime === void 0 ? void 0 : _currentTime.format('YYYY-MM-DD HH:mm:ss'));
203
+ },
204
+ disabledTime: unit === null || unit === void 0 ? void 0 : unit.disabledTime,
205
+ disabledDate: unit === null || unit === void 0 ? void 0 : unit.disabledDate
192
206
  }));
193
207
  };
194
208
  BizCycleTime.defaultProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.2.15-data.0",
3
+ "version": "1.2.15-data.2",
4
4
  "module": "es/index.js",
5
5
  "typings": "es/index.d.ts",
6
6
  "files": [