Commit b334f618 by cwq0219

合并

2 parents 734ac25d 9bf4d2fc
...@@ -9,9 +9,8 @@ import './styles/role-user-common.scss' ...@@ -9,9 +9,8 @@ import './styles/role-user-common.scss'
import './styles/index.scss' import './styles/index.scss'
import './date.js' import './date.js'
// import _ from 'lodash' // import _ from 'lodash'
import { MenuManager, Tree } from '@/components' import { Tree } from '@/components'
Vue.use(GlsxVueComponents) Vue.use(GlsxVueComponents)
Vue.component('menuManager', MenuManager)
Vue.component('tree', Tree) Vue.component('tree', Tree)
Vue.use(GlsxVueCommon, common) Vue.use(GlsxVueCommon, common)
......
import LeftManager from './src/main'
LeftManager.install = Vue => Vue.components(LeftManager.name, LeftManager)
export default LeftManager
<template>
<div class="menu-box box">
<div class="title">{{title}}</div>
<div class="console-btn">
<div><gl-button @click="openAll(openOrClose)">{{openOrClose ? '全部展开' : '全部收起'}}</gl-button></div>
<div><gl-button @click="pushSublings" type='primary' :disabled="value.push">添加同级菜单</gl-button></div>
<div><gl-button @click="pushChildren" type='primary' :disabled="value.push">添加子菜单</gl-button></div>
</div>
<tree
ref='tree'
@node-click='nodeClick'
></tree>
</div>
</template>
<script type='text/ecmascript-6'>
const timeTip = '系统自动生成(格式yyyy-MM-dd HH:mm:ss)'
export default {
name: 'leftManager',
data() {
return {
openOrClose: true
}
},
props: {
value: null,
title: {
type: String,
default: '标题'
},
nodeClick: {
type: Function,
default: () => {
return null
}
}
},
methods: {
// 展开与关闭
openAll(val) {
this.searchChildren(this.$refs.tree.$children[0].$children[0].store._getAllNodes(), val)
this.openOrClose = !this.openOrClose
},
searchChildren(data, val) {
data.forEach(el => {
this.$set(el, 'expanded', val)
if (el.childNodes) {
this.searchChildren(el.childNodes, val)
}
})
},
// 添加同级菜单
pushSublings() {
this.value.sublings = true
this.clearFrom()
},
// 添加子菜单
pushChildren() {
this.value.children = true
this.clearFrom()
},
clearFrom() {
this.value.btnTxt = '保存'
this.value.del = false
for (const key in this.value.form) {
this.value.form[key] = null
}
if (this.value.form.createTime !== undefined) {
this.value.form.createTime = timeTip
this.value.form.changeTime = timeTip
}
}
}
}
</script>
<style scoped>
.console-btn{
padding: 15px;
display: flex;
flex-wrap:wrap;
width: 100%;
box-sizing: border-box;
}
.console-btn div{
flex: 1;
height: 40px;
margin-bottom: 10px;
text-align: center;
}
.console-btn div button{
width: 126px;
box-sizing: border-box
}
</style>
\ No newline at end of file \ No newline at end of file
import MenuManager from './src/main'
MenuManager.install = Vue => Vue.components(MenuManager.name, MenuManager)
export default MenuManager
<template>
<gl-row :gutter="150">
<gl-col :span='8'>
<div class="menu-box box">
<div class="title" v-html="title"></div>
<div class="console-btn">
<div><gl-button @click="openAll(openOrClose)">{{openOrClose ? '全部展开' : '全部收起'}}</gl-button></div>
<div><gl-button @click="pushSublings" type='primary' :disabled="push">添加同级菜单</gl-button></div>
<div><gl-button @click="pushChildren" type='primary' :disabled="push">添加子菜单</gl-button></div>
</div>
<tree
ref='tree'
@node-click='nodeClick'
></tree>
</div>
</gl-col>
<gl-col :span='16' v-show="showDetails">
<div class="details box">
<div class="title">详情</div>
<gl-form :model='form' class="content" label-width="150px">
<gl-form-item label="名称" >
<gl-input v-model="form.name" ref="name"></gl-input>
</gl-form-item>
<gl-form-item label="主机自定义名称">
<gl-input v-model="form.newName"></gl-input>
</gl-form-item>
<gl-form-item label="打开模式">
<gl-select v-model="form.open" style="width:100%">
<gl-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</gl-option>
</gl-select>
</gl-form-item>
<gl-form-item label="功能类型">
<gl-select v-model="form.type" style="width:100%" placeholder="请选择功能类型">
<gl-option
v-for="item in options2"
:key="item.value"
:label="item.label"
:value="item.value">
</gl-option>
</gl-select>
</gl-form-item>
<gl-form-item label="上级菜单">
<gl-input v-model="form.upMenu" disabled></gl-input>
</gl-form-item>
<gl-form-item label="菜单路径">
<gl-input v-model="form.url" disabled></gl-input>
</gl-form-item>
<gl-form-item label="路由">
<gl-input v-model="form.router"></gl-input>
</gl-form-item>
<gl-form-item label="基础路径">
<gl-input v-model="form.defaultUrl"></gl-input>
</gl-form-item>
<gl-form-item label="排序">
<gl-input v-model="form.index"></gl-input>
</gl-form-item>
<gl-form-item label="是否隐藏">
<gl-switch v-model="form.Show"></gl-switch>
</gl-form-item>
<gl-form-item label="创建时间">
<gl-input v-model="form.createTime" disabled></gl-input>
</gl-form-item>
<gl-form-item label="修改时间">
<gl-input v-model="form.changeTime" disabled></gl-input>
</gl-form-item>
<gl-form-item>
<gl-button type="primary" @click="submit">{{btnTxt}}</gl-button>
<gl-button type="danger" v-show='del' @click="delData">删除</gl-button>
<gl-button @click="showDetails = false" style="float:right">取消</gl-button>
</gl-form-item>
</gl-form>
</div>
</gl-col>
</gl-row>
</template>
<script>
var timeTip = '系统自动生成(格式yyyy-MM-dd HH:mm:ss)'
export default {
name: 'MenuManager',
data() {
return {
data: [],
props: null,
openOrClose: true,
node: null,
btnTxt: '修改',
allNode: null,
push: true,
del: true,
showDetails: false,
_children: false,
_sublings: false,
form: {
name: '',
newName: '',
open: '新系统',
type: '',
upMenu: '',
url: '',
router: '',
defaultUrl: '',
index: '',
Show: true,
createTime: null,
changeTime: null
},
options: [
{
value: '选项1',
label: '本系统'
},
{
value: '选项2',
label: '新系统'
}
],
options2: [
{
value: '选项1',
label: '菜单路由'
},
{
value: '选项2',
label: '菜单'
},
{
value: '选项3',
label: '按钮'
}
]
}
},
props: {
title: {
type: String,
default: '标题'
}
},
watch: {
'form.name'(val) {
if (val !== '') this.$refs.name.$el.classList.remove('err')
}
},
methods: {
nodeClick(data, node, that, props) {
if (node.level === 1) this.data = node.parent.data
this.btnTxt = '修改'
this.node = node
this.allNode = data
this.props = props
this._sublings = false
this._children = false
this.del = true
this.push = false
this.showDetails = true
this.form.name = data.label || data[props.label]
this.form.upMenu = node.level === 1 ? '顶级菜单' : node.parent.data.label || node.parent.data[props.label]
this.form.defaultUrl = data.path
this.form.index = node.data.id
this.form.createTime = data.createTime
this.form.changeTime = data.changeTime
},
// 展开与关闭
openAll(val) {
this.searchChildren(this.$refs.tree.$children[0].$children[0].store._getAllNodes(), val)
this.openOrClose = !this.openOrClose
},
searchChildren(data, val) {
data.forEach(el => {
el.expanded = val
if (el.childNodes) {
this.searchChildren(el.childNodes, val)
}
})
},
// 添加同级菜单
pushSublings() {
this.btnTxt = '保存'
this._sublings = true
this._children = false
this.del = false
this.showDetails = true
for (const key in this.form) {
this.form[key] = null
}
this.form.createTime = timeTip
this.form.changeTime = timeTip
},
// 添加子菜单
pushChildren() {
this.btnTxt = '保存'
this._children = true
this._sublings = false
this.del = false
this.showDetails = true
for (const key in this.form) {
this.form[key] = null
}
this.form.createTime = timeTip
this.form.changeTime = timeTip
},
// 删除
delData() {
for (let index = 0; index < this.node.parent.childNodes.length; index++) {
if (this.node.parent.childNodes[index] === this.node) this.node.level === 1 ? this.node.parent.data.splice(index, 1) : this.node.parent.data.children.splice(index, 1)
}
this.$notify({
title: '删除成功',
type: 'success'
})
this.$set_session_config(this.data)
this.showDetails = false
},
// 保存修改
submit() {
if (this.form.name !== '' && this.form.name !== null) {
let arr = {}
// 添加同级
if (this._sublings) {
arr = {
id: this.form.index,
level: this.node.level,
createTime: new Date().format('yyyy-MM-dd HH:mm:ss')
}
arr[this.props.label] = this.form.name
if (this.node.level === 1) {
this.data.push(arr)
} else {
if (this.node.parent.data.children === undefined) this.$set(this.node.parent.data, 'children', [])
this.node.parent.data.children.push(arr)
}
} else if (this._children) { // 添加子级
arr = {
id: this.form.index,
level: this.node.level + 1,
createTime: new Date().format('yyyy-MM-dd HH:mm:ss')
}
arr[this.props.label] = this.form.name
if (this.allNode.children === undefined) this.$set(this.allNode, 'children', [])
this.allNode.children.push(arr)
} else { // 修改
this.node.data.id = this.form.index
this.node.data[this.props.label] = this.form.name
if (this.node.data.changeTime === undefined) this.$set(this.node.data, 'changeTime', '')
this.node.data.changeTime = new Date().format('yyyy-MM-dd HH:mm:ss')
}
this.showDetails = false
this.$notify({
title: '操作成功',
type: 'success'
})
this.$set_session_config(this.data)
} else {
this.$refs.name.$el.classList.add('err')
}
}
}
}
</script>
<style scoped>
.content{
padding: 15px;
}
.box{
margin-bottom: 20px;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
}
.title{
color: #333;
background-color: #f5f5f5;
border-color: #ddd;
padding: 10px 15px;
border-bottom: 1px solid transparent;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.el-form-item{
margin-bottom: 15px;
}
.console-btn{
padding: 15px;
display: flex;
flex-wrap:wrap;
width: 100%;
box-sizing: border-box;
}
.console-btn div{
flex: 1;
height: 40px;
margin-bottom: 10px;
}
.err::after{
content: '请填写列表名称';
display: block;
color: red;
}
</style>
import RightForm from './src/main'
RightForm.install = Vue => Vue.components(RightForm.name, RightForm)
export default RightForm
<template>
<div class="details box" v-show="value.showDetails">
<div class="title">详情</div>
<gl-form :model='value.form' class="content" label-width="120px" size="mini">
<gl-form-item v-for="(i, index) in form" :key="index" :label='i.label'>
<gl-select
v-if="i.type === 'select'"
v-model="value.form[i.value]"
style="width:100%"
:placeholder="i.placeholder"
:disabled="i.disabled">
<gl-option
v-for="item in i.options"
:key="item.value"
:label="item.label"
:value="item.value">
</gl-option>
</gl-select>
<gl-switch
v-else-if="i.type === 'switch'"
v-model="value.form[i.value]"
:disabled="i.disabled">
</gl-switch>
<gl-input
:ref='i.value'
v-else
v-model="value.form[i.value]"
:disabled="i.disabled">
</gl-input>
</gl-form-item>
<gl-form-item>
<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 @click='value.showDetails = false' style="float:right">取消</gl-button>
</gl-form-item>
</gl-form>
<gl-dialog
title="提示"
:visible.sync="centerDialogVisible"
width="30%"
center>
<div style="text-align:center">确定是否要删除</div>
<span slot="footer">
<gl-button @click="cancel">取 消</gl-button>
<gl-button type="primary" @click="delData">确 定</gl-button>
</span>
</gl-dialog>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'rightForm',
data() {
return {
centerDialogVisible: false
}
},
props: {
value: null,
form: {
type: Array,
default: () => []
}
},
watch: {
'value.form.name'(val) {
if (val !== '') this.$refs.name[0].$el.classList.remove('err')
}
},
methods: {
// 删除
delData() {
for (let index = 0; index < this.value.node.parent.childNodes.length; index++) {
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)
}
this.$notify({
title: '删除成功',
type: 'success'
})
this.centerDialogVisible = false
this.$set_session_config(this.value.data)
this.value.showDetails = false
},
cancel() {
this.centerDialogVisible = false
this.$notify({
title: '已取消',
type: 'info'
})
},
// 保存修改
submit() {
if (this.value.form.name !== '' && this.value.form.name !== null) {
let arr = {}
// 添加同级
if (this.value.sublings) {
arr = {
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) {
arr = {
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 {
this.value.node.data.id = this.value.form.index
this.value.node.data[this.value.props.label] = this.value.form.name
if (this.value.node.data.changeTime === undefined) this.$set(this.value.node.data, 'changeTime', '')
this.value.node.data.changeTime = new Date().format('yyyy-MM-dd HH:mm:ss')
}
this.value.showDetails = false
this.$notify({
title: '操作成功',
type: 'success'
})
this.$set_session_config(this.value.data)
} else {
this.$refs.name[0].$el.classList.add('err')
}
}
}
}
</script>
<style scoped>
.content{
padding: 15px;
}
.el-form-item{
margin-bottom: 15px;
}
.err::after{
content: '请填写列表名称';
display: block;
color: red;
}
</style>
\ No newline at end of file \ No newline at end of file
<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 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
ref='tree'
highlight-current
:data='data'
:show-checkbox='showCheckbox'
node-key='id'
:props='props'
:default-expand-all='defaultExpandAll'
:default-checked-keys="defaultCheckedKeys"
@check='check'
@node-click='nodeClick'
></gl-tree>
>>>>>>> 9bf4d2fc7a08913f8a8bbac501752e7dc6d5f705
</div> </div>
</template> </template>
...@@ -36,7 +51,11 @@ export default { ...@@ -36,7 +51,11 @@ export default {
showCheckbox: Boolean, showCheckbox: Boolean,
value: null, value: null,
defaultExpandAll: Boolean, defaultExpandAll: Boolean,
treeStyle: null treeStyle: null,
defaultCheckedKeys: {
type: Array,
default: () => []
}
}, },
mounted() { mounted() {
findMenuTree.req().then(res => { findMenuTree.req().then(res => {
......
...@@ -3,12 +3,14 @@ import UserDetail from './UserDetail' ...@@ -3,12 +3,14 @@ import UserDetail from './UserDetail'
import RoleCreate from './RoleCreate' import RoleCreate from './RoleCreate'
import RoleDetail from './RoleDetail' import RoleDetail from './RoleDetail'
import Tree from './Tree' import Tree from './Tree'
import MenuManager from './MenuManager' import LeftManager from './LeftManager'
import RightForm from './RightForm'
export { export {
UserCreate, UserCreate,
UserDetail, UserDetail,
RoleCreate, RoleCreate,
RoleDetail, RoleDetail,
Tree, Tree,
MenuManager LeftManager,
RightForm
} }
...@@ -73,3 +73,20 @@ a:hover { ...@@ -73,3 +73,20 @@ a:hover {
.app-container { .app-container {
padding: 20px; padding: 20px;
} }
//菜单管理,部门管理的标题
.title{
color: #333;
background-color: #f5f5f5;
border-color: #ddd;
padding: 10px 15px;
border-bottom: 1px solid transparent;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
//菜单管理,部门管理 边框
.box{
margin-bottom: 20px;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
}
\ No newline at end of file \ No newline at end of file
<!-- departmentManagement --> <!-- departmentManagement -->
<template> <template>
<div>departmentList</div> <gl-row :gutter="100">
<gl-col :span='8'>
<left-manager :title='"部门列表"' v-model="department" :nodeClick='nodeClick'></left-manager>
</gl-col>
<gl-col :span='16'>
<right-form :form='form' v-model="department"></right-form>
</gl-col>
</gl-row>
</template> </template>
<script> <script>
import { LeftManager, RightForm } from '@/components/index'
export default { export default {
name: 'department', name: 'department',
data() { data() {
return { return {
department: {
sublings: false,
children: false,
node: null,
props: null,
allNode: null,
del: false,
push: true,
showDetails: false,
btnTxt: '修改',
data: [],
form: {
name: '',
upDepartment: '',
index: ''
}
},
form: [
{ label: '部门名称', value: 'name' },
{ label: '上级部门', value: 'upDepartment', disabled: true },
{ label: '排序', value: 'index' }
]
}
},
components: {
LeftManager,
RightForm
},
methods: {
nodeClick(data, node, that, props) {
this.department.showDetails = true
if (node.level === 1) this.department.data = node.parent.data
this.department.btnTxt = '修改'
this.department.node = node
this.department.allNode = data
this.department.props = props
this.department.sublings = false
this.department.children = false
this.department.del = true
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.index = node.data.id
} }
} }
} }
......
<template> <template>
<div> <gl-row :gutter="100">
<menu-manager :title="'菜单列表'"></menu-manager> <gl-col :span='8'>
</div> <left-manager :title='"菜单列表"' v-model="menuMG" :node-click='nodeClick'></left-manager>
</gl-col>
<gl-col :span='16'>
<right-form :form='form' v-model="menuMG"></right-form>
</gl-col>
</gl-row>
</template> </template>
<script> <script>
import { LeftManager, RightForm } from '@/components/index'
export default { export default {
name: 'menuMG', name: 'menuMG',
data() { data() {
return { return {
menuMG: {
sublings: false,
children: false,
del: false,
push: true,
showDetails: false,
btnTxt: '修改',
node: null,
props: null,
allNode: null,
data: [],
form: {
name: '',
newName: '',
open: '新系统',
type: '',
upMenu: '',
url: '',
router: '',
defaultUrl: '',
index: '',
Show: true,
createTime: null,
changeTime: null
}
},
form: [
{ label: '名称', value: 'name' },
{ label: '主机自定义名称', value: 'newName' },
{
label: '打开模式',
value: 'open',
type: 'select',
options: [
{
value: '选项1',
label: '本系统'
},
{
value: '选项2',
label: '新系统'
}
]
},
{
label: '功能类型',
value: 'type',
type: 'select',
options: [
{
value: '选项1',
label: '菜单路由'
},
{
value: '选项2',
label: '菜单'
},
{
value: '选项3',
label: '按钮'
}
]
},
{ label: '上级菜单', value: 'upMenu', disabled: true },
{ label: '菜单路径', value: 'url', disabled: true },
{ label: '路由', value: 'router' },
{ label: '基础路径', value: 'defaultUrl' },
{ label: '排序', value: 'index' },
{ label: '是否隐藏', value: 'Show', type: 'switch' },
{ label: '创建时间', value: 'createTime', disabled: true },
{ label: '修改时间', value: 'changeTime', disabled: true }
]
}
},
components: {
LeftManager,
RightForm
},
methods: {
nodeClick(data, node, that, props) {
this.menuMG.showDetails = true
if (node.level === 1) this.menuMG.data = node.parent.data
this.menuMG.btnTxt = '修改'
this.menuMG.node = node
this.menuMG.allNode = data
this.menuMG.props = props
this.menuMG.sublings = false
this.menuMG.children = false
this.menuMG.del = true
this.menuMG.push = false
this.menuMG.form.name = data[props.label]
this.menuMG.form.upMenu = node.level === 1 ? '顶级菜单' : node.parent.data[props.label]
this.menuMG.form.defaultUrl = data.path
this.menuMG.form.index = node.data.id
this.menuMG.form.createTime = data.createTime
this.menuMG.form.changeTime = data.changeTime
} }
} }
} }
</script> </script>
\ No newline at end of file \ No newline at end of file
<style scoped>
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!