AntCron.vue 47.7 KB
Newer Older
陈浩玮's avatar
陈浩玮 committed
1
<template>
水落(YangLei)'s avatar
水落(YangLei) committed
2
    <a-modal
shuiluo's avatar
shuiluo committed
3
        :title="$t('corn.expression')"
水落(YangLei)'s avatar
水落(YangLei) committed
4 5 6 7 8
        :width="modalWidth"
        :visible="visible"
        :confirmLoading="confirmLoading"
        @ok="handleSubmit"
        @cancel="close"
shuiluo's avatar
shuiluo committed
9
        :cancelText="$t('corn.close')"
水落(YangLei)'s avatar
水落(YangLei) committed
10 11 12 13 14
        :getContainer="getContainer"
    >
        <div class="card-container">
            <a-tabs type="card">
                <a-tab-pane key="1" type="card">
shuiluo's avatar
shuiluo committed
15
                    <span slot="tab"> <a-icon type="schedule" />{{ $t('corn.second') }}</span>
水落(YangLei)'s avatar
水落(YangLei) committed
16 17
                    <a-radio-group v-model="result.second.cronEvery">
                        <a-row>
shuiluo's avatar
shuiluo committed
18
                            <a-radio value="1">{{ $t('corn.everySecond') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
19 20 21
                        </a-row>
                        <a-row>
                            <a-radio value="2">
shuiluo's avatar
shuiluo committed
22
                                {{ $t('corn.everyOther') }}
水落(YangLei)'s avatar
水落(YangLei) committed
23 24 25 26 27
                                <a-input-number
                                    size="small"
                                    v-model="result.second.incrementIncrement"
                                    :min="1"
                                    :max="60"
shuiluo's avatar
shuiluo committed
28
                                />秒执行 从
水落(YangLei)'s avatar
水落(YangLei) committed
29 30 31 32 33
                                <a-input-number
                                    size="small"
                                    v-model="result.second.incrementStart"
                                    :min="0"
                                    :max="59"
shuiluo's avatar
shuiluo committed
34
                                />秒开始
水落(YangLei)'s avatar
水落(YangLei) committed
35 36 37
                            </a-radio>
                        </a-row>
                        <a-row>
shuiluo's avatar
shuiluo committed
38
                            <a-radio value="3">{{ $t('corn.specificSeconds') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
39
                            <a-select
shuiluo's avatar
shuiluo committed
40
                                style="width: 354px"
水落(YangLei)'s avatar
水落(YangLei) committed
41 42 43 44
                                size="small"
                                mode="multiple"
                                v-model="result.second.specificSpecific"
                            >
shuiluo's avatar
shuiluo committed
45 46 47
                                <a-select-option v-for="(val, index) in 60" :key="index" :value="index">
                                    {{ index }}
                                </a-select-option>
水落(YangLei)'s avatar
水落(YangLei) committed
48 49 50 51 52 53 54 55 56 57
                            </a-select>
                        </a-row>
                        <a-row>
                            <a-radio value="4">
                                周期从
                                <a-input-number
                                    size="small"
                                    v-model="result.second.rangeStart"
                                    :min="1"
                                    :max="60"
shuiluo's avatar
shuiluo committed
58
                                />
水落(YangLei)'s avatar
水落(YangLei) committed
59 60 61 62 63
                                <a-input-number
                                    size="small"
                                    v-model="result.second.rangeEnd"
                                    :min="0"
                                    :max="59"
shuiluo's avatar
shuiluo committed
64
                                />
水落(YangLei)'s avatar
水落(YangLei) committed
65 66 67 68 69
                            </a-radio>
                        </a-row>
                    </a-radio-group>
                </a-tab-pane>
                <a-tab-pane key="2">
shuiluo's avatar
shuiluo committed
70
                    <span slot="tab"> <a-icon type="schedule" />{{ $t('corn.minute') }}</span>
水落(YangLei)'s avatar
水落(YangLei) committed
71 72 73
                    <div class="tabBody">
                        <a-radio-group v-model="result.minute.cronEvery">
                            <a-row>
shuiluo's avatar
shuiluo committed
74
                                <a-radio value="1">{{ $t('corn.everyMinute') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
75 76 77 78 79 80 81 82 83
                            </a-row>
                            <a-row>
                                <a-radio value="2">
                                    每隔
                                    <a-input-number
                                        size="small"
                                        v-model="result.minute.incrementIncrement"
                                        :min="1"
                                        :max="60"
shuiluo's avatar
shuiluo committed
84
                                    />分执行 从
水落(YangLei)'s avatar
水落(YangLei) committed
85 86 87 88 89
                                    <a-input-number
                                        size="small"
                                        v-model="result.minute.incrementStart"
                                        :min="0"
                                        :max="59"
shuiluo's avatar
shuiluo committed
90
                                    />分开始
水落(YangLei)'s avatar
水落(YangLei) committed
91 92 93
                                </a-radio>
                            </a-row>
                            <a-row>
shuiluo's avatar
shuiluo committed
94
                                <a-radio value="3">{{ $t('corn.specificMinutes') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
95
                                <a-select
shuiluo's avatar
shuiluo committed
96
                                    style="width: 340px"
水落(YangLei)'s avatar
水落(YangLei) committed
97 98 99 100 101 102 103 104 105
                                    size="small"
                                    mode="multiple"
                                    v-model="result.minute.specificSpecific"
                                >
                                    <a-select-option
                                        v-for="(val, index) in Array(60)"
                                        :key="index"
                                        :value="index"
                                    >
shuiluo's avatar
shuiluo committed
106 107
                                        {{ index }}
                                    </a-select-option>
水落(YangLei)'s avatar
水落(YangLei) committed
108 109 110 111 112 113 114 115 116 117
                                </a-select>
                            </a-row>
                            <a-row>
                                <a-radio value="4">
                                    周期从
                                    <a-input-number
                                        size="small"
                                        v-model="result.minute.rangeStart"
                                        :min="1"
                                        :max="60"
shuiluo's avatar
shuiluo committed
118
                                    /><a-input-number
水落(YangLei)'s avatar
水落(YangLei) committed
119 120 121 122
                                        size="small"
                                        v-model="result.minute.rangeEnd"
                                        :min="0"
                                        :max="59"
shuiluo's avatar
shuiluo committed
123
                                    />
水落(YangLei)'s avatar
水落(YangLei) committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
                                </a-radio>
                            </a-row>
                        </a-radio-group>
                    </div>
                </a-tab-pane>
                <a-tab-pane key="3">
                    <span slot="tab"> <a-icon type="schedule" /></span>
                    <div class="tabBody">
                        <a-radio-group v-model="result.hour.cronEvery">
                            <a-row>
                                <a-radio value="1">每一小时</a-radio>
                            </a-row>
                            <a-row>
                                <a-radio value="2">
                                    每隔
                                    <a-input-number
                                        size="small"
                                        v-model="result.hour.incrementIncrement"
                                        :min="0"
                                        :max="23"
                                    ></a-input-number
                                    >小时执行 从
                                    <a-input-number
                                        size="small"
                                        v-model="result.hour.incrementStart"
                                        :min="0"
                                        :max="23"
                                    ></a-input-number
                                    >小时开始
                                </a-radio>
                            </a-row>
                            <a-row>
shuiluo's avatar
shuiluo committed
156
                                <a-radio class="long" value="3">{{ $t('corn.specificHours') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
157
                                <a-select
shuiluo's avatar
shuiluo committed
158
                                    style="width: 340px"
水落(YangLei)'s avatar
水落(YangLei) committed
159 160 161 162
                                    size="small"
                                    mode="multiple"
                                    v-model="result.hour.specificSpecific"
                                >
shuiluo's avatar
shuiluo committed
163 164 165
                                    <a-select-option v-for="(val, index) in Array(24)" :key="index">
                                        {{ index }}
                                    </a-select-option>
水落(YangLei)'s avatar
水落(YangLei) committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
                                </a-select>
                            </a-row>
                            <a-row>
                                <a-radio value="4">
                                    周期从
                                    <a-input-number
                                        size="small"
                                        v-model="result.hour.rangeStart"
                                        :min="0"
                                        :max="23"
                                    ></a-input-number
                                    >
                                    <a-input-number
                                        size="small"
                                        v-model="result.hour.rangeEnd"
                                        :min="0"
                                        :max="23"
                                    ></a-input-number
                                    >小时
                                </a-radio>
                            </a-row>
                        </a-radio-group>
                    </div>
                </a-tab-pane>
                <a-tab-pane key="4">
shuiluo's avatar
shuiluo committed
191
                    <span slot="tab"> <a-icon type="schedule" />{{ $t('corn.day') }}</span>
水落(YangLei)'s avatar
水落(YangLei) committed
192 193 194
                    <div class="tabBody">
                        <a-radio-group v-model="result.day.cronEvery">
                            <a-row>
shuiluo's avatar
shuiluo committed
195
                                <a-radio value="1">{{ $t('corn.everyDay') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
                            </a-row>
                            <a-row>
                                <a-radio value="2">
                                    每隔
                                    <a-input-number
                                        size="small"
                                        v-model="result.week.incrementIncrement"
                                        :min="1"
                                        :max="7"
                                    ></a-input-number
                                    >周执行 从
                                    <a-select size="small" v-model="result.week.incrementStart">
                                        <a-select-option
                                            v-for="(val, index) in Array(7)"
                                            :key="index"
                                            :value="index - 1"
                                            >{{ weekDays[index - 1] }}</a-select-option
                                        > </a-select
                                    >开始
                                </a-radio>
                            </a-row>
                            <a-row>
                                <a-radio value="3">
                                    每隔
                                    <a-input-number
                                        size="small"
                                        v-model="result.day.incrementIncrement"
                                        :min="1"
                                        :max="31"
                                    ></a-input-number
                                    >天执行 从
                                    <a-input-number
                                        size="small"
                                        v-model="result.day.incrementStart"
                                        :min="1"
                                        :max="31"
                                    ></a-input-number
                                    >日开始
                                </a-radio>
                            </a-row>
                            <a-row>
shuiluo's avatar
shuiluo committed
237
                                <a-radio class="long" value="4">{{ $t('corn.specificDayOfWeek') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
238
                                <a-select
shuiluo's avatar
shuiluo committed
239
                                    style="width: 340px"
水落(YangLei)'s avatar
水落(YangLei) committed
240 241 242 243 244 245 246 247 248 249 250 251 252
                                    size="small"
                                    mode="multiple"
                                    v-model="result.week.specificSpecific"
                                >
                                    <a-select-option
                                        v-for="(val, index) in Array(7)"
                                        :key="index"
                                        :value="index - 1"
                                        >{{ weekDays[index - 1] }}</a-select-option
                                    >
                                </a-select>
                            </a-row>
                            <a-row>
shuiluo's avatar
shuiluo committed
253
                                <a-radio class="long" value="5">{{ $t('corn.specificDays') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
254
                                <a-select
shuiluo's avatar
shuiluo committed
255
                                    style="width: 354px"
水落(YangLei)'s avatar
水落(YangLei) committed
256 257 258 259 260 261 262 263 264
                                    size="small"
                                    mode="multiple"
                                    v-model="result.day.specificSpecific"
                                >
                                    <a-select-option
                                        v-for="(val, index) in Array(31)"
                                        :key="index"
                                        :value="index + 1"
                                    >
shuiluo's avatar
shuiluo committed
265 266
                                        {{ index + 1 }}
                                    </a-select-option>
水落(YangLei)'s avatar
水落(YangLei) committed
267 268 269
                                </a-select>
                            </a-row>
                            <a-row>
shuiluo's avatar
shuiluo committed
270
                                <a-radio value="6">{{ $t('corn.lastmonth') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
271 272
                            </a-row>
                            <a-row>
shuiluo's avatar
shuiluo committed
273
                                <a-radio value="7">{{ $t('corn.lastWorkingDay') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
                            </a-row>
                            <a-row>
                                <a-radio value="8">
                                    在这个月的最后一个
                                    <a-select size="small" v-model="result.day.cronLastSpecificDomDay">
                                        <a-select-option
                                            v-for="(val, index) in Array(7)"
                                            :key="index"
                                            :value="index + 1"
                                            >{{ weekDays[index] }}</a-select-option
                                        >
                                    </a-select>
                                </a-radio>
                            </a-row>
                            <a-row>
                                <a-radio value="9">
                                    在本月底前
                                    <a-input-number
                                        size="small"
                                        v-model="result.day.cronDaysBeforeEomMinus"
                                        :min="1"
                                        :max="31"
                                    ></a-input-number
                                    >
                                </a-radio>
                            </a-row>
                            <a-row>
                                <a-radio value="10">
                                    最近的工作日(周一至周五)至本月
                                    <a-input-number
                                        size="small"
                                        v-model="result.day.cronDaysNearestWeekday"
                                        :min="1"
                                        :max="31"
                                    ></a-input-number
                                    >
                                </a-radio>
                            </a-row>
                            <a-row>
                                <a-radio value="11">
                                    在这个月的第
                                    <a-input-number
                                        size="small"
                                        v-model="result.week.cronNthDayNth"
                                        :min="1"
                                        :max="5"
                                    ></a-input-number
                                    >
                                    <a-select size="small" v-model="result.week.cronNthDayDay">
                                        <a-select-option
                                            v-for="(val, index) in Array(7)"
                                            :key="index"
                                            :value="index"
                                        >
shuiluo's avatar
shuiluo committed
328 329
                                            {{ weekDays[index] }}
                                        </a-select-option>
水落(YangLei)'s avatar
水落(YangLei) committed
330 331 332 333 334 335 336
                                    </a-select>
                                </a-radio>
                            </a-row>
                        </a-radio-group>
                    </div>
                </a-tab-pane>
                <a-tab-pane key="5">
shuiluo's avatar
shuiluo committed
337
                    <span slot="tab"> <a-icon type="schedule" />{{ $t('corn.month') }} </span>
水落(YangLei)'s avatar
水落(YangLei) committed
338 339 340
                    <div class="tabBody">
                        <a-radio-group v-model="result.month.cronEvery">
                            <a-row>
shuiluo's avatar
shuiluo committed
341
                                <a-radio value="1">{{ $t('corn.everyMonth') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
                            </a-row>
                            <a-row>
                                <a-radio value="2">
                                    每隔
                                    <a-input-number
                                        size="small"
                                        v-model="result.month.incrementIncrement"
                                        :min="0"
                                        :max="12"
                                    ></a-input-number
                                    >月执行 从
                                    <a-input-number
                                        size="small"
                                        v-model="result.month.incrementStart"
                                        :min="0"
                                        :max="12"
                                    ></a-input-number
                                    >月开始
                                </a-radio>
                            </a-row>
                            <a-row>
shuiluo's avatar
shuiluo committed
363
                                <a-radio class="long" value="3">{{ $t('corn.specificMonths') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
364
                                <a-select
shuiluo's avatar
shuiluo committed
365
                                    style="width: 354px"
水落(YangLei)'s avatar
水落(YangLei) committed
366 367 368 369 370 371 372 373 374 375
                                    size="small"
                                    filterable
                                    mode="multiple"
                                    v-model="result.month.specificSpecific"
                                >
                                    <a-select-option
                                        v-for="(val, index) in Array(12)"
                                        :key="index"
                                        :value="index + 1"
                                    >
shuiluo's avatar
shuiluo committed
376 377
                                        {{ index + 1 }}
                                    </a-select-option>
水落(YangLei)'s avatar
水落(YangLei) committed
378 379 380 381 382 383 384 385 386 387
                                </a-select>
                            </a-row>
                            <a-row>
                                <a-radio value="4">

                                    <a-input-number
                                        size="small"
                                        v-model="result.month.rangeStart"
                                        :min="1"
                                        :max="12"
shuiluo's avatar
shuiluo committed
388
                                    />
水落(YangLei)'s avatar
水落(YangLei) committed
389 390 391 392 393
                                    <a-input-number
                                        size="small"
                                        v-model="result.month.rangeEnd"
                                        :min="1"
                                        :max="12"
shuiluo's avatar
shuiluo committed
394
                                    />月之间的每个月
水落(YangLei)'s avatar
水落(YangLei) committed
395 396 397 398 399 400
                                </a-radio>
                            </a-row>
                        </a-radio-group>
                    </div>
                </a-tab-pane>
                <a-tab-pane key="6">
shuiluo's avatar
shuiluo committed
401
                    <span slot="tab"> <a-icon type="schedule" />{{ $t('corn.year') }}</span>
水落(YangLei)'s avatar
水落(YangLei) committed
402 403 404
                    <div class="tabBody">
                        <a-radio-group v-model="result.year.cronEvery">
                            <a-row>
shuiluo's avatar
shuiluo committed
405
                                <a-radio value="1">{{ $t('corn.everyYear') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
                            </a-row>
                            <a-row>
                                <a-radio value="2">
                                    每隔
                                    <a-input-number
                                        size="small"
                                        v-model="result.year.incrementIncrement"
                                        :min="1"
                                        :max="99"
                                    ></a-input-number
                                    >年执行 从
                                    <a-input-number
                                        size="small"
                                        v-model="result.year.incrementStart"
                                        :min="curYear"
                                        :max="curYear + 100"
                                    ></a-input-number
                                    >年开始
                                </a-radio>
                            </a-row>
                            <a-row>
shuiluo's avatar
shuiluo committed
427
                                <a-radio class="long" value="3">{{ $('corn.specificYear') }}</a-radio>
水落(YangLei)'s avatar
水落(YangLei) committed
428
                                <a-select
shuiluo's avatar
shuiluo committed
429
                                    style="width: 354px"
水落(YangLei)'s avatar
水落(YangLei) committed
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
                                    size="small"
                                    filterable
                                    mode="multiple"
                                    v-model="result.year.specificSpecific"
                                >
                                    <a-select-option
                                        v-for="(val, index) in Array(100)"
                                        :key="index"
                                        :value="curYear + index - 1"
                                        >{{ curYear + index - 1 }}</a-select-option
                                    >
                                </a-select>
                            </a-row>
                            <a-row>
                                <a-radio value="4">

                                    <a-input-number
                                        size="small"
                                        v-model="result.year.rangeStart"
                                        :min="curYear"
                                        :max="curYear + 100"
                                    ></a-input-number
                                    >
                                    <a-input-number
                                        size="small"
                                        v-model="result.year.rangeEnd"
                                        :min="curYear"
                                        :max="curYear + 100"
                                    ></a-input-number
                                    >年之间的每一年
                                </a-radio>
                            </a-row>
                        </a-radio-group>
                    </div>
                </a-tab-pane>
            </a-tabs>
            <div class="bottom">
                <span class="value">{{ this.cron }}</span>
            </div>
        </div>
    </a-modal>
陈浩玮's avatar
陈浩玮 committed
471
</template>
shuiluo's avatar
shuiluo committed
472

陈浩玮's avatar
陈浩玮 committed
473 474 475 476
<script>
const now = new Date();
const curYear = now.getFullYear();
export default {
水落(YangLei)'s avatar
水落(YangLei) committed
477 478 479 480 481 482 483 484
    name: 'AntCron',
    props: ['data'],
    data() {
        return {
            curYear,
            visible: false,
            confirmLoading: false,
            size: 'large',
shuiluo's avatar
shuiluo committed
485
            weekDays: ['', '', '', '', '', '', ''].map((val) => '星期' + val),
水落(YangLei)'s avatar
水落(YangLei) committed
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
            result: {
                second: {},
                minute: {},
                hour: {},
                day: {},
                week: {},
                month: {},
                year: {},
            },
            defaultValue: {
                second: {
                    cronEvery: '',
                    incrementStart: 3,
                    incrementIncrement: 5,
                    rangeStart: 1,
                    rangeEnd: 0,
                    specificSpecific: [],
                },
                minute: {
                    cronEvery: '',
                    incrementStart: 3,
                    incrementIncrement: 5,
                    rangeStart: 1,
                    rangeEnd: '0',
                    specificSpecific: [],
                },
                hour: {
                    cronEvery: '',
                    incrementStart: 3,
                    incrementIncrement: 5,
                    rangeStart: '0',
                    rangeEnd: '0',
                    specificSpecific: [],
                },
                day: {
                    cronEvery: '',
                    incrementStart: 1,
                    incrementIncrement: '1',
                    rangeStart: '',
                    rangeEnd: '',
                    specificSpecific: [],
                    cronLastSpecificDomDay: 1,
                    cronDaysBeforeEomMinus: 1,
                    cronDaysNearestWeekday: 1,
                },
                week: {
                    cronEvery: '',
                    incrementStart: 1,
                    incrementIncrement: 1,
                    specificSpecific: [],
                    cronNthDayDay: 1,
                    cronNthDayNth: 1,
                },
                month: {
                    cronEvery: '',
                    incrementStart: 3,
                    incrementIncrement: 5,
                    rangeStart: 1,
                    rangeEnd: 1,
                    specificSpecific: [],
                },
                year: {
                    cronEvery: '',
                    incrementStart: curYear,
                    incrementIncrement: 1,
                    rangeStart: curYear,
                    rangeEnd: curYear,
                    specificSpecific: [],
                },
                label: '',
            },
        };
    },
    computed: {
        modalWidth() {
            return 608;
陈浩玮's avatar
陈浩玮 committed
562
        },
水落(YangLei)'s avatar
水落(YangLei) committed
563 564 565 566 567 568 569 570 571 572 573
        secondsText() {
            let seconds = '';
            let cronEvery = this.result.second.cronEvery || '';
            switch (cronEvery.toString()) {
                case '1':
                    seconds = '*';
                    break;
                case '2':
                    seconds = this.result.second.incrementStart + '/' + this.result.second.incrementIncrement;
                    break;
                case '3':
shuiluo's avatar
shuiluo committed
574
                    this.result.second.specificSpecific.map((val) => {
水落(YangLei)'s avatar
水落(YangLei) committed
575 576 577 578 579 580 581 582 583
                        seconds += val + ',';
                    });
                    seconds = seconds.slice(0, -1);
                    break;
                case '4':
                    seconds = this.result.second.rangeStart + '-' + this.result.second.rangeEnd;
                    break;
            }
            return seconds;
陈浩玮's avatar
陈浩玮 committed
584
        },
水落(YangLei)'s avatar
水落(YangLei) committed
585 586 587 588 589 590 591 592 593 594 595
        minutesText() {
            let minutes = '';
            let cronEvery = this.result.minute.cronEvery || '';
            switch (cronEvery.toString()) {
                case '1':
                    minutes = '*';
                    break;
                case '2':
                    minutes = this.result.minute.incrementStart + '/' + this.result.minute.incrementIncrement;
                    break;
                case '3':
shuiluo's avatar
shuiluo committed
596
                    this.result.minute.specificSpecific.map((val) => {
水落(YangLei)'s avatar
水落(YangLei) committed
597 598 599 600 601 602 603 604 605
                        minutes += val + ',';
                    });
                    minutes = minutes.slice(0, -1);
                    break;
                case '4':
                    minutes = this.result.minute.rangeStart + '-' + this.result.minute.rangeEnd;
                    break;
            }
            return minutes;
陈浩玮's avatar
陈浩玮 committed
606
        },
水落(YangLei)'s avatar
水落(YangLei) committed
607 608 609 610 611 612 613 614 615 616 617
        hoursText() {
            let hours = '';
            let cronEvery = this.result.hour.cronEvery || '';
            switch (cronEvery.toString()) {
                case '1':
                    hours = '*';
                    break;
                case '2':
                    hours = this.result.hour.incrementStart + '/' + this.result.hour.incrementIncrement;
                    break;
                case '3':
shuiluo's avatar
shuiluo committed
618
                    this.result.hour.specificSpecific.map((val) => {
水落(YangLei)'s avatar
水落(YangLei) committed
619 620 621 622 623 624 625 626 627
                        hours += val + ',';
                    });
                    hours = hours.slice(0, -1);
                    break;
                case '4':
                    hours = this.result.hour.rangeStart + '-' + this.result.hour.rangeEnd;
                    break;
            }
            return hours;
陈浩玮's avatar
陈浩玮 committed
628
        },
水落(YangLei)'s avatar
水落(YangLei) committed
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
        daysText() {
            let days = '';
            let cronEvery = this.result.day.cronEvery || '';
            switch (cronEvery.toString()) {
                case '1':
                    break;
                case '2':
                case '4':
                case '11':
                    days = '?';
                    break;
                case '3':
                    days = this.result.day.incrementStart + '/' + this.result.day.incrementIncrement;
                    break;
                case '5':
shuiluo's avatar
shuiluo committed
644
                    this.result.day.specificSpecific.map((val) => {
水落(YangLei)'s avatar
水落(YangLei) committed
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
                        days += val + ',';
                    });
                    days = days.slice(0, -1);
                    break;
                case '6':
                    days = 'L';
                    break;
                case '7':
                    days = 'LW';
                    break;
                case '8':
                    days = this.result.day.cronLastSpecificDomDay + 'L';
                    break;
                case '9':
                    days = 'L-' + this.result.day.cronDaysBeforeEomMinus;
                    break;
                case '10':
                    days = this.result.day.cronDaysNearestWeekday + 'W';
                    break;
            }
            return days;
陈浩玮's avatar
陈浩玮 committed
666
        },
水落(YangLei)'s avatar
水落(YangLei) committed
667 668 669 670 671 672 673 674 675 676 677 678 679
        weeksText() {
            let weeks = '';
            let cronEvery = this.result.day.cronEvery || '';
            switch (cronEvery.toString()) {
                case '1':
                case '3':
                case '5':
                    weeks = '?';
                    break;
                case '2':
                    weeks = this.result.week.incrementStart + '/' + this.result.week.incrementIncrement;
                    break;
                case '4':
shuiluo's avatar
shuiluo committed
680
                    this.result.week.specificSpecific.map((val) => {
水落(YangLei)'s avatar
水落(YangLei) committed
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696
                        weeks += val + ',';
                    });
                    weeks = weeks.slice(0, -1);
                    break;
                case '6':
                case '7':
                case '8':
                case '9':
                case '10':
                    weeks = '?';
                    break;
                case '11':
                    weeks = this.result.week.cronNthDayDay + '#' + this.result.week.cronNthDayNth;
                    break;
            }
            return weeks;
陈浩玮's avatar
陈浩玮 committed
697
        },
水落(YangLei)'s avatar
水落(YangLei) committed
698 699 700 701 702 703 704 705 706 707 708
        monthsText() {
            let months = '';
            let cronEvery = this.result.month.cronEvery || '';
            switch (cronEvery.toString()) {
                case '1':
                    months = '*';
                    break;
                case '2':
                    months = this.result.month.incrementStart + '/' + this.result.month.incrementIncrement;
                    break;
                case '3':
shuiluo's avatar
shuiluo committed
709
                    this.result.month.specificSpecific.map((val) => {
水落(YangLei)'s avatar
水落(YangLei) committed
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
                        months += val + ',';
                    });
                    months = months.slice(0, -1);
                    break;
                case '4':
                    months = this.result.month.rangeStart + '-' + this.result.month.rangeEnd;
                    break;
            }
            return months;
        },
        yearsText() {
            let years = '';
            let cronEvery = this.result.year.cronEvery || '';
            switch (cronEvery.toString()) {
                case '1':
                    years = '*';
                    break;
                case '2':
                    years = this.result.year.incrementStart + '/' + this.result.year.incrementIncrement;
                    break;
                case '3':
shuiluo's avatar
shuiluo committed
731
                    this.result.year.specificSpecific.map((val) => {
水落(YangLei)'s avatar
水落(YangLei) committed
732 733 734 735 736 737 738 739 740 741 742
                        years += val + ',';
                    });
                    years = years.slice(0, -1);
                    break;
                case '4':
                    years = this.result.year.rangeStart + '-' + this.result.year.rangeEnd;
                    break;
            }
            return years;
        },
        cron() {
shuiluo's avatar
shuiluo committed
743 744 745
            return `${this.secondsText || '*'} ${this.minutesText || '*'} ${this.hoursText || '*'} ${
                this.daysText || '*'
            } ${this.monthsText || '*'} ${this.weeksText || '?'} ${this.yearsText || '*'}`;
陈浩玮's avatar
陈浩玮 committed
746 747
        },
    },
水落(YangLei)'s avatar
水落(YangLei) committed
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785
    watch: {
        visible: {
            handler() {
                let label = this.data;
                if (label) {
                    label = label.trim();
                    const len = label.split(' ').length;
                    switch (true) {
                        case len > 0:
                            this.secondsReverseExp(label);
                            break;
                        case len > 1:
                            this.minutesReverseExp(label);
                            break;
                        case len > 2:
                            this.hoursReverseExp(label);
                            break;

                        case len > 3:
                            this.daysReverseExp(label);
                            break;

                        case len > 4:
                            this.daysReverseExp(label);
                            break;

                        case len > 5:
                            this.monthsReverseExp(label);
                            break;

                        case len > 6:
                            this.yearReverseExp(label);
                    }
                } else {
                    this.result = JSON.parse(JSON.stringify(this.defaultValue));
                }
            },
        },
陈浩玮's avatar
陈浩玮 committed
786
    },
水落(YangLei)'s avatar
水落(YangLei) committed
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
    methods: {
        getContainer(e) {
            return window.document.body;
        },
        show() {
            this.visible = true;
        },
        handleSubmit() {
            this.$emit('ok', this.cron);
            this.close();
            this.visible = false;
        },
        close() {
            this.visible = false;
        },
        secondsReverseExp(seconds) {
            let val = seconds.split(' ')[0];
            let second = {
                cronEvery: '',
                incrementStart: 3,
                incrementIncrement: 5,
                rangeStart: 1,
                rangeEnd: 0,
                specificSpecific: [],
            };
            switch (true) {
                case val.includes('*'):
                    second.cronEvery = '1';
                    break;
                case val.includes('/'):
                    second.cronEvery = '2';
                    second.incrementStart = val.split('/')[0];
                    second.incrementIncrement = val.split('/')[1];
                    break;
                case val.includes(','):
                    second.cronEvery = '3';
shuiluo's avatar
shuiluo committed
823
                    second.specificSpecific = val.split(',').map(Number).sort();
水落(YangLei)'s avatar
水落(YangLei) committed
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856
                    break;
                case val.includes('-'):
                    second.cronEvery = '4';
                    second.rangeStart = val.split('-')[0];
                    second.rangeEnd = val.split('-')[1];
                    break;
                default:
                    second.cronEvery = '3';
                    second.specificSpecific = [val];
            }
            this.result.second = second;
        },
        minutesReverseExp(minutes) {
            let val = minutes.split(' ')[1];
            let minute = {
                cronEvery: '',
                incrementStart: 3,
                incrementIncrement: 5,
                rangeStart: 1,
                rangeEnd: 0,
                specificSpecific: [],
            };
            switch (true) {
                case val.includes('*'):
                    minute.cronEvery = '1';
                    break;
                case val.includes('/'):
                    minute.cronEvery = '2';
                    minute.incrementStart = val.split('/')[0];
                    minute.incrementIncrement = val.split('/')[1];
                    break;
                case val.includes(','):
                    minute.cronEvery = '3';
shuiluo's avatar
shuiluo committed
857
                    minute.specificSpecific = val.split(',').map(Number).sort();
水落(YangLei)'s avatar
水落(YangLei) committed
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
                    break;
                case val.includes('-'):
                    minute.cronEvery = '4';
                    minute.rangeStart = val.split('-')[0];
                    minute.rangeEnd = val.split('-')[1];
                    break;
                default:
                    minute.cronEvery = '3';
                    minute.specificSpecific = [val];
            }
            this.result.minute = minute;
        },
        hoursReverseExp(hours) {
            let val = hours.split(' ')[2];
            let hour = {
                cronEvery: '',
                incrementStart: 3,
                incrementIncrement: 5,
                rangeStart: 1,
                rangeEnd: '0',
                specificSpecific: [],
            };
            switch (true) {
                case val.includes('*'):
                    hour.cronEvery = '1';
                    break;
                case val.includes('/'):
                    hour.cronEvery = '2';
                    hour.incrementStart = val.split('/')[0];
                    hour.incrementIncrement = val.split('/')[1];
                    break;
                case val.includes(','):
                    hour.cronEvery = '3';
shuiluo's avatar
shuiluo committed
891
                    hour.specificSpecific = val.split(',').map(Number).sort();
水落(YangLei)'s avatar
水落(YangLei) committed
892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939
                    break;
                case val.includes('-'):
                    hour.cronEvery = '4';
                    hour.rangeStart = val.split('-')[0];
                    hour.rangeEnd = val.split('-')[1];
                    break;
                default:
                    hour.cronEvery = '3';
                    hour.specificSpecific = [val];
            }
            this.result.hour = hour;
        },
        daysReverseExp(cron) {
            let days = cron.split(' ')[3];
            let weeks = cron.split(' ')[5];
            let day = {
                cronEvery: '',
                incrementStart: 1,
                incrementIncrement: 1,
                rangeStart: 1,
                rangeEnd: 1,
                specificSpecific: [],
                cronLastSpecificDomDay: 1,
                cronDaysBeforeEomMinus: 1,
                cronDaysNearestWeekday: 1,
            };
            let week = {
                cronEvery: '',
                incrementStart: 1,
                incrementIncrement: 1,
                specificSpecific: [],
                cronNthDayDay: 1,
                cronNthDayNth: 1,
            };
            if (!days.includes('?')) {
                switch (true) {
                    case days.includes('*'):
                        day.cronEvery = '1';
                        break;
                    case days.includes('?'):
                        break;
                    case days.includes('/'):
                        day.cronEvery = '3';
                        day.incrementStart = days.split('/')[0];
                        day.incrementIncrement = days.split('/')[1];
                        break;
                    case days.includes(','):
                        day.cronEvery = '5';
shuiluo's avatar
shuiluo committed
940
                        day.specificSpecific = days.split(',').map(Number).sort();
水落(YangLei)'s avatar
水落(YangLei) committed
941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965
                        break;
                    case days.includes('LW'):
                        day.cronEvery = '7';
                        break;
                    case days.includes('L-'):
                        day.cronEvery = '9';
                        day.cronDaysBeforeEomMinus = days.split('L-')[1];
                        break;
                    case days.includes('L'):
                        if (days.len == 1) {
                            day.cronEvery = '6';
                            day.cronLastSpecificDomDay = '1';
                        } else {
                            day.cronEvery = '8';
                            day.cronLastSpecificDomDay = Number(days.split('L')[0]);
                        }
                        break;
                    case days.includes('W'):
                        day.cronEvery = '10';
                        day.cronDaysNearestWeekday = days.split('W')[0];
                        break;
                    default:
                        day.cronEvery = '5';
                        day.specificSpecific = [days];
                }
陈浩玮's avatar
陈浩玮 committed
966
            } else {
水落(YangLei)'s avatar
水落(YangLei) committed
967 968 969 970 971 972 973 974
                switch (true) {
                    case weeks.includes('/'):
                        day.cronEvery = '2';
                        week.incrementStart = parseInt(weeks.split('/')[0]);
                        week.incrementIncrement = parseInt(weeks.split('/')[1]);
                        break;
                    case weeks.includes(','):
                        day.cronEvery = '4';
shuiluo's avatar
shuiluo committed
975
                        week.specificSpecific = weeks.split(',').map(Number).sort();
水落(YangLei)'s avatar
水落(YangLei) committed
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991
                        break;
                    case weeks.includes('#'):
                        day.cronEvery = '11';
                        week.cronNthDayDay = parseInt(weeks.split('#')[0]);
                        week.cronNthDayNth = parseInt(weeks.split('#')[1]);
                        break;
                    // case weeks.includes("-"):
                    //   day.cronEvery = "11";
                    //   week.cronNthDayDay = parseInt(weeks.split("#")[0]);
                    //   week.cronNthDayNth = parseInt(weeks.split("#")[1]);
                    //   break;
                    default:
                        day.cronEvery = '4';
                        week.cronEvery = '4';
                        week.specificSpecific = [parseInt(weeks)];
                }
陈浩玮's avatar
陈浩玮 committed
992
            }
水落(YangLei)'s avatar
水落(YangLei) committed
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
            this.result.day = day;
            this.result.week = week;
        },
        monthsReverseExp(cron) {
            let months = cron.split(' ')[4];
            let month = {
                cronEvery: '',
                incrementStart: 3,
                incrementIncrement: 5,
                rangeStart: 1,
                rangeEnd: 1,
                specificSpecific: [],
            };
            switch (true) {
                case months.includes('*'):
                    month.cronEvery = '1';
                    break;
                case months.includes('/'):
                    month.cronEvery = '2';
                    month.incrementStart = months.split('/')[0];
                    month.incrementIncrement = months.split('/')[1];
                    break;
                case months.includes(','):
                    month.cronEvery = '3';
shuiluo's avatar
shuiluo committed
1017
                    month.specificSpecific = months.split(',').map(Number).sort();
水落(YangLei)'s avatar
水落(YangLei) committed
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
                    break;
                case months.includes('-'):
                    month.cronEvery = '4';
                    month.rangeStart = months.split('-')[0];
                    month.rangeEnd = months.split('-')[1];
                    break;
                default:
                    month.cronEvery = '3';
                    month.specificSpecific = [months];
            }
            this.result.month = month;
        },
        yearReverseExp(cron) {
            let years = cron.split(' ')[6];
            let year = {
                cronEvery: '',
                incrementStart: curYear,
                incrementIncrement: 5,
                rangeStart: curYear,
                rangeEnd: curYear,
                specificSpecific: [],
            };
            if (years !== undefined) {
                switch (true) {
                    case years.includes('*'):
                        year.cronEvery = '1';
                        break;
                    case years.includes('/'):
                        year.cronEvery = '2';
                        year.incrementStart = years.split('/')[0];
                        year.incrementIncrement = years.split('/')[1];
                        break;
                    case years.includes(','):
                        year.cronEvery = '3';
shuiluo's avatar
shuiluo committed
1052
                        year.specificSpecific = years.split(',').map(Number).sort();
水落(YangLei)'s avatar
水落(YangLei) committed
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067
                        break;
                    case years.includes('-'):
                        year.cronEvery = '4';
                        year.rangeStart = years.split('-')[0];
                        year.rangeEnd = years.split('-')[1];
                        break;
                    default:
                        year.cronEvery = '3';
                        year.specificSpecific = [years];
                }
            } else {
                year.cronEvery = '1';
            }
            this.result.year = year;
        },
陈浩玮's avatar
陈浩玮 committed
1068 1069 1070
    },
};
</script>
水落(YangLei)'s avatar
水落(YangLei) committed
1071 1072

<style lang="less">
陈浩玮's avatar
陈浩玮 committed
1073
.card-container {
水落(YangLei)'s avatar
水落(YangLei) committed
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106
    background: #fff;
    overflow: hidden;
    padding: 12px;
    position: relative;
    width: 100%;
    .ant-tabs {
        border: 1px solid #e6ebf5;
        padding: 0;
        .ant-tabs-bar {
            margin: 0;
            outline: none;
            border-bottom: none;
            .ant-tabs-nav-container {
                margin: 0;
                .ant-tabs-tab {
                    padding: 0 24px !important;
                    background-color: #f5f7fa !important;
                    margin-right: 0px !important;
                    border-radius: 0;
                    line-height: 38px;
                    border: 1px solid transparent !important;
                    border-bottom: 1px solid #e6ebf5 !important;
                }
                .ant-tabs-tab-active.ant-tabs-tab {
                    color: #409eff;
                    background-color: #fff !important;
                    border-right: 1px solid #e6ebf5 !important;
                    border-left: 1px solid #e6ebf5 !important;
                    border-bottom: 1px solid #fff !important;
                    font-weight: normal;
                    transition: none !important;
                }
            }
陈浩玮's avatar
陈浩玮 committed
1107
        }
水落(YangLei)'s avatar
水落(YangLei) committed
1108 1109 1110 1111 1112 1113 1114 1115 1116
        .ant-tabs-tabpane {
            padding: 15px;
            .ant-row {
                margin: 10px 0;
            }
            .ant-select,
            .ant-input-number {
                width: 100px;
            }
陈浩玮's avatar
陈浩玮 committed
1117 1118 1119 1120
        }
    }
}
</style>
水落(YangLei)'s avatar
水落(YangLei) committed
1121 1122

<style lang="less" scoped>
陈浩玮's avatar
陈浩玮 committed
1123
.container-widthEn {
水落(YangLei)'s avatar
水落(YangLei) committed
1124
    width: 755px;
陈浩玮's avatar
陈浩玮 committed
1125 1126
}
.container-widthCn {
水落(YangLei)'s avatar
水落(YangLei) committed
1127
    width: 608px;
陈浩玮's avatar
陈浩玮 committed
1128 1129
}
.language {
水落(YangLei)'s avatar
水落(YangLei) committed
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
    text-align: center;
    position: absolute;
    right: 13px;
    top: 13px;
    border: 1px solid transparent;
    height: 40px;
    line-height: 38px;
    font-size: 16px;
    color: #409eff;
    z-index: 1;
    background: #f5f7fa;
    outline: none;
    width: 47px;
    border-bottom: 1px solid #e6ebf5;
    border-radius: 0;
陈浩玮's avatar
陈浩玮 committed
1145 1146
}
.card-container {
水落(YangLei)'s avatar
水落(YangLei) committed
1147 1148 1149 1150 1151 1152 1153 1154
    .bottom {
        display: flex;
        justify-content: center;
        padding: 10px 0 0 0;
        .cronButton {
            margin: 0 10px;
            line-height: 40px;
        }
陈浩玮's avatar
陈浩玮 committed
1155 1156 1157
    }
}
.tabBody {
水落(YangLei)'s avatar
水落(YangLei) committed
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
    .a-row {
        margin: 10px 0;
        .long {
            .a-select {
                width: 354px;
            }
        }
        .a-input-number {
            width: 110px;
        }
陈浩玮's avatar
陈浩玮 committed
1168 1169
    }
}
水落(YangLei)'s avatar
水落(YangLei) committed
1170
</style>