| | |
| | | <template> |
| | | <div>131</div> |
| | | <div class="main-div"> |
| | | <div class="side_div"> |
| | | <el-input placeholder="输入关键字进行过滤" v-model="filterText"> |
| | | </el-input> |
| | | <el-tree |
| | | class="filter-tree" |
| | | :data="data" |
| | | node-key="id" |
| | | :props="defaultProps" |
| | | default-expand-all |
| | | :filter-node-method="filterNode" |
| | | ref="tree" |
| | | @node-click="handleNodeClick" |
| | | > |
| | | </el-tree> |
| | | </div> |
| | | <div class="table_div"> |
| | | <div class="table_top_div"> |
| | | <span class="top_span" v-if="msg !== ''">{{ msg }}</span> |
| | | <div style="text-align: right; float: right"> |
| | | <el-button |
| | | type="primary" |
| | | size="small" |
| | | icon="el-icon-circle-plus-outline" |
| | | >新增</el-button |
| | | > |
| | | <el-button size="small" icon="el-icon-delete-solid">删除</el-button> |
| | | </div> |
| | | </div> |
| | | <div class="table-main-div"> |
| | | <el-table |
| | | ref="multipleTable" |
| | | :data="tableData" |
| | | border |
| | | height="100%" |
| | | tooltip-effect="dark" |
| | | style="width: 100%" |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="55"> </el-table-column> |
| | | <el-table-column label="日期" width="120"> |
| | | <template slot-scope="scope">{{ scope.row.date }}</template> |
| | | </el-table-column> |
| | | <el-table-column prop="name" label="姓名" width="120"> |
| | | </el-table-column> |
| | | <el-table-column prop="address" label="地址" show-overflow-tooltip> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getOrganizationalApi } from "@/api/laboratory/organizational"; |
| | | export default { |
| | | name: "Organizational", |
| | | data() { |
| | | return { |
| | | filterText: "", |
| | | msg: "", |
| | | data: [], |
| | | // tree树默认值配置 |
| | | defaultProps: { |
| | | children: "children", |
| | | label: "department", |
| | | id: "id", |
| | | }, |
| | | tableData: [ |
| | | { |
| | | date: "2016-05-02", |
| | | name: "王小虎", |
| | | address: "上海市普陀区金沙江路 1518 弄", |
| | | }, |
| | | { |
| | | date: "2016-05-04", |
| | | name: "王小虎", |
| | | address: "上海市普陀区金沙江路 1517 弄", |
| | | }, |
| | | { |
| | | date: "2016-05-01", |
| | | name: "王小虎", |
| | | address: "上海市普陀区金沙江路 1519 弄", |
| | | }, |
| | | { |
| | | date: "2016-05-03", |
| | | name: "王小虎", |
| | | address: "上海市普陀区金沙江路 1516 弄", |
| | | }, |
| | | ], |
| | | }; |
| | | }, |
| | | methods: { |
| | | // 树上方搜索框过滤器 |
| | | filterNode(value, data) { |
| | | if (!value) return true; |
| | | return data.department.indexOf(value) !== -1; |
| | | }, |
| | | // 初始化获取树数据 |
| | | treeInitialization() { |
| | | getOrganizationalApi().then((res) => { |
| | | this.data = res.data; |
| | | }); |
| | | }, |
| | | // 获取树路径 |
| | | getParentData(node, department) { |
| | | if (node !== null) { |
| | | if (node.data.department !== undefined) { |
| | | this.msg = node.data.department + " > " + department; |
| | | } |
| | | this.getParentData(node.parent, this.msg); |
| | | } |
| | | }, |
| | | // 点击树节点 |
| | | handleNodeClick(data, node, element) { |
| | | this.getParentData(node.parent, node.data.department); |
| | | console.log(`output->this.msg`, this.msg); |
| | | console.log(`output->data`, data); |
| | | console.log(`output->node`, node); |
| | | console.log(`output->element`, element); |
| | | }, |
| | | // 改变多选框状态 |
| | | toggleSelection(rows) { |
| | | if (rows) { |
| | | rows.forEach((row) => { |
| | | this.$refs.multipleTable.toggleRowSelection(row); |
| | | }); |
| | | } else { |
| | | this.$refs.multipleTable.clearSelection(); |
| | | } |
| | | }, |
| | | // 点击多选框以后的操作 |
| | | handleSelectionChange(val) { |
| | | this.multipleSelection = val; |
| | | }, |
| | | }, |
| | | mounted() { |
| | | this.treeInitialization(); |
| | | }, |
| | | watch: { |
| | | filterText(val) { |
| | | this.$refs.tree.filter(val); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style></style> |
| | | <style lang="scss"> |
| | | .main-div { |
| | | width: 99.2% !important; |
| | | height: 94vh !important; |
| | | margin: 5px 5px 5px 5px; |
| | | } |
| | | .side_div { |
| | | float: left; |
| | | width: 300px; |
| | | height: 95%; |
| | | margin-bottom: 5px; |
| | | background-color: #ffffff; |
| | | padding: 15px; |
| | | } |
| | | .table_div { |
| | | margin-left: 6px; |
| | | float: left; |
| | | width: calc(100% - 306px); |
| | | height: 95%; |
| | | background-color: #ffffff; |
| | | } |
| | | .filter-tree { |
| | | margin-top: 6px; |
| | | } |
| | | .table_top_div { |
| | | height: 80px; |
| | | width: 100%; |
| | | padding-top: 23px; |
| | | padding-right: 50px; |
| | | } |
| | | .table-main-div { |
| | | width: 100%; |
| | | height: 90.3%; |
| | | padding: 10px; |
| | | } |
| | | .top_span { |
| | | margin-left: 12px; |
| | | font-size: 16px; |
| | | font-weight: 500; |
| | | color: #999999; |
| | | } |
| | | </style> |