Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
da8c52e6
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 大约 3 年
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
da8c52e6
编写于
9月 01, 2020
作者:
C
Captain.B
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 合并代码修改部分页面显示
上级
5aa7019b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
286 addition
and
284 deletion
+286
-284
frontend/src/business/components/common/components/MsScheduleConfig.vue
...usiness/components/common/components/MsScheduleConfig.vue
+79
-73
frontend/src/business/components/common/components/MsScheduleEdit.vue
.../business/components/common/components/MsScheduleEdit.vue
+207
-211
未找到文件。
frontend/src/business/components/common/components/MsScheduleConfig.vue
浏览文件 @
da8c52e6
<
template
>
<div
class=
"schedule-config"
>
<div>
<div
class=
"schedule-config"
>
<div>
<span
class=
"cron-ico"
@
click=
"scheduleEdit"
>
<i
class=
"el-icon-date"
size=
"small"
></i>
<span
class=
"character"
>
SCHEDULER
</span>
</span>
<el-switch
:disabled=
"!schedule.value || isReadOnly"
v-model=
"schedule.enable"
@
change=
"scheduleChange"
/>
<ms-schedule-edit
:is-read-only=
"isReadOnly"
:schedule=
"schedule"
:save=
"save"
:custom-validate=
"customValidate"
ref=
"scheduleEdit"
/>
<el-switch
:disabled=
"!schedule.value || isReadOnly"
v-model=
"schedule.enable"
@
change=
"scheduleChange"
/>
<ms-schedule-edit
:is-read-only=
"isReadOnly"
:schedule=
"schedule"
:save=
"save"
:custom-validate=
"customValidate"
ref=
"scheduleEdit"
/>
</div>
<div>
</div>
<div>
<span>
{{
$t
(
'
schedule.next_execution_time
'
)
}}
:
<span
:class=
"
{'disable-character': !schedule.enable}" v-if="!schedule.enable">
{{
$t
(
'
schedule.not_set
'
)
}}
</span>
{{
$t
(
'
schedule.next_execution_time
'
)
}}
:
<span
:class=
"
{'disable-character': !schedule.enable}"
v-if="!schedule.enable">
{{
$t
(
'
schedule.not_set
'
)
}}
</span>
<crontab-result
v-if=
"schedule.enable"
:enable-simple-mode=
"true"
:ex=
"schedule.value"
ref=
"crontabResult"
/>
</span>
</div>
</div>
</div>
</
template
>
<
script
>
import
MsScheduleEdit
from
"
./MsScheduleEdit
"
;
import
CrontabResult
from
"
../cron/CrontabResult
"
;
import
MsScheduleEdit
from
"
./MsScheduleEdit
"
;
import
CrontabResult
from
"
../cron/CrontabResult
"
;
function
defaultCustomValidate
()
{
return
{
pass
:
true
};}
function
defaultCustomValidate
()
{
return
{
pass
:
true
};
}
export
default
{
name
:
"
MsScheduleConfig
"
,
components
:
{
CrontabResult
,
MsScheduleEdit
},
data
()
{
export
default
{
name
:
"
MsScheduleConfig
"
,
components
:
{
CrontabResult
,
MsScheduleEdit
},
data
()
{
return
{
recentList
:
[],
}
},
props
:
{
save
:
Function
,
schedule
:
{},
checkOpen
:
{
type
:
Function
,
default
()
{
return
{
recentList
:
[],
}
},
props
:
{
save
:
Function
,
schedule
:
{},
checkOpen
:
{
type
:
Function
,
default
()
{
return
{
checkOpen
()
{
return
true
;}
}
checkOpen
()
{
return
true
;
}
},
customValidate
:
{
type
:
Function
,
default
:
defaultCustomValidate
},
isReadOnly
:
{
type
:
Boolean
,
default
:
false
}
},
methods
:
{
scheduleEdit
()
{
if
(
!
this
.
checkOpen
())
{
return
;
}
this
.
$refs
.
scheduleEdit
.
open
();
},
scheduleChange
()
{
this
.
$emit
(
'
scheduleChange
'
);
},
flashResultList
()
{
this
.
$refs
.
crontabResult
.
expressionChange
();
}
}
},
customValidate
:
{
type
:
Function
,
default
:
defaultCustomValidate
},
isReadOnly
:
{
type
:
Boolean
,
default
:
false
}
},
methods
:
{
scheduleEdit
()
{
if
(
!
this
.
checkOpen
())
{
return
;
}
this
.
$refs
.
scheduleEdit
.
open
();
},
scheduleChange
()
{
this
.
$emit
(
'
scheduleChange
'
);
},
flashResultList
()
{
this
.
$refs
.
crontabResult
.
expressionChange
();
}
}
}
</
script
>
<
style
scoped
>
.schedule-config
{
float
:
right
;
width
:
250px
;
height
:
15px
;
line-height
:
25px
;
}
.schedule-config
{
float
:
right
;
width
:
250px
;
height
:
15px
;
line-height
:
25px
;
}
.el-icon-date
{
font-size
:
20px
;
margin-left
:
5px
;
}
.el-icon-date
{
font-size
:
20px
;
margin-left
:
5px
;
}
.character
{
font-weight
:
bold
;
margin
:
0
5px
;
}
.character
{
font-weight
:
bold
;
margin
:
0
5px
;
}
.disable-character
{
color
:
#cccccc
;
}
.disable-character
{
color
:
#cccccc
;
}
.el-switch
{
margin
:
0
5px
;
}
.el-switch
{
margin
:
0
5px
;
}
.cron-ico
{
cursor
:
pointer
;
}
.cron-ico
{
cursor
:
pointer
;
}
</
style
>
frontend/src/business/components/common/components/MsScheduleEdit.vue
浏览文件 @
da8c52e6
<
template
>
<el-dialog
:close-on-click-modal=
"false"
width=
"
35
%"
class=
"schedule-edit"
:visible.sync=
"dialogVisible"
<el-dialog
:close-on-click-modal=
"false"
width=
"
70
%"
class=
"schedule-edit"
:visible.sync=
"dialogVisible"
@
close=
"close"
>
<template>
<div>
<el-tabs
v-model=
"activeName"
@
tab-click=
"handleClick"
>
<el-tab-pane
:label=
"$t('schedule.edit_timer_task')"
name=
"first"
>
<el-form
:model=
"form"
:rules=
"rules"
ref=
"from"
>
<el-form-item
prop=
"cronValue"
>
<el-input
:disabled=
"isReadOnly"
v-model=
"form.cronValue"
class=
"inp"
:placeholder=
"$t('schedule.please_input_cron_expression')"
/>
<!--
<el-button
type=
"primary"
@
click=
"showCronDialog"
>
{{
$t
(
'
schedule.generate_expression
'
)
}}
</el-button>
-->
<el-button
:disabled=
"isReadOnly"
type=
"primary"
@
click=
"saveCron"
>
{{
$t
(
'
commons.save
'
)
}}
</el-button>
</el-form-item>
<el-form-item>
<el-link
:disabled=
"isReadOnly"
type=
"primary"
@
click=
"showCronDialog"
>
{{
$t
(
'
schedule.generate_expression
'
)
}}
</el-link>
</el-form-item>
<crontab-result
:ex=
"form.cronValue"
ref=
"crontabResult"
/>
</el-form>
<el-dialog
:title=
"$t('schedule.generate_expression')"
:visible.sync=
"showCron"
:modal=
"false"
>
<crontab
@
hide=
"showCron=false"
@
fill=
"crontabFill"
:expression=
"schedule.value"
ref=
"crontab"
/>
</el-dialog>
</el-tab-pane>
<el-tab-pane
:label=
"$t('schedule.task_notification')"
name=
"second"
>
<template>
<el-table
:data=
"tableData"
style=
"width: 100%"
>
<el-table-column
prop=
"event"
:label=
"$t('schedule.event')"
>
</el-table-column>
<el-table-column
prop=
"receiver"
:label=
"$t('schedule.receiver')"
width=
"200"
>
<template
v-slot:default=
"
{row}">
<el-input
size=
"mini"
type=
"textarea"
:rows=
"1"
class=
"edit-input"
v-model=
"row.receiver"
:placeholder=
"$t('schedule.receiver')"
clearable
>
</el-input>
</
template
>
</el-table-column>
<el-table-column
prop=
"email"
:label=
"$t('schedule.receiving_mode')"
width=
"300"
>
<
template
v-slot:default=
"{row}"
>
<el-input
size=
"mini"
type=
"textarea"
:rows=
"1"
class=
"edit-input"
v-model=
"row.email"
:placeholder=
"$t('schedule.input_email')"
clearable
>
</el-input>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
:label=
"$t('schedule.operation')"
show-overflow-tooltip
>
<
template
slot-scope=
"scope"
>
<el-switch
v-model=
"scope.row.status"
:active-value=
"1"
:inactive-value=
"2"
active-color=
"#13ce66"
inactive-color=
"#ff4949"
/>
</
template
>
</el-table-column>
</el-table>
</template>
</el-tab-pane>
</el-tabs>
</div>
</template>
<el-tabs
v-model=
"activeName"
@
tab-click=
"handleClick"
>
<el-tab-pane
:label=
"$t('schedule.edit_timer_task')"
name=
"first"
>
<el-form
:model=
"form"
:rules=
"rules"
ref=
"from"
>
<el-form-item
prop=
"cronValue"
>
<el-input
:disabled=
"isReadOnly"
v-model=
"form.cronValue"
class=
"inp"
:placeholder=
"$t('schedule.please_input_cron_expression')"
/>
<!--
<el-button
type=
"primary"
@
click=
"showCronDialog"
>
{{
$t
(
'
schedule.generate_expression
'
)
}}
</el-button>
-->
<el-button
:disabled=
"isReadOnly"
type=
"primary"
@
click=
"saveCron"
>
{{
$t
(
'
commons.save
'
)
}}
</el-button>
</el-form-item>
<el-form-item>
<el-link
:disabled=
"isReadOnly"
type=
"primary"
@
click=
"showCronDialog"
>
{{
$t
(
'
schedule.generate_expression
'
)
}}
</el-link>
</el-form-item>
<crontab-result
:ex=
"form.cronValue"
ref=
"crontabResult"
/>
</el-form>
<el-dialog
:title=
"$t('schedule.generate_expression')"
width=
"70%"
:visible.sync=
"showCron"
:modal=
"false"
>
<crontab
@
hide=
"showCron=false"
@
fill=
"crontabFill"
:expression=
"schedule.value"
ref=
"crontab"
/>
</el-dialog>
</el-tab-pane>
<el-tab-pane
:label=
"$t('schedule.task_notification')"
name=
"second"
>
<template>
<el-table
:data=
"tableData"
style=
"width: 100%"
>
<el-table-column
prop=
"event"
:label=
"$t('schedule.event')"
>
</el-table-column>
<el-table-column
prop=
"receiver"
:label=
"$t('schedule.receiver')"
width=
"200"
>
<template
v-slot:default=
"
{row}">
<el-input
size=
"mini"
type=
"textarea"
:rows=
"1"
class=
"edit-input"
v-model=
"row.receiver"
:placeholder=
"$t('schedule.receiver')"
clearable
>
</el-input>
</
template
>
</el-table-column>
<el-table-column
prop=
"email"
:label=
"$t('schedule.receiving_mode')"
width=
"300"
>
<
template
v-slot:default=
"{row}"
>
<el-input
size=
"mini"
type=
"textarea"
:rows=
"1"
class=
"edit-input"
v-model=
"row.email"
:placeholder=
"$t('schedule.input_email')"
clearable
>
</el-input>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
:label=
"$t('schedule.operation')"
show-overflow-tooltip
>
<
template
slot-scope=
"scope"
>
<el-switch
v-model=
"scope.row.status"
:active-value=
"1"
:inactive-value=
"2"
active-color=
"#13ce66"
inactive-color=
"#ff4949"
/>
</
template
>
</el-table-column>
</el-table>
</template>
</el-tab-pane>
</el-tabs>
</el-dialog>
</template>
<
script
>
import
Crontab
from
"
../cron/Crontab
"
;
import
CrontabResult
from
"
../cron/CrontabResult
"
;
import
{
cronValidate
}
from
"
../../../..
/common/js/cron
"
;
import
{
listenGoBack
,
removeGoBackListener
}
from
"
../../../..
/common/js/utils
"
;
import
Crontab
from
"
../cron/Crontab
"
;
import
CrontabResult
from
"
../cron/CrontabResult
"
;
import
{
cronValidate
}
from
"
@
/common/js/cron
"
;
import
{
listenGoBack
,
removeGoBackListener
}
from
"
@
/common/js/utils
"
;
function
defaultCustomValidate
()
{
return
{
pass
:
true
};
}
function
defaultCustomValidate
()
{
return
{
pass
:
true
};
}
export
default
{
name
:
"
MsScheduleEdit
"
,
components
:
{
CrontabResult
,
Crontab
},
props
:
{
save
:
Function
,
schedule
:
{},
customValidate
:
{
type
:
Function
,
default
:
defaultCustomValidate
export
default
{
name
:
"
MsScheduleEdit
"
,
components
:
{
CrontabResult
,
Crontab
},
props
:
{
save
:
Function
,
schedule
:
{},
customValidate
:
{
type
:
Function
,
default
:
defaultCustomValidate
},
isReadOnly
:
{
type
:
Boolean
,
default
:
false
}
},
watch
:
{
'
schedule.value
'
()
{
this
.
form
.
cronValue
=
this
.
schedule
.
value
;
}
},
data
()
{
const
validateCron
=
(
rule
,
cronValue
,
callback
)
=>
{
let
customValidate
=
this
.
customValidate
(
this
.
getIntervalTime
());
if
(
!
cronValue
)
{
callback
(
new
Error
(
this
.
$t
(
'
commons.input_content
'
)));
}
else
if
(
!
cronValidate
(
cronValue
))
{
callback
(
new
Error
(
this
.
$t
(
'
schedule.cron_expression_format_error
'
)));
}
// else if(!this.intervalShortValidate()) {
// callback(new Error(this.$t('schedule.cron_expression_interval_short_error')));
// }
else
if
(
!
customValidate
.
pass
)
{
callback
(
new
Error
(
customValidate
.
info
));
}
else
{
callback
();
}
};
return
{
operation
:
true
,
dialogVisible
:
false
,
showCron
:
false
,
form
:
{
cronValue
:
""
},
isReadOnly
:
{
type
:
Boolean
,
default
:
false
tableData
:
[
{
event
:
'
执行成功
'
,
receiver
:
''
,
email
:
''
,
operation
:
1
},
{
event
:
'
执行成功
'
,
receiver
:
''
,
email
:
''
,
operation
:
2
}
],
email
:
""
,
enable
:
true
,
activeName
:
'
first
'
,
rules
:
{
cronValue
:
[{
required
:
true
,
validator
:
validateCron
,
trigger
:
'
blur
'
}],
}
}
},
methods
:
{
handleClick
()
{
},
watch
:
{
'
schedule.value
'
()
{
this
.
form
.
cronValue
=
this
.
schedule
.
value
;
}
open
()
{
this
.
dialogVisible
=
true
;
this
.
form
.
cronValue
=
this
.
schedule
.
value
;
listenGoBack
(
this
.
close
);
},
data
()
{
const
validateCron
=
(
rule
,
cronValue
,
callback
)
=>
{
let
customValidate
=
this
.
customValidate
(
this
.
getIntervalTime
());
if
(
!
cronValue
)
{
callback
(
new
Error
(
this
.
$t
(
'
commons.input_content
'
)));
}
else
if
(
!
cronValidate
(
cronValue
))
{
callback
(
new
Error
(
this
.
$t
(
'
schedule.cron_expression_format_error
'
)));
}
// else if(!this.intervalShortValidate()) {
// callback(new Error(this.$t('schedule.cron_expression_interval_short_error')));
// }
else
if
(
!
customValidate
.
pass
)
{
callback
(
new
Error
(
customValidate
.
info
));
crontabFill
(
value
,
resultList
)
{
//确定后回传的值
this
.
form
.
cronValue
=
value
;
this
.
$refs
.
crontabResult
.
resultList
=
resultList
;
this
.
$refs
[
'
from
'
].
validate
();
},
showCronDialog
()
{
this
.
showCron
=
true
;
},
saveCron
()
{
this
.
$refs
[
'
from
'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
this
.
intervalShortValidate
();
this
.
save
(
this
.
form
.
cronValue
);
this
.
dialogVisible
=
false
;
}
else
{
callback
();
}
};
return
{
operation
:
true
,
dialogVisible
:
false
,
showCron
:
false
,
form
:
{
cronValue
:
""
},
tableData
:
[
{
event
:
'
执行成功
'
,
receiver
:
''
,
email
:
''
,
operation
:
1
},
{
event
:
'
执行成功
'
,
receiver
:
''
,
email
:
''
,
operation
:
2
}
],
email
:
""
,
enable
:
true
,
activeName
:
'
first
'
,
rules
:
{
cronValue
:
[{
required
:
true
,
validator
:
validateCron
,
trigger
:
'
blur
'
}],
return
false
;
}
});
},
close
()
{
this
.
dialogVisible
=
false
;
this
.
form
.
cronValue
=
''
;
this
.
$refs
[
'
from
'
].
resetFields
();
if
(
!
this
.
schedule
.
value
)
{
this
.
$refs
.
crontabResult
.
resultList
=
[];
}
removeGoBackListener
(
this
.
close
);
},
methods
:
{
handleClick
()
{
},
open
()
{
this
.
dialogVisible
=
true
;
this
.
form
.
cronValue
=
this
.
schedule
.
value
;
listenGoBack
(
this
.
close
);
},
crontabFill
(
value
,
resultList
)
{
//确定后回传的值
this
.
form
.
cronValue
=
value
;
this
.
$refs
.
crontabResult
.
resultList
=
resultList
;
this
.
$refs
[
'
from
'
].
validate
();
},
showCronDialog
()
{
this
.
showCron
=
true
;
},
saveCron
()
{
this
.
$refs
[
'
from
'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
this
.
intervalShortValidate
();
this
.
save
(
this
.
form
.
cronValue
);
this
.
dialogVisible
=
false
;
}
else
{
return
false
;
}
});
},
close
()
{
this
.
dialogVisible
=
false
;
this
.
form
.
cronValue
=
''
;
this
.
$refs
[
'
from
'
].
resetFields
();
if
(
!
this
.
schedule
.
value
)
{
this
.
$refs
.
crontabResult
.
resultList
=
[];
}
removeGoBackListener
(
this
.
close
);
},
intervalShortValidate
()
{
if
(
this
.
getIntervalTime
()
<
3
*
60
*
1000
)
{
// return false;
this
.
$info
(
this
.
$t
(
'
schedule.cron_expression_interval_short_error
'
));
}
return
true
;
},
resultListChange
()
{
this
.
$refs
[
'
from
'
].
validate
();
},
getIntervalTime
()
{
let
resultList
=
this
.
$refs
.
crontabResult
.
resultList
;
let
time1
=
new
Date
(
resultList
[
0
]);
let
time2
=
new
Date
(
resultList
[
1
]);
return
time2
-
time1
;
intervalShortValidate
()
{
if
(
this
.
getIntervalTime
()
<
3
*
60
*
1000
)
{
// return false;
this
.
$info
(
this
.
$t
(
'
schedule.cron_expression_interval_short_error
'
));
}
return
true
;
},
resultListChange
()
{
this
.
$refs
[
'
from
'
].
validate
();
},
getIntervalTime
()
{
let
resultList
=
this
.
$refs
.
crontabResult
.
resultList
;
let
time1
=
new
Date
(
resultList
[
0
]);
let
time2
=
new
Date
(
resultList
[
1
]);
return
time2
-
time1
;
}
}
}
</
script
>
<
style
scoped
>
.inp
{
width
:
50%
;
margin-right
:
20px
;
}
.inp
{
width
:
50%
;
margin-right
:
20px
;
}
.el-form-item
{
margin-bottom
:
10px
;
}
.el-form-item
{
margin-bottom
:
10px
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录