Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fk-spider-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
fk-spider-web
Commits
5b14a4c2
Commit
5b14a4c2
authored
Sep 19, 2025
by
yzh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:cron表达式组件修改完成
parent
f08f3e48
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
62 deletions
+85
-62
Crontab.vue
src/components/Crontab/src/Crontab.vue
+0
-0
ituDataTab.vue
src/views/os-dataDisplay/components/ituDataTab.vue
+2
-3
addTaskDialog.vue
src/views/os-taskInformation/components/addTaskDialog.vue
+82
-58
vite.config.ts
vite.config.ts
+1
-1
No files found.
src/components/Crontab/src/Crontab.vue
View file @
5b14a4c2
This diff is collapsed.
Click to expand it.
src/views/os-dataDisplay/components/ituDataTab.vue
View file @
5b14a4c2
...
...
@@ -307,10 +307,9 @@ const handleDetails = (row: any) => {
detailVisibleValue
.
value
=
true
}
const
getData
=
async
()
=>
{
console
.
log
(
'getData'
);
const
res
=
await
getItulist
({
page
:
pageObj
.
value
.
pageNo
,
size
:
pageObj
.
value
.
pageSize
})
tableData
.
value
=
res
.
data
.
list
pageObj
.
value
.
total
=
res
.
data
.
total
pageObj
.
value
.
total
=
res
.
data
.
length
tableData
.
value
=
res
.
data
}
const
handleClose
=
()
=>
{
...
...
src/views/os-taskInformation/components/addTaskDialog.vue
View file @
5b14a4c2
<
template
>
<el-dialog
v-model=
"currentVisible"
:title=
"currentMode === AddMode.ADD_TASK ? '新增' : '修改'"
width=
"
6
10"
center
<el-dialog
v-model=
"currentVisible"
:title=
"currentMode === AddMode.ADD_TASK ? '新增' : '修改'"
width=
"
7
10"
center
align-center
@
close=
"handleClose"
draggable
>
<el-form
:
inline=
"true"
v-if=
"currentMode === AddMode.ADD_TASK
"
>
<el-form-item
label=
"任务名称:"
>
<el-input
v-model=
"
taskName"
placeholder=
"请输入任务名称
"
/>
<el-form
:
model=
"ruleForm"
:rules=
"rules"
ref=
"ruleFormRef"
label-width=
"100px
"
>
<el-form-item
label=
"任务名称:"
v-if=
"currentMode === AddMode.ADD_TASK"
prop=
"taskName"
>
<el-input
v-model=
"
ruleForm.taskName"
placeholder=
"请输入任务名称"
style=
"width: 90%
"
/>
</el-form-item>
<el-form-item
label=
"所属爬虫:"
>
<el-select
v-model=
"
spiderTypeValue"
placeholder=
"请选择所属爬虫"
style=
"width: 181px
"
>
<el-form-item
label=
"所属爬虫:"
v-if=
"currentMode === AddMode.ADD_TASK"
prop=
"spiderTypeValue"
>
<el-select
v-model=
"
ruleForm.spiderTypeValue"
placeholder=
"请选择所属爬虫"
style=
"width: 90%
"
>
<el-option
v-for=
"item in spiderTypeOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"执行频率
(秒/次):
"
>
<Crontab
v-model=
"
cronExpression"
style=
"width: 250px;
"
/>
<el-form-item
label=
"执行频率
:"
prop=
"cronExpression
"
>
<Crontab
v-model=
"
ruleForm.cronExpression"
style=
"width: 90%
"
/>
</el-form-item>
</el-form>
<el-form
v-if=
"currentMode === AddMode.UPDATE_TASK"
>
<el-form-item
label=
"执行频率(秒/次):"
>
<Crontab
v-model=
"cronExpression"
/>
</el-form-item>
<!--
<el-form-item
label=
"启用/停止:"
v-if=
"currentMode === AddMode.UPDATE_TASK"
>
<el-switch
v-model=
"taskSwitchValue"
class=
"ml-2"
style=
"--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
/>
</el-form-item>
-->
</el-form>
<template
#
footer
>
<div
class=
"dialog-footer"
>
<el-button
@
click=
"handleClose"
>
取消
</el-button>
...
...
@@ -31,7 +22,6 @@
</el-button>
</div>
</
template
>
</el-dialog>
</template>
...
...
@@ -42,6 +32,19 @@ import { watch } from 'vue'
import
{
addSpiderTask
}
from
'@/api/spiderTask'
import
{
AddMode
}
from
'./enum'
import
{
Crontab
}
from
'@/components/Crontab/index'
import
type
{
FormInstance
,
FormRules
}
from
'element-plus'
interface
RuleForm
{
taskName
:
string
spiderTypeValue
:
string
cronExpression
:
string
}
const
ruleFormRef
=
ref
<
FormInstance
>
()
const
ruleForm
=
ref
<
RuleForm
>
({
taskName
:
''
,
spiderTypeValue
:
''
,
cronExpression
:
''
,
})
interface
addDialogPropType
{
dialogVisible
:
boolean
,
mode
:
AddMode
,
...
...
@@ -49,20 +52,35 @@ interface addDialogPropType {
cron
:
string
,
spiderType
:
string
,
options
:
string
,
// frequency: string,
// taskStatus: boolean
}
const
props
=
defineProps
<
addDialogPropType
>
()
const
rules
=
ref
<
FormRules
<
RuleForm
>>
({
taskName
:
[
{
required
:
true
,
message
:
'请输入任务名称'
,
trigger
:
'blur'
},
{
min
:
1
,
max
:
50
,
message
:
'任务名称应在1-50个字符之间'
,
trigger
:
'blur'
},
],
spiderTypeValue
:
[
{
required
:
true
,
message
:
'请选择所属爬虫'
,
trigger
:
'change'
,
},
],
cronExpression
:
[
{
required
:
true
,
message
:
'请输入执行频率'
,
trigger
:
'change'
,
},
{
min
:
1
,
message
:
'执行频率应为cron表达式'
,
trigger
:
'blur'
},
]
})
// 向父组件传递dialog值
const
emit
=
defineEmits
([
'update:dialogVisible'
,
'confirm'
,
'update:mode'
,
'getTaskList'
])
// 组件的状态
const
currentVisible
=
ref
(
props
.
dialogVisible
)
const
currentMode
=
ref
(
props
.
mode
)
const
taskName
=
ref
(
''
)
const
taskFrequency
=
ref
(
''
)
const
taskTime
=
ref
(
''
)
const
taskSwitchValue
=
ref
(
false
)
const
spiderTypeValue
=
ref
(
''
)
const
spiderTypeOptions
=
ref
([
{
...
...
@@ -84,43 +102,49 @@ const taskParams = ref({
project
:
'spiders'
})
const
cronExpression
=
ref
(
''
)
// const shortcuts = [
// { text: '每工作日9点', value: '0 0 9 ? * MON-FRI' },
// { text: '每季度第一天', value: '0 0 0 1 1/3 ?' }
// ]
// 关闭的方法
const
handleClose
=
()
=>
{
taskName
.
valu
e
=
''
taskFrequency
.
value
=
''
cronExpression
.
value
=
''
ruleForm
.
value
.
taskNam
e
=
''
ruleForm
.
value
.
spiderTypeValue
ruleForm
.
value
.
cronExpression
=
''
currentVisible
.
value
=
false
}
// 确定的方法
const
handleConfirm
=
async
()
=>
{
if
(
currentMode
.
value
===
AddMode
.
ADD_TASK
)
{
await
addSpiderTask
({
scrapyd_server_id
:
taskParams
.
value
.
scrapyd_server_id
,
schedule_type
:
taskParams
.
value
.
schedule_type
,
project
:
taskParams
.
value
.
project
,
spider
:
spiderTypeValue
.
value
,
cron
:
cronExpression
.
value
,
options
:
JSON
.
stringify
({
jobName
:
taskName
.
value
})
})
currentVisible
.
value
=
false
emit
(
'getTaskList'
)
}
else
if
(
currentMode
.
value
===
AddMode
.
UPDATE_TASK
)
{
await
addSpiderTask
({
scrapyd_server_id
:
taskParams
.
value
.
scrapyd_server_id
,
schedule_type
:
taskParams
.
value
.
schedule_type
,
project
:
taskParams
.
value
.
project
,
spider
:
props
.
spiderType
,
job_id
:
props
.
jobId
,
cron
:
cronExpression
.
value
,
options
:
props
.
options
})
currentVisible
.
value
=
false
emit
(
'getTaskList'
)
}
if
(
!
ruleFormRef
.
value
)
return
await
ruleFormRef
.
value
.
validate
(
async
(
valid
,
fields
)
=>
{
console
.
log
(
'开始校验'
);
//验证表单内容是否通过,通过继续执行
if
(
valid
)
{
if
(
currentMode
.
value
===
AddMode
.
ADD_TASK
)
{
await
addSpiderTask
({
scrapyd_server_id
:
taskParams
.
value
.
scrapyd_server_id
,
schedule_type
:
taskParams
.
value
.
schedule_type
,
project
:
taskParams
.
value
.
project
,
spider
:
ruleForm
.
value
.
spiderTypeValue
,
cron
:
ruleForm
.
value
.
cronExpression
,
options
:
JSON
.
stringify
({
jobName
:
ruleForm
.
value
.
taskName
})
})
currentVisible
.
value
=
false
emit
(
'getTaskList'
)
}
else
if
(
currentMode
.
value
===
AddMode
.
UPDATE_TASK
)
{
await
addSpiderTask
({
scrapyd_server_id
:
taskParams
.
value
.
scrapyd_server_id
,
schedule_type
:
taskParams
.
value
.
schedule_type
,
project
:
taskParams
.
value
.
project
,
spider
:
props
.
spiderType
,
job_id
:
props
.
jobId
,
cron
:
ruleForm
.
value
.
cronExpression
,
options
:
props
.
options
})
currentVisible
.
value
=
false
emit
(
'getTaskList'
)
}
}
else
{
console
.
log
(
'校验不通过'
);
}
})
}
// 监听props变化,同步给组件内部
...
...
@@ -150,13 +174,13 @@ watch(() => currentMode.value,
)
watch
(
[()
=>
props
.
dialogVisible
,
()
=>
props
.
mode
,
()
=>
props
.
cron
],
([
newVisible
,
newMode
,
newCron
])
=>
{
([
newVisible
,
newMode
,
newCron
])
=>
{
if
(
newVisible
&&
newMode
===
AddMode
.
UPDATE_TASK
)
{
cronExpression
.
value
=
newCron
;
ruleForm
.
value
.
cronExpression
=
newCron
;
}
if
(
!
newVisible
)
{
// 清空表单
cronExpression
.
value
=
''
cronExpression
.
value
=
''
}
},
{
immediate
:
true
}
...
...
vite.config.ts
View file @
5b14a4c2
...
...
@@ -30,7 +30,7 @@ export default defineConfig({
proxy
:
{
// 代理API请求,使用更精确的路径匹配
'/api'
:
{
target
:
'http://1
27.0.0.1
:5001/'
,
target
:
'http://1
92.168.0.200
:5001/'
,
changeOrigin
:
true
,
},
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment