组织修改
This commit is contained in:
parent
2d96581ee0
commit
fc77d32c22
|
@ -1,42 +1,7 @@
|
|||
<template>
|
||||
<a-row :gutter="24" >
|
||||
<a-col :md="5" :sm="24" >
|
||||
<a-card :bordered="false" :loading="treeLoading">
|
||||
<div v-if="this.orgTree!='' ">
|
||||
<a-tree
|
||||
style="scroll:true"
|
||||
:treeData="orgTree"
|
||||
v-if="orgTree.length"
|
||||
@select="handleClick"
|
||||
:defaultExpandAll="true"
|
||||
:defaultExpandedKeys="defaultExpandedKeys"
|
||||
:replaceFields="replaceFields" />
|
||||
</div>
|
||||
<div v-else>
|
||||
<a-empty :image="simpleImage" />
|
||||
</div>
|
||||
</a-card>
|
||||
</a-col>
|
||||
<a-col :md="19" :sm="24">
|
||||
<a-card :bordered="false">
|
||||
<div class="table-page-search-wrapper">
|
||||
<a-form layout="inline">
|
||||
<a-row :gutter="48">
|
||||
<a-col :md="8" :sm="24">
|
||||
<a-form-item label="机构名称" >
|
||||
<a-input v-model="queryParam.name" allow-clear placeholder="请输入机构名称"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :md="8" :sm="24">
|
||||
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
|
||||
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
</a-card>
|
||||
<a-card :bordered="false">
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-tabs default-active-key="1" >
|
||||
<a-tab-pane key="1" tab="单位部门信息" @change="tabsCallback">
|
||||
<div class="table-operator">
|
||||
<a-button @click="$refs.orgForm.add()" icon="plus" type="primary" v-if="hasPerm('sys:org:add')">新增机构</a-button>
|
||||
</div>
|
||||
|
@ -46,6 +11,8 @@
|
|||
:columns="columns"
|
||||
:data="loadData"
|
||||
:rowKey="(record) => record.id"
|
||||
:showPagination="false"
|
||||
:defaultExpandedRowKeys="expandedRowKeys"
|
||||
>
|
||||
|
||||
<span slot="action" slot-scope="text, record">
|
||||
|
@ -57,14 +24,37 @@
|
|||
</span>
|
||||
</s-table>
|
||||
<org-form ref="orgForm" @ok="handleOk" />
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="2" tab="项目工程信息" @change="tabsCallback">
|
||||
<div class="table-operator">
|
||||
<a-button @click="$refs.orgForm.add()" icon="plus" type="primary" v-if="hasPerm('sys:org:add')">新增项目</a-button>
|
||||
</div>
|
||||
|
||||
<s-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:data="loadData"
|
||||
:rowKey="(record) => record.id"
|
||||
:showPagination="false"
|
||||
:defaultExpandedRowKeys="expandedRowKeys"
|
||||
>
|
||||
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<a v-if="hasPerm('sys:org:edit')" @click="$refs.orgForm.edit(record)">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm('sys:org:edit') & hasPerm('sys:org:delete')"/>
|
||||
<a-popconfirm v-if="hasPerm('sys:org:delete')" placement="topRight" title="确认删除?" @confirm="() => singleDelete(record)">
|
||||
<a>删除</a>
|
||||
</a-popconfirm>
|
||||
</span>
|
||||
</s-table>
|
||||
<org-form ref="orgForm" @ok="handleOk" />
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</a-card>
|
||||
</template>
|
||||
<script>
|
||||
import { STable } from '@/components'
|
||||
import { Empty } from 'ant-design-vue'
|
||||
import { orgList, orgDel, orgPage } from '@/api/org/org'
|
||||
import { orgList, orgDel } from '@/api/org/org'
|
||||
import OrgForm from './OrgForm'
|
||||
import { listToTree } from '@/utils/util'
|
||||
const rootParentId = 0
|
||||
|
@ -78,6 +68,7 @@
|
|||
return {
|
||||
// 查询参数
|
||||
queryParam: {},
|
||||
expandedRowKeys: [],
|
||||
// 表头
|
||||
columns: [
|
||||
{
|
||||
|
@ -99,30 +90,18 @@
|
|||
],
|
||||
// 加载数据方法 必须为 Promise 对象
|
||||
loadData: parameter => {
|
||||
return orgPage(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||
return res
|
||||
return orgList(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||
const orgList = listToTree(res.data, [], rootParentId)
|
||||
// 默认展开目录级
|
||||
orgList.forEach(item => {
|
||||
this.expandedRowKeys.push(item.id)
|
||||
})
|
||||
return orgList
|
||||
})
|
||||
},
|
||||
orgTree: [],
|
||||
selectedRowKeys: [],
|
||||
selectedRows: [],
|
||||
defaultExpandedKeys: [],
|
||||
// 搜索的三个参数
|
||||
expandedKeys: [],
|
||||
searchValue: '',
|
||||
autoExpandParent: true,
|
||||
treeLoading: true,
|
||||
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
||||
replaceFields: {
|
||||
children: 'children',
|
||||
title: 'name',
|
||||
key: 'id',
|
||||
value: 'id'
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.getOrgTree()
|
||||
if (this.hasPerm('sys:org:edit') || this.hasPerm('sys:org:del')) {
|
||||
this.columns.push({
|
||||
title: '操作',
|
||||
|
@ -133,27 +112,11 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 获取到机构树,展开顶级下树节点,考虑到后期数据量变大,不建议全部展开
|
||||
*/
|
||||
getOrgTree () {
|
||||
orgList(Object.assign(this.queryParam)).then(res => {
|
||||
this.treeLoading = false
|
||||
if (!res.code === 200 || !res.data.length) {
|
||||
return
|
||||
}
|
||||
console.log(res.data)
|
||||
this.orgTree = listToTree(res.data, [], rootParentId)
|
||||
console.log(this.orgTree)
|
||||
this.queryParam.parentId = this.orgTree[0].id
|
||||
// 全部展开,上面api方法提供的不生效,先用此方法
|
||||
for (var item of res.data) {
|
||||
if (item.parentId === 0) {
|
||||
this.defaultExpandedKeys.push(item.id)
|
||||
}
|
||||
}
|
||||
this.$refs.table.refresh()
|
||||
})
|
||||
tabsCallback (key) {
|
||||
if (key === '1') {
|
||||
}
|
||||
if (key === '2') {
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 删除
|
||||
|
@ -171,19 +134,8 @@
|
|||
this.$message.error('删除错误:' + err.message)
|
||||
})
|
||||
},
|
||||
handleClick (e) {
|
||||
this.queryParam = {
|
||||
pid: e.toString()
|
||||
}
|
||||
this.$refs.table.refresh(true)
|
||||
},
|
||||
handleOk () {
|
||||
this.getOrgTree()
|
||||
this.$refs.table.refresh()
|
||||
},
|
||||
onSelectChange (selectedRowKeys, selectedRows) {
|
||||
this.selectedRowKeys = selectedRowKeys
|
||||
this.selectedRows = selectedRows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue