<template>
|
<div class="app-container">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" @submit.native.prevent>
|
<el-form-item label="机构名称" prop="name">
|
<el-input
|
v-model="queryParams.name"
|
placeholder="请输入机构名称"
|
clearable
|
size="small"
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-form>
|
|
<el-table
|
ref="singleTable"
|
v-loading="loading"
|
:data="organizationList"
|
row-key="id"
|
height="50vh"
|
default-expand-all
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
highlight-current-row
|
@current-change="handleCurrentChange"
|
>
|
<el-table-column label="序号" type="index" width="55"></el-table-column>
|
<el-table-column label="机构名称" align="left" prop="name"/>
|
<el-table-column label="机构编号" prop="code"/>
|
<el-table-column label="显示顺序" align="center" prop="orderNum"/>
|
</el-table>
|
</div>
|
</template>
|
|
<script>
|
import { listOrganization } from "@/api/oa/organization";
|
import Treeselect from "@riophae/vue-treeselect";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
export default {
|
name: "OrganizationList",
|
props: {
|
schoolId: {
|
type: Number,
|
default: undefined
|
}
|
},
|
components: {
|
Treeselect
|
},
|
data() {
|
return {
|
// 按钮loading
|
buttonLoading: false,
|
// 遮罩层
|
loading: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 高校组织机构表格数据
|
organizationList: [],
|
// 高校组织机构树选项
|
organizationOptions: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
name: undefined,
|
schoolId: this.schoolId
|
},
|
currentRow: undefined
|
};
|
},
|
mounted() {
|
this.getList()
|
},
|
methods: {
|
/** 查询建筑单元列表 */
|
getList() {
|
this.loading = true;
|
// 清空选中状态和数据
|
if (this.currentRow) {
|
this.$refs.singleTable.setCurrentRow();
|
this.currentRow = undefined;
|
}
|
listOrganization(Object.assign({}, this.queryParams, {schoolId: this.schoolId})).then(response => {
|
this.organizationList = this.handleTree(response.data, "id", "parentId");
|
this.loading = false;
|
});
|
},
|
/** 转换建筑单元数据结构 */
|
normalizer(node) {
|
if (node.children && !node.children.length) {
|
delete node.children;
|
}
|
return {
|
id: node.id,
|
label: node.name,
|
children: node.children
|
};
|
},
|
/** 查询建筑单元下拉树结构 */
|
getTreeselect() {
|
listOrganization({schoolId: this.schoolId}).then(response => {
|
this.organizationOptions = [];
|
const data = {id: 0, name: '顶级节点', children: []};
|
data.children = this.handleTree(response.data, "id", "parentId");
|
this.organizationOptions.push(data);
|
});
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm("queryForm");
|
this.handleQuery();
|
},
|
handleCurrentChange(v) {
|
this.currentRow = v;
|
}
|
}
|
};
|
</script>
|