Просмотр исходного кода

2024.03.30
- 对接定时任务相关接口;

zweiqin 1 год назад
Родитель
Сommit
2fa24892f4

+ 73 - 0
src/api/timedTasksManagement/timedTasksList.js

@@ -0,0 +1,73 @@
+import request from '@/utils/request'
+
+// 分页查询定时任务
+export function getPageQuartzJob(params) {
+  return request({
+    url: '/quartzJob/page',
+    method: 'get',
+    params
+  })
+}
+
+// 查询定时任务
+export function getIdQuartzJob(params) {
+  return request({
+    url: `/quartzJob/${params.id}`,
+    method: 'get',
+    params
+  })
+}
+
+// 新增定时任务
+export function saveQuartzJob(data) {
+  return request({
+    url: '/quartzJob/save',
+    method: 'post',
+    data
+  })
+}
+
+// 修改定时任务
+export function updateQuartzJob(data) {
+  return request({
+    url: '/quartzJob/update',
+    method: 'post',
+    data
+  })
+}
+
+// 删除定时任务
+export function deleteQuartzJob(params) {
+  return request({
+    url: '/quartzJob/delete',
+    method: 'delete',
+    params
+  })
+}
+
+// 立即执行任务
+export function updateRunQuartzJob(params) {
+  return request({
+    url: '/quartzJob/run',
+    method: 'get',
+    params
+  })
+}
+
+// 暂停定时任务
+export function updatePauseQuartzJob(data) {
+  return request({
+    url: '/quartzJob/pause',
+    method: 'post',
+    data
+  })
+}
+
+// 恢复定时任务
+export function updateResumeQuartzJob(data) {
+  return request({
+    url: '/quartzJob/resume',
+    method: 'post',
+    data
+  })
+}

+ 0 - 1
src/views/relationshipChainManagement/relationshipLevel/index.vue

@@ -87,7 +87,6 @@
       :title="dialogStatus === 'create' ? '新增会员等级' : '修改会员等级'" :visible.sync="dialogFormVisible" width="800px" center
       :close-on-click-modal="false"
     >
-    <!-- ref能tm写错,你是真nb zwq -->
       <div>
         <el-form ref="dataForm" :model="formData" label-width="140px" :rules="rules">
           <el-form-item label="等级名称" prop="levelName">

+ 27 - 0
src/views/setup/siteTemplateList/index.vue

@@ -0,0 +1,27 @@
+<template>
+  <div class="app-container">
+    <!-- 分页查询站内信模板表 -->
+  </div>
+</template>
+
+<script>
+
+export default {
+  name: 'SiteTemplateList',
+  components: {
+  },
+  data() {
+    return {
+    }
+  },
+  computed: {
+  },
+  created() {
+  },
+  methods: {
+  }
+}
+</script>
+
+<style lang="less" scoped>
+</style>

+ 112 - 0
src/views/setup/timedTasksList/components/DetailModal.vue

@@ -0,0 +1,112 @@
+<template>
+  <el-dialog
+    :visible.sync="visible"
+    v-bind="modalOptions"
+  >
+    <el-form
+      ref="formData"
+      :model="formData"
+      size="mini"
+      label-position="left"
+      label-suffix=":"
+      label-width="200px"
+    >
+      <!-- 定时任务信息 -->
+      <el-form-item label="ID" prop="jobId">
+        {{ formData.jobId || '--' }}
+      </el-form-item>
+      <el-form-item label="定时器名称" prop="jobName">
+        {{ formData.jobName || '--' }}
+      </el-form-item>
+      <el-form-item label="spring bean 名称" prop="beanName">
+        {{ formData.beanName || '--' }}
+      </el-form-item>
+      <el-form-item label="方法名" prop="methodName">
+        {{ formData.methodName || '--' }}
+      </el-form-item>
+      <el-form-item label="参数" prop="params">
+        {{ formData.params || '--' }}
+      </el-form-item>
+      <el-form-item label="cron表达式" prop="cronExpression">
+        {{ formData.cronExpression || '--' }}
+      </el-form-item>
+      <el-form-item label="任务状态" prop="status">
+        <span v-if="formData.status === 0">正常</span>
+        <span v-else-if="formData.status === 1">暂停</span>
+        <span v-else>--</span>
+      </el-form-item>
+      <el-form-item label="任务类型" prop="taskType">
+        {{ formData.taskType || '--' }}
+      </el-form-item>
+      <el-form-item label="备注" prop="remark">
+        {{ formData.remark || '--' }}
+      </el-form-item>
+      <el-form-item label="创建时间" prop="createTime">
+        {{ formData.createTime || '--' }}
+      </el-form-item>
+    </el-form>
+  </el-dialog>
+</template>
+
+<script>
+import { getIdQuartzJob } from '@/api/timedTasksManagement/timedTasksList'
+
+export default {
+  name: 'DetailModal',
+  data() {
+    return {
+      modalOptions: {
+        closeOnClickModal: false,
+        width: '800px',
+        title: '查看定时任务详情'
+      },
+      visible: false,
+      formData: {
+        jobId: '',
+        jobName: '',
+        beanName: '',
+        methodName: '',
+        params: '',
+        cronExpression: '',
+        status: '',
+        taskType: '',
+        remark: '',
+        createTime: ''
+      }
+    }
+  },
+  methods: {
+    handleClose() {
+      this.visible = false
+    },
+    handleOpen(params = {}) {
+      this.formData = Object.assign(this.$options.data().formData, params)
+      if (params.jobId) {
+        this.getInfo(params.jobId)
+      }
+      this.visible = true
+    },
+    async getInfo(id) {
+      const loading = this.$loading({ text: '加载中' })
+      try {
+        const res = await getIdQuartzJob({ id })
+        this.formData = Object.assign(this.$options.data().formData, res.data, {
+          jobId: res.data.jobId || '',
+          jobName: res.data.jobName || '',
+          beanName: res.data.beanName || '',
+          methodName: res.data.methodName || '',
+          params: res.data.params || '',
+          cronExpression: res.data.cronExpression || '',
+          status: res.data.status,
+          taskType: res.data.taskType || '',
+          remark: res.data.remark || '',
+          createTime: res.data.createTime || ''
+        })
+      } finally {
+        loading.close()
+      }
+    }
+  }
+}
+</script>
+

+ 172 - 0
src/views/setup/timedTasksList/components/EditModal.vue

@@ -0,0 +1,172 @@
+<template>
+  <el-dialog
+    :visible.sync="visible"
+    v-bind="modalOptions"
+  >
+    <el-form
+      ref="formData"
+      :model="formData"
+      :rules="formRules"
+      size="mini"
+      label-suffix=":"
+      label-width="150px"
+    >
+      <el-form-item label="定时器名称" prop="jobName">
+        <el-input v-model="formData.jobName" placeholder="请输入定时器名称" maxlength="30" show-word-limit />
+      </el-form-item>
+      <el-form-item label="spring bean 名称" prop="beanName">
+        <el-input v-model="formData.beanName" placeholder="请输入 spring bean 名称" maxlength="30" show-word-limit />
+      </el-form-item>
+      <el-form-item label="方法名" prop="methodName">
+        <el-input v-model="formData.methodName" placeholder="请输入方法名" maxlength="30" show-word-limit />
+      </el-form-item>
+      <el-form-item label="参数" prop="params">
+        <el-input v-model="formData.params" placeholder="请输入参数" />
+      </el-form-item>
+      <el-form-item label="cron表达式" prop="cronExpression">
+        <el-input v-model="formData.cronExpression" placeholder="请输入cron表达式" />
+      </el-form-item>
+      <el-form-item label="任务状态" prop="status">
+        <el-select v-model="formData.status" size="mini" placeholder="请选择任务状态">
+          <el-option label="正常" :value="0" />
+          <el-option label="暂停" :value="1" />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="任务类型" prop="taskType">
+        <el-input v-model="formData.taskType" placeholder="请输入任务类型" />
+      </el-form-item>
+      <el-form-item label="备注" prop="remark">
+        <el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" maxlength="520" :rows="3" show-word-limit />
+      </el-form-item>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button size="mini" @click="handleClose">取 消</el-button>
+      <el-button type="primary" size="mini" @click="handleSubmit">确 定</el-button>
+    </span>
+  </el-dialog>
+</template>
+
+<script>
+import { saveQuartzJob, updateQuartzJob, getIdQuartzJob } from '@/api/timedTasksManagement/timedTasksList'
+
+export default {
+  name: 'EditModal',
+  components: {
+  },
+  data() {
+    return {
+      modalOptions: {
+        closeOnClickModal: false,
+        width: '820px',
+        title: ''
+      },
+      visible: false,
+      formData: {
+        jobId: '',
+        jobName: '',
+        beanName: '',
+        methodName: '',
+        params: '',
+        cronExpression: '',
+        status: '',
+        taskType: '',
+        remark: '',
+        createTime: ''
+      },
+      formRules: {
+        jobName: [
+          { required: true, message: '请输入定时器名称' }
+        ],
+        beanName: [
+          { required: true, message: '请输入 spring bean 名称' }
+        ],
+        methodName: [
+          { required: true, message: '请输入方法名' }
+        ],
+        params: [
+          { required: false, message: '请输入参数' }
+        ],
+        cronExpression: [
+          { required: false, message: '请输入cron表达式' }
+        ],
+        status: [
+          { required: true, message: '请选择任务状态' }
+        ],
+        taskType: [
+          { required: false, message: '请输入任务类型' }
+        ],
+        remark: [
+          { required: false, message: '请输入备注' }
+        ]
+      }
+    }
+  },
+  methods: {
+    handleClose() {
+      this.visible = false
+    },
+    initList() {
+    },
+    handleOpen(params = {}) {
+      this.modalOptions.title = params.jobId ? '编辑定时任务' : '添加定时任务'
+      this.visible = true
+      this.initList()
+      if (params.jobId) {
+        this.getInfo(params.jobId)
+      } else {
+        this.$refs.formData && this.$refs.formData.resetFields()
+      }
+    },
+    async getInfo(id) {
+      const loading = this.$loading({ text: '加载中' })
+      try {
+        const res = await getIdQuartzJob({ id })
+        this.formData = Object.assign(this.$options.data().formData, res.data, {
+          jobId: res.data.jobId || '',
+          jobName: res.data.jobName || '',
+          beanName: res.data.beanName || '',
+          methodName: res.data.methodName || '',
+          params: res.data.params || '',
+          cronExpression: res.data.cronExpression || '',
+          status: res.data.status,
+          taskType: res.data.taskType || '',
+          remark: res.data.remark || '',
+          createTime: res.data.createTime || ''
+        })
+        this.$nextTick(() => {
+          this.$refs.formData && this.$refs.formData.validate()
+        })
+      } finally {
+        loading.close()
+      }
+    },
+    handleSubmit() {
+      this.$refs.formData.validate(async (valid) => {
+        if (valid) {
+          await this.$validatorForm('formData')
+          const loading = this.$elLoading()
+          try {
+            const { ...otps } = this.formData
+            const params = {
+              ...otps
+            }
+            this.formData.jobId ? await updateQuartzJob(params) : await saveQuartzJob(params)
+            loading.close()
+            this.$message({ message: `${this.formData.jobId ? '编辑' : '添加'}成功!`, type: 'success' })
+            this.$emit('success')
+            this.visible = false
+          } catch (e) {
+            loading.close()
+          } finally {
+            loading.close()
+          }
+        } else {
+          this.$message({ message: '请输入相关信息', type: 'warning' })
+          return false
+        }
+      })
+    }
+  }
+}
+</script>
+

+ 173 - 0
src/views/setup/timedTasksList/index.vue

@@ -0,0 +1,173 @@
+<template>
+  <div class="app-container">
+    <!-- 查询和其他操作 -->
+    <div class="filter-container">
+      <el-input
+        v-model="listQuery.beanName" clearable class="filter-item" style="width: 200px;"
+        placeholder="请输入 spring bean 名称"
+      />
+      <el-button
+        size="mini" class="filter-item" type="primary" icon="el-icon-search"
+        style="margin-left:10px;"
+        @click="handleSearch"
+      >
+        查找
+      </el-button>
+      <br />
+      <el-button
+        size="mini" type="primary" icon="el-icon-plus"
+        @click="$refs.EditModal && $refs.EditModal.handleOpen({ jobId: '' })"
+      >
+        添加
+      </el-button>
+    </div>
+
+    <!-- 查询结果 -->
+    <div>
+      <el-table
+        v-loading="listLoading" height="100%" element-loading-text="正在查询中。。。" :data="list"
+        v-bind="{ stripe: true, size: 'small', border: true, fit: true, highlightCurrentRow: true }"
+      >
+        <el-table-column align="center" width="100" label="ID" prop="jobId" fixed="left" />
+        <el-table-column align="center" width="150" label="定时器名称" prop="jobName" fixed="left" show-overflow-tooltip />
+        <el-table-column align="center" width="150" label="spring bean 名称" prop="beanName" show-overflow-tooltip />
+        <el-table-column align="center" width="200" label="方法名" prop="methodName" show-overflow-tooltip />
+        <el-table-column align="center" width="150" label="参数" prop="params" show-overflow-tooltip />
+        <el-table-column align="center" min-width="150" label="cron表达式" prop="cronExpression" show-overflow-tooltip />
+        <el-table-column align="center" label="任务状态" prop="status">
+          <template slot-scope="{ row }">
+            <el-tag v-if="row.status == 0" effect="plain">正常</el-tag>
+            <el-tag v-else-if="row.status == 1" effect="plain" type="danger">暂停</el-tag>
+            <span v-else>--</span>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" width="150" label="任务类型" prop="taskType" />
+        <el-table-column align="center" width="150" label="备注" prop="remark" />
+        <el-table-column align="center" width="150" label="创建时间" prop="createTime" />
+        <el-table-column align="center" label="操作" width="300" fixed="right" class-name="small-padding fixed-width">
+          <template slot-scope="{ row }">
+            <el-button size="mini" @click="handleDetail(row)">
+              查看
+            </el-button>
+            <el-button :disabled="!(row.status == 0)" type="danger" size="mini" @click="handleRunJob(row)">
+              执行
+            </el-button>
+            <el-button :disabled="!(row.status == 0)" type="warning" size="mini" @click="handlePauseJob(row)">
+              暂停
+            </el-button>
+            <el-button :disabled="!(row.status == 1)" type="success" size="mini" @click="handleResumeJob(row)">
+              恢复
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+
+    <div>
+      <el-pagination
+        :current-page="listQuery.current" :page-sizes="[10, 20, 50, 100]" :page-size="10"
+        layout="total, sizes, prev, pager, next, jumper" :total="total"
+        @size-change="(val) => ((listQuery.size = val) && getList())"
+        @current-change="(val) => ((listQuery.current = val) && getList())"
+      />
+    </div>
+
+    <!-- 新增编辑 -->
+    <EditModal ref="EditModal" @success="getList" />
+    <!-- 查看详情 -->
+    <DetailModal ref="DetailModal" @success="getList" />
+  </div>
+</template>
+
+<script>
+import EditModal from './components/EditModal'
+import DetailModal from './components/DetailModal'
+import { getPageQuartzJob, updateRunQuartzJob, updatePauseQuartzJob, updateResumeQuartzJob } from '@/api/timedTasksManagement/timedTasksList'
+
+export default {
+  name: 'TimedTasksList',
+  components: {
+    EditModal,
+    DetailModal
+  },
+  data() {
+    return {
+      list: [],
+      total: 0,
+      listLoading: true,
+      listQuery: {
+        current: 1,
+        size: 20,
+        beanName: ''
+      }
+    }
+  },
+  created() {
+    this.getList()
+  },
+  methods: {
+    async getList() {
+      this.listLoading = true
+      try {
+        const res = await getPageQuartzJob(this.listQuery)
+        this.list = res.data.items
+        this.total = res.data.total
+      } finally {
+        this.listLoading = false
+      }
+    },
+    handleSearch() {
+      this.listQuery.current = 1
+      this.getList()
+    },
+    handleDetail(row) {
+      this.$refs.DetailModal && this.$refs.DetailModal.handleOpen(row)
+    },
+    handleRunJob(row) {
+      this.$confirm('确定执行此项?')
+        .then(async () => {
+          await updateRunQuartzJob({ jobIds: [ row.jobId ] })
+          this.$message({ message: '执行成功!', type: 'success' })
+          this.handleSearch()
+        })
+        .catch(() => {})
+    },
+    handlePauseJob(row) {
+      this.$confirm('确定暂停此项?')
+        .then(async () => {
+          await updatePauseQuartzJob({ jobIds: [ row.jobId ] })
+          this.$message({ message: '暂停成功!', type: 'success' })
+          this.handleSearch()
+        })
+        .catch(() => {})
+    },
+    handleResumeJob(row) {
+      this.$confirm('确定恢复此项?')
+        .then(async () => {
+          await updateResumeQuartzJob({ jobIds: [ row.jobId ] })
+          this.$message({ message: '恢复成功!', type: 'success' })
+          this.handleSearch()
+        })
+        .catch(() => {})
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+.app-container {
+	padding: 20px;
+	display: flex;
+	flex-direction: column;
+}
+
+.filter-container {
+	// padding-bottom: 10px;
+
+	.filter-item {
+		display: inline-block;
+		vertical-align: middle;
+		margin-bottom: 10px;
+	}
+}
+</style>

+ 2 - 2
vue.config.js

@@ -41,8 +41,8 @@ module.exports = {
     // before: require('./mock/mock-server.js'),
     proxy: {
       '/api': {
-        // target: 'https://nsadminapi.tuanfengkeji.cn', // 测试
-        target: 'http://192.168.0.91:9103', // 平台端
+        target: 'https://nsadminapi.tuanfengkeji.cn', // 测试
+        // target: 'http://192.168.0.91:9103', // 平台端
         // target: 'http://192.168.0.91:9003', // 商家端
         changeOrigin: true,
         pathRewrite: {