d7968354 by xiaomiao

增加角色模块

1 parent 653d7b73
......@@ -299,6 +299,24 @@ export const asyncRoutes = [
component: () => import('@/views/system/timedTask/index'),
name: 'timedTask',
meta: { title: '定时任务' }
},
{
path: 'menus',
component: () => import('@/views/system/menus/index'),
name: 'menus',
meta: { title: '菜单管理' }
},
{
path: 'users',
component: () => import('@/views/system/users/index'),
name: 'users',
meta: { title: '人员管理' }
},
{
path: 'roles',
component: () => import('@/views/system/roles/index'),
name: 'roles',
meta: { title: '角色管理' }
}
]
}
......
import filter from '@/utils/filter.js'
class data extends filter {
constructor() {
super()
}
columns () {
return [
{
prop: "job_name",
label: "任务名称",
width: 130
},
{
prop: "description",
label: "任务描述",
width: 300
},
{
prop: "cron_expression",
label: "cron表达式"
},
{
prop: "bean_class",
width: 260,
label: "任务类"
},
{
prop: "job_group",
label: "任务分组"
},
{
label: "状态",
render: (h, scope) => {
return (
<div>
{ this.stateStatus(scope.row.job_status) }
</div>
)
},
}
]
}
}
export default new data()
<template>
<div class="timedTask from-clues">
<div class="from-clues-header">
<el-form ref="form" :model="form" label-width="80px">
<el-row>
<el-col :span="6">
<el-form-item label="搜索标题">
<el-input v-model="form.job_name" placeholder="请输入标题"></el-input>
</el-form-item>
</el-col>
<el-col :span="18" class="btnColRight">
<btn nativeType="cx" @click="handleSubmit">搜索</btn>
<btn nativeType="sb" @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="pageData.total"
@size-change="handleSizeChange" @p-current-change="handleCurrentChange" :column="tableData.columns"
:data="tableData.data">
</lb-table>
<add-task ref="task" :taskData="taskData" />
<message-tips ref="msg" :message="message" />
</div>
</div>
</template>
<script>
// 定时任务
import data from "./data"
import system from '@/api/system.js'
import tableMixin from '@/mixins/tableMixin.js'
import addTask from '../components/addTask.vue'
export default {
name: "menus",
mixins: [tableMixin],
components: {
addTask
},
data () {
return {
taskData: null,
form: {
job_name: '',
currentPage: 1
},
selectionList: [],
tableData: {
columns: [{
label: '序号',
type: 'index',
width: '50',
index: this.indexMethod,
}].concat(data.columns()).concat([
{
label: "操作",
width: 380,
render: (h, scope) => {
return (
<div>
<el-button type="text" size="mini" style="color: #67C23A"
v-show={scope.row.job_status !== '1' && scope.row.job_status !== '2'}
icon="el-icon-magic-stick"
onClick={() => { this.handleRecovery(scope.row) }}>激活
</el-button>
<el-button type="text" size="mini"
style="color: #67C23A;margin-left:0"
icon="el-icon-refresh-right"
v-show={scope.row.job_status === '2'}
onClick={() => { this.handleActivation(scope.row) }}>恢复
</el-button>
<el-button type="text" size="mini"
v-show={scope.row.job_status !== '1'}
icon="el-icon-stopwatch"
onClick={() => { this.handletest(scope.row) }}>手动测试
</el-button>
<el-button type="text" size="mini"
v-show={scope.row.job_status === '1'}
icon="el-icon-video-pause"
onClick={() => { this.handleSuspend(scope.row) }}>暂停
</el-button>
<el-button type="text" size="mini"
icon="el-icon-edit"
v-show={scope.row.job_status === '2' || scope.row.job_status === '-1' || scope.row.job_status === '0'}
onClick={() => { this.handleEdit(scope.row) }}>编辑
</el-button>
<el-button type="text" size="mini"
icon="el-icon-delete" style="color:#F56C6C"
v-show={scope.row.job_status !== '1'}
onClick={() => { this.handleDel(scope.row) }}>删除
</el-button>
</div>
);
},
},
]),
data: []
},
pageData: {
total: 0,
pageSize: 15,
current: 1,
},
}
},
methods: {
handleAdd () {
this.taskData = null
this.$refs.task.isShow()
},
async featchData () {
try {
this.form = Object.assign(this.form, this.formData)
let { result: { list, total, pages: pageSize, pageNum: current }
} = await system.getTaskListByName(this.form)
this.tableData.data = list
this.pageData = {
pageSize,
current,
total
}
} catch (error) {
this.message = error
this.$refs.msg.messageShow()
}
},
// 暂停
handleSuspend (row) {
this.$confirm('此操将进行暂停操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.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: '已取消',
})
})
},
// 激活
handleRecovery (row) {
this.$confirm('此操将进行激活操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.activateJob(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: '已取消',
})
})
},
// 恢复
handleActivation (row) {
this.$confirm('此操将进行恢复操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.resumeJob(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: '已取消',
})
})
},
// 手动测试
handletest (row) {
this.$confirm('此操将进行手动测试, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.sjsbTaskRun(row.id)
.then((res) => {
if ((res.code = 200)) {
this.$alert(res.message, '提示', {
confirmButtonText: '确定',
type: 'success'
});
this.featchData()
}
})
.catch((error) => {
this.$alert(error, '提示', {
confirmButtonText: '确定',
type: 'error'
})
})
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
})
})
},
handleEdit (row) {
this.taskData = row
this.$refs.task.isShow()
},
handleDel (row) {
this.$confirm('此操将进行删除操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.sjsbTaskRemove(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: '已取消',
})
})
}
}
}
</script>
<style scoped lang="scss">
@import "~@/styles/mixin.scss";
@import "~@/styles/public.scss";
</style>
import filter from '@/utils/filter.js'
class data extends filter {
constructor() {
super()
}
columns () {
return [
{
prop: "job_name",
label: "任务名称",
width: 130
},
{
prop: "description",
label: "任务描述",
width: 300
},
{
prop: "cron_expression",
label: "cron表达式"
},
{
prop: "bean_class",
width: 260,
label: "任务类"
},
{
prop: "job_group",
label: "任务分组"
},
{
label: "状态",
render: (h, scope) => {
return (
<div>
{ this.stateStatus(scope.row.job_status) }
</div>
)
},
}
]
}
}
export default new data()
<template>
<div class="timedTask from-clues">
<div class="from-clues-header">
<el-form ref="form" :model="form" label-width="80px">
<el-row>
<el-col :span="6">
<el-form-item label="搜索标题">
<el-input v-model="form.job_name" placeholder="请输入标题"></el-input>
</el-form-item>
</el-col>
<el-col :span="18" class="btnColRight">
<btn nativeType="cx" @click="handleSubmit">搜索</btn>
<btn nativeType="sb" @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="pageData.total"
@size-change="handleSizeChange" @p-current-change="handleCurrentChange" :column="tableData.columns"
:data="tableData.data">
</lb-table>
<add-task ref="task" :taskData="taskData" />
<message-tips ref="msg" :message="message" />
</div>
</div>
</template>
<script>
// 定时任务
import data from "./data"
import system from '@/api/system.js'
import tableMixin from '@/mixins/tableMixin.js'
import addTask from '../components/addTask.vue'
export default {
name: "roles",
mixins: [tableMixin],
components: {
addTask
},
data () {
return {
taskData: null,
form: {
job_name: '',
currentPage: 1
},
selectionList: [],
tableData: {
columns: [{
label: '序号',
type: 'index',
width: '50',
index: this.indexMethod,
}].concat(data.columns()).concat([
{
label: "操作",
width: 380,
render: (h, scope) => {
return (
<div>
<el-button type="text" size="mini" style="color: #67C23A"
v-show={scope.row.job_status !== '1' && scope.row.job_status !== '2'}
icon="el-icon-magic-stick"
onClick={() => { this.handleRecovery(scope.row) }}>激活
</el-button>
<el-button type="text" size="mini"
style="color: #67C23A;margin-left:0"
icon="el-icon-refresh-right"
v-show={scope.row.job_status === '2'}
onClick={() => { this.handleActivation(scope.row) }}>恢复
</el-button>
<el-button type="text" size="mini"
v-show={scope.row.job_status !== '1'}
icon="el-icon-stopwatch"
onClick={() => { this.handletest(scope.row) }}>手动测试
</el-button>
<el-button type="text" size="mini"
v-show={scope.row.job_status === '1'}
icon="el-icon-video-pause"
onClick={() => { this.handleSuspend(scope.row) }}>暂停
</el-button>
<el-button type="text" size="mini"
icon="el-icon-edit"
v-show={scope.row.job_status === '2' || scope.row.job_status === '-1' || scope.row.job_status === '0'}
onClick={() => { this.handleEdit(scope.row) }}>编辑
</el-button>
<el-button type="text" size="mini"
icon="el-icon-delete" style="color:#F56C6C"
v-show={scope.row.job_status !== '1'}
onClick={() => { this.handleDel(scope.row) }}>删除
</el-button>
</div>
);
},
},
]),
data: []
},
pageData: {
total: 0,
pageSize: 15,
current: 1,
},
}
},
methods: {
handleAdd () {
this.taskData = null
this.$refs.task.isShow()
},
async featchData () {
try {
this.form = Object.assign(this.form, this.formData)
let { result: { list, total, pages: pageSize, pageNum: current }
} = await system.getTaskListByName(this.form)
this.tableData.data = list
this.pageData = {
pageSize,
current,
total
}
} catch (error) {
this.message = error
this.$refs.msg.messageShow()
}
},
// 暂停
handleSuspend (row) {
this.$confirm('此操将进行暂停操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.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: '已取消',
})
})
},
// 激活
handleRecovery (row) {
this.$confirm('此操将进行激活操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.activateJob(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: '已取消',
})
})
},
// 恢复
handleActivation (row) {
this.$confirm('此操将进行恢复操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.resumeJob(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: '已取消',
})
})
},
// 手动测试
handletest (row) {
this.$confirm('此操将进行手动测试, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.sjsbTaskRun(row.id)
.then((res) => {
if ((res.code = 200)) {
this.$alert(res.message, '提示', {
confirmButtonText: '确定',
type: 'success'
});
this.featchData()
}
})
.catch((error) => {
this.$alert(error, '提示', {
confirmButtonText: '确定',
type: 'error'
})
})
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
})
})
},
handleEdit (row) {
this.taskData = row
this.$refs.task.isShow()
},
handleDel (row) {
this.$confirm('此操将进行删除操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.sjsbTaskRemove(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: '已取消',
})
})
}
}
}
</script>
<style scoped lang="scss">
@import "~@/styles/mixin.scss";
@import "~@/styles/public.scss";
</style>
import filter from '@/utils/filter.js'
class data extends filter {
constructor() {
super()
}
columns () {
return [
{
prop: "job_name",
label: "任务名称",
width: 130
},
{
prop: "description",
label: "任务描述",
width: 300
},
{
prop: "cron_expression",
label: "cron表达式"
},
{
prop: "bean_class",
width: 260,
label: "任务类"
},
{
prop: "job_group",
label: "任务分组"
},
{
label: "状态",
render: (h, scope) => {
return (
<div>
{ this.stateStatus(scope.row.job_status) }
</div>
)
},
}
]
}
}
export default new data()
<template>
<div class="timedTask from-clues">
<h1>水水水水水</h1>
</div>
</template>
<script>
// 定时任务
import data from "./data"
import system from '@/api/system.js'
import tableMixin from '@/mixins/tableMixin.js'
import addTask from '../components/addTask.vue'
export default {
name: "users",
mixins: [tableMixin],
components: {
addTask
},
data () {
return {
taskData: null,
form: {
job_name: '',
currentPage: 1
},
selectionList: [],
tableData: {
columns: [{
label: '序号',
type: 'index',
width: '50',
index: this.indexMethod,
}].concat(data.columns()).concat([
{
label: "操作",
width: 380,
render: (h, scope) => {
return (
<div>
<el-button type="text" size="mini" style="color: #67C23A"
v-show={scope.row.job_status !== '1' && scope.row.job_status !== '2'}
icon="el-icon-magic-stick"
onClick={() => { this.handleRecovery(scope.row) }}>激活
</el-button>
<el-button type="text" size="mini"
style="color: #67C23A;margin-left:0"
icon="el-icon-refresh-right"
v-show={scope.row.job_status === '2'}
onClick={() => { this.handleActivation(scope.row) }}>恢复
</el-button>
<el-button type="text" size="mini"
v-show={scope.row.job_status !== '1'}
icon="el-icon-stopwatch"
onClick={() => { this.handletest(scope.row) }}>手动测试
</el-button>
<el-button type="text" size="mini"
v-show={scope.row.job_status === '1'}
icon="el-icon-video-pause"
onClick={() => { this.handleSuspend(scope.row) }}>暂停
</el-button>
<el-button type="text" size="mini"
icon="el-icon-edit"
v-show={scope.row.job_status === '2' || scope.row.job_status === '-1' || scope.row.job_status === '0'}
onClick={() => { this.handleEdit(scope.row) }}>编辑
</el-button>
<el-button type="text" size="mini"
icon="el-icon-delete" style="color:#F56C6C"
v-show={scope.row.job_status !== '1'}
onClick={() => { this.handleDel(scope.row) }}>删除
</el-button>
</div>
);
},
},
]),
data: []
},
pageData: {
total: 0,
pageSize: 15,
current: 1,
},
}
},
methods: {
handleAdd () {
this.taskData = null
this.$refs.task.isShow()
},
async featchData () {
try {
this.form = Object.assign(this.form, this.formData)
let { result: { list, total, pages: pageSize, pageNum: current }
} = await system.getTaskListByName(this.form)
this.tableData.data = list
this.pageData = {
pageSize,
current,
total
}
} catch (error) {
this.message = error
this.$refs.msg.messageShow()
}
},
// 暂停
handleSuspend (row) {
this.$confirm('此操将进行暂停操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.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: '已取消',
})
})
},
// 激活
handleRecovery (row) {
this.$confirm('此操将进行激活操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.activateJob(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: '已取消',
})
})
},
// 恢复
handleActivation (row) {
this.$confirm('此操将进行恢复操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.resumeJob(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: '已取消',
})
})
},
// 手动测试
handletest (row) {
this.$confirm('此操将进行手动测试, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.sjsbTaskRun(row.id)
.then((res) => {
if ((res.code = 200)) {
this.$alert(res.message, '提示', {
confirmButtonText: '确定',
type: 'success'
});
this.featchData()
}
})
.catch((error) => {
this.$alert(error, '提示', {
confirmButtonText: '确定',
type: 'error'
})
})
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
})
})
},
handleEdit (row) {
this.taskData = row
this.$refs.task.isShow()
},
handleDel (row) {
this.$confirm('此操将进行删除操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
system.sjsbTaskRemove(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: '已取消',
})
})
}
}
}
</script>
<style scoped lang="scss">
@import "~@/styles/mixin.scss";
@import "~@/styles/public.scss";
</style>