Commit 4688b7a8 by 胡悦

提交菜单和组织部分接口,未完

1 parent 56b98c01
......@@ -150,7 +150,7 @@ export default {
},
radioChange(event, prop) {
// console.log(event,prop,'radioChange')
this.$emit('radio-change', event, prop)
this.$emit('radioChange', event, prop)
}
}
}
......
......@@ -41,10 +41,11 @@ const MENU_API = {
MENU_ADD: BASE_URL + '/usercenter/menu/add',
MENU_EDIT: BASE_URL + '/usercenter/menu/edit',
MENU_DELETE: BASE_URL + '/usercenter/menu/delete',
MENU_INFO: BASE_URL + '/usercenter/menu/info'
MENU_INFO: BASE_URL + '/usercenter/menu/info',
MENU_PERMTREE: BASE_URL + '/usercenter/menu/permtree'
}
const ORGINIZA_API = {
ORGINIZA_SEARCH: BASE_URL + '/usercenter/organization/rootList',
ORGINIZA_SEARCH: BASE_URL + '/usercenter/organization/search',
ORGINIZA_CHILDREN: BASE_URL + '/usercenter/organization/children',
ORGINIZA_SIMPLElIST: BASE_URL + '/usercenter/organization/simplelist',
ORGINIZA_TREEORY: BASE_URL + '/usercenter/organization/orgtree',
......
......@@ -33,4 +33,10 @@ function menuInfo (params) {
return request(params, url)
}
export { getMenuList, getMenuChildren, addMenu, editMenu, menuInfo, deleteMenu }
// 获取上级菜单
function getPermtree (params) {
const url = MENU_API.MENU_PERMTREE
return request(params, url)
}
export { getMenuList, getMenuChildren, addMenu, editMenu, menuInfo, deleteMenu, getPermtree }
......@@ -93,9 +93,8 @@ const Constants = {
// 组织管理状态
ORGINIZASTATUS: {
'0': '正常,green',
'1': '停用,gray',
'2': '注销,red'
'1': '正常,green',
'2': '停用,gray'
},
ORGINIZATYPE: {
'1': '层级',
......
......@@ -80,17 +80,17 @@
</template>
</el-table-column>
</el-table>
<!-- <el-pagination
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.pageNum"
:page-sizes="[10,20,30,40]"
:page-size="page.pageSize"
:total="getListApi ? total : tableTotal"
:total="total"
layout="sizes,total,->,prev,pager,next,jumper"
>
</el-pagination> -->
</el-pagination>
<basic-dialog
:title="menuDialogTitle"
:isVisible="menuVisible"
......@@ -102,6 +102,7 @@
:ruleForm="menuForm"
:rules="menuRules"
:ruleData="menuData"
@radioChange="radioChange"
ref='menuForm'
></rule-form>
</slot>
......@@ -135,7 +136,7 @@
</div>
</template>
<script>
import { getMenuList, getMenuChildren, addMenu, editMenu, menuInfo, deleteMenu } from 'services/menu';
import { getMenuList, getMenuChildren, addMenu, editMenu, menuInfo, deleteMenu, getPermtree } from 'services/menu';
export default {
data() {
return {
......@@ -145,7 +146,7 @@ export default {
{
type: 'input',
inputType: 'text',
prop: 'organizationName',
prop: 'name',
placeholder: '请输入菜单名称'
},
{
......@@ -154,7 +155,7 @@ export default {
placeholder: '请选择菜单状态',
options: [{
value: '1',
label: '正常'
label: '显示'
}, {
value: '2',
label: '不显示'
......@@ -167,12 +168,13 @@ export default {
{ prop: 'menuName', label: '菜单名称' },
{ prop: 'orderNum', label: '排序' },
{ prop: 'frontRoute', label: '请求地址' },
{ prop: 'type', label: '菜单类型' },
{ prop: 'enableStatus', label: '状态' },
{ prop: 'permissionTag', label: '权限标识' }
],
page: {
pageNum: 10,
pageSize: 1
pageSize: 10,
pageNumber: 1
},
total: 10,
tableParams: {
......@@ -205,7 +207,7 @@ export default {
},
menuData: [
{ label: '菜单类型', prop: 'type', type: 'radio', children: this.$Constants.MENU_TYPE },
{ label: '上级菜单', prop: 'parentName', type: 'input', readonly: true, clickFunc: this.selectSuperior },
{ label: '上级菜单', prop: 'parentName', type: 'input', readonly: true, clickFunc: this.selectSuperior, hidden: true },
{ label: '菜单名称', prop: 'menuName', type: 'input' },
{ label: '权限标识', prop: 'permissionTag', type: 'input' },
{ label: '前端路由', prop: 'frontRoute', type: 'input' },
......@@ -223,69 +225,7 @@ export default {
filterDialogTitle: '选择上级',
filterVisible: false,
filterText: '',
filterTextData: [
{
id: 1,
label: '广汇集团',
children: [
{
id: 10,
label: '东北大区'
}, {
id: 11,
label: '华南大区'
}, {
id: 12,
label: '西北大区',
children: [
{
id: 100,
label: '新疆',
children: [
{
id: 1000,
label: '新疆克拉玛依华威4S店'
}, {
id: 1001,
label: '新疆克拉玛依华威4S店'
}
]
}, {
id: 101,
label: '陕西'
}
]
}
]
}, {
id: 2,
label: '成都轱辘汽车服务公司',
children: [
{
id: 20,
label: '新疆克拉玛依华威4S店'
}, {
id: 21,
label: '深圳市',
children: [
{
id: 200,
label: '南山区',
children: [
{
id: 2000,
label: '南山科技园片区'
}
]
}, {
id: 201,
label: '福田竹子林金融产业园区'
}
]
}
]
}
],
filterTextData: [],
defaultProps: {
children: 'children',
label: 'label'
......@@ -301,16 +241,27 @@ export default {
}
},
mounted() {
this.getList()
this.search()
},
methods: {
search() {
this.getList(this.searchForm)
let params = Object.assign({}, this.searchForm, this.page)
console.log(params)
this.getList(params)
},
// 重置搜索条件
refresh() {
this.searchForm = {}
},
emptyData(params) {
let arr = params
for (let key in arr) {
if (params[key] == null || params[key] == '' || params[key] == []) {
delete params[key]
}
}
return arr
},
// 确定,新增、编辑
handleConfirm() {
console.log(this.menuForm)
......@@ -318,10 +269,20 @@ export default {
if (valid) {
let params = JSON.parse(JSON.stringify(this.menuForm))
params.enableStatus = this.menuForm.enableStatus ? 1 : 2
this.emptyData(params)
let api = addMenu
if (params.id) api = editMenu
api(params).then(res => {
this.handleClose()
if (res.code == 200) {
this.$message({
type: 'success',
message: '操作成功!'
})
this.handleClose()
this.search()
} else {
this.$message(res.message)
}
})
} else {
console.log('error')
......@@ -353,10 +314,11 @@ export default {
// 编辑触发事件
editEvent(row) {
console.log(row)
menuInfo({ id: row.id }).then(res => {
menuInfo({ menuId: row.id }).then(res => {
this.menuDialogTitle = '编辑菜单'
this.menuForm = JSON.parse(JSON.stringify(res.data))
this.menuForm.enableStatus = res.data.enableStatus == 1 ? true : false
this.menuForm.type = res.data.type + ''
this.handleClose(res.data)
})
},
......@@ -392,6 +354,7 @@ export default {
},
// 上级弹窗
selectSuperior() {
this.getPermtree()
this.closeFilter()
},
closeFilter() {
......@@ -410,8 +373,39 @@ export default {
},
getList(params) {
getMenuList(params).then((res) => {
this.menuTableData = res.data.list
if (res.code == 200) {
this.total = res.data.totalElements
this.menuTableData = res.data.list
} else {
this.menuTableData = []
}
})
},
// 获取上级菜单
getPermtree() {
getPermtree().then(res => {
if (res.code = 200) {
this.filterTextData = res.data
}
})
},
// 页码
handleSizeChange(value) {
this.page.pageSize = value
this.search()
},
handleCurrentChange(value) {
this.page.pageNumber = value
this.search()
},
radioChange(event, prop) {
console.log(event, prop)
if (event != 1) {
this.menuData[1].hidden = false
} else {
this.menuData[1].hidden = true
}
}
}
}
......
......@@ -30,6 +30,7 @@
>新增根组织</el-button>
</div>
<el-table
ref="table"
:data="orginTableData"
style="width: 100%"
row-key="id"
......@@ -80,6 +81,17 @@
</template>
</el-table-column>
</el-table>
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.pageNum"
:page-sizes="[10,20,30,40]"
:page-size="page.pageSize"
:total="total"
layout="sizes,total,->,prev,pager,next,jumper"
>
</el-pagination>
<basic-dialog
:title="orginizaDialogTitle"
:isVisible="orginizaVisible"
......@@ -117,10 +129,10 @@ export default {
prop: 'enableStatus',
placeholder: '请选择组织状态',
options: [{
value: '0',
value: '1',
label: '正常'
}, {
value: '1',
value: '2',
label: '停用'
}]
}
......@@ -132,6 +144,11 @@ export default {
{ prop: 'enableStatus', label: '状态' },
{ prop: 'createDate', label: '创建时间' }
],
page: {
pageSize: 10,
pageNumber: 1
},
total: 10,
tableParams: {
tableOption: {
btnList: [
......@@ -180,11 +197,12 @@ export default {
}
},
mounted() {
this.getList()
this.search()
},
methods: {
search() {
this.getList(this.searchForm)
let params = Object.assign({}, this.searchForm, this.page)
this.getList(params)
},
// 重置搜索条件
refresh() {
......@@ -196,11 +214,19 @@ export default {
this.$refs.orginizaForm.$children[0].validate((valid) => {
if (valid) {
let params = JSON.parse(JSON.stringify(this.orginizaForm))
params.enableStatus = this.orginizaForm.enableStatus ? 0 : 1
params.enableStatus = this.orginizaForm.enableStatus ? 1 : 2
if (params.departmentName) delete params.departmentName
let api = addOrganiza
if (params.id) api = editOrganiza
api(params).then(res => {
this.handleClose()
if (res.code = 200) {
this.$set(this.$refs.table.store.states.lazyTreeNodeMap, params.id, res.data)
this.$message({
type: 'success',
message: '操作成功'
})
this.handleClose()
}
})
} else {
console.log('error')
......@@ -226,6 +252,8 @@ export default {
case 'create':
this.orginizaData[0].hidden = false
this.orginizaDialogTitle = '新增组织'
this.orginizaForm.departmentName = scope.departmentName
this.orginizaForm.superiorId = scope.id
this.handleClose()
break
case 'edit':
......@@ -241,7 +269,7 @@ export default {
editEvent(row) {
console.log(row)
this.orginizaForm = JSON.parse(JSON.stringify(row))
this.orginizaForm.enableStatus = row.enableStatus == 0 ? true : false
this.orginizaForm.enableStatus = row.enableStatus == 1 ? true : false
this.handleClose()
},
// 删除触发事件
......@@ -266,20 +294,42 @@ export default {
// 树形table懒加载
load(tree, treeNode, resolve) {
console.log(tree, treeNode, resolve)
getChildren({ id: tree.id }).then(res => {
let nodes = res.data.list
nodes.map(item => {
const aa = this.num++
item.id = aa + '' + item.id
})
getChildren({ rootId: tree.id }).then(res => {
let nodes = res.data
resolve(nodes)
})
},
// 获取根节点列表
getList(params) {
getTableList(params).then((res) => {
this.orginTableData = res.data.list
if (res.code == 200) {
this.total = res.data.totalElements
this.orginTableData = res.data
} else {
this.orginTableData = []
}
})
}
},
// 子节点列表
getChildren(id) {
getChildren({ rootId: id }).then(res => {
let nodes = res.data
// nodes.map(item => {
// const aa = this.num++
// item.id = aa + '' + item.id
// })
return nodes
})
},
// 页码
handleSizeChange(value) {
this.page.pageSize = value
this.search()
},
handleCurrentChange(value) {
this.page.pageNumber = value
this.search()
},
}
}
</script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!