Commit 860d671d by cwq0219

修改

1 parent aea095d8
......@@ -39,7 +39,9 @@ const getRoleList = {
const saveRoleList = {
p: [__sSaveRoleList],
// req: params => GlAxios.post(__sSaveRoleList, JSON.stringify(params), { headers: { 'Content/-Type': 'application/json;charset=UTF-8' }})
// req: params => GlAxios.get(__sSaveRoleList, params)
// req: params => GlAxios.post(__sSaveRoleList, params, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }})
// req: params => GlAxios.post(__sSaveRoleList, params, { headers: { 'Content-Type': 'application/json; charset=utf-8' }})
req: params => GlAxios.post(__sSaveRoleList, params)
}
......
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from './roleConst'
import { roleCreateStructure, roleDataColumn, userRoleDetailColumn, userRoleDetailConsole } from './roleConst'
import { userDetailColumn } from './userConst'
export {
roleCreateStructure,
roleDataColumn,
userRoleDetailColumn,
userRoleDetailConsole,
userDetailColumn
......
import { deleteUserRoleById } from '@/api/api'
const roleCreateStructure = {
id: Number,
roleName: '',
description: '',
departName: '',
rights: Array,
// rights: Array,
state: 1,
createTime: ''
}
const roleDataColumn = [{
label: '序号',
prop: 'id'
}, {
label: '角色名字',
prop: 'roleName'
}, {
label: '所属部门',
prop: 'departName'
}, {
label: '状态',
prop: 'state',
formatter: (cellValue) => {
return cellValue < 1 ? '禁止' : '启动'
}
}, {
label: '创建时间',
prop: 'createTime'
}]
const userRoleDetailColumn = [{
label: '序号',
prop: 'userId'
......@@ -32,14 +54,22 @@ const userRoleDetailConsole = {
label: '删除',
type: 'text',
callback: (index, rows) => {
rows.splice(index, 1)
// this.$alert(rows[index])
const data = rows[index]
const params = { roleId: data.roleId, userId: data.userId }
deleteUserRoleById.req(params).then(res => {
// 加入提示消息!!!
rows.splice(index, 1)
// console.log(res)
}).catch(err => {
console.log(err)
})
}
}]
}
export {
roleCreateStructure,
roleDataColumn,
userRoleDetailColumn,
userRoleDetailConsole
}
......@@ -18,13 +18,13 @@
</gl-select>
</gl-form-item>
<gl-form-item label="菜单选项:">
<tree
<!-- <tree
ref='tree'
:show-checkbox="show_checkbox"
:defaultExpandAll="defaultExpandAll"
@input="getMenuOption"
style="height:160px"
></tree>
></tree> -->
</gl-form-item>
</gl-form>
<div slot="footer" class="dialog-footer">
......@@ -40,7 +40,7 @@ import { saveRoleList, updateRole } from '@/api/api'
export default {
name: 'RoleCreate',
props: {
createOrEditTitle: String,
// createOrEditTitle: String,
createVisible: Boolean,
createRuleForm: Object
},
......@@ -53,6 +53,7 @@ export default {
return {
show_checkbox: true,
defaultExpandAll: true,
createOrEditTitle: String,
createRules: {
roleName: [
{ required: true, message: '请输入角色名称!', trigger: 'blur' }
......@@ -70,7 +71,7 @@ export default {
methods: {
// tree-strat
getMenuOption(params) {
this.createRuleForm.rights = params.treeData.checkedKeys.concat(params.treeData.halfCheckedKeys)
// this.createRuleForm.rights = params.treeData.checkedKeys.concat(params.treeData.halfCheckedKeys)
},
// tree-end
getParams() {
......@@ -78,11 +79,13 @@ export default {
},
// 接口
addRole(flagEOrC, editData) {
// editData = { roleName: editData.roleName }
const aa = JSON.stringify(editData)
// console.log(aa)
// console.log(editData)
saveRoleList.req(aa).then((data) => {
editData = { roleName: editData.roleName }
const aa = { role: editData }
// const aa = JSON.stringify(editData)
console.log(aa)
console.log(editData)
const cc = { roleName: 'ggg' }
saveRoleList.req(cc).then((data) => {
console.log(data)
this.$emit('createClose', flagEOrC, editData)
}).catch(err => {
......
......@@ -30,7 +30,7 @@ export default {
},
apiParam(val) {
this.id = val.id
this.id !== Number && this.callApi()
this.id && this.callApi()
}
},
data() {
......@@ -85,7 +85,6 @@ export default {
// },
callApi() {
this.flagRoleOrUser && this.selectUser()
// !this.flagRoleOrUser && this.getUserRoles()
!this.flagRoleOrUser && (this.tableParam.data = [this.apiParam])
},
handleClose() {
......
......@@ -26,7 +26,7 @@
import { RoleCreate, RoleDetail, UserDetail } from '@/components/index'
// 接口
import { getRoleList, deleteRoleById } from '@/api/api'
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from '@/common/commonConst'
import { roleCreateStructure, roleDataColumn, userRoleDetailColumn, userRoleDetailConsole } from '@/common/commonConst'
export default {
name: 'role',
components: {
......@@ -57,25 +57,7 @@ export default {
border: true,
height: 400,
data: [],
column: [{
label: '序号',
prop: 'id'
}, {
label: '角色名字',
prop: 'roleName'
}, {
label: '所属部门',
prop: 'departName'
}, {
label: '状态',
prop: 'state',
formatter: (cellValue) => {
return cellValue < 1 ? '禁止' : '启动'
}
}, {
label: '创建时间',
prop: 'createTime'
}],
column: roleDataColumn,
console: {
label: '操作',
prop: 'roleOptions',
......@@ -135,7 +117,7 @@ export default {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 删除角色,根据返回的code值来判断是否删除成功
// 删除角色,根据返回的code值来判断是否删除成功(已有拦截器)
this.deleteRole(rows[index].id)
}).catch(() => {
this.message('取消删除')
......@@ -157,7 +139,6 @@ export default {
// console.log(res)
this.total = res.total
this.roleData.data = res.list
// console.log(this.roleData.data)
}).catch(err => {
console.log(err)
})
......@@ -167,21 +148,11 @@ export default {
deleteRoleById.req({ roleId: params }).then(res => {
this.message('删除成功', 'success')
this.getList()
}).catch(err => {
console.log(err)
}).catch(message => {
this.message(message, 'error')
})
},
// 接口请求-end---------------------------------------
// 新增用户到页面
// addRole(data) {
// 后台获取----------------------
// data.id = '1038'
// data.createTime = new Date().toLocaleString().split('/').join('-')
// 后台获取----------------------
// const newData = data
// this.roleData.data.push(newData)
// this.message('创建角色成功!', 'success')
// },
createDialogVisible() {
this.createVisible = !this.createVisible
},
......@@ -220,12 +191,13 @@ export default {
},
handleUserDetailClose() {
this.userDetailDialogVisible()
this.getList()
this.apiParam = Number
},
handleCreateOrEdit(title) {
this.createDialogVisible()
this.createOrEditTitle = title
this.roleParam !== roleCreateStructure ? this.roleParam : roleCreateStructure
this.createDialogVisible()
},
// 关闭新增用户组件
handleCreateClose(flagEOrC, data) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!