220 lines
7.4 KiB
Vue
220 lines
7.4 KiB
Vue
<template>
|
||
<div>
|
||
<h1 style="color: #00afff" align="center">发布任务</h1>
|
||
<el-form :inline="true" :model="formInline" class="demo-form-inline">
|
||
<el-form-item label="任务名称">
|
||
<el-input v-model="formInline.name" placeholder="请输入任务名称"></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="任务权重">
|
||
<el-select v-model="formInline.weight" placeholder="任务权重">
|
||
<el-option label="紧急" value="1"></el-option>
|
||
<el-option label="正常" value="2"></el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
|
||
<el-form-item label="任务执行状态">
|
||
<el-select v-model="formInline.processStatus" placeholder="任务执行状态">
|
||
<el-option label="待执行" value="1"></el-option>
|
||
<el-option label="已就绪" value="2"></el-option>
|
||
<el-option label="执行中" value="3"></el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item>
|
||
<el-button type="primary" @click="onSubmit">查询</el-button>
|
||
</el-form-item>
|
||
</el-form>
|
||
<el-table :data="tableData" style="width: 100%">
|
||
<el-table-column label="编号" width="50">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px">{{ scope.row.id }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="任务名称" width="120">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px">{{ scope.row.name }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="任务权重级别" width="120">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px" v-if="scope.row.weight == 1">紧急</span>
|
||
<span style="margin-left: 10px" v-if="scope.row.weight == 2">正常</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="任务执行状态" width="120">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px">{{ scope.row.processStatus }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="最终执行结果" width="120">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px" v-if="scope.row.status == 1">有错误</span>
|
||
<span style="margin-left: 10px" v-if="scope.row.status == 0">无错误</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="总处理条数" width="120">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px">{{ scope.row.total }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="创建人" width="60">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px">{{ scope.row.createBy }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="创建时间" width="150">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px">{{ scope.row.createTime }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="修改人" width="60">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px">{{ scope.row.updateBy }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="修改时间" width="150">
|
||
<template slot-scope="scope">
|
||
<span style="margin-left: 10px">{{ scope.row.updateTime }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
|
||
|
||
<el-table-column label="操作" width="300">
|
||
<template slot-scope="scope">
|
||
<el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑节点</el-button>
|
||
<el-button size="mini" @click="todoTask(scope.$index, scope.row)">执行任务</el-button>
|
||
<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-button @click="toAdd">添加任务</el-button>
|
||
<el-dialog
|
||
title="提示"
|
||
:visible.sync="dialogVisible"
|
||
width="30%"
|
||
>
|
||
<el-radio-group v-model="labelPosition" size="small">
|
||
<el-radio-button label="left">左对齐</el-radio-button>
|
||
<el-radio-button label="right">右对齐</el-radio-button>
|
||
<el-radio-button label="top">顶部对齐</el-radio-button>
|
||
</el-radio-group>
|
||
<div style="margin: 20px;"></div>
|
||
<el-form :label-position="labelPosition" label-width="80px" :model="task">
|
||
<el-form-item label="任务名称">
|
||
<el-input v-model="task.name"></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="任务权重">
|
||
<el-input v-model="task.weight"></el-input>
|
||
</el-form-item>
|
||
</el-form>
|
||
<span slot="footer" class="dialog-footer">
|
||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||
<el-button type="primary" @click="doAdd()">确 定</el-button>
|
||
</span>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等),
|
||
//例如:import 《组件名称》 from '《组件路径》,
|
||
import {addTask, delTask, showTask, todoTask} from "../../../api/etl/etl";
|
||
|
||
export default {
|
||
name: "Task",
|
||
//import引入的组件需要注入到对象中才能使用"
|
||
components: {},
|
||
props: {},
|
||
data() {
|
||
//这里存放数据"
|
||
|
||
return {
|
||
formInline:{
|
||
name : "",
|
||
weight : "",
|
||
processStatus : ""
|
||
},
|
||
task:{},
|
||
labelPosition: 'right',
|
||
tableData:[],
|
||
dialogVisible: false
|
||
};
|
||
},
|
||
//计算属性 类似于data概念",
|
||
computed: {},
|
||
//监控data中的数据变化",
|
||
watch: {},
|
||
//方法集合",
|
||
methods: {
|
||
todoTask(index,row){
|
||
todoTask(row.id).then(res => {
|
||
if (res.code == 200){
|
||
this.$message.success("操作成功")
|
||
}else {
|
||
this.$message.error(res.msg)
|
||
}
|
||
})
|
||
},
|
||
onSubmit(){
|
||
this.getData()
|
||
},
|
||
toAdd(){
|
||
this.dialogVisible = true
|
||
},
|
||
doAdd(){
|
||
this.dialogVisible = false
|
||
addTask(this.task).then(res =>{
|
||
if (res.code == 200){
|
||
this.$message.success("添加任务成功")
|
||
location.reload()
|
||
}else{
|
||
this.$message.error("异常")
|
||
}
|
||
})
|
||
},
|
||
getData(){
|
||
showTask(this.formInline).then(res => {
|
||
this.tableData = res.data
|
||
})
|
||
},
|
||
handleEdit(index, row) {
|
||
this.$router.push({path:"/etl/active",query:{"id":row.id}})
|
||
},
|
||
handleDelete(index, row) {
|
||
console.log(index, row);
|
||
delTask(row.id).then(res =>{
|
||
if (res.code == 200){
|
||
this.$message.success(res.msg)
|
||
location.reload()
|
||
}else{
|
||
this.$message.error(res.msg)
|
||
}
|
||
})
|
||
}
|
||
},
|
||
//生命周期 - 创建完成(可以访问当前this实例)",
|
||
created() {
|
||
this.getData()
|
||
},
|
||
//生命周期 - 挂载完成(可以访问DOM元素)",
|
||
mounted() {
|
||
},
|
||
beforeCreate() {
|
||
}, //生命周期 - 创建之前",
|
||
beforeMount() {
|
||
}, //生命周期 - 挂载之前",
|
||
beforeUpdate() {
|
||
}, //生命周期 - 更新之前",
|
||
updated() {
|
||
}, //生命周期 - 更新之后",
|
||
beforeDestroy() {
|
||
}, //生命周期 - 销毁之前",
|
||
destroyed() {
|
||
}, //生命周期 - 销毁完成",
|
||
activated() {
|
||
} //如果页面有keep-alive缓存功能,这个函数会触发",
|
||
};
|
||
</script>
|
||
<style scoped>
|
||
|
||
</style>
|