Commit 5028634d by 胡悦

Merge branch 'master' of https://github.com/glsx-web/authority

2 parents c46d3d45 cc0d14bd
...@@ -70,7 +70,7 @@ export default { ...@@ -70,7 +70,7 @@ export default {
} }
if (this.value.form.createTime !== undefined) { if (this.value.form.createTime !== undefined) {
this.value.form.createTime = timeTip this.value.form.createTime = timeTip
this.value.form.changeTime = timeTip this.value.form.updateTime = timeTip
} }
} }
} }
......
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
:disabled="i.disabled"> :disabled="i.disabled">
</gl-switch> </gl-switch>
<gl-input <gl-input
:ref='i.value'
v-else v-else
v-model="value.form[i.value]" v-model="value.form[i.value]"
:disabled="i.disabled"> :disabled="i.disabled">
</gl-input> </gl-input>
<div v-show="err && index === 0" class="err">{{errText}}</div>
</gl-form-item> </gl-form-item>
<gl-form-item> <gl-form-item>
<gl-button type="primary" @click="submit">{{value.btnTxt}}</gl-button> <gl-button type="primary" @click="submit">{{value.btnTxt}}</gl-button>
...@@ -41,19 +41,21 @@ ...@@ -41,19 +41,21 @@
center> center>
<div style="text-align:center">确定是否要删除</div> <div style="text-align:center">确定是否要删除</div>
<span slot="footer"> <span slot="footer">
<gl-button @click="cancel">取 消</gl-button> <gl-button @click="delTip(false)">取 消</gl-button>
<gl-button type="primary" @click="delData">确 定</gl-button> <gl-button type="primary" @click="delData">确 定</gl-button>
</span> </span>
</gl-dialog> </gl-dialog>
</div> </div>
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import { delDepartment, delMenu, editMenu } from '@/api/api' import { delDepartment, delMenu, editMenu, addMenu } from '@/api/api'
export default { export default {
name: 'rightForm', name: 'rightForm',
data() { data() {
return { return {
dialog: false dialog: false,
err: false,
errText: this.isDepart ? '请填写部门名称' : '请填写列表名称'
} }
}, },
props: { props: {
...@@ -65,69 +67,129 @@ export default { ...@@ -65,69 +67,129 @@ export default {
isDepart: Boolean isDepart: Boolean
}, },
watch: { watch: {
'value.form.urlName'(val) {
if (val !== '') this.err = false
}, },
mounted() { 'value.form.name'(val) {
if (val !== '') this.err = false
}
}, },
methods: { methods: {
getMenuObj(obj = {}) {
for (const key in this.value.form) {
obj[key] = this.value.form[key]
}
if (!this.isDepart) delete obj.name
return obj
},
// 删除 // 删除
delData() { delData() {
delete this.value.form['name'] const obj = this.getMenuObj()
console.log(this.value.form) obj.isHidden = this.value.form.isHidden === true ? 0 : 1
this.isDepart this.isDepart
? delDepartment.req(this.value.form).then(res => { ? delDepartment.req(obj).then(res => {
this.$notify({ this.delTip(true)
title: '删除成功', }).catch(err => {
type: 'success' console.log(err)
this.delErrTip()
}) })
this.dialog = false : delMenu.req(obj).then(res => {
this.value.showDetails = false this.delTip(true)
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
this.delErrTip()
}) })
: delMenu.req(this.value.form).then(res => { },
console.log(res) delTip(val) {
if (val) {
const parent = this.value.node.parent
const children = parent.data.children || parent.data
const index = children.findIndex(d => d.id === this.value.data.id)
children.splice(index, 1)
this.$notify({ this.$notify({
title: '删除成功', title: '删除成功',
type: 'success' type: 'success'
}) })
this.dialog = false
this.value.showDetails = false this.value.showDetails = false
}).catch(err => { } else {
console.log(err)
})
},
cancel() {
this.dialog = false
this.$notify({ this.$notify({
title: '已取消', title: '已取消',
type: 'info' type: 'info'
}) })
}
this.dialog = false
},
delErrTip() {
this.$notify({
title: '删除失败',
type: 'error'
})
this.dialog = false
}, },
// 保存修改 // 保存修改
submit() { submit() {
delete this.value.form['name'] const treeData = this.value.allNode
if (this.value.form[this.form[0].value] !== '' && this.value.form[this.form[0].value] !== null) { if (this.value.form[this.form[0].value] !== '' && this.value.form[this.form[0].value] !== null) {
const obj = this.getMenuObj()
obj.updateTime = new Date().getTime()
obj.isHidden = this.value.form.isHidden === true ? 0 : 1
console.log(obj)
// 添加同级 // 添加同级
if (this.value.sublings) { if (this.value.sublings) {
console.log(1) if (treeData.parent === '#') {
obj.parentId = 0
} else {
obj.parentId = treeData.parent
}
this.addData(obj)
// 添加子级 // 添加子级
} else if (this.value.children) { } else if (this.value.children) {
console.log(2) obj.parentId = treeData.id
this.addData(obj)
// 修改 // 修改
} else { } else {
editMenu.req(this.value.form).then(res => { obj.createTime = this.unix(this.value.form.createTime)
editMenu.req(obj).then(res => {
console.log(res) console.log(res)
this.$notify({ this.Tip(true)
title: '操作成功', }).catch(err => {
type: 'success' console.log(err)
this.Tip(false)
}) })
}
} else {
this.err = true
}
},
unix(time) {
time = time.substring(0, 19)
time = time.replace(/-/g, '/')
return new Date(time).getTime()
},
addData(obj) {
obj.createTime = new Date().getTime()
if (!this.isDepart) {
addMenu.req(obj).then(res => {
console.log(res)
this.Tip(true)
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
this.Tip(false)
}) })
} }
},
Tip(val) {
if (val) {
this.$notify({
title: '操作成功',
type: 'success'
})
this.value.showDetails = false this.value.showDetails = false
} else { } else {
this.$refs.urlName[0].$el.classList.add('err') this.$notify({
title: '操作失败',
type: 'error'
})
} }
} }
} }
...@@ -141,9 +203,7 @@ export default { ...@@ -141,9 +203,7 @@ export default {
.el-form-item{ .el-form-item{
margin-bottom: 15px; margin-bottom: 15px;
} }
.err::after{ .err{
content: '请填写列表名称';
display: block;
color: red; color: red;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<gl-input v-model="createRuleForm.description" type="textarea" :rows="3" clearable></gl-input> <gl-input v-model="createRuleForm.description" type="textarea" :rows="3" clearable></gl-input>
</gl-form-item> </gl-form-item>
<gl-form-item> <gl-form-item>
<span style="position:absolute; right:35px; top:-20px;">{{createRuleForm.description.length}}</span> <span :class="numberErr? 'err': false" style="position:absolute; right:35px; top:-20px;">{{createRuleForm.description.length}}</span>
<span style="position:absolute; right:5px; top:-20px;">/200</span> <span style="position:absolute; right:5px; top:-20px;">/200</span>
</gl-form-item> </gl-form-item>
<gl-form-item label="所属部门:" prop="departName"> <gl-form-item label="所属部门:" prop="departName">
...@@ -49,6 +49,9 @@ export default { ...@@ -49,6 +49,9 @@ export default {
flagCOrE(val) { flagCOrE(val) {
this.title = val ? '新建角色' : '角色列表' this.title = val ? '新建角色' : '角色列表'
// this.createRuleForm.rights = this.roleMenuTree // this.createRuleForm.rights = this.roleMenuTree
},
'createRuleForm.description.length'(val) {
this.numberErr = val > 200 ? 1 : 0
} }
}, },
data() { data() {
...@@ -57,6 +60,7 @@ export default { ...@@ -57,6 +60,7 @@ export default {
show_checkbox: true, show_checkbox: true,
defaultExpandAll: true, defaultExpandAll: true,
departName: [], departName: [],
numberErr: false,
title: '', title: '',
createRules: { createRules: {
roleName: [ roleName: [
...@@ -119,4 +123,7 @@ export default { ...@@ -119,4 +123,7 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
.err {
color: red;
}
</style> </style>
...@@ -56,13 +56,6 @@ export default { ...@@ -56,13 +56,6 @@ export default {
roleId: this.id roleId: this.id
} }
}, },
// getUserParams() {
// return {
// pageSize: this.pageSize,
// pageNum: this.pageNum,
// userId: this.id
// }
// },
// 获取角色的相关用户详细信息 // 获取角色的相关用户详细信息
selectUser() { selectUser() {
const params = this.getRoleParams() const params = this.getRoleParams()
...@@ -73,16 +66,6 @@ export default { ...@@ -73,16 +66,6 @@ export default {
console.log(err) console.log(err)
}) })
}, },
// 获取用户详情,包括角色
// getUserRoles() {
// const params = this.getUserParams()
// getWithRoles.req(params).then(res => {
// this.total = 1
// this.tableParam.data = [res]
// }).catch(err => {
// console.log(err)
// })
// },
callApi() { callApi() {
this.flagRoleOrUser && this.selectUser() this.flagRoleOrUser && this.selectUser()
!this.flagRoleOrUser && (this.tableParam.data = [this.apiParam]) !this.flagRoleOrUser && (this.tableParam.data = [this.apiParam])
......
export default { export default {
axios: { axios: {
baseURL: 'http://cas.dev.glsx.net/admin-operating-auth/', // baseURL: 'http://cas.dev.glsx.net/admin-operating-auth/',
// baseURL: 'http://192.168.3.171:7300/mock/5b91805391b67469b43e2921/subsystem/', baseURL: 'http://192.168.3.171:7300/mock/5b91805391b67469b43e2921/subsystem/',
whiteList: ['role/deleteRoleById', 'role/deleteUserRoleById', 'role/getRoleDetail', 'role/getRoleDetail', 'role/getRoleList', 'role/isRoleNameExit', 'role/saveRoleList', 'role/selectMenuTreeRoleId', 'role/selectUserRoleByRoleId', 'role/updateRole', 'user/batcheDel', 'user/findAll', 'user/get', 'user/getWithRoles', 'user/operatUser', 'user/updateUser', 'department/del', 'department/findTree', 'department/getPName', 'department/getTreeNode', 'department/updateDepartment', 'menu/add', 'menu/del', 'menu/edit', 'menu/findById', 'menu/findTree', 'menu/getByUserId', 'menu/getPName'], whiteList: ['role/deleteRoleById', 'role/deleteUserRoleById', 'role/getRoleDetail', 'role/getRoleDetail', 'role/getRoleList', 'role/isRoleNameExit', 'role/saveRoleList', 'role/selectMenuTreeRoleId', 'role/selectUserRoleByRoleId', 'role/updateRole', 'user/batcheDel', 'user/findAll', 'user/get', 'user/getWithRoles', 'user/operatUser', 'user/updateUser', 'department/del', 'department/findTree', 'department/getPName', 'department/getTreeNode', 'department/updateDepartment', 'menu/add', 'menu/del', 'menu/edit', 'menu/findById', 'menu/findTree', 'menu/getByUserId', 'menu/getPName'],
timeout: 15000, timeout: 15000,
result: { result: {
......
...@@ -28,6 +28,7 @@ export default { ...@@ -28,6 +28,7 @@ export default {
allNode: null, allNode: null,
data: [], data: [],
form: { form: {
id: 0,
urlName: '', urlName: '',
hostName: '', hostName: '',
openStyle: '新系统', openStyle: '新系统',
...@@ -42,7 +43,6 @@ export default { ...@@ -42,7 +43,6 @@ export default {
updateTime: null, updateTime: null,
grade: 0, grade: 0,
iconUrl: '', iconUrl: '',
id: 0,
lastOperatorId: 0, lastOperatorId: 0,
lastOperatorName: '', lastOperatorName: '',
parentId: 0, parentId: 0,
...@@ -82,7 +82,7 @@ export default { ...@@ -82,7 +82,7 @@ export default {
label: '菜单' label: '菜单'
}, },
{ {
value: '选项3', value: 2,
label: '按钮' label: '按钮'
} }
] ]
...@@ -115,7 +115,10 @@ export default { ...@@ -115,7 +115,10 @@ export default {
this.menuMG.del = true this.menuMG.del = true
this.menuMG.push = false this.menuMG.push = false
findMenuById.req({ id: data.id }).then(res => { findMenuById.req({ id: data.id }).then(res => {
console.log(res) // for (const key in res) {
// console.log(res[key], typeof res[key], key)
// }
// console.log(this.menuMG.allNode, this.menuMG.node)
for (const key in this.menuMG.form) { for (const key in this.menuMG.form) {
if (key === 'isHidden') { if (key === 'isHidden') {
this.menuMG.form[key] = res[key] === 0 this.menuMG.form[key] = res[key] === 0
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!