浏览代码

feat:【infra】任务管理:50%

YunaiV 4 月之前
父节点
当前提交
17218c1053

+ 60 - 0
src/api/infra/job/index.ts

@@ -0,0 +1,60 @@
+import type { PageParam, PageResult } from '@/http/types'
+import { http } from '@/http/http'
+
+// TODO @AI:不用 baseUrl 方式
+const baseUrl = '/infra/job'
+
+/** 定时任务信息 */
+export interface Job {
+  id?: number
+  name: string
+  status: number
+  handlerName: string
+  handlerParam: string
+  cronExpression: string
+  retryCount: number
+  retryInterval: number
+  monitorTimeout: number
+  createTime?: Date
+  nextTimes?: Date[]
+}
+
+/** 获取定时任务分页列表 */
+export function getJobPage(params: PageParam) {
+  return http.get<PageResult<Job>>(`${baseUrl}/page`, params)
+}
+
+/** 获取定时任务详情 */
+export function getJob(id: number) {
+  return http.get<Job>(`${baseUrl}/get?id=${id}`)
+}
+
+/** 创建定时任务 */
+export function createJob(data: Job) {
+  return http.post<number>(`${baseUrl}/create`, data)
+}
+
+/** 更新定时任务 */
+export function updateJob(data: Job) {
+  return http.put<boolean>(`${baseUrl}/update`, data)
+}
+
+/** 删除定时任务 */
+export function deleteJob(id: number) {
+  return http.delete<boolean>(`${baseUrl}/delete?id=${id}`)
+}
+
+/** 更新定时任务状态 */
+export function updateJobStatus(id: number, status: number) {
+  return http.put<boolean>(`${baseUrl}/update-status`, { id, status })
+}
+
+/** 立即执行一次定时任务 */
+export function runJob(id: number) {
+  return http.put<boolean>(`${baseUrl}/trigger?id=${id}`)
+}
+
+/** 获取定时任务的下 n 次执行时间 */
+export function getJobNextTimes(id: number) {
+  return http.get<Date[]>(`${baseUrl}/get_next_times?id=${id}`)
+}

+ 31 - 0
src/api/infra/job/log/index.ts

@@ -0,0 +1,31 @@
+import type { PageParam, PageResult } from '@/http/types'
+import { http } from '@/http/http'
+
+// TODO @AI:不用 baseUrl 方式
+const baseUrl = '/infra/job-log'
+
+/** 定时任务日志信息 */
+export interface JobLog {
+  id?: number
+  jobId: number
+  handlerName: string
+  handlerParam: string
+  cronExpression: string
+  executeIndex: string
+  beginTime: Date
+  endTime: Date
+  duration: string
+  status: number
+  createTime?: string
+  result: string
+}
+
+/** 获取定时任务日志分页列表 */
+export function getJobLogPage(params: PageParam) {
+  return http.get<PageResult<JobLog>>(`${baseUrl}/page`, params)
+}
+
+/** 获取定时任务日志详情 */
+export function getJobLog(id: number) {
+  return http.get<JobLog>(`${baseUrl}/get?id=${id}`)
+}

+ 143 - 0
src/pages-infra/job/components/job-list.vue

@@ -0,0 +1,143 @@
+<template>
+  <view>
+    <!-- 搜索组件 -->
+    <JobSearchForm @search="handleQuery" @reset="handleReset" />
+
+    <!-- 任务列表 -->
+    <view class="p-24rpx">
+      <view
+        v-for="item in list"
+        :key="item.id"
+        class="mb-24rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
+        @click="handleDetail(item)"
+      >
+        <view class="p-24rpx">
+          <view class="mb-16rpx flex items-center justify-between">
+            <view class="text-32rpx text-[#333] font-semibold">
+              {{ item.name }}
+            </view>
+            <dict-tag :type="DICT_TYPE.INFRA_JOB_STATUS" :value="item.status" />
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">处理器名称:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.handlerName || '-' }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">处理器参数:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.handlerParam || '-' }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx text-[#999]">CRON 表达式:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.cronExpression || '-' }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx text-[#999]">创建时间:</text>
+            <text>{{ formatDateTime(item.createTime) || '-' }}</text>
+          </view>
+        </view>
+      </view>
+
+      <!-- 加载更多 -->
+      <view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
+        <wd-status-tip image="content" tip="暂无定时任务数据" />
+      </view>
+      <wd-loadmore
+        v-if="list.length > 0"
+        :state="loadMoreState"
+        @reload="loadMore"
+      />
+    </view>
+
+    <!-- 新增按钮 -->
+    <wd-fab
+      v-if="hasAccessByCodes(['infra:job:create'])"
+      position="right-bottom"
+      type="primary"
+      :expandable="false"
+      @click="handleAdd"
+    />
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { Job } from '@/api/infra/job'
+import type { LoadMoreState } from '@/http/types'
+import { ref } from 'vue'
+import { getJobPage } from '@/api/infra/job'
+import { useAccess } from '@/hooks/useAccess'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDateTime } from '@/utils/date'
+import JobSearchForm from './job-search-form.vue'
+
+const { hasAccessByCodes } = useAccess()
+const total = ref(0)
+const list = ref<Job[]>([])
+const loadMoreState = ref<LoadMoreState>('loading')
+const queryParams = ref({
+  pageNo: 1,
+  pageSize: 10,
+})
+
+/** 查询列表 */
+async function getList() {
+  loadMoreState.value = 'loading'
+  try {
+    const data = await getJobPage(queryParams.value)
+    list.value = [...list.value, ...data.list]
+    total.value = data.total
+    loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
+  } catch {
+    queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
+    loadMoreState.value = 'error'
+  }
+}
+
+/** 搜索按钮操作 */
+function handleQuery(data?: Record<string, any>) {
+  queryParams.value = {
+    ...data,
+    pageNo: 1,
+    pageSize: queryParams.value.pageSize,
+  }
+  list.value = []
+  getList()
+}
+
+/** 重置按钮操作 */
+function handleReset() {
+  handleQuery()
+}
+
+/** 加载更多 */
+function loadMore() {
+  if (loadMoreState.value === 'finished') {
+    return
+  }
+  queryParams.value.pageNo++
+  getList()
+}
+
+/** 新增 */
+function handleAdd() {
+  uni.navigateTo({
+    url: '/pages-system/job/job/form/index',
+  })
+}
+
+/** 查看详情 */
+function handleDetail(item: Job) {
+  uni.navigateTo({
+    url: `/pages-system/job/job/detail/index?id=${item.id}`,
+  })
+}
+
+/** 触底加载更多 */
+onReachBottom(() => {
+  loadMore()
+})
+
+/** 初始化 */
+onMounted(() => {
+  getList()
+})
+</script>

+ 110 - 0
src/pages-infra/job/components/job-search-form.vue

@@ -0,0 +1,110 @@
+<template>
+  <!-- 搜索框入口 -->
+  <view @click="visible = true">
+    <wd-search :placeholder="placeholder" hide-cancel disabled />
+  </view>
+
+  <!-- 搜索弹窗 -->
+  <wd-popup v-model="visible" position="top" @close="visible = false">
+    <view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          任务名称
+        </view>
+        <wd-input
+          v-model="formData.name"
+          placeholder="请输入任务名称"
+          clearable
+        />
+      </view>
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          处理器名称
+        </view>
+        <wd-input
+          v-model="formData.handlerName"
+          placeholder="请输入处理器名称"
+          clearable
+        />
+      </view>
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          任务状态
+        </view>
+        <wd-radio-group v-model="formData.status" shape="button">
+          <wd-radio :value="-1">
+            全部
+          </wd-radio>
+          <wd-radio
+            v-for="dict in getIntDictOptions(DICT_TYPE.INFRA_JOB_STATUS)"
+            :key="dict.value"
+            :value="dict.value"
+          >
+            {{ dict.label }}
+          </wd-radio>
+        </wd-radio-group>
+      </view>
+      <view class="yd-search-form-actions">
+        <wd-button class="flex-1" plain @click="handleReset">
+          重置
+        </wd-button>
+        <wd-button class="flex-1" type="primary" @click="handleSearch">
+          搜索
+        </wd-button>
+      </view>
+    </view>
+  </wd-popup>
+</template>
+
+<script lang="ts" setup>
+import { computed, reactive, ref } from 'vue'
+import { getDictLabel, getIntDictOptions } from '@/hooks/useDict'
+import { getNavbarHeight } from '@/utils'
+import { DICT_TYPE } from '@/utils/constants'
+
+const emit = defineEmits<{
+  search: [data: Record<string, any>]
+  reset: []
+}>()
+
+const visible = ref(false)
+const formData = reactive({
+  name: undefined as string | undefined,
+  handlerName: undefined as string | undefined,
+  status: -1, // -1 表示全部
+})
+
+/** 搜索条件 placeholder 拼接 */
+const placeholder = computed(() => {
+  const conditions: string[] = []
+  if (formData.name) {
+    conditions.push(`任务名称:${formData.name}`)
+  }
+  if (formData.handlerName) {
+    conditions.push(`处理器:${formData.handlerName}`)
+  }
+  if (formData.status !== -1) {
+    conditions.push(`状态:${getDictLabel(DICT_TYPE.INFRA_JOB_STATUS, formData.status)}`)
+  }
+  return conditions.length > 0 ? conditions.join(' | ') : '搜索定时任务'
+})
+
+/** 搜索 */
+function handleSearch() {
+  visible.value = false
+  emit('search', {
+    name: formData.name || undefined,
+    handlerName: formData.handlerName || undefined,
+    status: formData.status === -1 ? undefined : formData.status,
+  })
+}
+
+/** 重置 */
+function handleReset() {
+  formData.name = undefined
+  formData.handlerName = undefined
+  formData.status = -1
+  visible.value = false
+  emit('reset')
+}
+</script>

+ 125 - 0
src/pages-infra/job/components/log-list.vue

@@ -0,0 +1,125 @@
+<template>
+  <view>
+    <!-- 搜索组件 -->
+    <LogSearchForm @search="handleQuery" @reset="handleReset" />
+
+    <!-- 日志列表 -->
+    <view class="p-24rpx">
+      <view
+        v-for="item in list"
+        :key="item.id"
+        class="mb-24rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
+        @click="handleDetail(item)"
+      >
+        <view class="p-24rpx">
+          <view class="mb-16rpx flex items-center justify-between">
+            <view class="text-32rpx text-[#333] font-semibold">
+              {{ item.handlerName }}
+            </view>
+            <dict-tag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="item.status" />
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">任务编号:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.jobId || '-' }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">处理器参数:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.handlerParam || '-' }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">执行时长:</text>
+            <text>{{ item.duration ? `${item.duration} ms` : '-' }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx text-[#999]">开始时间:</text>
+            <text>{{ formatDateTime(item.beginTime) || '-' }}</text>
+          </view>
+        </view>
+      </view>
+
+      <!-- 加载更多 -->
+      <view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
+        <wd-status-tip image="content" tip="暂无调度日志数据" />
+      </view>
+      <wd-loadmore
+        v-if="list.length > 0"
+        :state="loadMoreState"
+        @reload="loadMore"
+      />
+    </view>
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { JobLog } from '@/api/infra/job/log'
+import type { LoadMoreState } from '@/http/types'
+import { ref } from 'vue'
+import { getJobLogPage } from '@/api/infra/job/log'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDateTime } from '@/utils/date'
+import LogSearchForm from './log-search-form.vue'
+
+const total = ref(0)
+const list = ref<JobLog[]>([])
+const loadMoreState = ref<LoadMoreState>('loading')
+const queryParams = ref({
+  pageNo: 1,
+  pageSize: 10,
+})
+
+/** 查询列表 */
+async function getList() {
+  loadMoreState.value = 'loading'
+  try {
+    const data = await getJobLogPage(queryParams.value)
+    list.value = [...list.value, ...data.list]
+    total.value = data.total
+    loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
+  } catch {
+    queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
+    loadMoreState.value = 'error'
+  }
+}
+
+/** 搜索按钮操作 */
+function handleQuery(data?: Record<string, any>) {
+  queryParams.value = {
+    ...data,
+    pageNo: 1,
+    pageSize: queryParams.value.pageSize,
+  }
+  list.value = []
+  getList()
+}
+
+/** 重置按钮操作 */
+function handleReset() {
+  handleQuery()
+}
+
+/** 加载更多 */
+function loadMore() {
+  if (loadMoreState.value === 'finished') {
+    return
+  }
+  queryParams.value.pageNo++
+  getList()
+}
+
+/** 查看详情 */
+function handleDetail(item: JobLog) {
+  uni.navigateTo({
+    url: `/pages-system/job/log/detail/index?id=${item.id}`,
+  })
+}
+
+/** 触底加载更多 */
+onReachBottom(() => {
+  loadMore()
+})
+
+/** 初始化 */
+onMounted(() => {
+  getList()
+})
+</script>

+ 169 - 0
src/pages-infra/job/components/log-search-form.vue

@@ -0,0 +1,169 @@
+<template>
+  <!-- 搜索框入口 -->
+  <view @click="visible = true">
+    <wd-search :placeholder="placeholder" hide-cancel disabled />
+  </view>
+
+  <!-- 搜索弹窗 -->
+  <wd-popup v-model="visible" position="top" @close="visible = false">
+    <view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          任务编号
+        </view>
+        <wd-input
+          v-model="formData.jobId"
+          placeholder="请输入任务编号"
+          clearable
+        />
+      </view>
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          处理器名称
+        </view>
+        <wd-input
+          v-model="formData.handlerName"
+          placeholder="请输入处理器名称"
+          clearable
+        />
+      </view>
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          执行状态
+        </view>
+        <wd-radio-group v-model="formData.status" shape="button">
+          <wd-radio :value="-1">
+            全部
+          </wd-radio>
+          <wd-radio
+            v-for="dict in getIntDictOptions(DICT_TYPE.INFRA_JOB_LOG_STATUS)"
+            :key="dict.value"
+            :value="dict.value"
+          >
+            {{ dict.label }}
+          </wd-radio>
+        </wd-radio-group>
+      </view>
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          开始时间
+        </view>
+        <view class="yd-search-form-date-range-container">
+          <view class="flex-1" @click="visibleBeginTime[0] = true">
+            <view class="yd-search-form-date-range-picker">
+              {{ formatDate(formData.beginTime?.[0]) || '开始日期' }}
+            </view>
+          </view>
+          -
+          <view class="flex-1" @click="visibleBeginTime[1] = true">
+            <view class="yd-search-form-date-range-picker">
+              {{ formatDate(formData.beginTime?.[1]) || '结束日期' }}
+            </view>
+          </view>
+        </view>
+        <wd-datetime-picker-view v-if="visibleBeginTime[0]" v-model="tempBeginTime[0]" type="date" />
+        <view v-if="visibleBeginTime[0]" class="yd-search-form-date-range-actions">
+          <wd-button size="small" plain @click="visibleBeginTime[0] = false">
+            取消
+          </wd-button>
+          <wd-button size="small" type="primary" @click="handleBeginTime0Confirm">
+            确定
+          </wd-button>
+        </view>
+        <wd-datetime-picker-view v-if="visibleBeginTime[1]" v-model="tempBeginTime[1]" type="date" />
+        <view v-if="visibleBeginTime[1]" class="yd-search-form-date-range-actions">
+          <wd-button size="small" plain @click="visibleBeginTime[1] = false">
+            取消
+          </wd-button>
+          <wd-button size="small" type="primary" @click="handleBeginTime1Confirm">
+            确定
+          </wd-button>
+        </view>
+      </view>
+      <view class="yd-search-form-actions">
+        <wd-button class="flex-1" plain @click="handleReset">
+          重置
+        </wd-button>
+        <wd-button class="flex-1" type="primary" @click="handleSearch">
+          搜索
+        </wd-button>
+      </view>
+    </view>
+  </wd-popup>
+</template>
+
+<script lang="ts" setup>
+import { computed, reactive, ref } from 'vue'
+import { getDictLabel, getIntDictOptions } from '@/hooks/useDict'
+import { getNavbarHeight } from '@/utils'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDate, formatDateRange } from '@/utils/date'
+
+const emit = defineEmits<{
+  search: [data: Record<string, any>]
+  reset: []
+}>()
+
+const visible = ref(false)
+const formData = reactive({
+  jobId: undefined as string | undefined,
+  handlerName: undefined as string | undefined,
+  status: -1, // -1 表示全部
+  beginTime: [undefined, undefined] as [number | undefined, number | undefined],
+})
+
+/** 搜索条件 placeholder 拼接 */
+const placeholder = computed(() => {
+  const conditions: string[] = []
+  if (formData.jobId) {
+    conditions.push(`任务编号:${formData.jobId}`)
+  }
+  if (formData.handlerName) {
+    conditions.push(`处理器:${formData.handlerName}`)
+  }
+  if (formData.status !== -1) {
+    conditions.push(`状态:${getDictLabel(DICT_TYPE.INFRA_JOB_LOG_STATUS, formData.status)}`)
+  }
+  if (formData.beginTime?.[0] && formData.beginTime?.[1]) {
+    conditions.push(`时间:${formatDate(formData.beginTime[0])}~${formatDate(formData.beginTime[1])}`)
+  }
+  return conditions.length > 0 ? conditions.join(' | ') : '搜索调度日志'
+})
+
+// 时间范围选择器状态
+const visibleBeginTime = ref<[boolean, boolean]>([false, false])
+const tempBeginTime = ref<[number, number]>([Date.now(), Date.now()])
+
+/** 开始时间[0]确认 */
+function handleBeginTime0Confirm() {
+  formData.beginTime = [tempBeginTime.value[0], formData.beginTime?.[1]]
+  visibleBeginTime.value[0] = false
+}
+
+/** 开始时间[1]确认 */
+function handleBeginTime1Confirm() {
+  formData.beginTime = [formData.beginTime?.[0], tempBeginTime.value[1]]
+  visibleBeginTime.value[1] = false
+}
+
+/** 搜索 */
+function handleSearch() {
+  visible.value = false
+  emit('search', {
+    jobId: formData.jobId || undefined,
+    handlerName: formData.handlerName || undefined,
+    status: formData.status === -1 ? undefined : formData.status,
+    beginTime: formatDateRange(formData.beginTime),
+  })
+}
+
+/** 重置 */
+function handleReset() {
+  formData.jobId = undefined
+  formData.handlerName = undefined
+  formData.status = -1
+  formData.beginTime = [undefined, undefined]
+  visible.value = false
+  emit('reset')
+}
+</script>

+ 52 - 0
src/pages-infra/job/index.vue

@@ -0,0 +1,52 @@
+<template>
+  <view class="yd-page-container">
+    <!-- 顶部导航栏 -->
+    <wd-navbar
+      title="定时任务"
+      left-arrow placeholder safe-area-inset-top fixed
+      @click-left="handleBack"
+    />
+
+    <!-- Tab 切换 -->
+    <view class="bg-white">
+      <wd-tabs v-model="tabIndex" shrink @change="handleTabChange">
+        <wd-tab title="定时任务" />
+        <wd-tab title="调度日志" />
+      </wd-tabs>
+    </view>
+    <!-- 列表内容 -->
+    <JobList v-show="tabType === 'job'" />
+    <LogList v-show="tabType === 'log'" />
+  </view>
+</template>
+
+<script lang="ts" setup>
+import { computed, ref } from 'vue'
+import { navigateBackPlus } from '@/utils'
+import JobList from './components/job-list.vue'
+import LogList from './components/log-list.vue'
+
+definePage({
+  style: {
+    navigationBarTitleText: '',
+    navigationStyle: 'custom',
+  },
+})
+
+const tabTypes: string[] = ['job', 'log']
+const tabIndex = ref(0)
+const tabType = computed<string>(() => tabTypes[tabIndex.value])
+
+/** Tab 切换 */
+function handleTabChange({ index }: { index: number }) {
+  tabIndex.value = index
+}
+
+/** 返回上一页 */
+function handleBack() {
+  navigateBackPlus()
+}
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 162 - 0
src/pages-infra/job/job/detail/index.vue

@@ -0,0 +1,162 @@
+<template>
+  <view class="yd-page-container">
+    <!-- 顶部导航栏 -->
+    <wd-navbar
+      title="定时任务详情"
+      left-arrow placeholder safe-area-inset-top fixed
+      @click-left="handleBack"
+    />
+
+    <!-- 详情内容 -->
+    <view>
+      <wd-cell-group border>
+        <wd-cell title="任务编号" :value="String(formData?.id ?? '-')" />
+        <wd-cell title="任务名称" :value="String(formData?.name ?? '-')" />
+        <wd-cell title="任务状态">
+          <dict-tag :type="DICT_TYPE.INFRA_JOB_STATUS" :value="formData?.status" />
+        </wd-cell>
+        <wd-cell title="处理器名称" :value="String(formData?.handlerName ?? '-')" />
+        <wd-cell title="处理器参数" :value="String(formData?.handlerParam ?? '-')" />
+        <wd-cell title="CRON 表达式" :value="String(formData?.cronExpression ?? '-')" />
+        <wd-cell title="重试次数" :value="String(formData?.retryCount ?? '-')" />
+        <wd-cell title="重试间隔" :value="formData?.retryInterval ? `${formData.retryInterval} ms` : '-'" />
+        <wd-cell title="监控超时" :value="formData?.monitorTimeout ? `${formData.monitorTimeout} ms` : '-'" />
+        <wd-cell title="创建时间" :value="formatDateTime(formData?.createTime) || '-'" />
+      </wd-cell-group>
+    </view>
+
+    <!-- 底部操作按钮 -->
+    <view class="fixed bottom-0 left-0 right-0 bg-white p-24rpx">
+      <view class="w-full flex gap-24rpx">
+        <wd-button
+          v-if="hasAccessByCodes(['infra:job:trigger'])"
+          class="flex-1" type="success" :loading="running" @click="handleRun"
+        >
+          执行一次
+        </wd-button>
+        <wd-button
+          v-if="hasAccessByCodes(['infra:job:update'])"
+          class="flex-1" type="warning" @click="handleEdit"
+        >
+          编辑
+        </wd-button>
+        <wd-button
+          v-if="hasAccessByCodes(['infra:job:delete'])"
+          class="flex-1" type="error" :loading="deleting" @click="handleDelete"
+        >
+          删除
+        </wd-button>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { Job } from '@/api/infra/job'
+import { onMounted, ref } from 'vue'
+import { useToast } from 'wot-design-uni'
+import { deleteJob, getJob, runJob } from '@/api/infra/job'
+import { useAccess } from '@/hooks/useAccess'
+import { navigateBackPlus } from '@/utils'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDateTime } from '@/utils/date'
+
+const props = defineProps<{
+  id?: number | any
+}>()
+
+definePage({
+  style: {
+    navigationBarTitleText: '',
+    navigationStyle: 'custom',
+  },
+})
+
+const { hasAccessByCodes } = useAccess()
+const toast = useToast()
+const formData = ref<Job>()
+const deleting = ref(false)
+const running = ref(false)
+
+/** 返回上一页 */
+function handleBack() {
+  navigateBackPlus('/pages-system/job/index')
+}
+
+/** 加载详情 */
+async function getDetail() {
+  if (!props.id) {
+    return
+  }
+  try {
+    toast.loading('加载中...')
+    formData.value = await getJob(props.id)
+  } finally {
+    toast.close()
+  }
+}
+
+/** 执行一次 */
+function handleRun() {
+  if (!props.id) {
+    return
+  }
+  uni.showModal({
+    title: '提示',
+    content: '确定要立即执行一次该任务吗?',
+    success: async (res) => {
+      if (!res.confirm) {
+        return
+      }
+      running.value = true
+      try {
+        await runJob(props.id)
+        toast.success('执行成功')
+      } finally {
+        running.value = false
+      }
+    },
+  })
+}
+
+/** 编辑 */
+function handleEdit() {
+  uni.navigateTo({
+    url: `/pages-system/job/job/form/index?id=${props.id}`,
+  })
+}
+
+/** 删除 */
+function handleDelete() {
+  if (!props.id) {
+    return
+  }
+  uni.showModal({
+    title: '提示',
+    content: '确定要删除该定时任务吗?',
+    success: async (res) => {
+      if (!res.confirm) {
+        return
+      }
+      deleting.value = true
+      try {
+        await deleteJob(props.id)
+        toast.success('删除成功')
+        setTimeout(() => {
+          handleBack()
+        }, 500)
+      } finally {
+        deleting.value = false
+      }
+    },
+  })
+}
+
+/** 初始化 */
+onMounted(() => {
+  getDetail()
+})
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 176 - 0
src/pages-infra/job/job/form/index.vue

@@ -0,0 +1,176 @@
+<template>
+  <view class="yd-page-container">
+    <!-- 顶部导航栏 -->
+    <wd-navbar
+      :title="getTitle"
+      left-arrow placeholder safe-area-inset-top fixed
+      @click-left="handleBack"
+    />
+
+    <!-- 表单区域 -->
+    <view>
+      <wd-form ref="formRef" :model="formData" :rules="formRules">
+        <wd-cell-group border>
+          <wd-input
+            v-model="formData.name"
+            label="任务名称"
+            label-width="200rpx"
+            prop="name"
+            clearable
+            placeholder="请输入任务名称"
+          />
+          <wd-input
+            v-model="formData.handlerName"
+            label="处理器名称"
+            label-width="200rpx"
+            prop="handlerName"
+            clearable
+            placeholder="请输入处理器名称"
+          />
+          <wd-input
+            v-model="formData.handlerParam"
+            label="处理器参数"
+            label-width="200rpx"
+            prop="handlerParam"
+            clearable
+            placeholder="请输入处理器参数"
+          />
+          <wd-input
+            v-model="formData.cronExpression"
+            label="CRON 表达式"
+            label-width="200rpx"
+            prop="cronExpression"
+            clearable
+            placeholder="请输入 CRON 表达式"
+          />
+          <wd-input
+            v-model.number="formData.retryCount"
+            label="重试次数"
+            label-width="200rpx"
+            prop="retryCount"
+            type="number"
+            clearable
+            placeholder="请输入重试次数"
+          />
+          <wd-input
+            v-model.number="formData.retryInterval"
+            label="重试间隔(ms)"
+            label-width="200rpx"
+            prop="retryInterval"
+            type="number"
+            clearable
+            placeholder="请输入重试间隔"
+          />
+          <wd-input
+            v-model.number="formData.monitorTimeout"
+            label="监控超时(ms)"
+            label-width="200rpx"
+            prop="monitorTimeout"
+            type="number"
+            clearable
+            placeholder="请输入监控超时时间"
+          />
+        </wd-cell-group>
+      </wd-form>
+    </view>
+
+    <!-- 底部保存按钮 -->
+    <view class="fixed bottom-0 left-0 right-0 bg-white p-24rpx">
+      <wd-button
+        type="primary"
+        block
+        :loading="formLoading"
+        @click="handleSubmit"
+      >
+        保存
+      </wd-button>
+    </view>
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { Job } from '@/api/infra/job'
+import { computed, onMounted, ref } from 'vue'
+import { useToast } from 'wot-design-uni'
+import { createJob, getJob, updateJob } from '@/api/infra/job'
+import { navigateBackPlus } from '@/utils'
+
+const props = defineProps<{
+  id?: number | any
+}>()
+
+definePage({
+  style: {
+    navigationBarTitleText: '',
+    navigationStyle: 'custom',
+  },
+})
+
+const toast = useToast()
+const getTitle = computed(() => props.id ? '编辑定时任务' : '新增定时任务')
+const formLoading = ref(false)
+const formData = ref<Job>({
+  id: undefined,
+  name: '',
+  status: 0,
+  handlerName: '',
+  handlerParam: '',
+  cronExpression: '',
+  retryCount: 0,
+  retryInterval: 0,
+  monitorTimeout: 0,
+})
+const formRules = {
+  name: [{ required: true, message: '任务名称不能为空' }],
+  handlerName: [{ required: true, message: '处理器名称不能为空' }],
+  cronExpression: [{ required: true, message: 'CRON 表达式不能为空' }],
+  retryCount: [{ required: true, message: '重试次数不能为空' }],
+  retryInterval: [{ required: true, message: '重试间隔不能为空' }],
+}
+const formRef = ref()
+
+/** 返回上一页 */
+function handleBack() {
+  navigateBackPlus('/pages-system/job/index')
+}
+
+/** 加载详情 */
+async function getDetail() {
+  if (!props.id) {
+    return
+  }
+  formData.value = await getJob(props.id)
+}
+
+/** 提交表单 */
+async function handleSubmit() {
+  const { valid } = await formRef.value.validate()
+  if (!valid) {
+    return
+  }
+
+  formLoading.value = true
+  try {
+    if (props.id) {
+      await updateJob(formData.value)
+      toast.success('修改成功')
+    } else {
+      await createJob(formData.value)
+      toast.success('新增成功')
+    }
+    setTimeout(() => {
+      handleBack()
+    }, 500)
+  } finally {
+    formLoading.value = false
+  }
+}
+
+/** 初始化 */
+onMounted(() => {
+  getDetail()
+})
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 80 - 0
src/pages-infra/job/log/detail/index.vue

@@ -0,0 +1,80 @@
+<template>
+  <view class="yd-page-container">
+    <!-- 顶部导航栏 -->
+    <wd-navbar
+      title="调度日志详情"
+      left-arrow placeholder safe-area-inset-top fixed
+      @click-left="handleBack"
+    />
+
+    <!-- 详情内容 -->
+    <view>
+      <wd-cell-group border>
+        <wd-cell title="日志编号" :value="String(formData?.id ?? '-')" />
+        <wd-cell title="任务编号" :value="String(formData?.jobId ?? '-')" />
+        <wd-cell title="处理器名称" :value="String(formData?.handlerName ?? '-')" />
+        <wd-cell title="处理器参数" :value="String(formData?.handlerParam ?? '-')" />
+        <wd-cell title="CRON 表达式" :value="String(formData?.cronExpression ?? '-')" />
+        <wd-cell title="执行索引" :value="String(formData?.executeIndex ?? '-')" />
+        <wd-cell title="执行状态">
+          <dict-tag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="formData?.status" />
+        </wd-cell>
+        <wd-cell title="开始时间" :value="formatDateTime(formData?.beginTime) || '-'" />
+        <wd-cell title="结束时间" :value="formatDateTime(formData?.endTime) || '-'" />
+        <wd-cell title="执行时长" :value="formData?.duration ? `${formData.duration} ms` : '-'" />
+        <wd-cell title="执行结果" :value="String(formData?.result ?? '-')" />
+        <wd-cell title="创建时间" :value="formatDateTime(formData?.createTime) || '-'" />
+      </wd-cell-group>
+    </view>
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { JobLog } from '@/api/infra/job/log'
+import { onMounted, ref } from 'vue'
+import { useToast } from 'wot-design-uni'
+import { getJobLog } from '@/api/infra/job/log'
+import { navigateBackPlus } from '@/utils'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDateTime } from '@/utils/date'
+
+const props = defineProps<{
+  id?: number | any
+}>()
+
+definePage({
+  style: {
+    navigationBarTitleText: '',
+    navigationStyle: 'custom',
+  },
+})
+
+const toast = useToast()
+const formData = ref<JobLog>()
+
+/** 返回上一页 */
+function handleBack() {
+  navigateBackPlus('/pages-system/job/index')
+}
+
+/** 加载详情 */
+async function getDetail() {
+  if (!props.id) {
+    return
+  }
+  try {
+    toast.loading('加载中...')
+    formData.value = await getJobLog(Number(props.id))
+  } finally {
+    toast.close()
+  }
+}
+
+/** 初始化 */
+onMounted(() => {
+  getDetail()
+})
+</script>
+
+<style lang="scss" scoped>
+</style>