Commit e1b478e8 authored by 张伯涛's avatar 张伯涛

用户角色模块代码格式规范

parent 1a5f448d
...@@ -10,6 +10,7 @@ import Qs from 'qs' ...@@ -10,6 +10,7 @@ import Qs from 'qs'
* 6.角色状态修改 * 6.角色状态修改
* 7.删除角色 * 7.删除角色
* 8.导出角色 * 8.导出角色
* 9.查询角色下拉
* */ * */
// 查询角色列表 // 查询角色列表
...@@ -93,3 +94,10 @@ export function exportRole(query) { ...@@ -93,3 +94,10 @@ export function exportRole(query) {
responseType: 'blob' responseType: 'blob'
}) })
} }
// 查询角色下拉
export function getlistRole() {
return request({
url: 'system/role/listAll',
method: 'get'
})
}
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
</el-form-item> </el-form-item>
<div style="float: right"> <div style="float: right">
<el-form-item> <el-form-item>
<coolbutton style="padding: 8px 7px;" :type="typePrimary" :name="addName" :size="smallSize" :icon="addIcon" :haspermi="hasAddPerm" @btn-click="handleAdd" /> <coolbutton style="padding: 8px 7px;" :type="commonField.typePrimary" :name="commonField.addName" :size="commonField.smallSize" :icon="commonField.addIcon" :haspermi="hasAddPerm" @btn-click="handleAdd" />
<coolbutton style="padding: 8px 7px;" :type="typeSuccess" :name="exportName" :size="smallSize" :icon="exportIcon" :haspermi="hasExportPerm" @btn-click="handleExport" /> <coolbutton style="padding: 8px 7px;" :type="commonField.typeSuccess" :name="commonField.exportName" :size="commonField.smallSize" :icon="commonField.exportIcon" :haspermi="hasExportPerm" @btn-click="handleExport" />
</el-form-item> </el-form-item>
</div> </div>
</el-form> </el-form>
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" class-name="small-padding fixed-width" width="200px"> <el-table-column label="操作" class-name="small-padding fixed-width" width="200px">
<template slot-scope="scope"> <template slot-scope="scope">
<coolbutton style="color: #49cec9" :type="typeParent" :name="updateName" :size="size" :haspermi="hasUpdatePerm" @btn-click="handleUpdate(scope.row)" /> <coolbutton style="color: #49cec9" :type="commonField.typeParent" :name="commonField.updateName" :size="commonField.size" :haspermi="hasUpdatePerm" @btn-click="handleUpdate(scope.row)" />
<el-button <el-button
v-hasPermi="['sys:role:update']" v-hasPermi="['sys:role:update']"
size="mini" size="mini"
...@@ -234,9 +234,10 @@ ...@@ -234,9 +234,10 @@
<script> <script>
import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from '@/api/system/role' import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from '@/api/system/role'
import { roleMenuTreeselectMC, treeselect as menuTreeselect, roleMenuTreeselect } from '@/api/system/menu' import { roleMenuTreeselectMC, treeselect as menuTreeselect, roleMenuTreeselect } from '@/api/system/menu'
import { treeselect as deptTreeselect, roleDeptTreeselect } from '@/api/system/dept' import { roleDeptTreeselect } from '@/api/system/dept'
import Coolbutton from '@/components/coolbutton' import Coolbutton from '@/components/coolbutton'
import { getDataCache, setDataCache } from '@/assets/js/filterData' import { getDataCache, setDataCache } from '@/assets/js/filterData'
import commonField from '@/utils/commonField'
export default { export default {
name: 'Role', name: 'Role',
components: { Coolbutton }, components: { Coolbutton },
...@@ -246,20 +247,6 @@ export default { ...@@ -246,20 +247,6 @@ export default {
updateMenu: [], updateMenu: [],
// 自定义页面默认打开的树状菜单 // 自定义页面默认打开的树状菜单
customSizeTree: [], customSizeTree: [],
typeParent: 'text',
typePrimary: 'primary',
typeSuccess: 'success',
nameParent: '删除',
resetName: '重置',
addName: '新增',
exportName: '导出',
updateName: '修改',
size: 'mini',
smallSize: 'small',
delIcon: 'el-icon-delete',
addIcon: 'el-icon-plus',
exportIcon: 'el-icon-download',
resetIcon: '',
hasDelPerm: ['sys:role:delete'], hasDelPerm: ['sys:role:delete'],
hasResetPerm: ['sys:role:resetPwd'], hasResetPerm: ['sys:role:resetPwd'],
hasUpdatePerm: ['sys:role:update'], hasUpdatePerm: ['sys:role:update'],
...@@ -360,14 +347,19 @@ export default { ...@@ -360,14 +347,19 @@ export default {
deptOptions: [] deptOptions: []
} }
}, },
computed: {
commonField() {
return commonField
}
},
/** 路由离开前存储筛选条件*/ /** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) { beforeRouteLeave(to, from, next) {
setDataCache(this.$route.path, this.queryParams) setDataCache(this.$route.path, this.queryParams)
next() next()
}, },
created() { created() {
this.queryParams = JSON.parse(getDataCache(this.$route.path)) this.queryParams = JSON.parse(getDataCache(this.$route.path)) // 获取存储的筛选项
this.getList() this.getList() // 列表查询
}, },
methods: { methods: {
/** 菜单权限check事件*/ /** 菜单权限check事件*/
...@@ -394,7 +386,7 @@ export default { ...@@ -394,7 +386,7 @@ export default {
// console.log(node); // console.log(node);
if (node.parent) { if (node.parent) {
for (const key in node) { for (const key in node) {
if (key == 'id') { if (key === 'id') {
// console.log(node[key]); // console.log(node[key]);
this.$refs.menu.setChecked(node, true) this.$refs.menu.setChecked(node, true)
} }
...@@ -429,12 +421,6 @@ export default { ...@@ -429,12 +421,6 @@ export default {
this.loading = false this.loading = false
}) })
}, },
/** 查询部门树结构 */
getDeptTreeSelect() {
deptTreeselect().then(response => {
this.deptOptions = response.data
})
},
// 数据权限的树状菜单 // 数据权限的树状菜单
handleDeptCheckChange(data, check, subCheck) { handleDeptCheckChange(data, check, subCheck) {
// data为选中节点信息,check选中状态 // data为选中节点信息,check选中状态
...@@ -442,6 +428,7 @@ export default { ...@@ -442,6 +428,7 @@ export default {
this.checkDeptNode(data.children, check) // 调用checkNode方法 this.checkDeptNode(data.children, check) // 调用checkNode方法
} }
}, },
/** 遍历所有下级节点*/
checkDeptNode(data, check) { checkDeptNode(data, check) {
// 遍历所有下级节点信息 // 遍历所有下级节点信息
data.forEach(item => { data.forEach(item => {
......
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
</el-upload> </el-upload>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="upload.open = false">取 消</el-button> <el-button @click="upload.open = false">取 消</el-button>
<el-button :loading="importLoading" type="primary" @click.one="submitFileForm">确 定</el-button> <el-button :loading="importLoading" type="primary" @click="submitFileForm">确 定</el-button>
</div> </div>
</el-dialog> </el-dialog>
<el-dialog <el-dialog
...@@ -534,15 +534,16 @@ export default { ...@@ -534,15 +534,16 @@ export default {
}, },
created() { created() {
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改 // 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path)) this.queryParams = JSON.parse(getDataCache(this.$route.path)) // 获取存储的筛选项
this.getList() this.getList() // 列表查询
this.getTreeSelect() this.getTreeSelect() // 查询部门下拉树结构
this.getRole() this.getRole() // 查询角色下拉
// this.getConfigKey('sys.user.initPassword').then(response => { // this.getConfigKey('sys.user.initPassword').then(response => {
// this.initPassword = response.msg // this.initPassword = response.msg
// }) // })
}, },
methods: { methods: {
/** 部门change事件*/
changeValue() { changeValue() {
this.$refs.form.validateField('id') this.$refs.form.validateField('id')
}, },
...@@ -558,6 +559,7 @@ export default { ...@@ -558,6 +559,7 @@ export default {
} }
) )
}, },
/** 角色change事件*/
roleChange(e) { roleChange(e) {
// TODO: clear this log // TODO: clear this log
this.$forceUpdate() this.$forceUpdate()
...@@ -582,6 +584,7 @@ export default { ...@@ -582,6 +584,7 @@ export default {
// this.form.postId = response.data.checkedKeys // this.form.postId = response.data.checkedKeys
}) })
}, },
/** 查询角色下拉*/
getRole() { getRole() {
getlistRole().then( getlistRole().then(
response => { response => {
...@@ -664,7 +667,7 @@ export default { ...@@ -664,7 +667,7 @@ export default {
rows: 10, rows: 10,
username: '', username: '',
flag: '' flag: ''
}, }
this.handleQuery() this.handleQuery()
}, },
// 多选框选中数据 // 多选框选中数据
...@@ -712,6 +715,7 @@ export default { ...@@ -712,6 +715,7 @@ export default {
this.ruleForm.row = row.businessId this.ruleForm.row = row.businessId
this.resetPwdDiaLog = !this.resetPwdDiaLog this.resetPwdDiaLog = !this.resetPwdDiaLog
}, },
/** 修改密码确定操作*/
handleResetPwdSure() { handleResetPwdSure() {
this.$refs.ruleForm.validate(pass => { this.$refs.ruleForm.validate(pass => {
if (pass) { if (pass) {
...@@ -731,16 +735,6 @@ export default { ...@@ -731,16 +735,6 @@ export default {
} }
}) })
}, },
// 数组值是否相同
isAllEqual(array) {
if (array.length > 0) {
return !array.some(function(value, index) {
return value !== array[0]
})
} else {
return true
}
},
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs['form'].validate(valid => { this.$refs['form'].validate(valid => {
...@@ -885,18 +879,20 @@ export default { ...@@ -885,18 +879,20 @@ export default {
this.$message.success(err.message) this.$message.success(err.message)
this.importLoading = false this.importLoading = false
}) })
this.importLoading = false
} }
}, },
/** 导入change*/
employeeUpload(file, fileList) { employeeUpload(file, fileList) {
if (fileList.length > 1) { if (fileList.length > 1) {
fileList.splice(0, 1) fileList.splice(0, 1)
} }
this.fileList = fileList[0].raw this.fileList = fileList[0].raw
}, },
/** 导入remove操作*/
handleRemove(file, fileList) { handleRemove(file, fileList) {
this.fileList = [] this.fileList = []
}, },
/** 导入beforeRemove操作*/
beforeRemove(file, fileList) { beforeRemove(file, fileList) {
this.fileList = [] this.fileList = []
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment