Commit a2525cdc by 胡悦

提交组织、菜单接口

1 parent 8af2fb3e
...@@ -51,7 +51,8 @@ const ORGINIZA_API = { ...@@ -51,7 +51,8 @@ const ORGINIZA_API = {
ORGINIZA_TREEORY: BASE_URL + '/usercenter/organization/orgtree', ORGINIZA_TREEORY: BASE_URL + '/usercenter/organization/orgtree',
ORGINIZA_ADD: BASE_URL + '/usercenter/organization/add', ORGINIZA_ADD: BASE_URL + '/usercenter/organization/add',
ORGINIZA_EDIT: BASE_URL + '/usercenter/organization/edit', ORGINIZA_EDIT: BASE_URL + '/usercenter/organization/edit',
ORGINIZA_DELETE: BASE_URL + '/usercenter/organization/delete' ORGINIZA_DELETE: BASE_URL + '/usercenter/organization/delete',
ORGINIZA_INFO: BASE_URL + '/usercenter/organization/info'
} }
const DICT_API = { const DICT_API = {
DICT_SEARCH: BASE_URL + '/publiccenter/dict/type/search', DICT_SEARCH: BASE_URL + '/publiccenter/dict/type/search',
......
...@@ -32,9 +32,14 @@ function editOrganiza (params) { ...@@ -32,9 +32,14 @@ function editOrganiza (params) {
const url = ORGINIZA_API.ORGINIZA_EDIT const url = ORGINIZA_API.ORGINIZA_EDIT
return request(params, url, 'post') return request(params, url, 'post')
} }
// 添加组织 // 删除组织
function deleteOrganiza (params) { function deleteOrganiza (params) {
const url = ORGINIZA_API.ORGINIZA_DELETE const url = ORGINIZA_API.ORGINIZA_DELETE
return request(params, url) return request(params, url)
} }
export { getTableList, getChildren, getSimpleList, getTreeOrg, addOrganiza, editOrganiza, deleteOrganiza } // 组织详情
function organizaInfo (params) {
const url = ORGINIZA_API.ORGINIZA_INFO
return request(params, url)
}
export { getTableList, getChildren, getSimpleList, getTreeOrg, addOrganiza, editOrganiza, deleteOrganiza, organizaInfo }
...@@ -24,6 +24,10 @@ const Constants = { ...@@ -24,6 +24,10 @@ const Constants = {
2: '菜单', 2: '菜单',
3: '按钮' 3: '按钮'
}, },
MENU_OTYPE: {
2: '菜单',
3: '按钮'
},
// 菜单状态 // 菜单状态
MENU_STATUS: { MENU_STATUS: {
1: '正常, green', 1: '正常, green',
...@@ -81,8 +85,7 @@ const Constants = { ...@@ -81,8 +85,7 @@ const Constants = {
// 菜单管理状态 // 菜单管理状态
MENUSTATUS: { MENUSTATUS: {
'1': '显示,green', '1': '显示,green',
'0': '不显示,gray', '2': '不显示,gray'
'2': '注销,red'
}, },
// 菜单类型 // 菜单类型
MENUMANAGEMENUTYPE: { MENUMANAGEMENUTYPE: {
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
:data="menuTableData" :data="menuTableData"
style="width: 100%" style="width: 100%"
row-key="id" row-key="id"
border
lazy lazy
:load="load" :load="load"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
...@@ -62,6 +61,7 @@ ...@@ -62,6 +61,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
ref="table"
align="center" align="center"
width="170" width="170"
fixed="right" fixed="right"
...@@ -136,6 +136,7 @@ ...@@ -136,6 +136,7 @@
</div> </div>
</template> </template>
<script> <script>
import _ from 'lodash'
import { getMenuList, getMenuChildren, addMenu, editMenu, menuInfo, deleteMenu, getPermtree } from 'services/menu'; import { getMenuList, getMenuChildren, addMenu, editMenu, menuInfo, deleteMenu, getPermtree } from 'services/menu';
export default { export default {
data() { data() {
...@@ -155,7 +156,7 @@ export default { ...@@ -155,7 +156,7 @@ export default {
placeholder: '请选择菜单状态', placeholder: '请选择菜单状态',
options: [{ options: [{
value: '1', value: '1',
label: '显示' label: '正常'
}, { }, {
value: '2', value: '2',
label: '不显示' label: '不显示'
...@@ -165,7 +166,7 @@ export default { ...@@ -165,7 +166,7 @@ export default {
menuTableData: [], menuTableData: [],
// 列表 头部设置 数据 // 列表 头部设置 数据
listHeadData: [ listHeadData: [
{ prop: 'menuName', label: '菜单名称' }, { prop: 'menuName', label: '菜单名称', width: '200' },
{ prop: 'orderNum', label: '排序' }, { prop: 'orderNum', label: '排序' },
{ prop: 'frontRoute', label: '请求地址' }, { prop: 'frontRoute', label: '请求地址' },
{ prop: 'type', label: '菜单类型' }, { prop: 'type', label: '菜单类型' },
...@@ -183,7 +184,7 @@ export default { ...@@ -183,7 +184,7 @@ export default {
{ {
type: 'primary', type: 'primary',
name: '新增', name: '新增',
pType: 'create' pType: 'btnCreate'
}, },
{ {
type: 'primary', type: 'primary',
...@@ -205,6 +206,10 @@ export default { ...@@ -205,6 +206,10 @@ export default {
parentName: '', parentName: '',
enableStatus: true enableStatus: true
}, },
form: {
parentName: '',
enableStatus: true
},
menuData: [ menuData: [
{ label: '菜单类型', prop: 'type', type: 'radio', children: this.$Constants.MENU_TYPE }, { label: '菜单类型', prop: 'type', type: 'radio', children: this.$Constants.MENU_TYPE },
{ label: '上级菜单', prop: 'parentName', type: 'input', readonly: true, clickFunc: this.selectSuperior, hidden: true }, { label: '上级菜单', prop: 'parentName', type: 'input', readonly: true, clickFunc: this.selectSuperior, hidden: true },
...@@ -231,8 +236,7 @@ export default { ...@@ -231,8 +236,7 @@ export default {
label: 'label' label: 'label'
}, },
loading: false, loading: false,
num: 10 isOpen: true
} }
}, },
watch: { watch: {
...@@ -269,6 +273,8 @@ export default { ...@@ -269,6 +273,8 @@ export default {
if (valid) { if (valid) {
let params = JSON.parse(JSON.stringify(this.menuForm)) let params = JSON.parse(JSON.stringify(this.menuForm))
params.enableStatus = this.menuForm.enableStatus ? 1 : 2 params.enableStatus = this.menuForm.enableStatus ? 1 : 2
if (params.parentName) delete params.parentName
if (params.menuNo) delete params.menuNo
this.emptyData(params) this.emptyData(params)
let api = addMenu let api = addMenu
if (params.id) api = editMenu if (params.id) api = editMenu
...@@ -279,7 +285,13 @@ export default { ...@@ -279,7 +285,13 @@ export default {
message: '操作成功!' message: '操作成功!'
}) })
this.handleClose() this.handleClose()
if (params.parentId) {
getMenuChildren({ parentId: params.parentId }).then(res => {
this.$set(this.$refs.table.store.states.lazyTreeNodeMap, params.parentId, res.data)
})
} else {
this.search() this.search()
}
} else { } else {
this.$message(res.message) this.$message(res.message)
} }
...@@ -295,27 +307,46 @@ export default { ...@@ -295,27 +307,46 @@ export default {
this.$refs.menuForm.$children[0].resetFields() this.$refs.menuForm.$children[0].resetFields()
} }
this.menuVisible = !this.menuVisible this.menuVisible = !this.menuVisible
if (!this.menuVisible) this.menuForm = _.cloneDeep(this.form)
}, },
// 按钮事件 // 按钮事件
btnClick(pType, scope) { btnClick(pType, scope) {
console.log(pType, scope) console.log(pType, scope)
switch (pType) { switch (pType) {
case 'create': case 'create':
this.isOpen = true
this.menuDialogTitle = '新增菜单'
this.menuData[0].children = this.$Constants.MENU_TYPE
this.handleClose()
break
case 'btnCreate':
this.isOpen = true
this.menuDialogTitle = '新增菜单'
this.menuData[0].children = this.$Constants.MENU_OTYPE
this.handleClose() this.handleClose()
break break
case 'edit': case 'edit':
this.menuDialogTitle = '编辑菜单'
this.isOpen = false
this.editEvent(scope) this.editEvent(scope)
break break
case 'delete': case 'delete':
this.deleteEvent(scope.id) this.deleteEvent(scope)
break break
} }
}, },
// 编辑触发事件 // 编辑触发事件
editEvent(row) { editEvent(row) {
console.log(row) console.log(row)
if (row.parentId == 0) {
this.menuData[0].children = this.$Constants.MENU_TYPE
this.menuData[1].hidden = true
} else {
this.menuData[0].children = this.$Constants.MENU_OTYPE
this.menuData[1].hidden = false
}
menuInfo({ menuId: row.id }).then(res => { menuInfo({ menuId: row.id }).then(res => {
this.menuDialogTitle = '编辑菜单'
this.menuForm = JSON.parse(JSON.stringify(res.data)) this.menuForm = JSON.parse(JSON.stringify(res.data))
this.menuForm.enableStatus = res.data.enableStatus == 1 ? true : false this.menuForm.enableStatus = res.data.enableStatus == 1 ? true : false
this.menuForm.type = res.data.type + '' this.menuForm.type = res.data.type + ''
...@@ -323,7 +354,7 @@ export default { ...@@ -323,7 +354,7 @@ export default {
}) })
}, },
// 删除触发事件 // 删除触发事件
deleteEvent(id) { deleteEvent(row) {
const that = this const that = this
const tipData = { const tipData = {
that: that, that: that,
...@@ -331,11 +362,24 @@ export default { ...@@ -331,11 +362,24 @@ export default {
tipTitle: '提示', tipTitle: '提示',
type: 'error', type: 'error',
callBack: () => { callBack: () => {
deleteMenu({ id: id }).then(res => { deleteMenu({ menuId: row.id }).then(res => {
if (res.code == 200) {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}) })
if (row.parentId == 0) {
this.getList()
} else {
getMenuChildren({ parentId: row.parentId }).then(res => {
const nodes = res.data
this.$set(this.$refs.table.store.states.lazyTreeNodeMap, row.parentId, nodes)
})
}
} else {
this.$message(res.message)
}
}) })
} }
} }
...@@ -343,19 +387,17 @@ export default { ...@@ -343,19 +387,17 @@ export default {
}, },
load(tree, treeNode, resolve) { load(tree, treeNode, resolve) {
console.log(tree, treeNode, resolve) console.log(tree, treeNode, resolve)
getMenuChildren({ id: tree.id }).then(res => { getMenuChildren({ parentId: tree.menuNo }).then(res => {
let nodes = res.data resolve(res.data)
nodes.map(item => {
const aa = this.num++
item.id = aa + '' + item.id
})
resolve(nodes)
}) })
}, },
// 上级弹窗 // 上级弹窗
selectSuperior() { selectSuperior() {
if (this.isOpen) {
this.getPermtree() this.getPermtree()
this.closeFilter() this.closeFilter()
}
}, },
closeFilter() { closeFilter() {
this.filterVisible = !this.filterVisible this.filterVisible = !this.filterVisible
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
:data="orginTableData" :data="orginTableData"
style="width: 100%" style="width: 100%"
row-key="id" row-key="id"
border
lazy lazy
:load="load" :load="load"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
...@@ -111,7 +110,8 @@ ...@@ -111,7 +110,8 @@
</div> </div>
</template> </template>
<script> <script>
import { getTableList, getChildren, addOrganiza, editOrganiza, deleteOrganiza } from 'services/orginizaManage' import _ from 'lodash'
import { getTableList, getChildren, addOrganiza, editOrganiza, deleteOrganiza, organizaInfo } from 'services/orginizaManage'
export default { export default {
data() { data() {
return { return {
...@@ -121,7 +121,7 @@ export default { ...@@ -121,7 +121,7 @@ export default {
{ {
type: 'input', type: 'input',
inputType: 'text', inputType: 'text',
prop: 'organizationName', prop: 'orgName',
placeholder: '请输入组织名称' placeholder: '请输入组织名称'
}, },
{ {
...@@ -174,21 +174,25 @@ export default { ...@@ -174,21 +174,25 @@ export default {
orginizaDialogTitle: '新增组织', orginizaDialogTitle: '新增组织',
orginizaVisible: false, orginizaVisible: false,
orginizaForm: { orginizaForm: {
superiorName: '',
enableStatus: true
},
form: {
enableStatus: true enableStatus: true
}, },
orginizaData: [ orginizaData: [
{ label: '上级组织', prop: 'departmentName', type: 'input', hidden: false, readonly: true }, { label: '上级组织', prop: 'superiorName', type: 'input', hidden: false, readonly: true },
{ label: '组织名称', prop: 'name', type: 'input' }, { label: '组织名称', prop: 'departmentName', type: 'input' },
{ label: '显示排序', prop: 'orderNum', type: 'input' }, { label: '显示排序', prop: 'orderNum', type: 'input' },
{ label: '组织状态', prop: 'enableStatus', type: 'switch' } { label: '组织状态', prop: 'enableStatus', type: 'switch' }
], ],
orginizaRules: { orginizaRules: {
name: [{ required: true, message: '请输入组织名称', trigger: 'blur' }], departmentName: [{ required: true, message: '请输入组织名称', trigger: 'blur' }],
orderNum: [{ required: true, message: '请输入显示排序', trigger: 'blur' }], orderNum: [{ required: true, message: '请输入显示排序', trigger: 'blur' }],
enableStatus: [{ required: true }] enableStatus: [{ required: true }]
}, },
// 部门弹窗 // 部门弹窗
num: 1 isRoot: false
} }
}, },
...@@ -209,25 +213,44 @@ export default { ...@@ -209,25 +213,44 @@ export default {
refresh() { refresh() {
this.searchForm = {} 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() { handleConfirm() {
console.log(this.orginizaForm) console.log(this.orginizaForm)
this.$refs.orginizaForm.$children[0].validate((valid) => { this.$refs.orginizaForm.$children[0].validate((valid) => {
if (valid) { if (valid) {
let params = JSON.parse(JSON.stringify(this.orginizaForm)) let params = {
params.enableStatus = this.orginizaForm.enableStatus ? 1 : 2 departmentName: this.orginizaForm.departmentName,
if (params.departmentName) delete params.departmentName enableStatus: this.orginizaForm.enableStatus ? 1 : 2,
orderNum: this.orginizaForm.orderNum
}
if (this.orginizaForm.superiorId) params.superiorId = this.orginizaForm.superiorId
let api = addOrganiza let api = addOrganiza
if (params.id) api = editOrganiza if (this.orginizaForm.id) {
api = editOrganiza
params.id = this.orginizaForm.id
}
api(params).then(res => { api(params).then(res => {
if (res.code = 200) { if (res.code = 200) {
// this.$set(this.$refs.table.store.states.lazyTreeNodeMap, params.id, res.data)
this.$message({ this.$message({
type: 'success', type: 'success',
message: '操作成功' message: '操作成功'
}) })
if (this.orginizaDialogTitle == '新增根组织') { if (this.isRoot) {
this.getList() this.getList()
} else {
getChildren({ rootId: params.superiorId }).then(res => {
const nodes = res.data
this.$set(this.$refs.table.store.states.lazyTreeNodeMap, params.superiorId, nodes)
})
} }
this.handleClose() this.handleClose()
} }
...@@ -243,21 +266,31 @@ export default { ...@@ -243,21 +266,31 @@ export default {
this.$refs.orginizaForm.$children[0].resetFields() this.$refs.orginizaForm.$children[0].resetFields()
} }
this.orginizaVisible = !this.orginizaVisible this.orginizaVisible = !this.orginizaVisible
// if (!this.orginizaVisible) {
// this.orginizaForm = {}
// this.orginizaForm = _.cloneDeep(this.form)
// console.log(this.orginizaForm)
// }
}, },
// 按钮事件 // 按钮事件
btnClick(pType, scope) { btnClick(pType, scope) {
console.log(pType, scope) console.log(pType, scope, this.orginizaForm)
switch (pType) { switch (pType) {
case 'root': case 'root':
this.isRoot = true
this.orginizaData[0].hidden = true this.orginizaData[0].hidden = true
this.orginizaDialogTitle = '新增根组织' this.orginizaDialogTitle = '新增根组织'
this.handleClose() this.handleClose()
break break
case 'create': case 'create':
console.log('??????')
this.isRoot = false
this.orginizaData[0].hidden = false this.orginizaData[0].hidden = false
this.orginizaDialogTitle = '新增组织' // this.$set(this.orginizaForm, 'superiorName', scope.departmentName)
this.orginizaForm.departmentName = scope.departmentName this.orginizaForm['superiorName'] = _.cloneDeep(scope.departmentName)
this.orginizaForm.superiorId = scope.id this.orginizaForm['superiorId'] = _.cloneDeep(scope.id)
this.orginizaDialogTitle = '新增组织' + this.orginizaForm.superiorName
console.log(this.orginizaForm)
this.handleClose() this.handleClose()
break break
case 'edit': case 'edit':
...@@ -265,19 +298,29 @@ export default { ...@@ -265,19 +298,29 @@ export default {
this.editEvent(scope) this.editEvent(scope)
break break
case 'delete': case 'delete':
this.deleteEvent(scope.id) this.deleteEvent(scope)
break break
} }
}, },
// 编辑触发事件 // 编辑触发事件
editEvent(row) { editEvent(row) {
console.log(row) console.log(row)
this.orginizaForm = JSON.parse(JSON.stringify(row)) // this.orginizaForm = JSON.parse(JSON.stringify(this.form))
organizaInfo({ id: row.id }).then(res => {
this.orginizaForm = _.cloneDeep(res.data)
this.orginizaForm.enableStatus = row.enableStatus == 1 ? true : false this.orginizaForm.enableStatus = row.enableStatus == 1 ? true : false
if (!this.orginizaForm.superiorId) {
this.orginizaData[0].hidden = true
this.isRoot = true
} else {
this.isRoot = false
}
console.log(this.orginizaForm)
this.handleClose() this.handleClose()
})
}, },
// 删除触发事件 // 删除触发事件
deleteEvent(id) { deleteEvent(row) {
const that = this const that = this
const tipData = { const tipData = {
that: that, that: that,
...@@ -285,14 +328,19 @@ export default { ...@@ -285,14 +328,19 @@ export default {
tipTitle: '提示', tipTitle: '提示',
type: 'error', type: 'error',
callBack: () => { callBack: () => {
deleteOrganiza({ id: id }).then(res => { deleteOrganiza({ id: row.id }).then(res => {
if (res.code == 200) { if (res.code == 200) {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}) })
if (this.orginizaDialogTitle == '新增根组织') { if (!row.superiorId) {
this.getList() this.getList()
} else {
getChildren({ rootId: params.superiorId }).then(res => {
const nodes = res.data
this.$set(this.$refs.table.store.states.lazyTreeNodeMap, params.superiorId, nodes)
})
} }
} else { } else {
this.$message(res.message) this.$message(res.message)
...@@ -325,12 +373,7 @@ export default { ...@@ -325,12 +373,7 @@ export default {
// 子节点列表 // 子节点列表
getChildren(id) { getChildren(id) {
getChildren({ rootId: id }).then(res => { getChildren({ rootId: id }).then(res => {
let nodes = res.data return res.data
// nodes.map(item => {
// const aa = this.num++
// item.id = aa + '' + item.id
// })
return nodes
}) })
}, },
// 页码 // 页码
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!