Commit e863a9fc by 胡悦

提交组织管理接口

1 parent b71d9b4d
...@@ -46,7 +46,10 @@ const ORGINIZA_API = { ...@@ -46,7 +46,10 @@ const ORGINIZA_API = {
ORGINIZA_SEARCH: BASE_URL + '/usercenter/organization/rootList', ORGINIZA_SEARCH: BASE_URL + '/usercenter/organization/rootList',
ORGINIZA_CHILDREN: BASE_URL + '/usercenter/organization/children', ORGINIZA_CHILDREN: BASE_URL + '/usercenter/organization/children',
ORGINIZA_SIMPLElIST: BASE_URL + '/usercenter/organization/simpleList', ORGINIZA_SIMPLElIST: BASE_URL + '/usercenter/organization/simpleList',
ORGINIZA_TREEORY: BASE_URL + '/usercenter/organization/treeOrg' ORGINIZA_TREEORY: BASE_URL + '/usercenter/organization/treeOrg',
ORGINIZA_ADD: BASE_URL + '/usercenter/organization/add',
ORGINIZA_EDIT: BASE_URL + '/usercenter/organization/edit',
ORGINIZA_DELETE: BASE_URL + '/usercenter/organization/delete'
} }
const DICT_API = { const DICT_API = {
DICT_SEARCH: BASE_URL + '/publiccenter/dict/type/search', DICT_SEARCH: BASE_URL + '/publiccenter/dict/type/search',
......
import HTTP from '@/utils/http'
import { ORGINIZA_API } from '@/config/config' import { ORGINIZA_API } from '@/config/config'
import request from '@/services/request'
export default class OrginizaService extends HTTP { // 获取组织列表
// 获取组织列表 function getTableList (params) {
getTableList () { const url = ORGINIZA_API.ORGINIZA_SEARCH
return new Promise((resolve, reject) => { return request(params, url)
this.axiosGet({
url: ORGINIZA_API.ORGINIZA_SEARCH,
data: {},
success(data) {
resolve(data)
},
error(error) {
// 网络请求失败
console.log('网络请求失败')
}
})
})
}
// 根据根节点,获取子节点列表
getChildren (id) {
return new Promise((resolve, reject) => {
this.axiosGet({
url: ORGINIZA_API.ORGINIZA_CHILDREN,
data: {
rootId: id
},
success(data) {
resolve(data)
},
error(error) {
// 网络请求失败
console.log('网络请求失败')
}
})
})
}
// 获取组织列表树
getSimpleList () {
return new Promise((resolve, reject) => {
this.axiosGet({
url: ORGINIZA_API.ORGINIZA_SIMPLElIST,
data: {},
success(data) {
resolve(data)
},
error(error) {
// 网络请求失败
console.log('网络请求失败')
}
})
})
}
// 组织架构
getTreeOrg () {
return new Promise((resolve, reject) => {
this.axiosGet({
url: ORGINIZA_API.ORGINIZA_TREEORY,
data: {},
success(data) {
resolve(data)
},
error(error) {
// 网络请求失败
console.log('网络请求失败')
}
})
})
}
} }
// 根据根节点,获取子节点列表
function getChildren (params) {
const url = ORGINIZA_API.ORGINIZA_CHILDREN
return request(params, url)
}
// 获取组织列表树
function getSimpleList (params) {
const url = ORGINIZA_API.ORGINIZA_SIMPLElIST
return request(params, url)
}
// 组织架构
function getTreeOrg (params) {
const url = ORGINIZA_API.ORGINIZA_TREEORY
return request(params, url)
}
// 添加组织
function addOrganiza (params) {
const url = ORGINIZA_API.ORGINIZA_ADD
return request(params, url, 'post')
}
// 编辑组织
function editOrganiza (params) {
const url = ORGINIZA_API.ORGINIZA_EDIT
return request(params, url, 'post')
}
// 添加组织
function deleteOrganiza (params) {
const url = ORGINIZA_API.ORGINIZA_DELETE
return request(params, url)
}
export { getTableList, getChildren, getSimpleList, getTreeOrg, addOrganiza, editOrganiza, deleteOrganiza }
...@@ -93,9 +93,9 @@ const Constants = { ...@@ -93,9 +93,9 @@ const Constants = {
// 组织管理状态 // 组织管理状态
ORGINIZASTATUS: { ORGINIZASTATUS: {
'1': '正常,green', '0': '正常,green',
'2': '停用,gray', '1': '停用,gray',
'3': '注销,red' '2': '注销,red'
}, },
ORGINIZATYPE: { ORGINIZATYPE: {
'1': '层级', '1': '层级',
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
type="primary" type="primary"
:size="btn_size" :size="btn_size"
icon="el-icon-plus" icon="el-icon-plus"
@click="handleClose" @click="btnClick('create')"
>新增</el-button> >新增</el-button>
</div> </div>
<el-table <el-table
...@@ -290,7 +290,8 @@ export default { ...@@ -290,7 +290,8 @@ export default {
children: 'children', children: 'children',
label: 'label' label: 'label'
}, },
loading: false loading: false,
num: 10
} }
}, },
...@@ -304,7 +305,7 @@ export default { ...@@ -304,7 +305,7 @@ export default {
}, },
methods: { methods: {
search() { search() {
this.getList(this.searchForm)
}, },
// 重置搜索条件 // 重置搜索条件
refresh() { refresh() {
...@@ -338,6 +339,9 @@ export default { ...@@ -338,6 +339,9 @@ export default {
btnClick(pType, scope) { btnClick(pType, scope) {
console.log(pType, scope) console.log(pType, scope)
switch (pType) { switch (pType) {
case 'create':
this.handleClose()
break
case 'edit': case 'edit':
this.editEvent(scope) this.editEvent(scope)
break break
...@@ -376,21 +380,15 @@ export default { ...@@ -376,21 +380,15 @@ export default {
this.$Common.confirmDialog(tipData) this.$Common.confirmDialog(tipData)
}, },
load(tree, treeNode, resolve) { load(tree, treeNode, resolve) {
setTimeout(() => { console.log(tree, treeNode, resolve)
resolve([ getMenuChildren({ id: tree.id }).then(res => {
{ let nodes = res.data
id: 31, nodes.map(item => {
date: '2016-05-01', const aa = this.num++
name: '王小虎', item.id = aa + '' + item.id
address: '上海市普陀区金沙江路 1519 弄' })
}, { resolve(nodes)
id: 32, })
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}
])
}, 1000)
}, },
// 上级弹窗 // 上级弹窗
selectSuperior() { selectSuperior() {
...@@ -410,22 +408,10 @@ export default { ...@@ -410,22 +408,10 @@ export default {
if (!value) return true if (!value) return true
return data.label.indexOf(value) !== -1 return data.label.indexOf(value) !== -1
}, },
getList() { getList(params) {
getMenuList().then((res) => { getMenuList(params).then((res) => {
console.log(res); this.menuTableData = res.data.list
let arr = res.data.list })
// for (let i in arr) {
// console.log(i)
// if (arr[i].haschildren) {
// console.log('Jinlaile ')
// arr[i].children = []
// }
// }
this.menuTableData = arr
console.log(this.menuTableData)
}, (err) => {
});
} }
} }
} }
......
...@@ -11,12 +11,13 @@ ...@@ -11,12 +11,13 @@
type="primary" type="primary"
:size="btn_size" :size="btn_size"
icon="el-icon-search" icon="el-icon-search"
:id="tableParams.btnId" @click="search"
>搜索</el-button> >搜索</el-button>
<el-button <el-button
type="primary" type="primary"
:size="btn_size" :size="btn_size"
icon="el-icon-refresh" icon="el-icon-refresh"
@click="refresh"
>重置</el-button> >重置</el-button>
</slot> </slot>
</search-form> </search-form>
...@@ -25,28 +26,18 @@ ...@@ -25,28 +26,18 @@
type="primary" type="primary"
:size="btn_size" :size="btn_size"
icon="el-icon-plus" icon="el-icon-plus"
@click="btnClick('create')" @click="btnClick('root')"
>新增</el-button> >新增根组织</el-button>
</div> </div>
<el-table <el-table
v-loading="loading" :data="orginTableData"
align="center"
ref="multipleTable"
:data="listData"
tooltip-effect="dark"
style="width: 100%" style="width: 100%"
@row-click="rowClick" row-key="id"
:header-cell-style="{background:'#f5f7fa'}" border
lazy
:load="load"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
> >
<table-tree-column
ref='OrgiSort'
@table-click="tableClick"
prop="departmentName"
header-align="center"
treeKey="id"
width="300"
label="组织名称"
></table-tree-column>
<el-table-column <el-table-column
v-for="(item,index) in listHeadData" v-for="(item,index) in listHeadData"
:key="index" :key="index"
...@@ -58,13 +49,12 @@ ...@@ -58,13 +49,12 @@
show-overflow-tooltip show-overflow-tooltip
> >
<template slot-scope="scope"> <template slot-scope="scope">
<template v-if="item.prop === 'orgStatus'"> <template v-if="item.prop === 'enableStatus'">
dfs <span
<!-- <span
class="dot" class="dot"
:class="ORGINIZASTATUS[scope.row[item.prop]].split(',')[1]" :class="scope.row.enableStatus ? ORGINIZASTATUS[scope.row.enableStatus].split(',')[1] : ''"
></span> ></span>
<span class="statusText">{{ORGINIZASTATUS[scope.row[item.prop]].split(',')[0]}}</span> --> <span class="statusText">{{ scope.row.enableStatus ? ORGINIZASTATUS[scope.row.enableStatus].split(',')[0] : '--'}}</span>
</template> </template>
<template v-else> <template v-else>
{{scope.row[item.prop]?scope.row[item.prop]:'--'}} {{scope.row[item.prop]?scope.row[item.prop]:'--'}}
...@@ -85,7 +75,7 @@ ...@@ -85,7 +75,7 @@
:type="j.type" :type="j.type"
size="mini" size="mini"
plain plain
@click="btnClick(j.pType, scope.scope)" @click="btnClick(j.pType, scope.row)"
>{{j.name}}</el-button> >{{j.name}}</el-button>
</template> </template>
</el-table-column> </el-table-column>
...@@ -105,38 +95,11 @@ ...@@ -105,38 +95,11 @@
></rule-form> ></rule-form>
</slot> </slot>
</basic-dialog> </basic-dialog>
<basic-dialog
:title="filterDialogTitle"
:isVisible="filterVisible"
@confirmDialog="filterConfirm"
@closeDialog="closeFilter"
>
<slot>
<el-input
placeholder="输入关键字进行过滤"
v-model="filterText"
>
</el-input>
<el-tree
class="filter-tree"
:data="filterTextData"
:props="defaultProps"
:filter-node-method="filterNode"
ref="tree"
node-key="id"
check-on-click-node
>
</el-tree>
</slot>
</basic-dialog>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { getTableList, getChildren, addOrganiza, editOrganiza, deleteOrganiza } from 'services/orginizaManage'
import OrginizaService from 'services/orginizaManage';
const orginizaService = new OrginizaService();
export default { export default {
data() { data() {
return { return {
...@@ -162,10 +125,12 @@ export default { ...@@ -162,10 +125,12 @@ export default {
}] }]
} }
], ],
orginTableData: [],
listHeadData: [ // 列表 头部设置 数据 listHeadData: [ // 列表 头部设置 数据
{ prop: 'departmentName', label: '组织名称' },
{ prop: 'orderNum', label: '排序' }, { prop: 'orderNum', label: '排序' },
{ prop: 'enableStatus', label: '状态' }, { prop: 'enableStatus', label: '状态' },
{ prop: 'createTime', label: '创建时间' } { prop: 'createDate', label: '创建时间' }
], ],
tableParams: { tableParams: {
tableOption: { tableOption: {
...@@ -189,96 +154,23 @@ export default { ...@@ -189,96 +154,23 @@ export default {
} }
}, },
// 弹窗数据 // 弹窗数据
orginizaDialogTitle: '新增用户', orginizaDialogTitle: '新增组织',
orginizaVisible: false, orginizaVisible: false,
orginizaForm: { orginizaForm: {
account: '',
departmentId: '',
superiorId: '',
enableStatus: true
}, },
orginizaData: [ orginizaData: [
{ label: '组织名称', prop: 'account', type: 'input' }, { label: '上级组织', prop: 'departmentName', type: 'input', hidden: false, readonly: true },
{ label: '显示排序', prop: 'departmentId', type: 'input' }, { label: '组织名称', prop: 'name', type: 'input' },
{ label: '组织状态', prop: 'superiorId', type: 'radio', children: this.$Constants.ORGINIZA_STATUS } { label: '显示排序', prop: 'orderNum', type: 'input' },
{ label: '组织状态', prop: 'enableStatus', type: 'radio', children: this.$Constants.ORGINIZA_STATUS }
], ],
orginizaRules: { orginizaRules: {
account: [{ required: true, message: '请输入登录名称', trigger: blur }] name: [{ required: true, message: '请输入组织名称', trigger: 'blur' }],
orderNum: [{ required: true, message: '请输入显示排序', trigger: 'blur' }],
enableStatus: [{ required: true, message: '请选择组织状态', trigger: 'change' }]
}, },
// 部门弹窗 // 部门弹窗
filterDialogTitle: '选择组织', num: 1
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: '福田竹子林金融产业园区'
}
]
}
]
}
],
defaultProps: {
children: 'children',
label: 'label'
},
listData: [
],
loading: false
} }
}, },
...@@ -291,12 +183,25 @@ export default { ...@@ -291,12 +183,25 @@ export default {
this.getList() this.getList()
}, },
methods: { methods: {
// 确定,新增用户、编辑用户 search() {
this.getList(this.searchForm)
},
// 重置搜索条件
refresh() {
this.searchForm = {}
},
// 确定,新增组织、编辑组织
handleConfirm() { handleConfirm() {
console.log(this.$refs.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))
params.enableStatus = this.orginizaForm.enableStatus ? 0 : 1
let api = addOrganiza
if (params.id) api = editOrganiza
api(params).then(res => {
this.handleClose() this.handleClose()
})
} else { } else {
console.log('error') console.log('error')
} }
...@@ -313,10 +218,18 @@ export default { ...@@ -313,10 +218,18 @@ export default {
btnClick(pType, scope) { btnClick(pType, scope) {
console.log(pType, scope) console.log(pType, scope)
switch (pType) { switch (pType) {
case 'root':
this.orginizaData[0].hidden = true
this.orginizaDialogTitle = '新增根组织'
this.handleClose()
break
case 'create': case 'create':
this.orginizaData[0].hidden = false
this.orginizaDialogTitle = '新增组织'
this.handleClose() this.handleClose()
break break
case 'edit': case 'edit':
this.orginizaDialogTitle = '编辑组织'
this.editEvent(scope) this.editEvent(scope)
break break
case 'delete': case 'delete':
...@@ -326,6 +239,9 @@ export default { ...@@ -326,6 +239,9 @@ export default {
}, },
// 编辑触发事件 // 编辑触发事件
editEvent(row) { editEvent(row) {
console.log(row)
this.orginizaForm = JSON.parse(JSON.stringify(row))
this.orginizaForm.enableStatus = row.enableStatus == 0 ? true : false
this.handleClose() this.handleClose()
}, },
// 删除触发事件 // 删除触发事件
...@@ -337,55 +253,32 @@ export default { ...@@ -337,55 +253,32 @@ export default {
tipTitle: '提示', tipTitle: '提示',
type: 'error', type: 'error',
callBack: () => { callBack: () => {
deleteOrganiza({ id: id }).then(res => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}) })
})
} }
} }
this.$Common.confirmDialog(tipData) this.$Common.confirmDialog(tipData)
}, },
// 部门弹窗 // 树形table懒加载
selectDepart() { load(tree, treeNode, resolve) {
this.filterDialogTitle = '选择组织' console.log(tree, treeNode, resolve)
this.closeFilter() getChildren({ id: tree.id }).then(res => {
}, let nodes = res.data.list
// 上级弹窗 nodes.map(item => {
selectSuperior() { const aa = this.num++
this.filterDialogTitle = '选择直接上级' item.id = aa + '' + item.id
this.closeFilter() })
}, resolve(nodes)
closeFilter() {
this.filterVisible = !this.filterVisible
},
filterConfirm() {
console.log(this.$refs.tree.getCheckedKeys(false, true))
// this.closeFilter()
},
filterNode(value, data) {
console.log(value, data)
if (!value) return true
return data.label.indexOf(value) !== -1
},
// 表格方法
rowClick(row, e, col) {
console.log(row, e, col, 'row cliock data')
orginizaService.getChildren(row.id).then(res => {
console.log(res)
row.children = res.data.list
}) })
}, },
// 业务 getList(params) {
tableClick(that, index, row, data) { getTableList(params).then((res) => {
console.log(that, index, row, data, 'tableClick') this.orginTableData = res.data.list
}, })
getList() {
orginizaService.getTableList().then((res) => {
console.log(res);
this.listData = res.data.list
}, (err) => {
});
} }
} }
} }
......
...@@ -121,8 +121,7 @@ ...@@ -121,8 +121,7 @@
// import UserService from 'services/user'; // import UserService from 'services/user';
import { getUserList, getSuperUser, addUser, editUser, detailUser, deleteUser, roleList } from 'services/user'; import { getUserList, getSuperUser, addUser, editUser, detailUser, deleteUser, roleList } from 'services/user';
import OrginizaService from 'services/orginizaManage'; import { getSimpleList, getTreeOrg } from 'services/orginizaManage'
const orginizaService = new OrginizaService();
export default { export default {
data() { data() {
return { return {
...@@ -445,14 +444,14 @@ export default { ...@@ -445,14 +444,14 @@ export default {
}, },
// 获取组织树 // 获取组织树
getSimpleList() { getSimpleList() {
orginizaService.getSimpleList().then(res => { getSimpleList().then(res => {
console.log(res) console.log(res)
this.filterTextData = res.data.list this.filterTextData = res.data.list
}) })
}, },
// 获取组织架构 // 获取组织架构
getTreeOrg() { getTreeOrg() {
orginizaService.getTreeOrg().then(res => { getTreeOrg().then(res => {
console.log(res) console.log(res)
this.data = res.data.list this.data = res.data.list
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!