Commit 550e667e by cwq0219

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

2 parents 860d671d 3133be1b
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<tree <tree
ref='tree' ref='tree'
@node-click='nodeClick' @node-click='nodeClick'
:isDepart='isDepart'
></tree> ></tree>
</div> </div>
</template> </template>
...@@ -33,7 +34,8 @@ export default { ...@@ -33,7 +34,8 @@ export default {
default: () => { default: () => {
return null return null
} }
} },
isDepart: Boolean
}, },
methods: { methods: {
// 展开与关闭 // 展开与关闭
...@@ -60,6 +62,7 @@ export default { ...@@ -60,6 +62,7 @@ export default {
this.clearFrom() this.clearFrom()
}, },
clearFrom() { clearFrom() {
this.value.showDetails = true
this.value.btnTxt = '保存' this.value.btnTxt = '保存'
this.value.del = false this.value.del = false
for (const key in this.value.form) { for (const key in this.value.form) {
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
</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>
<gl-button type="danger" v-show='value.del' @click="centerDialogVisible = true ">删除</gl-button> <gl-button type="danger" v-show='value.del' @click="dialog = true ">删除</gl-button>
<gl-button @click='value.showDetails = false' style="float:right">取消</gl-button> <gl-button @click='value.showDetails = false' style="float:right">取消</gl-button>
</gl-form-item> </gl-form-item>
</gl-form> </gl-form>
<gl-dialog <gl-dialog
title="提示" title="提示"
:visible.sync="centerDialogVisible" :visible.sync="dialog"
width="30%" width="30%"
center> center>
<div style="text-align:center">确定是否要删除</div> <div style="text-align:center">确定是否要删除</div>
...@@ -47,13 +47,13 @@ ...@@ -47,13 +47,13 @@
</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'
export default { export default {
name: 'rightForm', name: 'rightForm',
data() { data() {
return { return {
centerDialogVisible: false dialog: false
} }
}, },
props: { props: {
...@@ -61,29 +61,43 @@ export default { ...@@ -61,29 +61,43 @@ export default {
form: { form: {
type: Array, type: Array,
default: () => [] default: () => []
} },
isDepart: Boolean
}, },
watch: { watch: {
'value.form.name'(val) { },
if (val !== '') this.$refs.name[0].$el.classList.remove('err') mounted() {
}
}, },
methods: { methods: {
// 删除 // 删除
delData() { delData() {
for (let index = 0; index < this.value.node.parent.childNodes.length; index++) { delete this.value.form['name']
if (this.value.node.parent.childNodes[index] === this.value.node) this.value.node.level === 1 ? this.value.node.parent.data.splice(index, 1) : this.value.node.parent.data.children.splice(index, 1) console.log(this.value.form)
} this.isDepart
this.$notify({ ? delDepartment.req(this.value.form).then(res => {
title: '删除成功', this.$notify({
type: 'success' title: '删除成功',
}) type: 'success'
this.centerDialogVisible = false })
this.$set_session_config(this.value.data) this.dialog = false
this.value.showDetails = false this.value.showDetails = false
}).catch(err => {
console.log(err)
})
: delMenu.req(this.value.form).then(res => {
console.log(res)
this.$notify({
title: '删除成功',
type: 'success'
})
this.dialog = false
this.value.showDetails = false
}).catch(err => {
console.log(err)
})
}, },
cancel() { cancel() {
this.centerDialogVisible = false this.dialog = false
this.$notify({ this.$notify({
title: '已取消', title: '已取消',
type: 'info' type: 'info'
...@@ -91,47 +105,29 @@ export default { ...@@ -91,47 +105,29 @@ export default {
}, },
// 保存修改 // 保存修改
submit() { submit() {
if (this.value.form.name !== '' && this.value.form.name !== null) { delete this.value.form['name']
let arr = {} if (this.value.form[this.form[0].value] !== '' && this.value.form[this.form[0].value] !== null) {
// 添加同级 // 添加同级
if (this.value.sublings) { if (this.value.sublings) {
arr = { console.log(1)
id: this.value.form.index,
level: this.value.node.level,
createTime: new Date().format('yyyy-MM-dd HH:mm:ss')
}
arr[this.value.props.label] = this.value.form.name
if (this.value.node.level === 1) {
this.value.data.push(arr)
} else {
if (this.value.node.parent.data.children === undefined) this.$set(this.value.node.parent.data, 'children', [])
this.value.node.parent.data.children.push(arr)
}
// 添加子级 // 添加子级
} else if (this.value.children) { } else if (this.value.children) {
arr = { console.log(2)
id: this.value.form.index,
level: this.value.node.level + 1,
createTime: new Date().format('yyyy-MM-dd HH:mm:ss')
}
arr[this.value.props.label] = this.value.form.name
if (this.value.allNode.children === undefined) this.$set(this.value.allNode, 'children', [])
this.value.allNode.children.push(arr)
// 修改 // 修改
} else { } else {
this.value.node.data.id = this.value.form.index editMenu.req(this.value.form).then(res => {
this.value.node.data[this.value.props.label] = this.value.form.name console.log(res)
if (this.value.node.data.changeTime === undefined) this.$set(this.value.node.data, 'changeTime', '') this.$notify({
this.value.node.data.changeTime = new Date().format('yyyy-MM-dd HH:mm:ss') title: '操作成功',
type: 'success'
})
}).catch(err => {
console.log(err)
})
} }
this.value.showDetails = false this.value.showDetails = false
this.$notify({
title: '操作成功',
type: 'success'
})
this.$set_session_config(this.value.data)
} else { } else {
this.$refs.name[0].$el.classList.add('err') this.$refs.urlName[0].$el.classList.add('err')
} }
} }
} }
......
<template> <template>
<div class="tree" :style="treeStyle"> <div class="tree" :style="treeStyle">
<<<<<<< HEAD
<gl-tree ref='tree' highlight-current :data='data' :show-checkbox='showCheckbox' node-key='id' :props='props' :default-expand-all='defaultExpandAll' @check='check' @node-click='nodeClick'></gl-tree>
=======
<gl-tree <gl-tree
ref='tree' ref='tree'
highlight-current highlight-current
...@@ -15,34 +12,17 @@ ...@@ -15,34 +12,17 @@
@check='check' @check='check'
@node-click='nodeClick' @node-click='nodeClick'
></gl-tree> ></gl-tree>
>>>>>>> 9bf4d2fc7a08913f8a8bbac501752e7dc6d5f705
</div> </div>
</template> </template>
<script> <script>
import { findMenuTree } from '@/api/api' import { findMenuTree, findDepartTree } from '@/api/api'
function fn(data, pid) {
var result = []
let temp = null
for (var i in data) {
if (data[i].parent == pid) {
result.push(data[i])
temp = fn(data, data[i].id)
if (temp.length > 0) {
data[i].children = temp
}
}
}
return result
}
export default { export default {
name: 'Tree', name: 'Tree',
data() { data() {
return { return {
// data: this.$get_session_config().resources || this.$get_session_config(), data: null,
data: [Array, Function],
props: { props: {
// label: 'title'
label: 'text' label: 'text'
} }
} }
...@@ -55,17 +35,8 @@ export default { ...@@ -55,17 +35,8 @@ export default {
defaultCheckedKeys: { defaultCheckedKeys: {
type: Array, type: Array,
default: () => [] default: () => []
} },
}, isDepart: Boolean
mounted() {
findMenuTree.req().then(res => {
// this.data = res
// this.data = this.$get_menus(res, '#', 'parent')
this.data = fn(res, '#')
// console.log(this.data)
}).catch(err => {
console.log(err)
})
}, },
methods: { methods: {
nodeClick(data, treeData, vue) { nodeClick(data, treeData, vue) {
...@@ -74,7 +45,34 @@ export default { ...@@ -74,7 +45,34 @@ export default {
check(data, treeData) { check(data, treeData) {
this.$emit('input', { data, treeData }) this.$emit('input', { data, treeData })
} }
},
mounted() {
!this.isDepart
? findMenuTree.req().then(res => {
this.data = fn(res, '#')
}).catch(err => {
console.log(err)
})
: findDepartTree.req().then(res => {
this.data = fn(res, '#')
}).catch(err => {
console.log(err)
})
}
}
function fn(data, pid) {
var result = []
var temp = null
for (var i in data) {
if (data[i].parent == pid) {
result.push(data[i])
temp = fn(data, data[i].id)
if (temp.length > 0) {
data[i].children = temp
}
}
} }
return result
} }
</script> </script>
<style scoped> <style scoped>
......
function format(formatStr) { function format(formatStr) {
const date = this const date = this
var zeroize = function(value, length) { var zeroize = function(value, length) {
if (!length) { let zeros = ''
length = 2 if (!length) length = 2
} value = value.toString()
for (var i = 0, zeros = ''; i < (length - value.length); i++) { for (let i = 0; i < (length - value.length); i++) {
zeros += '0' zeros += '0'
} }
return zeros + value return zeros + value
......
<!-- departmentManagement --> <!-- departmentManagement -->
<template> <template>
<gl-row :gutter="100"> <gl-row :gutter="50">
<gl-col :span='8'> <gl-col :span='8'>
<left-manager :title='"部门列表"' v-model="department" :nodeClick='nodeClick'></left-manager> <left-manager :title='"部门列表"' isDepart v-model="department" :nodeClick='nodeClick'></left-manager>
</gl-col> </gl-col>
<gl-col :span='16'> <gl-col :span='16'>
<right-form :form='form' v-model="department"></right-form> <right-form :form='form' isDepart v-model="department"></right-form>
</gl-col> </gl-col>
</gl-row> </gl-row>
</template> </template>
<script> <script>
import { LeftManager, RightForm } from '@/components/index' import { LeftManager, RightForm } from '@/components/index'
import { getDepartTreeNode } from '@/api/api'
export default { export default {
name: 'department', name: 'department',
data() { data() {
...@@ -30,13 +31,13 @@ export default { ...@@ -30,13 +31,13 @@ export default {
form: { form: {
name: '', name: '',
upDepartment: '', upDepartment: '',
index: '' iorder: ''
} }
}, },
form: [ form: [
{ label: '部门名称', value: 'name' }, { label: '部门名称', value: 'name' },
{ label: '上级部门', value: 'upDepartment', disabled: true }, { label: '上级部门', value: 'upDepartment', disabled: true },
{ label: '排序', value: 'index' } { label: '排序', value: 'iorder' }
] ]
} }
}, },
...@@ -56,9 +57,13 @@ export default { ...@@ -56,9 +57,13 @@ export default {
this.department.children = false this.department.children = false
this.department.del = true this.department.del = true
this.department.push = false this.department.push = false
this.department.form.name = data[props.label]
this.department.form.upDepartment = node.level === 1 ? '广联赛讯' : node.parent.data[props.label] this.department.form.upDepartment = node.level === 1 ? '广联赛讯' : node.parent.data[props.label]
this.department.form.index = node.data.id getDepartTreeNode.req({ id: data.id }).then(res => {
this.department.form.name = res.name
this.department.form.iorder = res.iorder
}).catch(err => {
console.log(err)
})
} }
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<script> <script>
import { LeftManager, RightForm } from '@/components/index' import { LeftManager, RightForm } from '@/components/index'
import { findMenuById } from '@/api/api'
export default { export default {
name: 'menuMG', name: 'menuMG',
data() { data() {
...@@ -27,49 +28,57 @@ export default { ...@@ -27,49 +28,57 @@ export default {
allNode: null, allNode: null,
data: [], data: [],
form: { form: {
urlName: '',
hostName: '',
openStyle: '新系统',
menuType: '',
name: '', name: '',
newName: '', path: '',
open: '新系统',
type: '',
upMenu: '',
url: '', url: '',
router: '', baseUrl: '',
defaultUrl: '', iorder: null,
index: '', isHidden: 0,
Show: true,
createTime: null, createTime: null,
changeTime: null updateTime: null,
grade: 0,
iconUrl: '',
id: 0,
lastOperatorId: 0,
lastOperatorName: '',
parentId: 0,
state: 0,
title: ''
} }
}, },
form: [ form: [
{ label: '名称', value: 'name' }, { label: '名称', value: 'urlName' },
{ label: '主机自定义名称', value: 'newName' }, { label: '主机自定义名称', value: 'hostName' },
{ {
label: '打开模式', label: '打开模式',
value: 'open', value: 'openStyle',
type: 'select', type: 'select',
options: [ options: [
{ {
value: '选项1', value: 0,
label: '本系统' label: '本系统'
}, },
{ {
value: '选项2', value: 1,
label: '新系统' label: '新系统'
} }
] ]
}, },
{ {
label: '功能类型', label: '功能类型',
value: 'type', value: 'menuType',
type: 'select', type: 'select',
options: [ options: [
{ {
value: '选项1', value: 0,
label: '菜单路由' label: '菜单路由'
}, },
{ {
value: '选项2', value: 1,
label: '菜单' label: '菜单'
}, },
{ {
...@@ -78,14 +87,14 @@ export default { ...@@ -78,14 +87,14 @@ export default {
} }
] ]
}, },
{ label: '上级菜单', value: 'upMenu', disabled: true }, { label: '上级菜单', value: 'name', disabled: true },
{ label: '菜单路径', value: 'url', disabled: true }, { label: '菜单路径', value: 'path', disabled: true },
{ label: '路由', value: 'router' }, { label: '路由', value: 'url' },
{ label: '基础路径', value: 'defaultUrl' }, { label: '基础路径', value: 'baseUrl' },
{ label: '排序', value: 'index' }, { label: '排序', value: 'iorder' },
{ label: '是否隐藏', value: 'Show', type: 'switch' }, { label: '是否隐藏', value: 'isHidden', type: 'switch' },
{ label: '创建时间', value: 'createTime', disabled: true }, { label: '创建时间', value: 'createTime', disabled: true },
{ label: '修改时间', value: 'changeTime', disabled: true } { label: '修改时间', value: 'updateTime', disabled: true }
] ]
} }
}, },
...@@ -105,12 +114,22 @@ export default { ...@@ -105,12 +114,22 @@ export default {
this.menuMG.children = false this.menuMG.children = false
this.menuMG.del = true this.menuMG.del = true
this.menuMG.push = false this.menuMG.push = false
this.menuMG.form.name = data[props.label] findMenuById.req({ id: data.id }).then(res => {
this.menuMG.form.upMenu = node.level === 1 ? '顶级菜单' : node.parent.data[props.label] console.log(res)
this.menuMG.form.defaultUrl = data.path for (const key in this.menuMG.form) {
this.menuMG.form.index = node.data.id if (key === 'isHidden') {
this.menuMG.form.createTime = data.createTime this.menuMG.form[key] = res[key] === 0
this.menuMG.form.changeTime = data.changeTime } else if (key === 'createTime' || key === 'updateTime') {
this.menuMG.form[key] = new Date(res[key]).format('yyyy-MM-dd HH:mm:ss')
} else if (key === 'name') {
this.menuMG.form[key] = node.level === 1 ? '顶级菜单' : node.parent.data[props.label]
} else {
this.menuMG.form[key] = res[key]
}
}
}).catch(err => {
console.log(err)
})
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!