Commit 23b4a568 authored by shuiluo's avatar shuiluo

feat: acron组件国际化完善

parent 775f2127
...@@ -47,7 +47,6 @@ export default { ...@@ -47,7 +47,6 @@ export default {
cron(val) { cron(val) {
console.log(replaceWeekName(val)); console.log(replaceWeekName(val));
this.afterCron = replaceWeekName(val); this.afterCron = replaceWeekName(val);
console.log(val);
this.$emit('input', val); this.$emit('input', val);
}, },
}, },
......
<template> <template>
<a-modal <a-modal
title="corn表达式" :title="$t('corn.expression')"
:width="modalWidth" :width="modalWidth"
:visible="visible" :visible="visible"
:confirmLoading="confirmLoading" :confirmLoading="confirmLoading"
@ok="handleSubmit" @ok="handleSubmit"
@cancel="close" @cancel="close"
cancelText="关闭" :cancelText="$t('corn.close')"
:getContainer="getContainer" :getContainer="getContainer"
> >
<div class="card-container"> <div class="card-container">
<a-tabs type="card"> <a-tabs type="card">
<a-tab-pane key="1" type="card"> <a-tab-pane key="1" type="card">
<span slot="tab"> <a-icon type="schedule" /></span> <span slot="tab"> <a-icon type="schedule" />{{ $t('corn.second') }}</span>
<a-radio-group v-model="result.second.cronEvery"> <a-radio-group v-model="result.second.cronEvery">
<a-row> <a-row>
<a-radio value="1">每一秒钟</a-radio> <a-radio value="1">{{ $t('corn.everySecond') }}</a-radio>
</a-row> </a-row>
<a-row> <a-row>
<a-radio value="2"> <a-radio value="2">
每隔 {{ $t('corn.everyOther') }}
<a-input-number <a-input-number
size="small" size="small"
v-model="result.second.incrementIncrement" v-model="result.second.incrementIncrement"
:min="1" :min="1"
:max="60" :max="60"
></a-input-number />秒执行 从
>秒执行 从
<a-input-number <a-input-number
size="small" size="small"
v-model="result.second.incrementStart" v-model="result.second.incrementStart"
:min="0" :min="0"
:max="59" :max="59"
></a-input-number />秒开始
>秒开始
</a-radio> </a-radio>
</a-row> </a-row>
<a-row> <a-row>
<a-radio value="3">具体秒数(可多选)</a-radio> <a-radio value="3">具体秒数(可多选)</a-radio>
<a-select <a-select
style="width:354px;" style="width: 354px"
size="small" size="small"
mode="multiple" mode="multiple"
v-model="result.second.specificSpecific" v-model="result.second.specificSpecific"
...@@ -99,7 +97,7 @@ ...@@ -99,7 +97,7 @@
<a-row> <a-row>
<a-radio value="3">具体分钟数(可多选)</a-radio> <a-radio value="3">具体分钟数(可多选)</a-radio>
<a-select <a-select
style="width:340px;" style="width: 340px"
size="small" size="small"
mode="multiple" mode="multiple"
v-model="result.minute.specificSpecific" v-model="result.minute.specificSpecific"
...@@ -163,7 +161,7 @@ ...@@ -163,7 +161,7 @@
<a-row> <a-row>
<a-radio class="long" value="3">具体小时数(可多选)</a-radio> <a-radio class="long" value="3">具体小时数(可多选)</a-radio>
<a-select <a-select
style="width:340px;" style="width: 340px"
size="small" size="small"
mode="multiple" mode="multiple"
v-model="result.hour.specificSpecific" v-model="result.hour.specificSpecific"
...@@ -244,7 +242,7 @@ ...@@ -244,7 +242,7 @@
<a-row> <a-row>
<a-radio class="long" value="4">具体星期几(可多选)</a-radio> <a-radio class="long" value="4">具体星期几(可多选)</a-radio>
<a-select <a-select
style="width:340px;" style="width: 340px"
size="small" size="small"
mode="multiple" mode="multiple"
v-model="result.week.specificSpecific" v-model="result.week.specificSpecific"
...@@ -260,7 +258,7 @@ ...@@ -260,7 +258,7 @@
<a-row> <a-row>
<a-radio class="long" value="5">具体天数(可多选)</a-radio> <a-radio class="long" value="5">具体天数(可多选)</a-radio>
<a-select <a-select
style="width:354px;" style="width: 354px"
size="small" size="small"
mode="multiple" mode="multiple"
v-model="result.day.specificSpecific" v-model="result.day.specificSpecific"
...@@ -368,7 +366,7 @@ ...@@ -368,7 +366,7 @@
<a-row> <a-row>
<a-radio class="long" value="3">具体月数(可多选)</a-radio> <a-radio class="long" value="3">具体月数(可多选)</a-radio>
<a-select <a-select
style="width:354px;" style="width: 354px"
size="small" size="small"
filterable filterable
mode="multiple" mode="multiple"
...@@ -433,7 +431,7 @@ ...@@ -433,7 +431,7 @@
<a-row> <a-row>
<a-radio class="long" value="3">具体年份(可多选)</a-radio> <a-radio class="long" value="3">具体年份(可多选)</a-radio>
<a-select <a-select
style="width:354px;" style="width: 354px"
size="small" size="small"
filterable filterable
mode="multiple" mode="multiple"
...@@ -476,6 +474,7 @@ ...@@ -476,6 +474,7 @@
</div> </div>
</a-modal> </a-modal>
</template> </template>
<script> <script>
const now = new Date(); const now = new Date();
const curYear = now.getFullYear(); const curYear = now.getFullYear();
...@@ -488,7 +487,7 @@ export default { ...@@ -488,7 +487,7 @@ export default {
visible: false, visible: false,
confirmLoading: false, confirmLoading: false,
size: 'large', size: 'large',
weekDays: ['', '', '', '', '', '', ''].map(val => '星期' + val), weekDays: ['', '', '', '', '', '', ''].map((val) => '星期' + val),
result: { result: {
second: {}, second: {},
minute: {}, minute: {},
...@@ -577,7 +576,7 @@ export default { ...@@ -577,7 +576,7 @@ export default {
seconds = this.result.second.incrementStart + '/' + this.result.second.incrementIncrement; seconds = this.result.second.incrementStart + '/' + this.result.second.incrementIncrement;
break; break;
case '3': case '3':
this.result.second.specificSpecific.map(val => { this.result.second.specificSpecific.map((val) => {
seconds += val + ','; seconds += val + ',';
}); });
seconds = seconds.slice(0, -1); seconds = seconds.slice(0, -1);
...@@ -599,7 +598,7 @@ export default { ...@@ -599,7 +598,7 @@ export default {
minutes = this.result.minute.incrementStart + '/' + this.result.minute.incrementIncrement; minutes = this.result.minute.incrementStart + '/' + this.result.minute.incrementIncrement;
break; break;
case '3': case '3':
this.result.minute.specificSpecific.map(val => { this.result.minute.specificSpecific.map((val) => {
minutes += val + ','; minutes += val + ',';
}); });
minutes = minutes.slice(0, -1); minutes = minutes.slice(0, -1);
...@@ -621,7 +620,7 @@ export default { ...@@ -621,7 +620,7 @@ export default {
hours = this.result.hour.incrementStart + '/' + this.result.hour.incrementIncrement; hours = this.result.hour.incrementStart + '/' + this.result.hour.incrementIncrement;
break; break;
case '3': case '3':
this.result.hour.specificSpecific.map(val => { this.result.hour.specificSpecific.map((val) => {
hours += val + ','; hours += val + ',';
}); });
hours = hours.slice(0, -1); hours = hours.slice(0, -1);
...@@ -647,7 +646,7 @@ export default { ...@@ -647,7 +646,7 @@ export default {
days = this.result.day.incrementStart + '/' + this.result.day.incrementIncrement; days = this.result.day.incrementStart + '/' + this.result.day.incrementIncrement;
break; break;
case '5': case '5':
this.result.day.specificSpecific.map(val => { this.result.day.specificSpecific.map((val) => {
days += val + ','; days += val + ',';
}); });
days = days.slice(0, -1); days = days.slice(0, -1);
...@@ -683,7 +682,7 @@ export default { ...@@ -683,7 +682,7 @@ export default {
weeks = this.result.week.incrementStart + '/' + this.result.week.incrementIncrement; weeks = this.result.week.incrementStart + '/' + this.result.week.incrementIncrement;
break; break;
case '4': case '4':
this.result.week.specificSpecific.map(val => { this.result.week.specificSpecific.map((val) => {
weeks += val + ','; weeks += val + ',';
}); });
weeks = weeks.slice(0, -1); weeks = weeks.slice(0, -1);
...@@ -712,7 +711,7 @@ export default { ...@@ -712,7 +711,7 @@ export default {
months = this.result.month.incrementStart + '/' + this.result.month.incrementIncrement; months = this.result.month.incrementStart + '/' + this.result.month.incrementIncrement;
break; break;
case '3': case '3':
this.result.month.specificSpecific.map(val => { this.result.month.specificSpecific.map((val) => {
months += val + ','; months += val + ',';
}); });
months = months.slice(0, -1); months = months.slice(0, -1);
...@@ -734,7 +733,7 @@ export default { ...@@ -734,7 +733,7 @@ export default {
years = this.result.year.incrementStart + '/' + this.result.year.incrementIncrement; years = this.result.year.incrementStart + '/' + this.result.year.incrementIncrement;
break; break;
case '3': case '3':
this.result.year.specificSpecific.map(val => { this.result.year.specificSpecific.map((val) => {
years += val + ','; years += val + ',';
}); });
years = years.slice(0, -1); years = years.slice(0, -1);
...@@ -746,9 +745,9 @@ export default { ...@@ -746,9 +745,9 @@ export default {
return years; return years;
}, },
cron() { cron() {
return `${this.secondsText || '*'} ${this.minutesText || '*'} ${this.hoursText || '*'} ${this return `${this.secondsText || '*'} ${this.minutesText || '*'} ${this.hoursText || '*'} ${
.daysText || '*'} ${this.monthsText || '*'} ${this.weeksText || '?'} ${this.yearsText || this.daysText || '*'
'*'}`; } ${this.monthsText || '*'} ${this.weeksText || '?'} ${this.yearsText || '*'}`;
}, },
}, },
watch: { watch: {
...@@ -826,10 +825,7 @@ export default { ...@@ -826,10 +825,7 @@ export default {
break; break;
case val.includes(','): case val.includes(','):
second.cronEvery = '3'; second.cronEvery = '3';
second.specificSpecific = val second.specificSpecific = val.split(',').map(Number).sort();
.split(',')
.map(Number)
.sort();
break; break;
case val.includes('-'): case val.includes('-'):
second.cronEvery = '4'; second.cronEvery = '4';
...@@ -863,10 +859,7 @@ export default { ...@@ -863,10 +859,7 @@ export default {
break; break;
case val.includes(','): case val.includes(','):
minute.cronEvery = '3'; minute.cronEvery = '3';
minute.specificSpecific = val minute.specificSpecific = val.split(',').map(Number).sort();
.split(',')
.map(Number)
.sort();
break; break;
case val.includes('-'): case val.includes('-'):
minute.cronEvery = '4'; minute.cronEvery = '4';
...@@ -900,10 +893,7 @@ export default { ...@@ -900,10 +893,7 @@ export default {
break; break;
case val.includes(','): case val.includes(','):
hour.cronEvery = '3'; hour.cronEvery = '3';
hour.specificSpecific = val hour.specificSpecific = val.split(',').map(Number).sort();
.split(',')
.map(Number)
.sort();
break; break;
case val.includes('-'): case val.includes('-'):
hour.cronEvery = '4'; hour.cronEvery = '4';
...@@ -952,10 +942,7 @@ export default { ...@@ -952,10 +942,7 @@ export default {
break; break;
case days.includes(','): case days.includes(','):
day.cronEvery = '5'; day.cronEvery = '5';
day.specificSpecific = days day.specificSpecific = days.split(',').map(Number).sort();
.split(',')
.map(Number)
.sort();
break; break;
case days.includes('LW'): case days.includes('LW'):
day.cronEvery = '7'; day.cronEvery = '7';
...@@ -990,10 +977,7 @@ export default { ...@@ -990,10 +977,7 @@ export default {
break; break;
case weeks.includes(','): case weeks.includes(','):
day.cronEvery = '4'; day.cronEvery = '4';
week.specificSpecific = weeks week.specificSpecific = weeks.split(',').map(Number).sort();
.split(',')
.map(Number)
.sort();
break; break;
case weeks.includes('#'): case weeks.includes('#'):
day.cronEvery = '11'; day.cronEvery = '11';
...@@ -1035,10 +1019,7 @@ export default { ...@@ -1035,10 +1019,7 @@ export default {
break; break;
case months.includes(','): case months.includes(','):
month.cronEvery = '3'; month.cronEvery = '3';
month.specificSpecific = months month.specificSpecific = months.split(',').map(Number).sort();
.split(',')
.map(Number)
.sort();
break; break;
case months.includes('-'): case months.includes('-'):
month.cronEvery = '4'; month.cronEvery = '4';
...@@ -1073,10 +1054,7 @@ export default { ...@@ -1073,10 +1054,7 @@ export default {
break; break;
case years.includes(','): case years.includes(','):
year.cronEvery = '3'; year.cronEvery = '3';
year.specificSpecific = years year.specificSpecific = years.split(',').map(Number).sort();
.split(',')
.map(Number)
.sort();
break; break;
case years.includes('-'): case years.includes('-'):
year.cronEvery = '4'; year.cronEvery = '4';
......
export default { export default {
'corn.title': ['Cron 控件', 'Cron Component'], 'corn.title': ['Cron 控件', 'Cron Component'],
'corn.expression': ['corn表达式', 'Corn Expression'],
'corn.close': ['关闭', 'Close'],
'corn.second': ['', 'second'],
'corn.everySecond': ['每一秒钟', 'Every Second'],
'corn.everyOther': ['每隔', 'Every Other'],
}; };
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment