<template>
|
<div class="app-container">
|
<div class="filter-container">
|
<!-- <el-input v-model="listQuery.keyword" size="small" placeholder="请输入关键词" clearable class="filter-item w-200" /> -->
|
<el-button-group class="filter-item">
|
<!-- <el-button size="small" type="primary" icon="el-icon-search" @click="search">
|
搜索
|
</el-button> -->
|
<el-button size="small" type="primary" icon="el-icon-refresh" @click="refresh">
|
刷新
|
</el-button>
|
<el-button v-if="uadd=='Yes'" size="small" type="primary" icon="el-icon-plus" @click="add">
|
新增
|
</el-button>
|
</el-button-group>
|
</div>
|
|
<el-table v-loading="listLoading" :data="list" element-loading-text="Loading" border fit height="100%"
|
class="table-container" highlight-current-row>
|
<el-table-column fixed label="序号" width="80" >
|
<template slot-scope="scope">
|
{{ scope.row.id }}
|
</template>
|
</el-table-column>
|
<el-table-column label="角色" >
|
<template slot-scope="scope">
|
{{ scope.row.name }}
|
</template>
|
</el-table-column>
|
<el-table-column label="添加人员" >
|
<template slot-scope="scope">
|
{{ scope.row.adduser }}
|
</template>
|
</el-table-column>
|
<el-table-column label="添加时间" >
|
<template slot-scope="scope">
|
{{ scope.row.addtime }}
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="200" v-if="uupdate=='Yes' || udelete=='Yes'">
|
<template slot-scope="scope">
|
<el-button-group>
|
<el-button v-if="uupdate=='Yes'" type="primary" icon="el-icon-edit" size="mini" @click="edit(scope)">
|
修改
|
</el-button>
|
<el-button v-if="udelete=='Yes'" type="danger" icon="el-icon-delete" size="mini" @click="del(scope)">
|
删除
|
</el-button>
|
</el-button-group>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination v-show="total > 0" :total="total" :page.sync="listQuery.current" :limit.sync="listQuery.size"
|
@pagination="fetchData" />
|
|
<el-dialog :visible.sync="dialogVisible" :title="dialogType === 'modify' ? '修改' : '新增'">
|
<el-form :ref="temp" :model="temp" label-width="120px" label-position="right" :rules="rules">
|
<el-form-item label="角色" prop="name">
|
<el-input v-model="temp.name
|
" placeholder="请输入角色" />
|
</el-form-item>
|
</el-form>
|
<div class="text-right">
|
<el-button type="danger" @click="dialogVisible = false">
|
取消
|
</el-button>
|
<el-button type="primary" @click="submit">
|
确定
|
</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import Pagination from '@/components/Pagination'
|
import { getUserJuesePage, delUserJuese, addorupUserJuese, searchUserJuese,addSystemOperationLog } from '@/api/userjuese'
|
import { deepClone } from '@/utils'
|
|
const _temp = {
|
id: '',
|
name: '',
|
adduser:''
|
}
|
|
export default {
|
components: {
|
Pagination
|
},
|
data() {
|
return {
|
uadd:'',
|
udelete:'',
|
uupdate:'',
|
total: 0,
|
list: [],
|
menus: [],
|
listLoading: true,
|
listQuery: {
|
current: 1,
|
size: 20,
|
keyword: undefined,
|
},
|
uploadUrl: '',
|
temp: Object.assign({}, _temp),
|
dialogVisible: false,
|
dialogType: 'create',
|
loading: false,
|
rules: {
|
name: [
|
{ required: true, message: '请选择角色', trigger: 'change' }
|
]
|
},
|
}
|
},
|
created() {
|
this.fetchData()
|
},
|
methods: {
|
// 搜索
|
search() {
|
this.listLoading = true
|
searchUserJuese(this.listQuery).then(response => {
|
this.list = response.data.records
|
this.total = response.data.total
|
this.listLoading = false
|
})
|
},
|
refresh() {
|
this.listQuery = {
|
current: 1,
|
size: 20,
|
keyword: undefined
|
}
|
this.fetchData()
|
},
|
// 分页数据
|
fetchData() {
|
this.uadd = localStorage.getItem('uadd') || '';
|
this.udelete = localStorage.getItem('udelete') || '';
|
this.uupdate = localStorage.getItem('uupdate') || '';
|
this.listLoading = true
|
getUserJuesePage(this.listQuery).then(response => {
|
this.list = response.data.records
|
this.total = response.data.total
|
this.listLoading = false
|
})
|
},
|
resetTemp() {
|
this.temp = Object.assign({}, _temp)
|
},
|
add() {
|
this.resetTemp()
|
this.dialogVisible = true
|
this.dialogType = 'create'
|
// this.$nextTick(() => {
|
// this.$refs['dataForm'].clearValidate()
|
// })
|
},
|
edit(scope) {
|
this.resetTemp()
|
this.dialogVisible = true
|
this.dialogType = 'modify'
|
this.temp = deepClone(scope.row)
|
// this.$nextTick(() => {
|
// this.$refs['dataForm'].clearValidate()
|
// })
|
},
|
changeStatus(value, scope) {
|
setTimeout(() => {
|
this.list[scope.$index].status = value
|
this.$message({
|
message: '更新成功',
|
type: 'success'
|
})
|
}, 300)
|
},
|
// 删除
|
del(scope) {
|
this.$confirm('确认删除该条数据吗?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
setTimeout(() => {
|
const params = { id: scope.row.id };
|
this.list.splice(scope.$index, 1)
|
delUserJuese(params).then(response => {
|
this.temp.adminname = localStorage.getItem('username') || '';
|
const params = { name: this.temp.adminname, content: '删除了一个角色,该角色名称为:'+scope.row.name };
|
addSystemOperationLog(params).then(response => {
|
|
})
|
this.$message({
|
message: '删除成功',
|
type: 'success'
|
})
|
this.fetchData()
|
})
|
}, 300)
|
})
|
},
|
submit() {
|
this.temp.adduser = localStorage.getItem('username') || '';
|
if (this.loading) {
|
return
|
}
|
this.loading = true
|
this.$refs[this.temp].validate((valid) => {
|
if (valid) {
|
addorupUserJuese(this.temp).then(() => {
|
if (this.temp.id=="") {
|
this.temp.adminname = localStorage.getItem('username') || '';
|
const params = { name: this.temp.adminname, content: '新增了一个角色,该角色名称为:'+this.temp.name };
|
addSystemOperationLog(params).then(response => {
|
|
})
|
} else {
|
this.temp.adminname = localStorage.getItem('username') || '';
|
const params = { name: this.temp.adminname, content: '修改了一个角色,该角色名称为:'+this.temp.name };
|
addSystemOperationLog(params).then(response => {
|
|
})
|
}
|
this.fetchData()
|
setTimeout(() => {
|
this.$message({
|
message: '提交成功',
|
type: 'success'
|
})
|
this.dialogVisible = false
|
this.loading = false
|
}, 300)
|
})
|
} else {
|
this.$message({
|
message: '提交失败,请检查表单必填项是否为空',
|
type: 'error'
|
})
|
console.log('error submit!!');
|
return false;
|
}
|
});
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.el-upload {
|
border: 1px dashed #d9d9d9 !important;
|
border-radius: 6px;
|
cursor: pointer;
|
position: relative;
|
overflow: hidden;
|
|
.el-icon-plus.avatar-uploader-icon {
|
border: 1px dashed #d9d9d9 !important;
|
border-radius: 6px;
|
font-size: 28px;
|
color: #8c939d;
|
width: 128px;
|
height: 128px;
|
line-height: 128px;
|
text-align: center;
|
}
|
}
|
|
.avatar-uploader {
|
height: 128px;
|
|
img {
|
width: 128px;
|
height: 128px;
|
}
|
}
|
</style>
|