end: 更新优化

This commit is contained in:
wangiegie@gmail.com 2017-11-28 17:41:04 +08:00
parent d54680c4d8
commit 7bab062c14
6 changed files with 239 additions and 55 deletions

View File

@ -18,7 +18,7 @@
"codemirror": "5.26.0",
"dropzone": "5.1.0",
"echarts": "3.7.2",
"element-ui": "1.4.2",
"element-ui": "1.4.10",
"file-saver": "1.3.3",
"js-cookie": "2.1.4",
"jsonlint": "1.6.2",

View File

@ -14,3 +14,26 @@ export function delObj(id) {
method: 'delete'
})
}
export function addObj(obj) {
return fetch({
url: '/admin/user/',
method: 'post',
data: obj
})
}
export function getObj(id) {
return fetch({
url: '/admin/user/' + id,
method: 'get'
})
}
export function putObj(obj) {
return fetch({
url: '/admin/user/',
method: 'put',
data: obj
})
}

View File

@ -55,3 +55,10 @@ export function permissionUpd(roleId, menuIds) {
}
})
}
export function fetchRoleTree(roleName) {
return fetch({
url: '/admin/menu/roleTree/' + roleName,
method: 'get'
})
}

View File

@ -1,55 +1,78 @@
<template>
<div class="app-container calendar-list-container">
<div class="filter-container">
<el-button v-if="sys_log_add" class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="edit">添加
</el-button>
</div>
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit
highlight-current-row style="width: 100%">
<el-table-column align="center" label="序号">
<el-table-column align="center" label="编号">
<template scope="scope">
<span>{{scope.row.id}}</span>
<span>{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column label="URI">
<el-table-column align="center" label="日志类型">
<template scope="scope">
<span>{{ scope.row.requestUri}}</span>
<span>{{ scope.row.type }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="IP">
<el-table-column align="center" label="日志标题">
<template scope="scope">
<span>{{scope.row.remoteAddr}}</span>
<span>{{ scope.row.title }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="METHOD">
<el-table-column align="center" label="创建者">
<template scope="scope">
<span>{{scope.row.method}}</span>
<span>{{ scope.row.createBy }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="PARAMS">
<template scope="scope">
<span>{{scope.row.params}}</span>
</template>
</el-table-column>
<el-table-column align="center" label="EXCEPTION">
<template scope="scope">
<span>{{scope.row.time}}</span>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间">
<template scope="scope">
<span>{{scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
<span>{{ scope.row.createTime }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="更新时间">
<template scope="scope">
<span>{{ scope.row.updateTime }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作IP地址">
<template scope="scope">
<span>{{ scope.row.remoteAddr }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="用户代理">
<template scope="scope">
<span>{{ scope.row.userAgent }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="请求URI">
<template scope="scope">
<span>{{ scope.row.requestUri }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作方式">
<template scope="scope">
<span>{{ scope.row.method }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作提交的数据">
<template scope="scope">
<span>{{ scope.row.params }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="执行时间">
<template scope="scope">
<span>{{ scope.row.time }}</span>
</template>
</el-table-column>
<el-table-column label="操作">
<template scope="scope">
<el-button size="mini" type="danger"
<el-button v-if="sys_log_upd" size="small" type="success"
@click="handleUpdate(scope.row)">编辑
</el-button>
<el-button v-if="sys_log_del" size="mini" type="danger"
@click="handleDelete(scope.row)">删除
</el-button>
</template>
@ -62,15 +85,61 @@
layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination>
</div>
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
<el-form :model="form" :rules="rules" ref="form" label-width="100px">
<el-form-item label="编号" prop="username">
<el-input v-model="form.id" placeholder="编号"></el-input>
</el-form-item>
<el-form-item label="日志类型" prop="username">
<el-input v-model="form.type" placeholder="日志类型"></el-input>
</el-form-item>
<el-form-item label="日志标题" prop="username">
<el-input v-model="form.title" placeholder="日志标题"></el-input>
</el-form-item>
<el-form-item label="创建者" prop="username">
<el-input v-model="form.createBy" placeholder="创建者"></el-input>
</el-form-item>
<el-form-item label="创建时间" prop="username">
<el-input v-model="form.createTime" placeholder="创建时间"></el-input>
</el-form-item>
<el-form-item label="更新时间" prop="username">
<el-input v-model="form.updateTime" placeholder="更新时间"></el-input>
</el-form-item>
<el-form-item label="操作IP地址" prop="username">
<el-input v-model="form.remoteAddr" placeholder="操作IP地址"></el-input>
</el-form-item>
<el-form-item label="用户代理" prop="username">
<el-input v-model="form.userAgent" placeholder="用户代理"></el-input>
</el-form-item>
<el-form-item label="请求URI" prop="username">
<el-input v-model="form.requestUri" placeholder="请求URI"></el-input>
</el-form-item>
<el-form-item label="操作方式" prop="username">
<el-input v-model="form.method" placeholder="操作方式"></el-input>
</el-form-item>
<el-form-item label="操作提交的数据" prop="username">
<el-input v-model="form.params" placeholder="操作提交的数据"></el-input>
</el-form-item>
<el-form-item label="执行时间" prop="username">
<el-input v-model="form.time" placeholder="执行时间"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel('form')"> </el-button>
<el-button v-if="dialogStatus=='create'" type="primary" @click="create('form')"> </el-button>
<el-button v-else type="primary" @click="update('form')"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { fetchList, delObj } from '@/api/log'
import { fetchList, addObj, putObj, delObj } from '@/api/log'
import waves from '@/directive/waves/index.js' //
import { mapGetters } from 'vuex'
export default {
name: 'table_log',
name: 'table_sys_log',
directives: {
waves
},
@ -83,11 +152,41 @@
page: 1,
limit: 20
},
rules: {
},
form: {
},
dialogFormVisible: false,
dialogStatus: '',
sys_log_add: false,
sys_log_upd: false,
sys_log_del: false,
textMap: {
update: '编辑',
create: '创建'
},
tableKey: 0
}
},
computed: {
...mapGetters([
'permissions'
])
},
filters: {
statusFilter(status) {
const statusMap = {
0: '有效',
1: '无效'
}
return statusMap[status]
}
},
created() {
this.getList()
this.sys_log_add = this.permissions['sys_log_add']
this.sys_log_upd = this.permissions['sys_log_upd']
this.sys_log_del = this.permissions['sys_log_del']
},
methods: {
getList() {
@ -118,7 +217,57 @@
duration: 2000
})
})
}
},
handleCreate() {
this.dialogStatus = 'create'
this.dialogFormVisible = true
},
create(formName) {
const set = this.$refs
set[formName].validate(valid => {
if (valid) {
addObj(this.form)
.then(() => {
this.dialogFormVisible = false
this.getList()
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
})
})
} else {
return false
}
})
},
cancel(formName) {
this.dialogFormVisible = false
const set = this.$refs
set[formName].resetFields()
},
update(formName) {
const set = this.$refs
set[formName].validate(valid => {
if (valid) {
this.dialogFormVisible = false
this.form.password = undefined
putObj(this.form).then(() => {
this.dialogFormVisible = false
this.getList()
this.$notify({
title: '成功',
message: '修改成功',
type: 'success',
duration: 2000
})
})
} else {
return false
}
})
},
}
}
</script>

View File

@ -47,7 +47,7 @@
@click="handleDelete(scope.row)">删除
</el-button>
<el-button size="mini" type="info" plain
@click="handlePermission(scope.row.roleId)">权限
@click="handlePermission(scope.row)">权限
</el-button>
</template>
</el-table-column>
@ -94,15 +94,15 @@
>
</el-tree>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="updatePermession(roleId)"> </el-button>
<el-button type="primary" @click="updatePermession(roleId, roleCode)"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { fetchList, getObj, addObj, putObj, delObj, permissionUpd } from '@/api/role'
import { fetchUserTree, fetchTree } from '@/api/menu'
import { fetchList, getObj, addObj, putObj, delObj, permissionUpd, fetchRoleTree } from '@/api/role'
import { fetchTree } from '@/api/menu'
import waves from '@/directive/waves/index.js' //
export default {
@ -130,6 +130,8 @@
roleCode: undefined,
roleDesc: undefined
},
roleId: undefined,
roleCode: undefined,
rules: {
roleName: [
{
@ -217,18 +219,19 @@
this.dialogStatus = 'update'
})
},
handlePermission(roleId) {
this.roleId = roleId
handlePermission(row) {
fetchRoleTree(row.roleCode).then(response => {
this.checkedKeys = response.data
})
fetchTree()
.then(response => {
this.treeData = response.data
this.dialogStatus = 'permission'
this.dialogPermissionVisible = true
this.roleId = row.roleId
this.roleCode = row.roleCode
})
fetchUserTree(0).then(response => {
this.checkedKeys = response.data
})
},
filterNode(value, data) {
if (!value) return true
@ -294,7 +297,7 @@
}
})
},
updatePermession(roleId) {
updatePermession(roleId, roleCode) {
permissionUpd(roleId, this.$refs.menuTree.getCheckedKeys())
.then(() => {
this.dialogPermissionVisible = false
@ -302,7 +305,7 @@
.then(response => {
this.treeData = response.data
})
fetchUserTree(0).then(response => {
fetchRoleTree(roleCode).then(response => {
this.checkedKeys = response.data
})
this.$notify({

View File

@ -5,7 +5,7 @@
v-model="listQuery.username">
</el-input>
<el-button class="filter-item" type="primary" v-waves icon="search" @click="handleFilter">搜索</el-button>
<el-button v-if="userAdd" class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="edit">添加
<el-button v-if="sys_user_add" class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="edit">添加
</el-button>
<el-button class="filter-item" type="primary" icon="document" @click="handleDownload">导出</el-button>
</div>
@ -52,7 +52,7 @@
<el-table-column label="操作">
<template scope="scope">
<el-button v-if="userUpd" size="small" type="success"
<el-button v-if="sys_user_upd" size="small" type="success"
@click="handleUpdate(scope.row)">编辑
</el-button>
</template>
@ -75,14 +75,14 @@
<el-form-item v-if="dialogStatus == 'create'" label="密码" placeholder="请输入密码" prop="password">
<el-input type="password" v-model="form.password"></el-input>
</el-form-item>
<el-form-item label="角色">
<el-form-item label="角色" prop="role">
<el-select class="filter-item" v-model="form.role" placeholder="请选择">
<el-option v-for="item in rolesOptions" :key="item.roleId" :label="item.roleCode" :value="item.roleId"> </el-option>
<el-option v-for="item in rolesOptions" :key="item.roleId" :label="item.roleCode" :value="item.roleId"></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态" v-if="dialogStatus == 'update' && userDel" >
<el-form-item label="状态" v-if="dialogStatus == 'update' && sys_user_del " prop="delFlag" >
<el-select class="filter-item" v-model="form.delFlag" placeholder="请选择">
<el-option v-for="item in statusOptions" :key="item" :label="item | statusFilter" :value="item"> </el-option>
<el-option v-for="item in statusOptions" :key="item" :label="item | statusFilter" :value="item"> </el-option>
</el-select>
</el-form-item>
</el-form>
@ -118,7 +118,9 @@
},
form: {
username: undefined,
password: undefined
password: undefined,
delFlag: undefined,
role: undefined
},
rules: {
username: [
@ -149,7 +151,7 @@
]
},
statusOptions: ['0', '1'],
rolesOptions: undefined,
rolesOptions: [],
dialogFormVisible: false,
userAdd: false,
userUpd: false,
@ -178,9 +180,9 @@
},
created() {
this.getList()
this.userAdd = this.permissions['userAdd']
this.userUpd = this.permissions['userUpd']
this.userDel = this.permissions['userDel']
this.sys_user_add = this.permissions['sys_user_add']
this.sys_user_upd = this.permissions['sys_user_upd']
this.sys_user_del = this.permissions['sys_user_del']
},
methods: {
getList() {
@ -216,13 +218,13 @@
getObj(row.userId)
.then(response => {
this.form = response.data
this.form.role = row.roleList[0].roleId
this.dialogFormVisible = true
this.dialogStatus = 'update'
})
roleList()
.then(response => {
this.rolesOptions = response.data
this.form.role = row.roleList[0].roleId
})
},
create(formName) {