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

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

parent 1a5f448d
......@@ -10,6 +10,7 @@ import Qs from 'qs'
* 6.角色状态修改
* 7.删除角色
* 8.导出角色
* 9.查询角色下拉
* */
// 查询角色列表
......@@ -93,3 +94,10 @@ export function exportRole(query) {
responseType: 'blob'
})
}
// 查询角色下拉
export function getlistRole() {
return request({
url: 'system/role/listAll',
method: 'get'
})
}
......@@ -44,8 +44,8 @@
</el-form-item>
<div style="float: right">
<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="typeSuccess" :name="exportName" :size="smallSize" :icon="exportIcon" :haspermi="hasExportPerm" @btn-click="handleExport" />
<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="commonField.typeSuccess" :name="commonField.exportName" :size="commonField.smallSize" :icon="commonField.exportIcon" :haspermi="hasExportPerm" @btn-click="handleExport" />
</el-form-item>
</div>
</el-form>
......@@ -86,7 +86,7 @@
</el-table-column>
<el-table-column label="操作" class-name="small-padding fixed-width" width="200px">
<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
v-hasPermi="['sys:role:update']"
size="mini"
......@@ -234,9 +234,10 @@
<script>
import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from '@/api/system/role'
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 { getDataCache, setDataCache } from '@/assets/js/filterData'
import commonField from '@/utils/commonField'
export default {
name: 'Role',
components: { Coolbutton },
......@@ -246,20 +247,6 @@ export default {
updateMenu: [],
// 自定义页面默认打开的树状菜单
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'],
hasResetPerm: ['sys:role:resetPwd'],
hasUpdatePerm: ['sys:role:update'],
......@@ -360,14 +347,19 @@ export default {
deptOptions: []
}
},
computed: {
commonField() {
return commonField
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
setDataCache(this.$route.path, this.queryParams)
next()
},
created() {
this.queryParams = JSON.parse(getDataCache(this.$route.path))
this.getList()
this.queryParams = JSON.parse(getDataCache(this.$route.path)) // 获取存储的筛选项
this.getList() // 列表查询
},
methods: {
/** 菜单权限check事件*/
......@@ -394,7 +386,7 @@ export default {
// console.log(node);
if (node.parent) {
for (const key in node) {
if (key == 'id') {
if (key === 'id') {
// console.log(node[key]);
this.$refs.menu.setChecked(node, true)
}
......@@ -429,12 +421,6 @@ export default {
this.loading = false
})
},
/** 查询部门树结构 */
getDeptTreeSelect() {
deptTreeselect().then(response => {
this.deptOptions = response.data
})
},
// 数据权限的树状菜单
handleDeptCheckChange(data, check, subCheck) {
// data为选中节点信息,check选中状态
......@@ -442,6 +428,7 @@ export default {
this.checkDeptNode(data.children, check) // 调用checkNode方法
}
},
/** 遍历所有下级节点*/
checkDeptNode(data, check) {
// 遍历所有下级节点信息
data.forEach(item => {
......
......@@ -280,7 +280,7 @@
</el-upload>
<div slot="footer" class="dialog-footer">
<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>
</el-dialog>
<el-dialog
......@@ -534,15 +534,16 @@ export default {
},
created() {
// 分页参数初始化为{"page":1,"rows":10},如需自定义分页参数,自行修改
this.queryParams = JSON.parse(getDataCache(this.$route.path))
this.getList()
this.getTreeSelect()
this.getRole()
this.queryParams = JSON.parse(getDataCache(this.$route.path)) // 获取存储的筛选项
this.getList() // 列表查询
this.getTreeSelect() // 查询部门下拉树结构
this.getRole() // 查询角色下拉
// this.getConfigKey('sys.user.initPassword').then(response => {
// this.initPassword = response.msg
// })
},
methods: {
/** 部门change事件*/
changeValue() {
this.$refs.form.validateField('id')
},
......@@ -558,6 +559,7 @@ export default {
}
)
},
/** 角色change事件*/
roleChange(e) {
// TODO: clear this log
this.$forceUpdate()
......@@ -582,6 +584,7 @@ export default {
// this.form.postId = response.data.checkedKeys
})
},
/** 查询角色下拉*/
getRole() {
getlistRole().then(
response => {
......@@ -664,7 +667,7 @@ export default {
rows: 10,
username: '',
flag: ''
},
}
this.handleQuery()
},
// 多选框选中数据
......@@ -712,6 +715,7 @@ export default {
this.ruleForm.row = row.businessId
this.resetPwdDiaLog = !this.resetPwdDiaLog
},
/** 修改密码确定操作*/
handleResetPwdSure() {
this.$refs.ruleForm.validate(pass => {
if (pass) {
......@@ -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() {
this.$refs['form'].validate(valid => {
......@@ -885,18 +879,20 @@ export default {
this.$message.success(err.message)
this.importLoading = false
})
this.importLoading = false
}
},
/** 导入change*/
employeeUpload(file, fileList) {
if (fileList.length > 1) {
fileList.splice(0, 1)
}
this.fileList = fileList[0].raw
},
/** 导入remove操作*/
handleRemove(file, fileList) {
this.fileList = []
},
/** 导入beforeRemove操作*/
beforeRemove(file, 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