From 73c154cba6f95745bdfde79508b7e624f083f838 Mon Sep 17 00:00:00 2001
From: liriming <1343021927@qq.com>
Date: 星期一, 14 十月 2024 14:15:08 +0800
Subject: [PATCH] 定时任务修改

---
 src/views/energy/job/index.vue |  222 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 222 insertions(+), 0 deletions(-)

diff --git a/src/views/energy/job/index.vue b/src/views/energy/job/index.vue
new file mode 100644
index 0000000..59f38b7
--- /dev/null
+++ b/src/views/energy/job/index.vue
@@ -0,0 +1,222 @@
+<template>
+  <!-- 搜索 -->
+  <ContentWrap>
+    <el-form
+      class="-mb-15px"
+      :model="queryParams"
+      ref="queryFormRef"
+      :inline="true"
+      label-width="80px"
+    >
+      <el-form-item label="bean名称" prop="beanName">
+        <el-input
+          v-model="queryParams.beanName"
+          placeholder="请输入bean名称"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="handleQuery">
+          <Icon icon="ep:search" class="mr-5px" />
+          搜索
+        </el-button>
+        <el-button @click="resetQuery">
+          <Icon icon="ep:refresh" class="mr-5px" />
+          重置
+        </el-button>
+        <el-button
+          type="primary"
+          plain
+          @click="openForm('create')"
+          v-hasPermi="['shasteel:schedule:create']"
+        >
+          <Icon icon="ep:plus" class="mr-5px" />
+          新增
+        </el-button>
+      </el-form-item>
+    </el-form>
+  </ContentWrap>
+
+  <!-- 列表 -->
+  <ContentWrap>
+    <el-table v-loading="loading" :data="list">
+      <el-table-column label="bean名称" align="center" prop="beanName" />
+      <el-table-column label="参数" align="center" prop="params" />
+      <el-table-column label="cron表达式" align="center" prop="cronExpression" />
+      <el-table-column label="备注" align="center" prop="remark" />
+      <el-table-column label="状态" align="center" prop="status" >
+        <template #default="scope">
+          <el-tag v-if="scope.row.status === 1" size="small">正常</el-tag>
+          <el-tag v-else size="small" type="danger">暂停</el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" min-width="110" fixed="right">
+        <template #default="scope">
+          <el-button
+            link
+            type="primary"
+            @click="openForm('update', scope.row.id)"
+            v-hasPermi="['shasteel:schedule:update']"
+          >
+            编辑
+          </el-button>
+          <el-button
+            link
+            type="danger"
+            @click="handleDelete(scope.row.id)"
+            v-hasPermi="['shasteel:schedule:delete']"
+          >
+            删除
+          </el-button>
+          <el-button
+            link
+            type="primary"
+            @click="handlePause(scope.row.id)"
+          >
+            暂停
+          </el-button>
+          <el-button
+            link
+            type="primary"
+            @click="handleResume(scope.row.id)"
+          >
+            恢复
+          </el-button>
+          <el-button
+            link
+            type="primary"
+            @click="handleRun(scope.row.id)"
+          >
+            执行
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 分页 -->
+    <Pagination
+      :total="total"
+      v-model:page="queryParams.pageNo"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </ContentWrap>
+
+  <!-- 表单弹窗:添加/修改 -->
+  <ScheduleJobForm ref="formRef" @success="getList" />
+
+</template>
+<script lang="ts" setup>
+import * as ScheduleJobApi from '@/api/job'
+import ScheduleJobForm from './ScheduleJobForm.vue'
+
+defineOptions({name: 'DataSchedule'})
+
+  const message = useMessage() // 消息弹窗
+  const {t} = useI18n() // 国际化
+
+  const loading = ref(true) // 列表的加载中
+  const total = ref(0) // 列表的总页数
+  const list = ref([]) // 列表的数据
+  const queryParams = reactive({
+    pageNo: 1,
+    pageSize: 10,
+    name: undefined,
+    address: undefined
+  })
+  const queryFormRef = ref() // 搜索的表单
+  const exportLoading = ref(false) // 导出的加载中
+
+  /** 查询列表 */
+  const getList = async () => {
+    loading.value = true
+    try {
+      debugger
+      const page = await ScheduleJobApi.getScheduleJobPage(queryParams)
+      list.value = page.list
+      total.value = page.total
+    } finally {
+      loading.value = false
+    }
+  }
+
+  /** 搜索按钮操作 */
+  const handleQuery = () => {
+    queryParams.pageNo = 1
+    getList()
+  }
+
+  /** 重置按钮操作 */
+  const resetQuery = () => {
+    queryFormRef.value.resetFields()
+    handleQuery()
+  }
+
+  /** 添加/修改操作 */
+  const formRef = ref()
+  const openForm = (type: string, id?: number) => {
+    formRef.value.open(type, id)
+  }
+
+  /** 删除按钮操作 */
+  const handleDelete = async (id: number) => {
+    try {
+      // 删除的二次确认
+      await message.delConfirm()
+      // 发起删除
+      await ScheduleJobApi.deleteScheduleJob(id)
+      message.success(t('common.delSuccess'))
+      // 刷新列表
+      await getList()
+    } catch {
+    }
+  }
+
+  /** 暂停按钮操作 */
+  const handlePause = async (id: number) => {
+    try {
+      // 暂停的二次确认
+      await message.confirm('确认暂停?', '暂停定时')
+      // 发起暂停
+      await ScheduleJobApi.pauseScheduleJob(id)
+      message.success('暂停成功')
+      // 刷新列表
+      await getList()
+    } catch {
+    }
+  }
+
+  /** 恢复按钮操作 */
+  const handleResume = async (id: number) => {
+    try {
+      // 恢复的二次确认
+      await message.confirm('确认恢复?', '恢复定时')
+      // 发起恢复
+      await ScheduleJobApi.resumeScheduleJob(id)
+      message.success('恢复成功')
+      // 刷新列表
+      await getList()
+    } catch {
+    }
+  }
+
+  /** 执行按钮操作 */
+  const handleRun = async (id: number) => {
+    try {
+      // 执行的二次确认
+      await message.confirm('确认执行?', '执行定时')
+      // 发起执行
+      await ScheduleJobApi.runScheduleJob(id)
+      message.success('执行成功')
+      // 刷新列表
+      await getList()
+    } catch {
+    }
+  }
+
+  /** 初始化 **/
+  onMounted(async () => {
+    await getList()
+  })
+</script>

--
Gitblit v1.9.3