效果图:
1、页面:
<template>
<div class="app-container">
<el-row class="location-query">
<el-button type="primary" icon="el-icon-search" @click="fetchData()">查询</el-button>
</el-row>
<el-row class='query-id'>
<el-input v-model="pageParam.nickName" placeholder="请输入昵称" @keyup.enter.native="fetchData()"></el-input>
</el-row>
<el-table :data="list" v-loading.body="listLoading" element-loading-text="拼命加载中" border fit highlight-current-row>
<el-table-column label="用户名" min-width="22" align="center" show-overflow-tooltip>
<template slot-scope="scope">
{{scope.row.userName}}
</template>
</el-table-column>
<el-table-column label="昵称" min-width="18" align="center" show-overflow-tooltip>
<template slot-scope="scope">
{{scope.row.userNickName}}
</template>
</el-table-column>
<el-table-column label="操作" min-width="60" align="center">
<template slot-scope="scope">
<el-button type="danger" size="mini" round @click="deleteProcess(scope.row.id)">删除</el-button>
<el-button type="primary" size="mini" round @click="viewSql(scope.row.id)">修改</el-button>
</template>
</el-table-column>
</el-table>
<!-- 修改开始 -->
<el-dialog title="修改用户信息" :visible.sync="updateView">
<el-form ref="updateUserDetail" :model="updateProcessDetail" label-width="100px">
<el-form-item label="用户账号">
<el-input v-model="updateProcessDetail.userName"></el-input>
</el-form-item>
<el-form-item label="昵称">
<el-input v-model="updateProcessDetail.userNickName"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="updateProcess">修改</el-button>
<el-button @click="updateView=false">取消</el-button>
</el-form-item>
</el-form>
</el-dialog>
<!--修改结束-->
<div class="block">
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageParam.pageIndex" :page-sizes="pageSizes" :page-size="pageParam.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination>
</div>
</div>
</template>
<script>
import { parseTime } from '../../utils/index.js'
import { getPagerUser } from '@/api/user'
import qs from 'qs'
export default {
data() {
return {
// 执行
reTryView: false,
// 编辑
updateView: false,
updateProcessDetail: {
id: '',
name: '',
displayName: '',
job: { cronExpression: '', startTime: '', endTime: '' },
nodeDetails: []
},
list: [],
listLoading: true, // true
pageSizes: [5, 10, 15],
total: 0,
pageParam: {
pageIndex: 1,
pageSize: 5,
nickName:''
}
}
},
created() {
this.fetchData()
},
filters: {
parseTime(time) {
var date = new Date(time)
return parseTime(date)
}
},
methods: {
handleChange(value) {
console.log(value)
},
// 取消
calcelSql() {
this.isSqlView = false
this.currNodeIndex = 0
},
fetchData() {
this.getList()
},
handleSizeChange(val) {
this.pageParam.pageSize = val
this.getList()
},
handleCurrentChange(val) {
this.pageParam.pageIndex = val
this.getList()
},
suspend(jobId) {
suspend(jobId).then(res => {
this.getList()
})
},
reStart(jobId) {
reStart(jobId).then(res => {
this.getList()
})
},
getList() {
getPagerUser(this.pageParam)
.then(res => {
this.listLoading = false
if (res.data !== null) {
this.list = res.data.list
this.total = res.data.total
}
})
.catch(err => {
console.log(err)
})
},
/**
* 取消任务重试看板
*/
cancelRetry() {
this.reTryView = false
this.isPartView = false
},
/**
* 任务重试看板
*/
viewReTryNodes(processId) {
this.reTryView = true
this.currentProcessId = processId
// 获取节点
getTaskNodes(processId).then(res => {
if (res.code === 200) {
this.dateParts = res.data
this.isPartView = true
}
})
},
/**
删除任务 */
deleteProcess(processId) {
this.$confirm('确认删除?')
.then(_ => {
deleteProcess(processId)
.then(res => {
if (res.code === 200) {
this.message('删除成功')
this.getList()
} else {
this.message(res.msg)
}
})
.catch(err => {
console.log(err)
})
})
.catch(_ => {})
},
/**
* 任务重试
*/
taskRetry() {
this.reTryView = false
taskRetry(
this.currentProcessId,
this.dateParts,
this.datePartsMap
).then(res => {
if (res.code === 200) {
this.message('任务重试成功')
} else {
this.message(res.msg)
}
})
},
// 打开编辑页面
getUpdateViw(processId) {
getProcessDetail(processId)
.then(res => {
if (res.code === 200) {
this.updateView = true
this.updateProcessDetail = res.data
this.updateProcessDetail.job.startTime = parseTime(
this.updateProcessDetail.job.startTime
)
this.updateProcessDetail.job.endTime = parseTime(
this.updateProcessDetail.job.endTime
)
} else {
this.message(res.msg)
}
})
.catch(err => {
console.log(err)
})
},
// 编辑
updateProcess() {
updateProcess(this.updateProcessDetail)
.then(res => {
if (res.code === 200) {
this.message('修改成功')
} else {
this.message('修改失败')
}
})
.catch(err => {
console.log(err)
})
this.updateView = false
},
// 打开节点编辑页面
nodeDetailInfo(index) {
this.nodeDetailView = true
this.currentNode = this.updateProcessDetail.nodeDetails[index]
},
message(msg) {
this.$message({
type: 'warning',
message: msg
})
}
}
}
</script>
<style>
.product-new {
float: left;
margin-bottom: 15px;
}
.product {
margin-left: 2%;
float: left;
}
.product-query {
float: right;
}
.block {
margin-bottom: 20px;
margin-top: 20px;
float: right;
}
.product-create {
width: 50%;
margin-left: 25%;
}
.row-text {
margin-bottom: 15px;
}
.product-text {
margin-top: 10px;
width: 30%;
float: left;
}
.product-title {
width: 70%;
float: left;
}
.query-role,.location-query{
float: right;
margin-left: 30px;
}
.query-startTime,.query-endTime,.query-id,.position-status{
float: right;
margin-left: 20px;
}
</style>
2、api:
export function getPagerUser(userQuery) {
return request({
url: '/user/getPagerUser',
method: 'post',
data:userQuery
})
}