@zgfe/business-lib 1.2.19 → 1.2.20
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.
|
@@ -13,6 +13,8 @@ import { DatePickerTypes } from './types';
|
|
|
13
13
|
import locale from 'antd/es/date-picker/locale/zh_CN';
|
|
14
14
|
import DatePickerContext from './context';
|
|
15
15
|
import BizGlobalDataContext from '../context';
|
|
16
|
+
import { isTodayInRange } from './utils';
|
|
17
|
+
import _ from 'lodash';
|
|
16
18
|
var RangePicker = DatePicker.RangePicker;
|
|
17
19
|
var BizDateBeyondRange = false;
|
|
18
20
|
var BizDate = function BizDate(_ref) {
|
|
@@ -104,7 +106,11 @@ var BizDate = function BizDate(_ref) {
|
|
|
104
106
|
}
|
|
105
107
|
},
|
|
106
108
|
onChange: function onChange(value) {
|
|
107
|
-
|
|
109
|
+
var subtractDays = 0;
|
|
110
|
+
if (includeToday && value && value.length === 2 && isTodayInRange(value[0], value[1])) {
|
|
111
|
+
subtractDays = 1;
|
|
112
|
+
}
|
|
113
|
+
if (value && value.length === 2 && moment(_.cloneDeep(value[1]).subtract(subtractDays, 'days').format('YYYY-MM-DD')).diff(moment(value[0].format('YYYY-MM-DD')), selectRangeUnit || 'months') >= (selectRange ? selectRange : 12)) {
|
|
108
114
|
BizDateBeyondRange = true;
|
|
109
115
|
return;
|
|
110
116
|
}
|
|
@@ -39,10 +39,10 @@ export default (function () {
|
|
|
39
39
|
})), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(BizDatePicker, {
|
|
40
40
|
mode: "simple",
|
|
41
41
|
onChange: handleChange,
|
|
42
|
-
includeToday:
|
|
42
|
+
includeToday: true,
|
|
43
43
|
value: time,
|
|
44
44
|
defaultValue: time,
|
|
45
|
-
selectRange:
|
|
46
|
-
selectRangeUnit: '
|
|
45
|
+
selectRange: 1,
|
|
46
|
+
selectRangeUnit: 'weeks'
|
|
47
47
|
}), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, "\u5F53\u524D\u503C\uFF1A", JSON.stringify(time)));
|
|
48
48
|
});
|
package/es/datePicker/utils.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
1
2
|
import { DatePickerTypes } from './types';
|
|
2
3
|
export declare const getDateRange: (type: DatePickerTypes.Unit, count: number, includeToday: boolean) => {
|
|
3
4
|
begin: string;
|
|
4
5
|
end: string;
|
|
5
6
|
};
|
|
7
|
+
export declare const isTodayInRange: (_startDate: moment.Moment, _endDate: moment.Moment) => boolean;
|
package/es/datePicker/utils.js
CHANGED
|
@@ -32,4 +32,10 @@ export var getDateRange = function getDateRange(type, count, includeToday) {
|
|
|
32
32
|
begin: moment(res.startDate).format('YYYY-MM-DD'),
|
|
33
33
|
end: moment(res.endDate).format('YYYY-MM-DD')
|
|
34
34
|
};
|
|
35
|
+
};
|
|
36
|
+
export var isTodayInRange = function isTodayInRange(_startDate, _endDate) {
|
|
37
|
+
var startDate = _startDate.format('x');
|
|
38
|
+
var endDate = moment(_endDate).add(1, 'days').format('x');
|
|
39
|
+
var dateToCheck = moment(new Date()).format('x');
|
|
40
|
+
return dateToCheck >= startDate && dateToCheck <= endDate;
|
|
35
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgfe/business-lib",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.20",
|
|
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": "a9f3f73cc4152e63735bc0ab5115033e6be8b21d",
|
|
59
59
|
"gitHooks": {
|
|
60
60
|
"pre-commit": "lint-staged"
|
|
61
61
|
}
|