Commit 5028634d by 胡悦

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

2 parents c46d3d45 cc0d14bd
......@@ -70,7 +70,7 @@ export default {
}
if (this.value.form.createTime !== undefined) {
this.value.form.createTime = timeTip
this.value.form.changeTime = timeTip
this.value.form.updateTime = timeTip
}
}
}
......
......@@ -22,11 +22,11 @@
:disabled="i.disabled">
</gl-switch>
<gl-input
:ref='i.value'
v-else
v-model="value.form[i.value]"
:disabled="i.disabled">
</gl-input>
<div v-show="err && index === 0" class="err">{{errText}}</div>
</gl-form-item>
<gl-form-item>
<gl-button type="primary" @click="submit">{{value.btnTxt}}</gl-button>
......@@ -41,19 +41,21 @@
center>
<div style="text-align:center">确定是否要删除</div>
<span slot="footer">
<gl-button @click="cancel">取 消</gl-button>
<gl-button @click="delTip(false)">取 消</gl-button>
<gl-button type="primary" @click="delData">确 定</gl-button>
</span>
</gl-dialog>
</div>
</template>
<script type='text/ecmascript-6'>
import { delDepartment, delMenu, editMenu } from '@/api/api'
import { delDepartment, delMenu, editMenu, addMenu } from '@/api/api'
export default {
name: 'rightForm',
data() {
return {
dialog: false
dialog: false,
err: false,
errText: this.isDepart ? '请填写部门名称' : '请填写列表名称'
}
},
props: {
......@@ -65,69 +67,129 @@ export default {
isDepart: Boolean
},
watch: {
},
mounted() {
'value.form.urlName'(val) {
if (val !== '') this.err = false
},
'value.form.name'(val) {
if (val !== '') this.err = false
}
},
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() {
delete this.value.form['name']
console.log(this.value.form)
const obj = this.getMenuObj()
obj.isHidden = this.value.form.isHidden === true ? 0 : 1
this.isDepart
? delDepartment.req(this.value.form).then(res => {
this.$notify({
title: '删除成功',
type: 'success'
})
this.dialog = false
this.value.showDetails = false
? delDepartment.req(obj).then(res => {
this.delTip(true)
}).catch(err => {
console.log(err)
this.delErrTip()
})
: delMenu.req(this.value.form).then(res => {
console.log(res)
this.$notify({
title: '删除成功',
type: 'success'
})
this.dialog = false
this.value.showDetails = false
: delMenu.req(obj).then(res => {
this.delTip(true)
}).catch(err => {
console.log(err)
this.delErrTip()
})
},
cancel() {
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({
title: '删除成功',
type: 'success'
})
this.value.showDetails = false
} else {
this.$notify({
title: '已取消',
type: 'info'
})
}
this.dialog = false
},
delErrTip() {
this.$notify({
title: '已取消',
type: 'info'
title: '删除失败',
type: 'error'
})
this.dialog = false
},
// 保存修改
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) {
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) {
console.log(1)
if (treeData.parent === '#') {
obj.parentId = 0
} else {
obj.parentId = treeData.parent
}
this.addData(obj)
// 添加子级
} else if (this.value.children) {
console.log(2)
obj.parentId = treeData.id
this.addData(obj)
// 修改
} else {
editMenu.req(this.value.form).then(res => {
obj.createTime = this.unix(this.value.form.createTime)
editMenu.req(obj).then(res => {
console.log(res)
this.$notify({
title: '操作成功',
type: 'success'
})
this.Tip(true)
}).catch(err => {
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 => {
console.log(err)
this.Tip(false)
})
}
},
Tip(val) {
if (val) {
this.$notify({
title: '操作成功',
type: 'success'
})
this.value.showDetails = false
} else {
this.$refs.urlName[0].$el.classList.add('err')
this.$notify({
title: '操作失败',
type: 'error'
})
}
}
}
......@@ -141,9 +203,7 @@ export default {
.el-form-item{
margin-bottom: 15px;
}
.err::after{
content: '请填写列表名称';
display: block;
.err{
color: red;
}
</style>
\ No newline at end of file
......@@ -9,7 +9,7 @@
<gl-input v-model="createRuleForm.description" type="textarea" :rows="3" clearable></gl-input>
</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>
</gl-form-item>
<gl-form-item label="所属部门:" prop="departName">
......@@ -49,6 +49,9 @@ export default {
flagCOrE(val) {
this.title = val ? '新建角色' : '角色列表'
// this.createRuleForm.rights = this.roleMenuTree
},
'createRuleForm.description.length'(val) {
this.numberErr = val > 200 ? 1 : 0
}
},
data() {
......@@ -57,6 +60,7 @@ export default {
show_checkbox: true,
defaultExpandAll: true,
departName: [],
numberErr: false,
title: '',
createRules: {
roleName: [
......@@ -119,4 +123,7 @@ export default {
}
</script>
<style scoped>
.err {
color: red;
}
</style>
......@@ -56,13 +56,6 @@ export default {
roleId: this.id
}
},
// getUserParams() {
// return {
// pageSize: this.pageSize,
// pageNum: this.pageNum,
// userId: this.id
// }
// },
// 获取角色的相关用户详细信息
selectUser() {
const params = this.getRoleParams()
......@@ -73,16 +66,6 @@ export default {
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() {
this.flagRoleOrUser && this.selectUser()
!this.flagRoleOrUser && (this.tableParam.data = [this.apiParam])
......
export default {
axios: {
baseURL: 'http://cas.dev.glsx.net/admin-operating-auth/',
// baseURL: 'http://192.168.3.171:7300/mock/5b91805391b67469b43e2921/subsystem/',
// baseURL: 'http://cas.dev.glsx.net/admin-operating-auth/',
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'],
timeout: 15000,
result: {
......
......@@ -28,6 +28,7 @@ export default {
allNode: null,
data: [],
form: {
id: 0,
urlName: '',
hostName: '',
openStyle: '新系统',
......@@ -42,7 +43,6 @@ export default {
updateTime: null,
grade: 0,
iconUrl: '',
id: 0,
lastOperatorId: 0,
lastOperatorName: '',
parentId: 0,
......@@ -82,7 +82,7 @@ export default {
label: '菜单'
},
{
value: '选项3',
value: 2,
label: '按钮'
}
]
......@@ -115,7 +115,10 @@ export default {
this.menuMG.del = true
this.menuMG.push = false
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) {
if (key === 'isHidden') {
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!