@pisell/utils 3.0.6 → 3.0.7
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/es/arrayUtils.d.ts +23 -26
- package/es/arrayUtils.js +157 -97
- package/es/common/index.d.ts +5 -0
- package/es/common/index.js +5 -0
- package/es/common/stateHelper.d.ts +2 -6
- package/es/common/stateHelper.js +24 -22
- package/es/common/types.d.ts +10 -13
- package/es/common/types.js +1 -0
- package/es/componentStorage.d.ts +25 -27
- package/es/componentStorage.js +130 -94
- package/es/constants/index.js +9 -7
- package/es/date.js +53 -36
- package/es/document.js +67 -43
- package/es/escPosPrinter/EscPosPrinter.js +490 -353
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +52 -37
- package/es/firebase/config/index.js +54 -0
- package/es/firebase/index.js +232 -0
- package/es/format.d.ts +15 -12
- package/es/format.js +156 -89
- package/es/image.js +60 -48
- package/es/index.d.ts +24 -39
- package/es/index.js +35 -40
- package/es/jsBridge/index.d.ts +4 -8
- package/es/jsBridge/index.js +55 -56
- package/es/jsBridge/regDeviceApi.js +126 -87
- package/es/jsBridge/types.d.ts +115 -95
- package/es/jsBridge/types.js +1 -0
- package/es/locales.d.ts +8 -11
- package/es/locales.js +96 -77
- package/es/log.d.ts +6 -11
- package/es/log.js +59 -37
- package/es/miniRedux.d.ts +13 -20
- package/es/miniRedux.js +76 -42
- package/es/number-input/hooks/index.d.ts +4 -0
- package/es/number-input/hooks/index.js +5 -0
- package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/es/number-input/hooks/useNumberInputState.js +128 -71
- package/es/number-input/index.d.ts +14 -0
- package/es/number-input/index.js +21 -0
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/types.js +1 -0
- package/es/number-input/utils/formatter.d.ts +10 -13
- package/es/number-input/utils/formatter.js +77 -51
- package/es/number-input/utils/index.d.ts +7 -0
- package/es/number-input/utils/index.js +8 -0
- package/es/number-input/utils/validation.d.ts +2 -7
- package/es/number-input/utils/validation.js +66 -51
- package/es/otherUtils.d.ts +9 -12
- package/es/otherUtils.js +129 -71
- package/es/platform.d.ts +9 -12
- package/es/platform.js +85 -61
- package/es/select/hooks/index.d.ts +5 -0
- package/es/select/hooks/index.js +6 -0
- package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/es/select/hooks/useDebouncedSearch.js +53 -39
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +113 -56
- package/es/select/index.d.ts +8 -7
- package/es/select/index.js +13 -0
- package/es/select/types.d.ts +211 -211
- package/es/select/types.js +1 -0
- package/es/select/utils/filterOptions.d.ts +6 -7
- package/es/select/utils/filterOptions.js +31 -26
- package/es/select/utils/helpers.d.ts +9 -10
- package/es/select/utils/helpers.js +52 -42
- package/es/select/utils/index.d.ts +7 -4
- package/es/select/utils/index.js +8 -0
- package/es/select/utils/sortOptions.d.ts +5 -6
- package/es/select/utils/sortOptions.js +31 -19
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +47 -34
- package/es/text-input/hooks/index.d.ts +4 -0
- package/es/text-input/hooks/index.js +5 -0
- package/es/text-input/hooks/useTextInputState.d.ts +2 -6
- package/es/text-input/hooks/useTextInputState.js +126 -69
- package/es/text-input/index.d.ts +14 -0
- package/es/text-input/index.js +20 -0
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/types.js +1 -0
- package/es/text-input/utils/index.d.ts +5 -0
- package/es/text-input/utils/index.js +7 -0
- package/es/text-input/utils/validation.d.ts +2 -7
- package/es/text-input/utils/validation.js +70 -50
- package/es/typeUtils.js +84 -61
- package/es/walletValidity.d.ts +42 -44
- package/es/walletValidity.js +557 -396
- package/es/weighing.d.ts +45 -48
- package/es/weighing.js +106 -83
- package/lib/arrayUtils.d.ts +23 -26
- package/lib/arrayUtils.js +111 -101
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.js +29 -0
- package/lib/common/stateHelper.d.ts +2 -6
- package/lib/common/stateHelper.js +32 -21
- package/lib/common/types.d.ts +10 -13
- package/lib/common/types.js +17 -0
- package/lib/componentStorage.d.ts +25 -27
- package/lib/componentStorage.js +126 -96
- package/lib/constants/index.js +36 -7
- package/lib/date.js +65 -43
- package/lib/document.js +62 -46
- package/lib/escPosPrinter/EscPosPrinter.js +403 -327
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +84 -38
- package/lib/firebase/config/index.js +79 -0
- package/lib/firebase/index.js +180 -0
- package/lib/format.d.ts +15 -12
- package/lib/format.js +133 -91
- package/lib/image.js +74 -48
- package/lib/index.d.ts +24 -39
- package/lib/index.js +80 -137
- package/lib/jsBridge/index.d.ts +4 -8
- package/lib/jsBridge/index.js +76 -57
- package/lib/jsBridge/regDeviceApi.js +133 -86
- package/lib/jsBridge/types.d.ts +115 -95
- package/lib/jsBridge/types.js +17 -0
- package/lib/locales.d.ts +8 -11
- package/lib/locales.js +90 -79
- package/lib/log.d.ts +6 -11
- package/lib/log.js +61 -37
- package/lib/miniRedux.d.ts +13 -20
- package/lib/miniRedux.js +89 -43
- package/lib/number-input/hooks/index.d.ts +4 -0
- package/lib/number-input/hooks/index.js +29 -0
- package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/lib/number-input/hooks/useNumberInputState.js +81 -71
- package/lib/number-input/index.d.ts +14 -0
- package/lib/number-input/index.js +41 -0
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/types.js +17 -0
- package/lib/number-input/utils/formatter.d.ts +10 -13
- package/lib/number-input/utils/formatter.js +49 -52
- package/lib/number-input/utils/index.d.ts +7 -0
- package/lib/number-input/utils/index.js +39 -0
- package/lib/number-input/utils/validation.d.ts +2 -7
- package/lib/number-input/utils/validation.js +52 -50
- package/lib/otherUtils.d.ts +9 -12
- package/lib/otherUtils.js +98 -86
- package/lib/platform.d.ts +9 -12
- package/lib/platform.js +123 -68
- package/lib/select/hooks/index.d.ts +5 -0
- package/lib/select/hooks/index.js +34 -0
- package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/lib/select/hooks/useDebouncedSearch.js +41 -40
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +93 -58
- package/lib/select/index.d.ts +8 -7
- package/lib/select/index.js +53 -0
- package/lib/select/types.d.ts +211 -211
- package/lib/select/types.js +17 -0
- package/lib/select/utils/filterOptions.d.ts +6 -7
- package/lib/select/utils/filterOptions.js +37 -26
- package/lib/select/utils/helpers.d.ts +9 -10
- package/lib/select/utils/helpers.js +41 -45
- package/lib/select/utils/index.d.ts +7 -4
- package/lib/select/utils/index.js +48 -0
- package/lib/select/utils/sortOptions.d.ts +5 -6
- package/lib/select/utils/sortOptions.js +39 -18
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +41 -33
- package/lib/text-input/hooks/index.d.ts +4 -0
- package/lib/text-input/hooks/index.js +29 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
- package/lib/text-input/hooks/useTextInputState.js +79 -69
- package/lib/text-input/index.d.ts +14 -0
- package/lib/text-input/index.js +35 -0
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/types.js +17 -0
- package/lib/text-input/utils/index.d.ts +5 -0
- package/lib/text-input/utils/index.js +32 -0
- package/lib/text-input/utils/validation.d.ts +2 -7
- package/lib/text-input/utils/validation.js +58 -49
- package/lib/typeUtils.js +73 -68
- package/lib/walletValidity.d.ts +42 -44
- package/lib/walletValidity.js +393 -410
- package/lib/weighing.d.ts +45 -48
- package/lib/weighing.js +149 -104
- package/package.json +1 -1
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
- package/es/date.d.ts +0 -31
- package/es/document.d.ts +0 -16
- package/es/image.d.ts +0 -14
- package/es/typeUtils.d.ts +0 -45
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
- package/lib/_virtual/_rolldown/runtime.js +0 -23
- package/lib/date.d.ts +0 -31
- package/lib/document.d.ts +0 -16
- package/lib/image.d.ts +0 -14
- package/lib/typeUtils.d.ts +0 -45
package/es/walletValidity.js
CHANGED
|
@@ -1,443 +1,604 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
import dayjs from 'dayjs';
|
|
14
|
+
|
|
15
|
+
// 文案配置类型定义
|
|
16
|
+
|
|
17
|
+
// 常量定义
|
|
18
|
+
var CONSTANTS = {
|
|
19
|
+
ALL_DAY_START: '00:00',
|
|
20
|
+
ALL_DAY_END: '23:59',
|
|
21
|
+
SECONDS_SUFFIX: ':59'
|
|
8
22
|
};
|
|
23
|
+
|
|
24
|
+
// 日程项接口定义
|
|
25
|
+
|
|
26
|
+
// API 日期使用店铺的日历日期;不要把已格式化的 DD/MM/YYYY 文案重新解析为日期。
|
|
9
27
|
function getValidityDate(value) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
if (typeof value !== 'string') return null;
|
|
29
|
+
var match = value.match(/^(\d{4}-\d{2}-\d{2})(?:$|[ T])/);
|
|
30
|
+
if (!match) return null;
|
|
31
|
+
var date = dayjs(match[1]);
|
|
32
|
+
return date.isValid() && date.format('YYYY-MM-DD') === match[1] ? match[1] : null;
|
|
15
33
|
}
|
|
34
|
+
|
|
16
35
|
/** 仅计算展示日期的交集,不修改日程的重复起点或每日使用时段。 */
|
|
17
|
-
function getWalletValidityRange(start, end, validity) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
export function getWalletValidityRange(start, end, validity) {
|
|
37
|
+
var scheduleStart = getValidityDate(start);
|
|
38
|
+
var scheduleEnd = getValidityDate(end);
|
|
39
|
+
var passStart = getValidityDate(validity === null || validity === void 0 ? void 0 : validity.start_date);
|
|
40
|
+
var passEnd = getValidityDate(validity === null || validity === void 0 ? void 0 : validity.expire_date) || getValidityDate(validity === null || validity === void 0 ? void 0 : validity.expire_time);
|
|
41
|
+
var startDate = passStart && (!scheduleStart || passStart > scheduleStart) ? passStart : scheduleStart;
|
|
42
|
+
var endDate = passEnd && (!scheduleEnd || passEnd < scheduleEnd) ? passEnd : scheduleEnd;
|
|
43
|
+
return {
|
|
44
|
+
startDate: startDate,
|
|
45
|
+
endDate: endDate,
|
|
46
|
+
isEmpty: Boolean(startDate && endDate && startDate > endDate)
|
|
47
|
+
};
|
|
29
48
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
every: "every ",
|
|
121
|
-
day: "day",
|
|
122
|
-
week: "week",
|
|
123
|
-
month: "month",
|
|
124
|
-
year: "year",
|
|
125
|
-
available: "available",
|
|
126
|
-
unlimited: "unlimited",
|
|
127
|
-
noAvailableDates: "No available dates",
|
|
128
|
-
multipleRules: "Multiple rules, see details",
|
|
129
|
-
multipleSlots: ", multiple slots",
|
|
130
|
-
until: "Until ",
|
|
131
|
-
daily: "daily",
|
|
132
|
-
days: "days",
|
|
133
|
-
weeks: "weeks",
|
|
134
|
-
everyPrefix: "every ",
|
|
135
|
-
weekPrefix: "",
|
|
136
|
-
dateFormat: "DD MMM YYYY",
|
|
137
|
-
dateTimeFormat: "DD MMM YYYY h:mm A",
|
|
138
|
-
longTermValidFrom: "from ",
|
|
139
|
-
noExpiry: ", no expiry",
|
|
140
|
-
on: "on "
|
|
141
|
-
}
|
|
49
|
+
|
|
50
|
+
// 多语言文案配置
|
|
51
|
+
var textConfig = {
|
|
52
|
+
'zh-HK': {
|
|
53
|
+
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
|
|
54
|
+
separator: '、',
|
|
55
|
+
timeSeparator: '–',
|
|
56
|
+
rangeSeparator: ' 至 ',
|
|
57
|
+
periodSeparator: ';',
|
|
58
|
+
timeSlotSeparator: ',',
|
|
59
|
+
every: '每',
|
|
60
|
+
day: '天',
|
|
61
|
+
week: '周',
|
|
62
|
+
month: '月',
|
|
63
|
+
year: '年',
|
|
64
|
+
available: '可用',
|
|
65
|
+
unlimited: '无限期',
|
|
66
|
+
noAvailableDates: '無可用日期',
|
|
67
|
+
multipleRules: '多規則,點詳情',
|
|
68
|
+
multipleSlots: ',多時段',
|
|
69
|
+
until: '至',
|
|
70
|
+
daily: '每天',
|
|
71
|
+
days: '天',
|
|
72
|
+
weeks: '周',
|
|
73
|
+
everyPrefix: '每',
|
|
74
|
+
weekPrefix: '周',
|
|
75
|
+
dateFormat: 'YYYY-MM-DD',
|
|
76
|
+
dateTimeFormat: 'YYYY-MM-DD HH:mm',
|
|
77
|
+
longTermValidFrom: '自',
|
|
78
|
+
noExpiry: '起長期有效',
|
|
79
|
+
on: ''
|
|
80
|
+
},
|
|
81
|
+
'zh-CN': {
|
|
82
|
+
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
|
|
83
|
+
separator: '、',
|
|
84
|
+
timeSeparator: '–',
|
|
85
|
+
rangeSeparator: ' 至 ',
|
|
86
|
+
periodSeparator: ';',
|
|
87
|
+
timeSlotSeparator: ',',
|
|
88
|
+
every: '每',
|
|
89
|
+
day: '天',
|
|
90
|
+
week: '周',
|
|
91
|
+
month: '月',
|
|
92
|
+
year: '年',
|
|
93
|
+
available: '可用',
|
|
94
|
+
unlimited: '无限期',
|
|
95
|
+
noAvailableDates: '无可用日期',
|
|
96
|
+
multipleRules: '多规则,点详情',
|
|
97
|
+
multipleSlots: ',多时段',
|
|
98
|
+
until: '至',
|
|
99
|
+
daily: '每天',
|
|
100
|
+
days: '天',
|
|
101
|
+
weeks: '周',
|
|
102
|
+
everyPrefix: '每',
|
|
103
|
+
weekPrefix: '周',
|
|
104
|
+
dateFormat: 'YYYY-MM-DD',
|
|
105
|
+
dateTimeFormat: 'YYYY-MM-DD HH:mm',
|
|
106
|
+
longTermValidFrom: '自',
|
|
107
|
+
noExpiry: '起长期有效',
|
|
108
|
+
on: ''
|
|
109
|
+
},
|
|
110
|
+
'en': {
|
|
111
|
+
weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
112
|
+
separator: ', ',
|
|
113
|
+
timeSeparator: '–',
|
|
114
|
+
rangeSeparator: ' - ',
|
|
115
|
+
periodSeparator: '; ',
|
|
116
|
+
timeSlotSeparator: ', ',
|
|
117
|
+
every: 'every ',
|
|
118
|
+
day: 'day',
|
|
119
|
+
week: 'week',
|
|
120
|
+
month: 'month',
|
|
121
|
+
year: 'year',
|
|
122
|
+
available: 'available',
|
|
123
|
+
unlimited: 'unlimited',
|
|
124
|
+
noAvailableDates: 'No available dates',
|
|
125
|
+
multipleRules: 'Multiple rules, see details',
|
|
126
|
+
multipleSlots: ', multiple slots',
|
|
127
|
+
until: 'Until ',
|
|
128
|
+
daily: 'daily',
|
|
129
|
+
days: 'days',
|
|
130
|
+
weeks: 'weeks',
|
|
131
|
+
everyPrefix: 'every ',
|
|
132
|
+
weekPrefix: '',
|
|
133
|
+
dateFormat: 'DD MMM YYYY',
|
|
134
|
+
dateTimeFormat: 'DD MMM YYYY h:mm A',
|
|
135
|
+
longTermValidFrom: 'from ',
|
|
136
|
+
noExpiry: ', no expiry',
|
|
137
|
+
on: 'on '
|
|
138
|
+
}
|
|
142
139
|
};
|
|
140
|
+
|
|
143
141
|
/**
|
|
144
|
-
* 获取星期几的表示
|
|
145
|
-
* @param dayNumbers 星期几的数字数组 (0-6, 0代表周日)
|
|
146
|
-
* @param locale 语言设置
|
|
147
|
-
* @param separator 分隔符,可选,默认使用locale配置的分隔符
|
|
148
|
-
* @returns 格式化的星期几文案
|
|
149
|
-
*/
|
|
142
|
+
* 获取星期几的表示
|
|
143
|
+
* @param dayNumbers 星期几的数字数组 (0-6, 0代表周日)
|
|
144
|
+
* @param locale 语言设置
|
|
145
|
+
* @param separator 分隔符,可选,默认使用locale配置的分隔符
|
|
146
|
+
* @returns 格式化的星期几文案
|
|
147
|
+
*/
|
|
150
148
|
function getWeekdayText(dayNumbers, locale, separator) {
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
var config = textConfig[locale];
|
|
150
|
+
return _toConsumableArray(new Set(dayNumbers)).sort(function (a, b) {
|
|
151
|
+
return a - b;
|
|
152
|
+
}).map(function (day) {
|
|
153
|
+
return config.weekdays[day];
|
|
154
|
+
}).join(separator || config.separator);
|
|
153
155
|
}
|
|
156
|
+
|
|
154
157
|
/**
|
|
155
|
-
* 获取指定语言的文案配置
|
|
156
|
-
* @param locale 语言设置
|
|
157
|
-
* @param key 配置项key
|
|
158
|
-
* @returns 对应语言的文案
|
|
159
|
-
*/
|
|
158
|
+
* 获取指定语言的文案配置
|
|
159
|
+
* @param locale 语言设置
|
|
160
|
+
* @param key 配置项key
|
|
161
|
+
* @returns 对应语言的文案
|
|
162
|
+
*/
|
|
160
163
|
function getText(locale, key) {
|
|
161
|
-
|
|
164
|
+
return textConfig[locale][key];
|
|
162
165
|
}
|
|
166
|
+
|
|
163
167
|
/**
|
|
164
|
-
* 获取指定语言的配置对象(缓存优化)
|
|
165
|
-
* @param locale 语言设置
|
|
166
|
-
* @returns 对应语言的完整配置对象
|
|
167
|
-
*/
|
|
168
|
+
* 获取指定语言的配置对象(缓存优化)
|
|
169
|
+
* @param locale 语言设置
|
|
170
|
+
* @returns 对应语言的完整配置对象
|
|
171
|
+
*/
|
|
168
172
|
function getConfig(locale) {
|
|
169
|
-
|
|
173
|
+
return textConfig[locale];
|
|
170
174
|
}
|
|
175
|
+
|
|
171
176
|
/**
|
|
172
|
-
* 获取每日频率文案
|
|
173
|
-
* @param frequency 频率数字
|
|
174
|
-
* @param locale 语言设置
|
|
175
|
-
* @returns 格式化的每日频率文案
|
|
176
|
-
*/
|
|
177
|
+
* 获取每日频率文案
|
|
178
|
+
* @param frequency 频率数字
|
|
179
|
+
* @param locale 语言设置
|
|
180
|
+
* @returns 格式化的每日频率文案
|
|
181
|
+
*/
|
|
177
182
|
function getDailyFrequencyText(frequency, locale) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
183
|
+
if (frequency === 1) {
|
|
184
|
+
return getText(locale, 'daily');
|
|
185
|
+
}
|
|
186
|
+
var config = textConfig[locale];
|
|
187
|
+
if (locale === 'en') {
|
|
188
|
+
return "".concat(config.everyPrefix).concat(frequency, " ").concat(config.days);
|
|
189
|
+
} else {
|
|
190
|
+
return "".concat(config.everyPrefix).concat(frequency).concat(config.days);
|
|
191
|
+
}
|
|
182
192
|
}
|
|
193
|
+
|
|
183
194
|
/**
|
|
184
|
-
* 获取每周频率前缀文案
|
|
185
|
-
* @param frequency 频率数字
|
|
186
|
-
* @param locale 语言设置
|
|
187
|
-
* @returns 格式化的每周频率前缀文案
|
|
188
|
-
*/
|
|
195
|
+
* 获取每周频率前缀文案
|
|
196
|
+
* @param frequency 频率数字
|
|
197
|
+
* @param locale 语言设置
|
|
198
|
+
* @returns 格式化的每周频率前缀文案
|
|
199
|
+
*/
|
|
189
200
|
function getWeeklyFrequencyPrefix(frequency, locale) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
201
|
+
if (frequency === 1) {
|
|
202
|
+
return '';
|
|
203
|
+
}
|
|
204
|
+
var config = textConfig[locale];
|
|
205
|
+
if (locale === 'en') {
|
|
206
|
+
return "".concat(config.everyPrefix).concat(frequency, " ").concat(config.weeks, ", ");
|
|
207
|
+
} else {
|
|
208
|
+
return "".concat(config.everyPrefix).concat(frequency).concat(config.weeks, " ");
|
|
209
|
+
}
|
|
194
210
|
}
|
|
211
|
+
|
|
195
212
|
/**
|
|
196
|
-
* 格式化日期时间函数
|
|
197
|
-
* @param dateTime 日期时间字符串
|
|
198
|
-
* @param isAll 是否为全天
|
|
199
|
-
* @param locale 语言设置
|
|
200
|
-
* @returns 格式化后的日期时间字符串
|
|
201
|
-
*/
|
|
202
|
-
function formatDateTime(dateTime
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
213
|
+
* 格式化日期时间函数
|
|
214
|
+
* @param dateTime 日期时间字符串
|
|
215
|
+
* @param isAll 是否为全天
|
|
216
|
+
* @param locale 语言设置
|
|
217
|
+
* @returns 格式化后的日期时间字符串
|
|
218
|
+
*/
|
|
219
|
+
function formatDateTime(dateTime) {
|
|
220
|
+
var isAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
221
|
+
var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'zh-CN';
|
|
222
|
+
var date = dayjs(dateTime);
|
|
223
|
+
var config = getConfig(locale);
|
|
224
|
+
if (isAll) {
|
|
225
|
+
// 全天情况下的日期格式
|
|
226
|
+
return date.format(config.dateFormat);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 非全天情况下的日期时间格式
|
|
230
|
+
return date.format(config.dateTimeFormat);
|
|
207
231
|
}
|
|
232
|
+
|
|
208
233
|
/**
|
|
209
|
-
* 判断是否为全天日程
|
|
210
|
-
* @param startTime 开始时间 (HH:mm格式)
|
|
211
|
-
* @param endTime 结束时间 (HH:mm格式)
|
|
212
|
-
* @returns 是否为全天日程
|
|
213
|
-
*/
|
|
234
|
+
* 判断是否为全天日程
|
|
235
|
+
* @param startTime 开始时间 (HH:mm格式)
|
|
236
|
+
* @param endTime 结束时间 (HH:mm格式)
|
|
237
|
+
* @returns 是否为全天日程
|
|
238
|
+
*/
|
|
214
239
|
function isAllDaySchedule(startTime, endTime) {
|
|
215
|
-
|
|
240
|
+
return startTime === CONSTANTS.ALL_DAY_START && endTime === CONSTANTS.ALL_DAY_END;
|
|
216
241
|
}
|
|
242
|
+
|
|
217
243
|
/**
|
|
218
|
-
* 生成日期范围文案
|
|
219
|
-
* @param startDate 开始日期
|
|
220
|
-
* @param endDate 结束日期
|
|
221
|
-
* @param isStarted 是否已开始
|
|
222
|
-
* @param locale 语言设置
|
|
223
|
-
* @param isAllDay 是否为全天
|
|
224
|
-
* @returns 格式化的日期范围文案
|
|
225
|
-
*/
|
|
226
|
-
function formatDateRange(startDate, endDate, isStarted, locale
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
244
|
+
* 生成日期范围文案
|
|
245
|
+
* @param startDate 开始日期
|
|
246
|
+
* @param endDate 结束日期
|
|
247
|
+
* @param isStarted 是否已开始
|
|
248
|
+
* @param locale 语言设置
|
|
249
|
+
* @param isAllDay 是否为全天
|
|
250
|
+
* @returns 格式化的日期范围文案
|
|
251
|
+
*/
|
|
252
|
+
function formatDateRange(startDate, endDate, isStarted, locale) {
|
|
253
|
+
var isAllDay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
254
|
+
var validity = arguments.length > 5 ? arguments[5] : undefined;
|
|
255
|
+
var config = getConfig(locale);
|
|
256
|
+
var range = getWalletValidityRange(startDate, endDate, validity);
|
|
257
|
+
if (range.isEmpty) return config.noAvailableDates;
|
|
258
|
+
var effectiveStart = range.startDate === getValidityDate(startDate) ? startDate : "".concat(range.startDate, " 00:00:00");
|
|
259
|
+
var effectiveEnd = range.endDate === getValidityDate(endDate) ? endDate : "".concat(range.endDate, " 23:59:59");
|
|
260
|
+
if (!range.endDate) return config.unlimited;
|
|
261
|
+
var hasStarted = range.startDate ? dayjs(effectiveStart).isBefore(dayjs()) : isStarted;
|
|
262
|
+
if (hasStarted || !range.startDate) {
|
|
263
|
+
var endDateStr = formatDateTime(effectiveEnd, isAllDay, locale);
|
|
264
|
+
return "".concat(config.until).concat(endDateStr);
|
|
265
|
+
} else {
|
|
266
|
+
var startDateStr = formatDateTime(effectiveStart, isAllDay, locale);
|
|
267
|
+
var _endDateStr = formatDateTime(effectiveEnd, isAllDay, locale);
|
|
268
|
+
return "".concat(startDateStr).concat(config.rangeSeparator).concat(_endDateStr);
|
|
269
|
+
}
|
|
241
270
|
}
|
|
271
|
+
|
|
242
272
|
/**
|
|
243
|
-
* 获取schedule摘要信息
|
|
244
|
-
* @param scheduleList 日程列表
|
|
245
|
-
* @param locale 语言设置
|
|
246
|
-
* @returns 摘要文本
|
|
247
|
-
*/
|
|
248
|
-
function getScheduleSummary(scheduleList
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
273
|
+
* 获取schedule摘要信息
|
|
274
|
+
* @param scheduleList 日程列表
|
|
275
|
+
* @param locale 语言设置
|
|
276
|
+
* @returns 摘要文本
|
|
277
|
+
*/
|
|
278
|
+
export function getScheduleSummary(scheduleList) {
|
|
279
|
+
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'zh-CN';
|
|
280
|
+
var validity = arguments.length > 2 ? arguments[2] : undefined;
|
|
281
|
+
try {
|
|
282
|
+
locale = textConfig[locale] ? locale : 'en';
|
|
283
|
+
// 输入验证
|
|
284
|
+
if (!scheduleList || !Array.isArray(scheduleList)) {
|
|
285
|
+
return '';
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// 多规则摘要仍保留卡的到期边界。
|
|
289
|
+
if (scheduleList.length > 1) {
|
|
290
|
+
var range = getWalletValidityRange(null, null, validity);
|
|
291
|
+
if (!range.startDate && !range.endDate) return getText(locale, 'multipleRules');
|
|
292
|
+
var summaries = scheduleList.map(function (schedule) {
|
|
293
|
+
return getScheduleSummary([schedule], locale, validity);
|
|
294
|
+
}).filter(function (summary) {
|
|
295
|
+
return summary !== getText(locale, 'noAvailableDates');
|
|
296
|
+
});
|
|
297
|
+
if (summaries.length === 0) return getText(locale, 'noAvailableDates');
|
|
298
|
+
if (summaries.length === 1 && summaries[0]) return summaries[0];
|
|
299
|
+
var prefix = range.endDate ? "".concat(formatDateRange(range.startDate || '', range.endDate, false, locale, true)).concat(getText(locale, 'periodSeparator')) : '';
|
|
300
|
+
return "".concat(prefix).concat(getText(locale, 'multipleRules'));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// 如果没有日程,返回空字符串
|
|
304
|
+
if (scheduleList.length === 0) {
|
|
305
|
+
return '';
|
|
306
|
+
}
|
|
307
|
+
var schedule = scheduleList[0];
|
|
308
|
+
if (!schedule) {
|
|
309
|
+
return '';
|
|
310
|
+
}
|
|
311
|
+
var now = dayjs();
|
|
312
|
+
|
|
313
|
+
// 获取日程开始时间
|
|
314
|
+
var startTime = null;
|
|
315
|
+
if (schedule.start_time) {
|
|
316
|
+
startTime = dayjs(schedule.start_time);
|
|
317
|
+
} else if (schedule.designation && schedule.designation.length > 0) {
|
|
318
|
+
// designation类型,取第一个日期作为开始时间
|
|
319
|
+
var firstDesignation = schedule.designation[0];
|
|
320
|
+
if (firstDesignation && firstDesignation.start_date && firstDesignation.start_time) {
|
|
321
|
+
startTime = dayjs("".concat(firstDesignation.start_date, " ").concat(firstDesignation.start_time));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
var passStart = getValidityDate(validity === null || validity === void 0 ? void 0 : validity.start_date);
|
|
325
|
+
if (passStart && (!startTime || dayjs(passStart).isAfter(startTime))) {
|
|
326
|
+
startTime = dayjs(passStart);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// 判断开始时间是否在当前时间之后
|
|
330
|
+
var isStarted = startTime ? isTimeStarted(now, startTime) : false;
|
|
331
|
+
|
|
332
|
+
// 根据不同类型和状态返回摘要
|
|
333
|
+
var summary = generateSummaryText(schedule, isStarted, locale, validity);
|
|
334
|
+
// 包含日期可独立于循环日程的日期范围生效。
|
|
335
|
+
if (summary === getText(locale, 'noAvailableDates')) {
|
|
336
|
+
var _schedule$repeat_rule;
|
|
337
|
+
var included = (_schedule$repeat_rule = schedule.repeat_rule) === null || _schedule$repeat_rule === void 0 || (_schedule$repeat_rule = _schedule$repeat_rule.included_date) === null || _schedule$repeat_rule === void 0 ? void 0 : _schedule$repeat_rule.filter(function (item) {
|
|
338
|
+
return !getWalletValidityRange(item.start, item.end, validity).isEmpty;
|
|
339
|
+
});
|
|
340
|
+
if (included !== null && included !== void 0 && included.length) {
|
|
341
|
+
return getScheduleSummary([_objectSpread(_objectSpread({}, schedule), {}, {
|
|
342
|
+
start_time: null,
|
|
343
|
+
end_time: null,
|
|
344
|
+
type: 'designation',
|
|
345
|
+
repeat_type: 'none',
|
|
346
|
+
repeat_rule: null,
|
|
347
|
+
is_all: 1,
|
|
348
|
+
designation: included.map(function (item) {
|
|
349
|
+
return {
|
|
350
|
+
start_date: item.start,
|
|
351
|
+
end_date: item.end,
|
|
352
|
+
start_time: '00:00',
|
|
353
|
+
end_time: '23:59'
|
|
354
|
+
};
|
|
355
|
+
})
|
|
356
|
+
})], locale, validity);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return summary;
|
|
360
|
+
} catch (error) {
|
|
361
|
+
console.warn('Error in getScheduleSummary:', error);
|
|
362
|
+
return '';
|
|
363
|
+
}
|
|
296
364
|
}
|
|
365
|
+
|
|
297
366
|
/**
|
|
298
|
-
* 判断开始时间是否在当前时间之后
|
|
299
|
-
* @param now 当前时间
|
|
300
|
-
* @param startTime 开始时间
|
|
301
|
-
* @returns 是否已开始
|
|
302
|
-
*/
|
|
367
|
+
* 判断开始时间是否在当前时间之后
|
|
368
|
+
* @param now 当前时间
|
|
369
|
+
* @param startTime 开始时间
|
|
370
|
+
* @returns 是否已开始
|
|
371
|
+
*/
|
|
303
372
|
function isTimeStarted(now, startTime) {
|
|
304
|
-
|
|
373
|
+
return startTime.isBefore(now);
|
|
305
374
|
}
|
|
375
|
+
|
|
306
376
|
/**
|
|
307
|
-
* 生成摘要文本
|
|
308
|
-
* @param schedule 日程对象
|
|
309
|
-
* @param isStarted 是否已开始
|
|
310
|
-
* @param locale 语言设置
|
|
311
|
-
* @returns 生成的摘要文本
|
|
312
|
-
*/
|
|
377
|
+
* 生成摘要文本
|
|
378
|
+
* @param schedule 日程对象
|
|
379
|
+
* @param isStarted 是否已开始
|
|
380
|
+
* @param locale 语言设置
|
|
381
|
+
* @returns 生成的摘要文本
|
|
382
|
+
*/
|
|
313
383
|
function generateSummaryText(schedule, isStarted, locale, validity) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
384
|
+
// 1. 多天多段 (designation类型且有多个日期段)
|
|
385
|
+
if (schedule.type === 'designation' && schedule.designation && schedule.designation.length > 1) {
|
|
386
|
+
var passRange = getWalletValidityRange(null, null, validity);
|
|
387
|
+
if (!passRange.startDate && !passRange.endDate) return getText(locale, 'multipleRules');
|
|
388
|
+
var designation = schedule.designation.filter(function (item) {
|
|
389
|
+
return !getWalletValidityRange(item.start_date, item.end_date, validity).isEmpty;
|
|
390
|
+
});
|
|
391
|
+
if (!designation.length) return getText(locale, 'noAvailableDates');
|
|
392
|
+
if (designation.length === 1) {
|
|
393
|
+
return generateSingleScheduleSummary(_objectSpread(_objectSpread({}, schedule), {}, {
|
|
394
|
+
designation: designation
|
|
395
|
+
}), isStarted, locale, validity);
|
|
396
|
+
}
|
|
397
|
+
var range = getWalletValidityRange(designation.map(function (item) {
|
|
398
|
+
return item.start_date;
|
|
399
|
+
}).sort()[0], designation.map(function (item) {
|
|
400
|
+
return item.end_date;
|
|
401
|
+
}).sort().pop(), validity);
|
|
402
|
+
var prefix = range.endDate ? "".concat(formatDateRange(range.startDate || '', range.endDate, isStarted, locale, true)).concat(getText(locale, 'periodSeparator')) : '';
|
|
403
|
+
return "".concat(prefix).concat(getText(locale, 'multipleRules'));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// 2. 单日多段 (time-slots类型)
|
|
407
|
+
if (schedule.type === 'time-slots') {
|
|
408
|
+
var _range = getWalletValidityRange(schedule.start_time, getScheduleEndDate(schedule), validity);
|
|
409
|
+
if (_range.isEmpty) return getText(locale, 'noAvailableDates');
|
|
410
|
+
var endDateStr = _range.endDate ? formatDateTime(_range.endDate, true, locale) : getText(locale, 'unlimited');
|
|
411
|
+
var suffix = getText(locale, 'multipleSlots');
|
|
412
|
+
return "".concat(endDateStr).concat(suffix);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// 3. 循环日程
|
|
416
|
+
if (schedule.repeat_type !== 'none' && schedule.repeat_rule) {
|
|
417
|
+
return generateRecurringSummary(schedule, isStarted, locale, validity);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// 4. 单个日程(包括designation类型的单个日期段)
|
|
421
|
+
return generateSingleScheduleSummary(schedule, isStarted, locale, validity);
|
|
330
422
|
}
|
|
423
|
+
|
|
331
424
|
/**
|
|
332
|
-
* 生成循环日程摘要
|
|
333
|
-
* @param schedule 日程对象
|
|
334
|
-
* @param isStarted 是否已开始
|
|
335
|
-
* @param locale 语言设置
|
|
336
|
-
* @returns 循环日程摘要文本
|
|
337
|
-
*/
|
|
425
|
+
* 生成循环日程摘要
|
|
426
|
+
* @param schedule 日程对象
|
|
427
|
+
* @param isStarted 是否已开始
|
|
428
|
+
* @param locale 语言设置
|
|
429
|
+
* @returns 循环日程摘要文本
|
|
430
|
+
*/
|
|
338
431
|
function generateRecurringSummary(schedule, isStarted, locale, validity) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
432
|
+
var repeat_type = schedule.repeat_type,
|
|
433
|
+
repeat_rule = schedule.repeat_rule;
|
|
434
|
+
if (!repeat_rule) return '';
|
|
435
|
+
var frequency = repeat_rule.frequency,
|
|
436
|
+
frequency_date = repeat_rule.frequency_date,
|
|
437
|
+
end = repeat_rule.end;
|
|
438
|
+
var range = getWalletValidityRange(schedule.start_time, getScheduleEndDate(schedule), validity);
|
|
439
|
+
if (range.isEmpty) return getText(locale, 'noAvailableDates');
|
|
440
|
+
|
|
441
|
+
// 特殊处理:当 end.type === 'never' 时的格式
|
|
442
|
+
if (end.type === 'never' && !range.endDate) {
|
|
443
|
+
return generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeat_type, frequency, frequency_date, validity);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// 原有逻辑:有结束时间的循环日程
|
|
447
|
+
var endDate = range.endDate;
|
|
448
|
+
if (!endDate) return '';
|
|
449
|
+
|
|
450
|
+
// 按天循环
|
|
451
|
+
if (repeat_type === 'daily') {
|
|
452
|
+
var frequencyText = getDailyFrequencyText(frequency, locale);
|
|
453
|
+
var dateRange = formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity);
|
|
454
|
+
return "".concat(dateRange).concat(getText(locale, 'timeSlotSeparator')).concat(frequencyText);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// 按周循环
|
|
458
|
+
if (repeat_type === 'weekly') {
|
|
459
|
+
var weekdaysText = getWeekdayText(frequency_date, locale, '/');
|
|
460
|
+
var frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
461
|
+
var config = getConfig(locale);
|
|
462
|
+
var _dateRange = formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity);
|
|
463
|
+
return "".concat(_dateRange).concat(config.timeSlotSeparator).concat(frequencyPrefix).concat(config.weekPrefix).concat(weekdaysText);
|
|
464
|
+
}
|
|
465
|
+
return '';
|
|
358
466
|
}
|
|
467
|
+
|
|
359
468
|
/**
|
|
360
|
-
* 生成永不结束的循环日程摘要
|
|
361
|
-
* @param schedule 日程对象
|
|
362
|
-
* @param isStarted 是否已开始
|
|
363
|
-
* @param locale 语言设置
|
|
364
|
-
* @param repeatType 循环类型
|
|
365
|
-
* @param frequency 频率
|
|
366
|
-
* @param frequencyDate 频率日期数组(用于周循环)
|
|
367
|
-
* @returns 永不结束的循环日程摘要文本
|
|
368
|
-
*/
|
|
469
|
+
* 生成永不结束的循环日程摘要
|
|
470
|
+
* @param schedule 日程对象
|
|
471
|
+
* @param isStarted 是否已开始
|
|
472
|
+
* @param locale 语言设置
|
|
473
|
+
* @param repeatType 循环类型
|
|
474
|
+
* @param frequency 频率
|
|
475
|
+
* @param frequencyDate 频率日期数组(用于周循环)
|
|
476
|
+
* @returns 永不结束的循环日程摘要文本
|
|
477
|
+
*/
|
|
369
478
|
function generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeatType, frequency, frequencyDate, validity) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
479
|
+
var config = getConfig(locale);
|
|
480
|
+
|
|
481
|
+
// 按天循环
|
|
482
|
+
if (repeatType === 'daily') {
|
|
483
|
+
if (frequency === 1) {
|
|
484
|
+
// 频率=1:中文"自 YYYY-MM-DD 起长期有效",英文"Valid from DD MMM YYYY, no expiry"
|
|
485
|
+
var range = getWalletValidityRange(schedule.start_time, null, validity);
|
|
486
|
+
if (range.startDate) {
|
|
487
|
+
var startDateStr = formatDateTime(range.startDate, true, locale);
|
|
488
|
+
return "".concat(config.longTermValidFrom).concat(startDateStr).concat(config.noExpiry);
|
|
489
|
+
}
|
|
490
|
+
return '';
|
|
491
|
+
} else {
|
|
492
|
+
// 频率>1:中文"每2天可用",英文"Every 2 days"
|
|
493
|
+
var frequencyText = getDailyFrequencyText(frequency, locale);
|
|
494
|
+
if (locale === 'en') {
|
|
495
|
+
return "".concat(frequencyText);
|
|
496
|
+
} else {
|
|
497
|
+
return "".concat(frequencyText).concat(config.available);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// 按周循环
|
|
503
|
+
if (repeatType === 'weekly') {
|
|
504
|
+
var weekdaysText = getWeekdayText(frequencyDate, locale, locale === 'en' ? ' & ' : '/');
|
|
505
|
+
if (frequency === 1) {
|
|
506
|
+
// 频率=1:中文"每周三/五可用",英文"on Wed & Fri"
|
|
507
|
+
if (locale === 'en') {
|
|
508
|
+
return "".concat(config.on).concat(weekdaysText);
|
|
509
|
+
} else {
|
|
510
|
+
return "".concat(config.everyPrefix).concat(config.weekPrefix).concat(weekdaysText).concat(config.available);
|
|
511
|
+
}
|
|
512
|
+
} else {
|
|
513
|
+
// 频率>1:中文"每2周 周三/五",英文"Every 2 weeks, on Wed & Fri"
|
|
514
|
+
var frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
515
|
+
if (locale === 'en') {
|
|
516
|
+
return "".concat(frequencyPrefix).concat(config.on).concat(weekdaysText);
|
|
517
|
+
} else {
|
|
518
|
+
return "".concat(frequencyPrefix).concat(config.weekPrefix).concat(weekdaysText);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return '';
|
|
394
523
|
}
|
|
524
|
+
|
|
395
525
|
/**
|
|
396
|
-
* 生成单个日程摘要
|
|
397
|
-
* @param schedule 日程对象
|
|
398
|
-
* @param isStarted 是否已开始
|
|
399
|
-
* @param locale 语言设置
|
|
400
|
-
* @returns 单个日程摘要文本
|
|
401
|
-
*/
|
|
526
|
+
* 生成单个日程摘要
|
|
527
|
+
* @param schedule 日程对象
|
|
528
|
+
* @param isStarted 是否已开始
|
|
529
|
+
* @param locale 语言设置
|
|
530
|
+
* @returns 单个日程摘要文本
|
|
531
|
+
*/
|
|
402
532
|
function generateSingleScheduleSummary(schedule, isStarted, locale, validity) {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
533
|
+
var isAllDay = schedule.is_all === 1;
|
|
534
|
+
|
|
535
|
+
// 处理designation类型的单个日期段
|
|
536
|
+
if (schedule.type === 'designation' && schedule.designation && schedule.designation.length === 1) {
|
|
537
|
+
var designation = schedule.designation[0];
|
|
538
|
+
var startDate = designation.start_date;
|
|
539
|
+
var endDate = designation.end_date;
|
|
540
|
+
var startTime = designation.start_time;
|
|
541
|
+
var endTime = designation.end_time;
|
|
542
|
+
|
|
543
|
+
// 判断是否为全天
|
|
544
|
+
var isDesignationAllDay = isAllDaySchedule(startTime, endTime);
|
|
545
|
+
if (isDesignationAllDay || isAllDay) {
|
|
546
|
+
// 全天日程
|
|
547
|
+
return formatDateRange(startDate, endDate, isStarted, locale, true, validity);
|
|
548
|
+
} else {
|
|
549
|
+
// 非全天日程
|
|
550
|
+
var startDateTime = "".concat(startDate, " ").concat(startTime).concat(CONSTANTS.SECONDS_SUFFIX);
|
|
551
|
+
var endDateTime = "".concat(endDate, " ").concat(endTime).concat(CONSTANTS.SECONDS_SUFFIX);
|
|
552
|
+
return formatDateRange(startDateTime, endDateTime, isStarted, locale, false, validity);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// 标准日程处理
|
|
557
|
+
if (isAllDay) {
|
|
558
|
+
// 全天日程
|
|
559
|
+
var _endDate = getScheduleEndDate(schedule);
|
|
560
|
+
if (!_endDate) return '';
|
|
561
|
+
return formatDateRange(schedule.start_time, _endDate, isStarted, locale, true, validity);
|
|
562
|
+
} else {
|
|
563
|
+
// 非全天日程
|
|
564
|
+
return formatDateRange(schedule.start_time, schedule.end_time, isStarted, locale, false, validity);
|
|
565
|
+
}
|
|
418
566
|
}
|
|
567
|
+
|
|
419
568
|
/**
|
|
420
|
-
* 获取日程结束日期
|
|
421
|
-
* @param schedule 日程对象
|
|
422
|
-
* @returns 结束日期字符串,如果无法确定则返回null
|
|
423
|
-
*/
|
|
569
|
+
* 获取日程结束日期
|
|
570
|
+
* @param schedule 日程对象
|
|
571
|
+
* @returns 结束日期字符串,如果无法确定则返回null
|
|
572
|
+
*/
|
|
424
573
|
function getScheduleEndDate(schedule) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
574
|
+
try {
|
|
575
|
+
// 循环日程
|
|
576
|
+
if (schedule.repeat_rule) {
|
|
577
|
+
if (schedule.repeat_rule.end.type === 'never') {
|
|
578
|
+
return null;
|
|
579
|
+
} else if (schedule.repeat_rule.end.end_date) {
|
|
580
|
+
return "".concat(schedule.repeat_rule.end.end_date, " ").concat(CONSTANTS.ALL_DAY_END).concat(CONSTANTS.SECONDS_SUFFIX);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// designation类型
|
|
585
|
+
if (schedule.designation && schedule.designation.length > 0) {
|
|
586
|
+
var lastDesignation = schedule.designation[schedule.designation.length - 1];
|
|
587
|
+
return "".concat(lastDesignation.end_date, " ").concat(lastDesignation.end_time).concat(CONSTANTS.SECONDS_SUFFIX);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// 标准日程
|
|
591
|
+
if (schedule.end_time) {
|
|
592
|
+
return schedule.end_time;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// time-slots类型
|
|
596
|
+
if (schedule.start_time) {
|
|
597
|
+
return schedule.start_time;
|
|
598
|
+
}
|
|
599
|
+
return null;
|
|
600
|
+
} catch (error) {
|
|
601
|
+
console.warn('Error in getScheduleEndDate:', error);
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
}
|