index.vue 7.63 KB
<template>
  <div class="from-clues">
    <div class="from-clues-header">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item v-if="BASE_API.THEME == 'jg'">
          <Breadcrumb />
        </el-form-item>
        <el-row class="mb-5">
          <el-col :span="6">
            <el-form-item label="搜索标题">
              <el-input v-model="form.jobName" placeholder="标题"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="18" class="btnColRight">
            <btn nativeType="cx" @click="handleSubmit">查询</btn>
            <btn nativeType="cx" @click="resetSe">重置</btn>
            <btn nativeType="cx" @click="handleAdd">新增</btn>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="from-clues-content">
      <lb-table :page-size="pageData.size" :current-page.sync="pageData.current" :total="tableData.total"
        @size-change="handleSizeChange" @p-current-change="handleCurrentChange" :column="tableData.columns"
        :data="tableData.data">
      </lb-table>
      <add-task ref="task" :taskData="taskData" v-model="isDialog" />
    </div>
  </div>
</template>
<script>
  // 定时任务
  import data from "./data"
  import sjsbTask from '@/api/sjsbTask.js'
  import tableMixin from '@/mixins/tableMixin.js'
  import addTask from '../components/addTask.vue'
  export default {
    name: "timedTask",
    mixins: [tableMixin],
    components: {
      addTask
    },
    data () {
      return {
        taskData: null,
        isDialog: false,
        form: {
          jobName: '',
          currentPage: 1
        },
        selectionList: [],
        // 表格数据
        tableData: {
          columns: [{
            label: '序号',
            type: 'index',
            width: '50',
            index: this.indexMethod,
          }].concat(data.columns()).concat([
            {
              label: "操作",
              width: 230,
              render: (h, scope) => {
                return (
                  <div>
                    <el-button type="text"
                      size="mini"
                      v-show={scope.row.jobStatus === 0}
                      class='btnColor'
                      onClick={() => { this.handleActive(scope.row) }}>激活
                    </el-button>
                    <el-button type="text"
                      size="mini"
                      v-show={scope.row.jobStatus === -1}
                      class='btnColor'
                      onClick={() => { this.recover(scope.row) }}>恢复
                    </el-button>
                    <el-button type="text"
                      size="mini"
                      class='successColor'
                      onClick={() => { this.handleEdit(scope.row) }}>编辑
                    </el-button>
                    <el-button type="text"
                      size="mini"
                      class='successColor'
                      v-show={scope.row.jobStatus !== -1}
                      onClick={() => { this.handleDel(scope.row) }}>删除
                    </el-button>
                  </div>
                );
              },
            },
          ]),
          data: [],
          total: 0
        },
        // 分页
        pageData: {

          pageSize: 15,
          current: 1,
        }
      }
    },
    methods: {
      handleAdd () {
        this.taskData = null
        this.isDialog = true
      },
      resetSe () {
        this.form.jobName = ''
        this.featchData()
      },
      async featchData () {
        try {
          this.form = Object.assign(this.form, this.formData)
          let { result } = await sjsbTask.getTaskListByName(this.form)
          this.tableData.data = result.list
          this.tableData.total = result.total
        } catch (error) {
          this.message = error
        }
      },
      recover (row) {
        this.$confirm('此操将进行恢复操作, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            sjsbTask.recover(row.jobId)
              .then((res) => {
                if ((res.code = 200)) {
                  this.$message({
                    type: 'success',
                    message: res.message,
                  })
                  this.featchData()
                }
              })
              .catch((error) => {
                this.$alert(error, '提示', {
                  confirmButtonText: '确定',
                  type: 'error'
                })
              })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消',
            })
          })
      },

      handleActive (row) {
        this.$confirm('此操将进行激活操作, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            sjsbTask.active(row.jobId)
              .then((res) => {
                if ((res.code = 200)) {
                  this.$message({
                    type: 'success',
                    message: res.message,
                  })
                  this.featchData()
                }
              })
              .catch((error) => {
                this.$alert(error, '提示', {
                  confirmButtonText: '确定',
                  type: 'error'
                })
              })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消',
            })
          })
      },
      // 暂停
      handleSuspend (row) {
        this.$confirm('此操将进行暂停操作, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            sjsbTask.pauseJob(row.id)
              .then((res) => {
                if ((res.code = 200)) {
                  this.$message({
                    type: 'success',
                    message: res.message,
                  })
                  this.featchData()
                }
              })
              .catch((error) => {
                this.$alert(error, '提示', {
                  confirmButtonText: '确定',
                  type: 'error'
                })
              })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消',
            })
          })
      },
      handleEdit (row) {
        this.taskData = row
        this.isDialog = true
      },
      handleDel (row) {
        this.$confirm('此操将进行删除操作, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            sjsbTask.sjsbTaskRemove(row.jobId)
              .then((res) => {
                if ((res.code = 200)) {
                  this.$message({
                    type: 'success',
                    message: res.message,
                  })
                  this.featchData()
                }
              })
              .catch((error) => {
                this.$alert(error, '提示', {
                  confirmButtonText: '确定',
                  type: 'error'
                })
              })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消',
            })
          })
      }
    }
  }
</script>
<style scoped lang="scss">
  // @import "~@/styles/mixin.scss";
</style>