@para-ui/core 4.0.2 → 4.0.3
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/CycleSelector/index.d.ts +35 -0
- package/CycleSelector/index.js +716 -0
- package/CycleSelector/lang/en_US.d.ts +80 -0
- package/CycleSelector/lang/index.d.ts +161 -0
- package/CycleSelector/lang/zh_CN.d.ts +80 -0
- package/README.md +4 -0
- package/index.d.ts +2 -0
- package/index.js +3 -2
- package/locale/en-US.d.ts +79 -0
- package/locale/index.d.ts +158 -0
- package/locale/index.js +158 -0
- package/locale/zh-CN.d.ts +79 -0
- package/package.json +1 -1
- package/umd/CycleSelector.js +43 -0
- package/umd/locale.js +1 -1
|
@@ -0,0 +1,716 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import React__default, { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import CloseIcon from '@para-ui/icons/Close';
|
|
6
|
+
import WarningCircleF from '@para-ui/icons/WarningCircleF';
|
|
7
|
+
import { $ as $prefixCls } from '../_verture/constant-5317fc89.js';
|
|
8
|
+
import DatePicker from '../DatePicker/index.js';
|
|
9
|
+
import Select from '../Select/index.js';
|
|
10
|
+
import { TextField } from '../TextField/index.js';
|
|
11
|
+
import { Popover } from '../Popover/index.js';
|
|
12
|
+
import { Button } from '../Button/index.js';
|
|
13
|
+
import GlobalContext from '@para-ui/core/GlobalContext';
|
|
14
|
+
import { u as useFormatMessage } from '../_verture/useFormatMessage-eb13cf56.js';
|
|
15
|
+
import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
|
|
16
|
+
import 'rc-picker/es/generate/dayjs';
|
|
17
|
+
import '../Tag/index.js';
|
|
18
|
+
import '../_verture/tslib.es6-55ed4bd2.js';
|
|
19
|
+
import '@para-ui/icons/EditOutline';
|
|
20
|
+
import '../AutoTips/index.js';
|
|
21
|
+
import '../Tooltip/index.js';
|
|
22
|
+
import 'rc-tooltip';
|
|
23
|
+
import 'rc-tooltip/lib/placements';
|
|
24
|
+
import '@para-ui/icons/Forbid';
|
|
25
|
+
import '@paraview/lib';
|
|
26
|
+
import '../_verture/tinycolor-ece3542d.js';
|
|
27
|
+
import '@para-ui/icons/Plus';
|
|
28
|
+
import '../_verture/defineProperty-1d116156.js';
|
|
29
|
+
import '../_verture/typeof-adeedc13.js';
|
|
30
|
+
import 'rc-picker';
|
|
31
|
+
import '@para-ui/icons/CloseCircleF';
|
|
32
|
+
import '@para-ui/icons/Calendar';
|
|
33
|
+
import '@para-ui/icons/Time';
|
|
34
|
+
import '../_verture/index-389675ab.js';
|
|
35
|
+
import 'rc-dropdown';
|
|
36
|
+
import '../_verture/usePopupContainer-635f66f4.js';
|
|
37
|
+
import 'rc-picker/lib/locale/en_US';
|
|
38
|
+
import 'rc-picker/lib/locale/zh_CN';
|
|
39
|
+
import '../Label/index.js';
|
|
40
|
+
import '../Help/index.js';
|
|
41
|
+
import '@para-ui/icons/Help';
|
|
42
|
+
import '../HelperText/index.js';
|
|
43
|
+
import '@para-ui/icons/SortRight';
|
|
44
|
+
import '../Empty/index.js';
|
|
45
|
+
import '../_verture/useGlobalProps-1e416658.js';
|
|
46
|
+
import '@para-ui/icons/Down';
|
|
47
|
+
import '@para-ui/icons/Check';
|
|
48
|
+
import '@para-ui/icons/Search';
|
|
49
|
+
import '../Loading/index.js';
|
|
50
|
+
import '@para-ui/icons/LoadingF';
|
|
51
|
+
import '@para-ui/icons/PreviewClose';
|
|
52
|
+
import '@para-ui/icons/PreviewOpen';
|
|
53
|
+
|
|
54
|
+
var en = {
|
|
55
|
+
placeholder: 'Please select',
|
|
56
|
+
pleaseSelect: 'Please select',
|
|
57
|
+
week1: 'Monday',
|
|
58
|
+
week2: 'Tuesday',
|
|
59
|
+
week3: 'Wednesday',
|
|
60
|
+
week4: 'Thursday',
|
|
61
|
+
week5: 'Friday',
|
|
62
|
+
week6: 'Saturday',
|
|
63
|
+
week0: 'Sunday',
|
|
64
|
+
every: 'Every ',
|
|
65
|
+
day: 'Day',
|
|
66
|
+
week: 'Week',
|
|
67
|
+
month: 'Month',
|
|
68
|
+
year: 'Year',
|
|
69
|
+
one: 'One',
|
|
70
|
+
two: 'Two',
|
|
71
|
+
three: 'Three',
|
|
72
|
+
four: 'Four',
|
|
73
|
+
five: 'Five',
|
|
74
|
+
six: 'Six',
|
|
75
|
+
seven: 'Seven',
|
|
76
|
+
day1: 'Day 1',
|
|
77
|
+
day2: 'Day 2',
|
|
78
|
+
day3: 'Day 3',
|
|
79
|
+
day4: 'Day 4',
|
|
80
|
+
day5: 'Day 5',
|
|
81
|
+
day6: 'Day 6',
|
|
82
|
+
day7: 'Day 7',
|
|
83
|
+
day8: 'Day 8',
|
|
84
|
+
day9: 'Day 9',
|
|
85
|
+
day10: 'Day 10',
|
|
86
|
+
day11: 'Day 11',
|
|
87
|
+
day12: 'Day 12',
|
|
88
|
+
day13: 'Day 13',
|
|
89
|
+
day14: 'Day 14',
|
|
90
|
+
day15: 'Day 15',
|
|
91
|
+
day16: 'Day 16',
|
|
92
|
+
day17: 'Day 17',
|
|
93
|
+
day18: 'Day 18',
|
|
94
|
+
day19: 'Day 19',
|
|
95
|
+
day20: 'Day 20',
|
|
96
|
+
day21: 'Day 21',
|
|
97
|
+
day22: 'Day 22',
|
|
98
|
+
day23: 'Day 23',
|
|
99
|
+
day24: 'Day 24',
|
|
100
|
+
day25: 'Day 25',
|
|
101
|
+
day26: 'Day 26',
|
|
102
|
+
day27: 'Day 27',
|
|
103
|
+
day28: 'Day 28',
|
|
104
|
+
day29: 'Day 29',
|
|
105
|
+
day30: 'Day 30',
|
|
106
|
+
day31: 'Day 31',
|
|
107
|
+
the1: 'The first ',
|
|
108
|
+
the2: 'The 2nd ',
|
|
109
|
+
the3: 'The 3rd ',
|
|
110
|
+
the4: 'The 4th ',
|
|
111
|
+
the5: 'The 5th ',
|
|
112
|
+
infiniteRepetition: 'Infinite repetition',
|
|
113
|
+
deadline: 'Deadline',
|
|
114
|
+
limitNum: 'Limited number of times',
|
|
115
|
+
noRepetition: 'No repetition',
|
|
116
|
+
repeatEveryDay: 'Repeat every day',
|
|
117
|
+
repeatEveryWeek: 'Repeat every week',
|
|
118
|
+
repeatEveryMonth: 'Repeat every month',
|
|
119
|
+
repeatEveryYear: 'Repeat every year',
|
|
120
|
+
customRepetition: 'Custom repetition',
|
|
121
|
+
th: 'th',
|
|
122
|
+
repetitionFrequency: 'Repetition frequency',
|
|
123
|
+
update: 'update',
|
|
124
|
+
text1: '{every} {time}',
|
|
125
|
+
text2: ', Terminate duplication after detecting {limitNum} times',
|
|
126
|
+
text3: ', End time: {date}',
|
|
127
|
+
weekTip: 'The current schedule time is {week}',
|
|
128
|
+
endRepetition: 'End repetition',
|
|
129
|
+
customCycle: 'Custom cycle',
|
|
130
|
+
cancel: 'Cancel',
|
|
131
|
+
confirm: 'Confirm'
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
var zh = {
|
|
135
|
+
placeholder: '请输入',
|
|
136
|
+
pleaseSelect: '请选择',
|
|
137
|
+
week1: '星期一',
|
|
138
|
+
week2: '星期二',
|
|
139
|
+
week3: '星期三',
|
|
140
|
+
week4: '星期四',
|
|
141
|
+
week5: '星期五',
|
|
142
|
+
week6: '星期六',
|
|
143
|
+
week0: '星期日',
|
|
144
|
+
every: '每',
|
|
145
|
+
day: '天',
|
|
146
|
+
week: '周',
|
|
147
|
+
month: '月',
|
|
148
|
+
year: '年',
|
|
149
|
+
one: '一',
|
|
150
|
+
two: '二',
|
|
151
|
+
three: '三',
|
|
152
|
+
four: '四',
|
|
153
|
+
five: '五',
|
|
154
|
+
six: '六',
|
|
155
|
+
seven: '日',
|
|
156
|
+
day1: '第一天',
|
|
157
|
+
day2: '第二天',
|
|
158
|
+
day3: '第三天',
|
|
159
|
+
day4: '第四天',
|
|
160
|
+
day5: '第五天',
|
|
161
|
+
day6: '第六天',
|
|
162
|
+
day7: '第七天',
|
|
163
|
+
day8: '第八天',
|
|
164
|
+
day9: '第九天',
|
|
165
|
+
day10: '第十天',
|
|
166
|
+
day11: '第十一天',
|
|
167
|
+
day12: '第十二天',
|
|
168
|
+
day13: '第十三天',
|
|
169
|
+
day14: '第十四天',
|
|
170
|
+
day15: '第十五天',
|
|
171
|
+
day16: '第十六天',
|
|
172
|
+
day17: '第十七天',
|
|
173
|
+
day18: '第十八天',
|
|
174
|
+
day19: '第十九天',
|
|
175
|
+
day20: '第二十天',
|
|
176
|
+
day21: '第二十一天',
|
|
177
|
+
day22: '第二十二天',
|
|
178
|
+
day23: '第二十三天',
|
|
179
|
+
day24: '第二十四天',
|
|
180
|
+
day25: '第二十五天',
|
|
181
|
+
day26: '第二十六天',
|
|
182
|
+
day27: '第二十七天',
|
|
183
|
+
day28: '第二十八天',
|
|
184
|
+
day29: '第二十九天',
|
|
185
|
+
day30: '第三十天',
|
|
186
|
+
day31: '第三十一天',
|
|
187
|
+
the1: '第一个',
|
|
188
|
+
the2: '第二个',
|
|
189
|
+
the3: '第三个',
|
|
190
|
+
the4: '第四个',
|
|
191
|
+
the5: '第五个',
|
|
192
|
+
infiniteRepetition: '无限重复',
|
|
193
|
+
deadline: '截止时间',
|
|
194
|
+
limitNum: '限定次数',
|
|
195
|
+
noRepetition: '不重复',
|
|
196
|
+
repeatEveryDay: '每天重复',
|
|
197
|
+
repeatEveryWeek: '每周重复',
|
|
198
|
+
repeatEveryMonth: '每月重复',
|
|
199
|
+
repeatEveryYear: '每年重复',
|
|
200
|
+
customRepetition: '自定义重复',
|
|
201
|
+
th: '号',
|
|
202
|
+
repetitionFrequency: '重复频率',
|
|
203
|
+
update: '更改',
|
|
204
|
+
text1: '{every}的{time}',
|
|
205
|
+
text2: ',检测{limitNum}次后终止重复',
|
|
206
|
+
text3: ',结束时间:{date}',
|
|
207
|
+
weekTip: '当前日程时间为{week},无法取消勾选',
|
|
208
|
+
endRepetition: '结束重复',
|
|
209
|
+
customCycle: '自定义周期',
|
|
210
|
+
cancel: '取 消',
|
|
211
|
+
confirm: '确 定'
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
var localeJson = {
|
|
215
|
+
zh,
|
|
216
|
+
en
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
var css_248z = "@charset \"UTF-8\";\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-cycle-selector .cycle-selector-content {\n display: flex;\n}\n.paraui-v4-cycle-selector .cycle-selector-content .time-select {\n flex: 1;\n overflow: hidden;\n}\n.paraui-v4-cycle-selector .cycle-selector-content .select-type {\n flex: 1;\n overflow: hidden;\n margin-left: 10px;\n}\n.paraui-v4-cycle-selector .text-tip {\n font-size: 12px;\n color: rgb(29, 33, 38);\n margin-top: 10px;\n}\n.paraui-v4-cycle-selector .text-tip button {\n height: inherit;\n font-size: 12px;\n margin-left: 8px;\n}\n\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content {\n width: 480px;\n padding: 15px 20px 20px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .title {\n display: flex;\n line-height: 20px;\n align-items: center;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .title .label {\n flex: 1;\n font-size: 14px;\n color: rgb(29, 33, 38);\n font-weight: 600;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .title svg {\n color: rgb(92, 101, 115);\n cursor: pointer;\n font-size: 18px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .title svg:hover {\n color: rgb(87, 131, 235);\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content {\n margin-top: 16px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .item {\n display: flex;\n margin-bottom: 20px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .item .label {\n line-height: 32px;\n width: 150px;\n color: rgb(92, 101, 115);\n font-size: 14px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .item .form-content {\n display: flex;\n flex: 1;\n overflow: hidden;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .frequency .form-content .frequency-select {\n margin-right: 10px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .end-type .form-content .end-type-select {\n flex: 1;\n overflow: hidden;\n margin-right: 10px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .end-type .form-content .right-box {\n flex: 1;\n overflow: hidden;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day {\n margin-bottom: 0;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day .form-content {\n display: flex;\n flex-direction: column;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day .form-content .execution-day-select {\n display: flex;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day .form-content .execution-day-select > div {\n flex: 1;\n overflow: hidden;\n height: 28px;\n margin-right: 6px;\n border: 1px solid rgb(212, 218, 227);\n border-radius: 4px;\n line-height: 26px;\n text-align: center;\n cursor: pointer;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day .form-content .execution-day-select > div.select-item {\n background-color: rgb(46, 101, 230);\n color: rgb(255, 255, 255);\n border-color: rgb(46, 101, 230);\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day .form-content .execution-day-select > div:last-child {\n margin-right: 0;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day .form-content > .tip {\n min-height: 20px;\n display: flex;\n opacity: 0;\n transition: all 0.3s;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day .form-content > .tip.show-tip {\n opacity: 1;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day .form-content > .tip svg {\n color: rgb(255, 147, 38);\n font-size: 16px;\n vertical-align: middle;\n margin-right: 4px;\n margin-top: 2px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .execution-day .form-content > .tip span {\n font-size: 12px;\n color: rgb(255, 147, 38);\n flex: 1;\n overflow: hidden;\n line-height: 20px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .month-cycle-type-list .form-content > div {\n flex: 1;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .content .month-cycle-type-list .form-content > div:first-child {\n margin-right: 10px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .footer {\n text-align: right;\n margin-top: 30px;\n}\n.paraui-v4-cycle-selector-popover .cycle-selector-popover-content .footer button:last-child {\n margin-left: 16px;\n}";
|
|
220
|
+
styleInject(css_248z);
|
|
221
|
+
|
|
222
|
+
const CycleSelector = props => {
|
|
223
|
+
const {
|
|
224
|
+
className,
|
|
225
|
+
style,
|
|
226
|
+
value,
|
|
227
|
+
onChange
|
|
228
|
+
} = props;
|
|
229
|
+
const {
|
|
230
|
+
language,
|
|
231
|
+
locale
|
|
232
|
+
} = React__default.useContext(GlobalContext);
|
|
233
|
+
const intl = useFormatMessage('CycleSelector', localeJson);
|
|
234
|
+
const [valueCom, setValueCom] = useState({});
|
|
235
|
+
const [list, setList] = useState([]);
|
|
236
|
+
const [open, setOpen] = useState(false);
|
|
237
|
+
const [frequencyList, setFrequencyList] = useState([]);
|
|
238
|
+
const [frequencyTypeList, setFrequencyTypeList] = useState([]);
|
|
239
|
+
const [endType, setEndType] = useState([]);
|
|
240
|
+
const [monthCycleTypeList, setMonthCycleTypeList] = useState([]);
|
|
241
|
+
const [tipWeek, setTipWeek] = useState(false);
|
|
242
|
+
const constData = useRef({
|
|
243
|
+
valueCom,
|
|
244
|
+
value
|
|
245
|
+
});
|
|
246
|
+
constData.current.valueCom = valueCom;
|
|
247
|
+
constData.current.value = value;
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
const arr = [];
|
|
250
|
+
for (let i = 1; i < 30; i++) {
|
|
251
|
+
arr.push({
|
|
252
|
+
label: intl('every') + i,
|
|
253
|
+
value: i
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
setFrequencyList(arr);
|
|
257
|
+
setFrequencyTypeList([{
|
|
258
|
+
label: intl('day'),
|
|
259
|
+
value: 'day'
|
|
260
|
+
}, {
|
|
261
|
+
label: intl('week'),
|
|
262
|
+
value: 'week'
|
|
263
|
+
}, {
|
|
264
|
+
label: intl('month'),
|
|
265
|
+
value: 'month'
|
|
266
|
+
}, {
|
|
267
|
+
label: intl('year'),
|
|
268
|
+
value: 'year'
|
|
269
|
+
}]);
|
|
270
|
+
setEndType([{
|
|
271
|
+
label: intl('infiniteRepetition'),
|
|
272
|
+
value: 0
|
|
273
|
+
}, {
|
|
274
|
+
label: intl('deadline'),
|
|
275
|
+
value: 1
|
|
276
|
+
}, {
|
|
277
|
+
label: intl('limitNum'),
|
|
278
|
+
value: 2
|
|
279
|
+
}]);
|
|
280
|
+
constData.current.endTypeMap = {
|
|
281
|
+
0: intl('infiniteRepetition'),
|
|
282
|
+
1: intl('deadline'),
|
|
283
|
+
2: intl('limitNum')
|
|
284
|
+
};
|
|
285
|
+
return () => {
|
|
286
|
+
clearTimeout(constData.current.timerTip);
|
|
287
|
+
};
|
|
288
|
+
}, [language]);
|
|
289
|
+
useEffect(() => {
|
|
290
|
+
const valC = value ? Object.assign({}, value) : {};
|
|
291
|
+
if (!valC.startTime) valC.cycleType = 0;
|
|
292
|
+
setValueCom(valC);
|
|
293
|
+
constData.current.valueCom = valC;
|
|
294
|
+
handleSelectData();
|
|
295
|
+
}, [value, language]);
|
|
296
|
+
// 处理下拉框选择
|
|
297
|
+
const handleSelectData = () => {
|
|
298
|
+
var _a, _b, _c, _d;
|
|
299
|
+
if (!((_a = constData.current.valueCom) === null || _a === void 0 ? void 0 : _a.startTime)) {
|
|
300
|
+
setList([{
|
|
301
|
+
label: intl('noRepetition'),
|
|
302
|
+
value: 0
|
|
303
|
+
}]);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const time = new Date((_b = constData.current.valueCom) === null || _b === void 0 ? void 0 : _b.startTime);
|
|
307
|
+
const month = time.getMonth() + 1;
|
|
308
|
+
const day = time.getDate();
|
|
309
|
+
const weekDay = time.getDay();
|
|
310
|
+
const hm = (_c = constData.current.valueCom) === null || _c === void 0 ? void 0 : _c.startTime.split(' ')[1];
|
|
311
|
+
const date = (_d = constData.current.valueCom) === null || _d === void 0 ? void 0 : _d.startTime.split(' ')[0];
|
|
312
|
+
const week = Math.ceil((day + 6 - (weekDay === 0 ? 7 : weekDay)) / 7);
|
|
313
|
+
constData.current.timeDetail = {
|
|
314
|
+
month,
|
|
315
|
+
day,
|
|
316
|
+
weekDay,
|
|
317
|
+
hm,
|
|
318
|
+
week,
|
|
319
|
+
date
|
|
320
|
+
};
|
|
321
|
+
const selectList = [{
|
|
322
|
+
label: intl('noRepetition'),
|
|
323
|
+
value: 0
|
|
324
|
+
}, {
|
|
325
|
+
label: intl('repeatEveryDay') + ' ' + hm,
|
|
326
|
+
value: 1
|
|
327
|
+
}, {
|
|
328
|
+
label: intl('repeatEveryWeek') + ' ' + intl('week' + weekDay) + ' ' + hm,
|
|
329
|
+
value: 2
|
|
330
|
+
}, {
|
|
331
|
+
label: intl('repeatEveryMonth') + ' ' + day + intl('th'),
|
|
332
|
+
value: 3
|
|
333
|
+
}, {
|
|
334
|
+
label: intl('repeatEveryYear') + ' ' + month + intl('month') + day + intl('th'),
|
|
335
|
+
value: 4
|
|
336
|
+
}, {
|
|
337
|
+
label: intl('customRepetition'),
|
|
338
|
+
value: 5
|
|
339
|
+
}];
|
|
340
|
+
setList(selectList);
|
|
341
|
+
setMonthCycleTypeList([{
|
|
342
|
+
label: intl('day' + day),
|
|
343
|
+
value: 'day'
|
|
344
|
+
}, {
|
|
345
|
+
label: intl('the' + week) + intl('week' + weekDay),
|
|
346
|
+
value: 'week'
|
|
347
|
+
}]);
|
|
348
|
+
constData.current.monthCycleTypeListMap = {
|
|
349
|
+
'day': intl('day' + day),
|
|
350
|
+
'week': intl('the' + week) + intl('week' + weekDay)
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
// 改变开始时间
|
|
354
|
+
const changeStartTime = (date, dateString) => {
|
|
355
|
+
constData.current.valueCom.startTime = dateString;
|
|
356
|
+
clearPopoverValue();
|
|
357
|
+
changeCom();
|
|
358
|
+
};
|
|
359
|
+
// 判断是否存在值
|
|
360
|
+
const isNotExist = name => {
|
|
361
|
+
const val = constData.current.valueCom[name];
|
|
362
|
+
return val === undefined || val === '' || val === null;
|
|
363
|
+
};
|
|
364
|
+
// 处理弹窗里面的默认值
|
|
365
|
+
const handlePopoverDefaultValue = () => {
|
|
366
|
+
var _a, _b;
|
|
367
|
+
if (isNotExist('frequency')) constData.current.valueCom.frequency = 1;
|
|
368
|
+
if (isNotExist('frequencyUnit')) constData.current.valueCom.frequencyUnit = 'day';
|
|
369
|
+
if (isNotExist('endType')) constData.current.valueCom.endType = 0;
|
|
370
|
+
if (isNotExist('monthCycleType')) constData.current.valueCom.monthCycleType = 'day';
|
|
371
|
+
if (isNotExist('endTime')) constData.current.valueCom.endTime = (_a = constData.current.timeDetail) === null || _a === void 0 ? void 0 : _a.date;
|
|
372
|
+
if (isNotExist('limitNum')) constData.current.valueCom.limitNum = 0;
|
|
373
|
+
if (isNotExist('executionDay')) constData.current.valueCom.executionDay = ((_b = constData.current.timeDetail) === null || _b === void 0 ? void 0 : _b.weekDay) + '';
|
|
374
|
+
setValueCom(Object.assign({}, constData.current.valueCom));
|
|
375
|
+
};
|
|
376
|
+
// 清空弹窗里面的默认值
|
|
377
|
+
const clearPopoverValue = () => {
|
|
378
|
+
constData.current.valueCom = {
|
|
379
|
+
startTime: constData.current.valueCom.startTime,
|
|
380
|
+
cycleType: 0
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
// 选择下拉框
|
|
384
|
+
const changeSelect = val => {
|
|
385
|
+
constData.current.valueCom.cycleType = val;
|
|
386
|
+
setValueCom(Object.assign({}, constData.current.valueCom));
|
|
387
|
+
if (val === 5) {
|
|
388
|
+
setOpen(true);
|
|
389
|
+
handlePopoverDefaultValue();
|
|
390
|
+
} else {
|
|
391
|
+
changeCom();
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
// 向外抛值
|
|
395
|
+
const changeCom = cancel => {
|
|
396
|
+
if (constData.current.valueCom.cycleType === 5) {
|
|
397
|
+
if (constData.current.valueCom.frequencyUnit === 'week') {
|
|
398
|
+
delete constData.current.valueCom.monthCycleType;
|
|
399
|
+
} else if (constData.current.valueCom.frequencyUnit === 'month') {
|
|
400
|
+
delete constData.current.valueCom.executionDay;
|
|
401
|
+
} else {
|
|
402
|
+
delete constData.current.valueCom.monthCycleType;
|
|
403
|
+
delete constData.current.valueCom.executionDay;
|
|
404
|
+
}
|
|
405
|
+
if (constData.current.valueCom.endType === 0) {
|
|
406
|
+
delete constData.current.valueCom.endTime;
|
|
407
|
+
delete constData.current.valueCom.limitNum;
|
|
408
|
+
} else if (constData.current.valueCom.endType === 1) {
|
|
409
|
+
delete constData.current.valueCom.limitNum;
|
|
410
|
+
} else {
|
|
411
|
+
delete constData.current.valueCom.endTime;
|
|
412
|
+
}
|
|
413
|
+
} else {
|
|
414
|
+
delete constData.current.valueCom.frequency;
|
|
415
|
+
delete constData.current.valueCom.frequencyUnit;
|
|
416
|
+
delete constData.current.valueCom.endType;
|
|
417
|
+
delete constData.current.valueCom.monthCycleType;
|
|
418
|
+
delete constData.current.valueCom.endTime;
|
|
419
|
+
delete constData.current.valueCom.limitNum;
|
|
420
|
+
delete constData.current.valueCom.executionDay;
|
|
421
|
+
}
|
|
422
|
+
onChange(cancel ? Object.assign({}, constData.current.value) : Object.assign({}, constData.current.valueCom));
|
|
423
|
+
};
|
|
424
|
+
const onVisibleChange = bol => {
|
|
425
|
+
if (!bol) setOpen(false);
|
|
426
|
+
};
|
|
427
|
+
const clickBtn = () => {
|
|
428
|
+
setOpen(true);
|
|
429
|
+
handlePopoverDefaultValue();
|
|
430
|
+
};
|
|
431
|
+
// 自定义周期文案提示
|
|
432
|
+
const handleText = () => {
|
|
433
|
+
var _a, _b;
|
|
434
|
+
if ((value === null || value === void 0 ? void 0 : value.cycleType) !== 5) return;
|
|
435
|
+
const text = [];
|
|
436
|
+
const everyText1 = intl('every') + value.frequency + intl(value.frequencyUnit);
|
|
437
|
+
const timeText = (_a = constData.current.timeDetail) === null || _a === void 0 ? void 0 : _a.hm;
|
|
438
|
+
if (value.frequencyUnit === 'week') {
|
|
439
|
+
const arr = [];
|
|
440
|
+
(_b = value.executionDay) === null || _b === void 0 ? void 0 : _b.split(',').forEach(item => {
|
|
441
|
+
arr.push(intl('week' + (item === '7' ? 0 : item)));
|
|
442
|
+
});
|
|
443
|
+
text.push(intl('text1', {
|
|
444
|
+
every: everyText1 + arr.join('、'),
|
|
445
|
+
time: timeText
|
|
446
|
+
}));
|
|
447
|
+
} else if (value.frequencyUnit === 'month') {
|
|
448
|
+
text.push(intl('text1', {
|
|
449
|
+
every: everyText1,
|
|
450
|
+
time: constData.current.monthCycleTypeListMap[value.monthCycleType] + timeText
|
|
451
|
+
}));
|
|
452
|
+
} else {
|
|
453
|
+
text.push(intl('text1', {
|
|
454
|
+
every: everyText1,
|
|
455
|
+
time: timeText
|
|
456
|
+
}));
|
|
457
|
+
}
|
|
458
|
+
if (value.endType === 2) {
|
|
459
|
+
text.push(intl('text2', {
|
|
460
|
+
limitNum: value.limitNum
|
|
461
|
+
}));
|
|
462
|
+
}
|
|
463
|
+
if (value.endType === 1) {
|
|
464
|
+
text.push(intl('text3', {
|
|
465
|
+
date: value.endTime
|
|
466
|
+
}));
|
|
467
|
+
}
|
|
468
|
+
return jsxs("p", Object.assign({
|
|
469
|
+
className: 'text-tip'
|
|
470
|
+
}, {
|
|
471
|
+
children: [text, jsx(Button, Object.assign({
|
|
472
|
+
variant: "text",
|
|
473
|
+
onClick: clickBtn
|
|
474
|
+
}, {
|
|
475
|
+
children: intl('update')
|
|
476
|
+
}))]
|
|
477
|
+
}));
|
|
478
|
+
};
|
|
479
|
+
// 改变结束时间
|
|
480
|
+
const changeEndTypeTime = (date, dateString) => {
|
|
481
|
+
valueCom.endTime = dateString;
|
|
482
|
+
setValueCom(Object.assign({}, valueCom));
|
|
483
|
+
};
|
|
484
|
+
// 改变结束次数
|
|
485
|
+
const changeLimitNum = event => {
|
|
486
|
+
valueCom.limitNum = Number(event.target.value);
|
|
487
|
+
setValueCom(Object.assign({}, valueCom));
|
|
488
|
+
};
|
|
489
|
+
const changeSelectVal = name => val => {
|
|
490
|
+
valueCom[name] = val;
|
|
491
|
+
setValueCom(Object.assign({}, valueCom));
|
|
492
|
+
};
|
|
493
|
+
// 点击周 按钮
|
|
494
|
+
const clickWeekBtn = index => () => {
|
|
495
|
+
var _a, _b;
|
|
496
|
+
if (((_a = constData.current.timeDetail) === null || _a === void 0 ? void 0 : _a.weekDay) === index) {
|
|
497
|
+
setTipWeek(true);
|
|
498
|
+
clearTimeout(constData.current.timerTip);
|
|
499
|
+
constData.current.timerTip = setTimeout(() => {
|
|
500
|
+
setTipWeek(false);
|
|
501
|
+
}, 1300);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
const arr = ((_b = valueCom.executionDay) === null || _b === void 0 ? void 0 : _b.split(',')) || [];
|
|
505
|
+
const json = {};
|
|
506
|
+
arr.forEach(item => {
|
|
507
|
+
json[item] = true;
|
|
508
|
+
});
|
|
509
|
+
if (json[index.toString()]) {
|
|
510
|
+
delete json[index.toString()];
|
|
511
|
+
} else {
|
|
512
|
+
json[index.toString()] = true;
|
|
513
|
+
}
|
|
514
|
+
valueCom.executionDay = Object.keys(json).join(',');
|
|
515
|
+
setValueCom(Object.assign({}, valueCom));
|
|
516
|
+
};
|
|
517
|
+
// 处理 天 周 月 年 展示不一样的周期
|
|
518
|
+
const handleTypeContent = () => {
|
|
519
|
+
var _a;
|
|
520
|
+
return jsxs(Fragment, {
|
|
521
|
+
children: [jsxs("div", Object.assign({
|
|
522
|
+
className: 'item frequency'
|
|
523
|
+
}, {
|
|
524
|
+
children: [jsx("div", Object.assign({
|
|
525
|
+
className: 'label'
|
|
526
|
+
}, {
|
|
527
|
+
children: intl('repetitionFrequency')
|
|
528
|
+
})), jsxs("div", Object.assign({
|
|
529
|
+
className: 'form-content'
|
|
530
|
+
}, {
|
|
531
|
+
children: [jsx(Select, {
|
|
532
|
+
value: valueCom.frequency,
|
|
533
|
+
list: frequencyList,
|
|
534
|
+
className: 'frequency-select',
|
|
535
|
+
onChange: changeSelectVal('frequency')
|
|
536
|
+
}), jsx(Select, {
|
|
537
|
+
value: valueCom.frequencyUnit,
|
|
538
|
+
list: frequencyTypeList,
|
|
539
|
+
onChange: changeSelectVal('frequencyUnit')
|
|
540
|
+
})]
|
|
541
|
+
}))]
|
|
542
|
+
})), valueCom.frequencyUnit === 'week' && jsxs("div", Object.assign({
|
|
543
|
+
className: 'item execution-day'
|
|
544
|
+
}, {
|
|
545
|
+
children: [jsx("div", {
|
|
546
|
+
className: 'label'
|
|
547
|
+
}), jsxs("div", Object.assign({
|
|
548
|
+
className: 'form-content'
|
|
549
|
+
}, {
|
|
550
|
+
children: [jsx("div", Object.assign({
|
|
551
|
+
className: 'execution-day-select'
|
|
552
|
+
}, {
|
|
553
|
+
children: new Array(7).fill(1).map((item, index) => {
|
|
554
|
+
var _a, _b;
|
|
555
|
+
const numMap = {
|
|
556
|
+
1: 'one',
|
|
557
|
+
2: 'two',
|
|
558
|
+
3: 'three',
|
|
559
|
+
4: 'four',
|
|
560
|
+
5: 'five',
|
|
561
|
+
6: 'six',
|
|
562
|
+
7: 'seven'
|
|
563
|
+
};
|
|
564
|
+
const oreder = index + 1;
|
|
565
|
+
const indexOfVal = (_a = valueCom.executionDay) === null || _a === void 0 ? void 0 : _a.indexOf(oreder.toString());
|
|
566
|
+
let selectBol = indexOfVal !== undefined && indexOfVal !== -1;
|
|
567
|
+
if (((_b = constData.current.timeDetail) === null || _b === void 0 ? void 0 : _b.weekDay) === oreder) {
|
|
568
|
+
selectBol = true;
|
|
569
|
+
}
|
|
570
|
+
return jsx("div", Object.assign({
|
|
571
|
+
className: selectBol ? 'select-item' : '',
|
|
572
|
+
onClick: clickWeekBtn(oreder)
|
|
573
|
+
}, {
|
|
574
|
+
children: intl(numMap[oreder])
|
|
575
|
+
}), index);
|
|
576
|
+
})
|
|
577
|
+
})), jsxs("p", Object.assign({
|
|
578
|
+
className: tipWeek ? 'tip show-tip' : 'tip'
|
|
579
|
+
}, {
|
|
580
|
+
children: [jsx(WarningCircleF, {}), jsx("span", {
|
|
581
|
+
children: intl('weekTip', {
|
|
582
|
+
week: intl('week' + ((_a = constData.current.timeDetail) === null || _a === void 0 ? void 0 : _a.weekDay))
|
|
583
|
+
})
|
|
584
|
+
})]
|
|
585
|
+
}))]
|
|
586
|
+
}))]
|
|
587
|
+
})), valueCom.frequencyUnit === 'month' && jsxs("div", Object.assign({
|
|
588
|
+
className: 'item month-cycle-type-list'
|
|
589
|
+
}, {
|
|
590
|
+
children: [jsx("div", {
|
|
591
|
+
className: 'label'
|
|
592
|
+
}), jsxs("div", Object.assign({
|
|
593
|
+
className: 'form-content'
|
|
594
|
+
}, {
|
|
595
|
+
children: [jsx("div", {}), jsx(Select, {
|
|
596
|
+
value: valueCom.monthCycleType,
|
|
597
|
+
list: monthCycleTypeList,
|
|
598
|
+
onChange: changeSelectVal('monthCycleType')
|
|
599
|
+
})]
|
|
600
|
+
}))]
|
|
601
|
+
})), jsxs("div", Object.assign({
|
|
602
|
+
className: 'item end-type'
|
|
603
|
+
}, {
|
|
604
|
+
children: [jsx("div", Object.assign({
|
|
605
|
+
className: 'label'
|
|
606
|
+
}, {
|
|
607
|
+
children: intl('endRepetition')
|
|
608
|
+
})), jsxs("div", Object.assign({
|
|
609
|
+
className: 'form-content'
|
|
610
|
+
}, {
|
|
611
|
+
children: [jsx(Select, {
|
|
612
|
+
value: valueCom.endType,
|
|
613
|
+
list: endType,
|
|
614
|
+
className: 'end-type-select',
|
|
615
|
+
onChange: changeSelectVal('endType')
|
|
616
|
+
}), jsxs("div", Object.assign({
|
|
617
|
+
className: 'right-box'
|
|
618
|
+
}, {
|
|
619
|
+
children: [valueCom.endType === 1 && jsx(DatePicker, {
|
|
620
|
+
disabledDate: current => {
|
|
621
|
+
return current && current < dayjs(valueCom.startTime);
|
|
622
|
+
},
|
|
623
|
+
value: valueCom.endTime,
|
|
624
|
+
format: 'YYYY-MM-DD',
|
|
625
|
+
onChange: changeEndTypeTime
|
|
626
|
+
}), valueCom.endType === 2 && jsx(TextField, {
|
|
627
|
+
min: 0,
|
|
628
|
+
type: "number",
|
|
629
|
+
placeholder: intl('placeholder'),
|
|
630
|
+
value: valueCom.limitNum,
|
|
631
|
+
onChange: changeLimitNum,
|
|
632
|
+
rightIcon: '次后'
|
|
633
|
+
})]
|
|
634
|
+
}))]
|
|
635
|
+
}))]
|
|
636
|
+
}))]
|
|
637
|
+
});
|
|
638
|
+
};
|
|
639
|
+
const cancelPopover = () => {
|
|
640
|
+
setOpen(false);
|
|
641
|
+
changeCom(true);
|
|
642
|
+
};
|
|
643
|
+
const confirmPopover = () => {
|
|
644
|
+
setOpen(false);
|
|
645
|
+
changeCom();
|
|
646
|
+
};
|
|
647
|
+
// 浮层内容
|
|
648
|
+
const handleContent = () => {
|
|
649
|
+
return jsxs("div", Object.assign({
|
|
650
|
+
className: 'cycle-selector-popover-content'
|
|
651
|
+
}, {
|
|
652
|
+
children: [jsxs("div", Object.assign({
|
|
653
|
+
className: 'title'
|
|
654
|
+
}, {
|
|
655
|
+
children: [jsx("span", Object.assign({
|
|
656
|
+
className: 'label'
|
|
657
|
+
}, {
|
|
658
|
+
children: intl('customCycle')
|
|
659
|
+
})), jsx(CloseIcon, {
|
|
660
|
+
onClick: cancelPopover
|
|
661
|
+
})]
|
|
662
|
+
})), jsx("div", Object.assign({
|
|
663
|
+
className: 'content'
|
|
664
|
+
}, {
|
|
665
|
+
children: handleTypeContent()
|
|
666
|
+
})), jsxs("div", Object.assign({
|
|
667
|
+
className: 'footer'
|
|
668
|
+
}, {
|
|
669
|
+
children: [jsx(Button, Object.assign({
|
|
670
|
+
variant: "outlined",
|
|
671
|
+
onClick: cancelPopover
|
|
672
|
+
}, {
|
|
673
|
+
children: intl('cancel')
|
|
674
|
+
})), jsx(Button, Object.assign({
|
|
675
|
+
onClick: confirmPopover
|
|
676
|
+
}, {
|
|
677
|
+
children: intl('confirm')
|
|
678
|
+
}))]
|
|
679
|
+
}))]
|
|
680
|
+
}));
|
|
681
|
+
};
|
|
682
|
+
return jsxs("div", Object.assign({
|
|
683
|
+
className: clsx("".concat($prefixCls, "-cycle-selector"), className),
|
|
684
|
+
style: style
|
|
685
|
+
}, {
|
|
686
|
+
children: [jsx(Popover, Object.assign({
|
|
687
|
+
content: handleContent(),
|
|
688
|
+
open: open,
|
|
689
|
+
placement: "bottomRight",
|
|
690
|
+
overlayClassName: "".concat($prefixCls, "-cycle-selector-popover"),
|
|
691
|
+
onVisibleChange: onVisibleChange
|
|
692
|
+
}, {
|
|
693
|
+
children: jsxs("div", Object.assign({
|
|
694
|
+
className: 'cycle-selector-content'
|
|
695
|
+
}, {
|
|
696
|
+
children: [jsx(DatePicker, {
|
|
697
|
+
value: valueCom.startTime,
|
|
698
|
+
className: 'time-select',
|
|
699
|
+
showTime: true,
|
|
700
|
+
format: 'YYYY-MM-DD HH:mm',
|
|
701
|
+
placeholder: intl('pleaseSelect'),
|
|
702
|
+
onChange: changeStartTime
|
|
703
|
+
}), jsx(Select, {
|
|
704
|
+
disabled: !valueCom.startTime,
|
|
705
|
+
list: list,
|
|
706
|
+
className: 'select-type',
|
|
707
|
+
placeholder: intl('pleaseSelect'),
|
|
708
|
+
value: valueCom.cycleType,
|
|
709
|
+
onChange: changeSelect
|
|
710
|
+
})]
|
|
711
|
+
}))
|
|
712
|
+
})), handleText()]
|
|
713
|
+
}));
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
export { CycleSelector as default };
|