Commit f08f3e48 by yzh

feat:完成了暂停任务启动任务接口

parent 87d1de03
...@@ -55,8 +55,8 @@ export const scrapydServerApi = { ...@@ -55,8 +55,8 @@ export const scrapydServerApi = {
deleteScrapydServer: '/scrapydServer/deleteScrapydServer' deleteScrapydServer: '/scrapydServer/deleteScrapydServer'
} as const } as const
export const systemApi = {
// 系统相关 // 系统相关
export const systemApi = {
systemInfo: '/system/systemInfo', systemInfo: '/system/systemInfo',
systemData: '/system/systemData', systemData: '/system/systemData',
systemConfig: '/system/systemConfig', systemConfig: '/system/systemConfig',
...@@ -64,16 +64,16 @@ export const systemApi = { ...@@ -64,16 +64,16 @@ export const systemApi = {
scrapydServerList: '/system/scrapydServerList' // 没用 scrapydServerList: '/system/scrapydServerList' // 没用
} as const } as const
export const statsApi = {
// 统计相关 // 统计相关
export const statsApi = {
statsList: '/statsCollection/listItem', statsList: '/statsCollection/listItem',
statsDetail: '/statsCollection/detail', statsDetail: '/statsCollection/detail',
removeStats: '/statsCollection/delete', removeStats: '/statsCollection/delete',
clearAllStats: '/statsCollection/clearAll' // TODO 未实现 clearAllStats: '/statsCollection/clearAll' // TODO 未实现
} as const } as const
export const userApi = {
// 系统用户相关接口 // 系统用户相关接口
export const userApi = {
userList: '/user/list', userList: '/user/list',
addUser: '/user/insert', addUser: '/user/insert',
updateUser: '/user/update', updateUser: '/user/update',
...@@ -81,13 +81,13 @@ export const userApi = { ...@@ -81,13 +81,13 @@ export const userApi = {
batchDelete: '/user/batchDelete', batchDelete: '/user/batchDelete',
} as const } as const
export const spiderApi = {
// 系统用户相关接口 // 系统用户相关接口
export const spiderApi = {
spiderList: '/scrapyd/listSpiders', spiderList: '/scrapyd/listSpiders',
} as const } as const
export const spiderTaskApi = {
// 爬虫任务相关接口 // 爬虫任务相关接口
export const spiderTaskApi = {
taskList: '/schedule/getJobs', taskList: '/schedule/getJobs',
taskRecord: '/schedule/scheduleLogs', taskRecord: '/schedule/scheduleLogs',
addTask: '/schedule/addJob', addTask: '/schedule/addJob',
...@@ -96,3 +96,13 @@ export const spiderTaskApi = { ...@@ -96,3 +96,13 @@ export const spiderTaskApi = {
resumeJob: '/schedule/resumeJob', resumeJob: '/schedule/resumeJob',
jobDetail: '/schedule/jobDetail', jobDetail: '/schedule/jobDetail',
} as const } as const
// 爬虫数据相关接口
export const spiderDataApi = {
dsnList: '/dsn/list',
dsnDetail: '/dsn/detail',
dsnDataDelete: '/dsn/delete',
ituList: '/itu/list',
ituDetail: '/itu/detail',
ituDataDelete: '/itu/delete',
} as const
\ No newline at end of file
import { request, POST } from '@/utils/request'
import type { ApiResponse, QueryParams, UserQueryParams } from '@/utils/request'
import { spiderDataApi } from './apiPaths'
// 获取dsn数据列表
export function getDsnlist(data: UserQueryParams) {
return request({
url: spiderDataApi.dsnList,
method: POST,
data
}) as unknown as Promise<ApiResponse>
}
// 获取dsn数据详情
export function getDsnDetail(data: UserQueryParams) {
return request({
url: spiderDataApi.dsnDetail,
method: POST,
data
}) as unknown as Promise<ApiResponse>
}
// 删除dsn数据
export function deleteDsnData(data: UserQueryParams) {
return request({
url: spiderDataApi.dsnDataDelete,
method: POST,
data
}) as unknown as Promise<ApiResponse>
}
// 获取itu数据列表
export function getItulist(data: UserQueryParams) {
return request({
url: spiderDataApi.ituList,
method: POST,
data
}) as unknown as Promise<ApiResponse>
}
// 获取itu数据详情
export function getItuDetail(data: UserQueryParams) {
return request({
url: spiderDataApi.ituDetail,
method: POST,
data
}) as unknown as Promise<ApiResponse>
}
// 删除itu数据
export function deleteItuData(data: UserQueryParams) {
return request({
url: spiderDataApi.ituDataDelete,
method: POST,
data
}) as unknown as Promise<ApiResponse>
}
\ No newline at end of file
...@@ -200,9 +200,10 @@ ...@@ -200,9 +200,10 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { onMounted, ref } from 'vue'
import Pagination from '@/components/pagination/index.vue' import Pagination from '@/components/pagination/index.vue'
import exportDialog from '@/components/Export/index.vue' import exportDialog from '@/components/Export/index.vue'
import { getDsnlist, getDsnDetail, deleteDsnData } from '@/api/spiderData'
const showDeleteDialog = ref(false) const showDeleteDialog = ref(false)
const timeValue = ref('') const timeValue = ref('')
...@@ -243,51 +244,7 @@ const recordTime = ref('') ...@@ -243,51 +244,7 @@ const recordTime = ref('')
const isSuspended = ref('') const isSuspended = ref('')
const tableData = ref([ const tableData = ref([
{
number: '1',
targetName: 'maven',
distance: '2000',
roundTripTime: '12',
stationName: 'CANBERRA',
targetAzimuth: '11',
targetElevation: '24',
targetDistance: '2000',
windSpeed: '10',
upSignalSource: 'maven',
upSignalFrequencyBand: 'X',
upSignalLaunchPower: '123',
downSignalSignalSource: 'maven',
downSignalFrequencyBand: 'S',
downSignalReceptionPower: '23',
dataTime: '2025-06-21 12:00:00',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
]) ])
const pageObj = ref({ const pageObj = ref({
total: 10, total: 10,
...@@ -299,8 +256,11 @@ const handleDetails = (row: any) => { ...@@ -299,8 +256,11 @@ const handleDetails = (row: any) => {
detailVisibleValue.value = true detailVisibleValue.value = true
} }
const getData = () => { const getData = async () => {
console.log('getData'); console.log('getData');
const res = await getDsnlist({page:pageObj.value.pageNo,size:pageObj.value.pageSize})
tableData.value = res.data.list
pageObj.value.total = res.data.total
} }
const handleClose = () => { const handleClose = () => {
...@@ -312,6 +272,9 @@ const handleExportConfirm = () => { ...@@ -312,6 +272,9 @@ const handleExportConfirm = () => {
const handleExport = () => { const handleExport = () => {
showDeleteDialog.value = true showDeleteDialog.value = true
} }
onMounted(() => {
getData()
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -242,9 +242,10 @@ ...@@ -242,9 +242,10 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { onMounted, ref } from 'vue'
import Pagination from '@/components/pagination/index.vue' import Pagination from '@/components/pagination/index.vue'
import exportDialog from '@/components/Export/index.vue' import exportDialog from '@/components/Export/index.vue'
import { getItulist, getItuDetail, deleteItuData } from '@/api/spiderData'
const showDeleteDialog = ref(false) const showDeleteDialog = ref(false)
const timeValue = ref('') const timeValue = ref('')
...@@ -295,55 +296,7 @@ const isRestoreUsed = ref('') ...@@ -295,55 +296,7 @@ const isRestoreUsed = ref('')
const validityPeriodSatelliteNetworkOldName = ref('') const validityPeriodSatelliteNetworkOldName = ref('')
// 最新相关 BR IFIC 发布日期 // 最新相关 BR IFIC 发布日期
const BFIFICdate = ref('') const BFIFICdate = ref('')
const tableData = ref([ const tableData = ref([])
{
number: '1',
SNSNoticeID: '86550007',
department: 'ARG',
targetName: 'ARGOS',
planType: '计划',
syncType: '否',
syncPosition: '-',
perigee: '2000',
apogee: '2500',
lowestAltitude: '165',
referenceSubject: '地球',
lowestFrequency: 'None',
highestFrequency: 'None',
status: 'None',
validityPeriod: '-',
earliestUsageDate: 'None',
isUsed: 'No',
isPauseUsed: 'No',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
{
name: '1',
},
])
const pageObj = ref({ const pageObj = ref({
total: 10, total: 10,
pageSize: 10, pageSize: 10,
...@@ -353,8 +306,12 @@ const handleDetails = (row: any) => { ...@@ -353,8 +306,12 @@ const handleDetails = (row: any) => {
console.log(row); console.log(row);
detailVisibleValue.value = true detailVisibleValue.value = true
} }
const getData = () => { const getData = async () => {
console.log('getData'); 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
} }
const handleClose = () => { const handleClose = () => {
detailVisibleValue.value = false detailVisibleValue.value = false
...@@ -365,6 +322,10 @@ const handleExportConfirm = () => { ...@@ -365,6 +322,10 @@ const handleExportConfirm = () => {
const handleExport = () => { const handleExport = () => {
showDeleteDialog.value = true showDeleteDialog.value = true
} }
onMounted(() => {
getData()
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
<el-form-item> <el-form-item>
<el-space> <el-space>
<span class="wordStyle">启用/停止: </span> <span class="wordStyle">启用/停止: </span>
<el-switch v-model="task.status" :active-value="1" :inactive-value="0" @change="changeStatus(task)" /> <el-switch v-model="task.status" :active-value="'running'" :inactive-value="'paused'"
@change="(newStatus:any) => changeStatus(task, newStatus)" />
<span class="wordStyle">执行频率: {{ task.frequency }} </span> <span class="wordStyle">执行频率: {{ task.frequency }} </span>
</el-space> </el-space>
</el-form-item> </el-form-item>
...@@ -88,7 +89,7 @@ ...@@ -88,7 +89,7 @@
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import addTaskDialog from './addTaskDialog.vue' import addTaskDialog from './addTaskDialog.vue'
import { getSpiderTaskList } from '@/api/spiderTask' import { getSpiderTaskList, resumeSpiderTask, pauseSpiderTask } from '@/api/spiderTask'
import { DeleteMode } from '@/components/Delete/enum.ts' import { DeleteMode } from '@/components/Delete/enum.ts'
import { AddMode } from './enum' import { AddMode } from './enum'
import deleteDialog from './deleteDialog.vue' import deleteDialog from './deleteDialog.vue'
...@@ -136,17 +137,7 @@ const showTaskDialog = ref(false) ...@@ -136,17 +137,7 @@ const showTaskDialog = ref(false)
const taskSwitch = ref(false) const taskSwitch = ref(false)
const taskOptions = ref('') const taskOptions = ref('')
const jobId = ref('') const jobId = ref('')
const taskList = ref([ const taskList = ref<any[]>([])
{
taskId: 1,
name: '任务1',
status: 1,
frequency: '每天',
kwargs: {
options: ''
}
}
])
const deleteTask = (task: any) => { const deleteTask = (task: any) => {
console.log(task); console.log(task);
...@@ -173,9 +164,14 @@ const goToTaskRecord = () => { ...@@ -173,9 +164,14 @@ const goToTaskRecord = () => {
} }
}) })
} }
const changeStatus = (task: any) => { const changeStatus = async (task: any, newStatus: string) => {
if (newStatus === "running") {
} await resumeSpiderTask({ job_id: task.id });
} else if (newStatus === "paused") {
await pauseSpiderTask({ job_id: task.id });
}
await getData();
};
const handleEdit = () => { const handleEdit = () => {
} }
...@@ -184,7 +180,7 @@ const openTaskDialog = () => { ...@@ -184,7 +180,7 @@ const openTaskDialog = () => {
showTaskDialog.value = true showTaskDialog.value = true
} }
const getData = async () => { const getData = async () => {
const res = await getSpiderTaskList({ spiders: searchCondition.value.spiders ? [searchCondition.value.spiders] : [] , options: JSON.stringify({ jobName: taskName.value }) }) const res = await getSpiderTaskList({ spiders: searchCondition.value.spiders ? [searchCondition.value.spiders] : [], options: JSON.stringify({ jobName: taskName.value }) })
taskList.value = res.data taskList.value = res.data
} }
...@@ -287,7 +283,7 @@ onMounted(() => { ...@@ -287,7 +283,7 @@ onMounted(() => {
border: none; border: none;
} */ } */
.el-input { .el-input {
color: #FFFFFF; color: #FFFFFF;
} }
</style> </style>
\ No newline at end of file
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