当前位置:网站首页>el-tree结合el-table,树形添加修改操作
el-tree结合el-table,树形添加修改操作
2022-07-04 21:03:00 【七彩猫猫虫】
效果图

html
<div class="container">
<my-crumbs :crumbs="crumbs"></my-crumbs>
<contentArea ref="contentBox">
<div slot="btnCon">
<el-button
size="small"
icon="el-icon-plus"
type="primary"
@click="addGroup"
>新增事业群</el-button
>
</div>
<!-- <div slot="searchCon">
<el-button @click="searchBtn" icon="el-icon-search" type="primary" size="small"></el-button>
</div> -->
<!-- 搜索条件 -->
<div slot="searchBox">资产类型管理</div>
<!-- 表格部分 -->
<div slot="tableCon">
<el-row :gutter="24">
<el-col :xs="24" :sm="24" :md="6">
<div class="tree_box">
<el-card>
<div class="searchLeft">
<el-input
placeholder="输入关键字进行过滤"
v-model="filterText"
>
</el-input>
</div>
<el-tree
class="tree-line"
:data="treeData"
:props="defaultProps"
default-expand-all
:key="tree_key"
node-key="id"
:render-content="renderContent"
:expand-on-click-node="false"
:filter-node-method="filterNode"
@node-click="changeNodeTree"
ref="tree"
>
</el-tree>
</el-card>
</div>
</el-col>
<el-col :xs="24" :sm="24" :md="18">
<div class="table_box">
<el-card>
<el-table
:data="tableData"
ref="multipleTable"
style="width: 100%"
height="600"
v-loading="loading"
>
<el-table-column type="index" label="序号" width="120"
><template slot-scope="scope">
<span>{
{
(page - 1) * limit + scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column prop="name" label="事业群名" width="260">
</el-table-column>
<el-table-column prop="pid_name" label="上级事业群">
</el-table-column>
<el-table-column prop="remark" label="备注">
</el-table-column>
<el-table-column fixed="right" label="操作" align="center">
<template slot-scope="scope">
<el-button
@click="change(scope.row)"
type="text"
size="medium"
style="color: #f8ac59"
><div class="editBtn">
<div class="icon">
<img src="../../assets/icon/change.png" alt="" />
</div>
<div class="text charge">修改</div>
</div></el-button
>
</template>
</el-table-column>
</el-table>
<div class="page_box">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="pageSizes"
:page-size="limit"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
>
</el-pagination>
</div>
</el-card>
</div>
</el-col>
</el-row>
</div>
</contentArea>
<!-- 新增分类 -->
<el-dialog
:title="title"
:visible.sync="groupDialogVisible"
width="40%"
@close="groupClose"
:close-on-click-modal="false"
>
<el-form
ref="addGroupForm"
:label-position="labelPosition"
:rules="groupRules"
label-width="120px"
:model="groupForm"
>
<el-form-item label="事业群名称:" prop="name">
<el-input
v-model="groupForm.name"
placeholder="请输入事业群名称"
></el-input>
</el-form-item>
<el-form-item label="上级事业群:" prop="pid">
<!-- <el-select v-model="groupForm.pid" placeholder="请选择上级事业群" style="width:100%" clearable>
<el-option
v-for="item in groupListNoTree"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select> -->
<el-cascader
v-model="groupForm.pid"
filterable
placeholder="请选择事业群"
:show-all-levels="false"
:options="groupList"
:props="{ checkStrictly: true, emitPath: false }"
style="width: 100%"
></el-cascader>
</el-form-item>
<el-form-item label="备注:" prop="remark">
<el-input
v-model="groupForm.remark"
placeholder="请输入备注"
></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="groupDialogVisible = false">取 消</el-button>
<el-button type="primary" @click="addGroupSubmit" v-if="!isChange"
>确 定</el-button
>
<el-button type="primary" @click="editSubmit" v-if="isChange"
>确 定</el-button
>
</span>
</el-dialog>
<!-- 新增子事业群 -->
<el-dialog
:title="titleChild"
:visible.sync="dialogAddChildFormVisible"
width="40%"
@close="closeChild"
>
<el-form
:model="addChildForm"
ref="addChildForm"
label-width="120px"
:rules="groupRules"
:label-position="labelPosition"
>
<el-form-item label="事业群名称:" prop="name">
<el-input
v-model="addChildForm.name"
placeholder="请输入事业群名称"
></el-input>
</el-form-item>
<el-form-item label="上级事业群:" prop="pid">
<!-- <el-select v-model="groupForm.pid" placeholder="请选择上级事业群" style="width:100%" clearable>
<el-option
v-for="item in groupListNoTree"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select> -->
<el-cascader
v-model="addChildForm.pid"
filterable
placeholder="请选择上级事业群"
:show-all-levels="false"
:options="groupList"
:props="{ checkStrictly: true, emitPath: false }"
style="width: 100%"
></el-cascader>
</el-form-item>
<el-form-item label="备注:" prop="remark">
<el-input
v-model="addChildForm.remark"
placeholder="请输入备注"
></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogAddChildFormVisible = false">取 消</el-button>
<el-button
type="primary"
@click="addChildGroupSubmit"
v-if="!isChangeChild"
>确 定</el-button
>
<el-button type="primary" @click="editChildSubmit" v-if="isChangeChild"
>确 定</el-button
>
</span>
</el-dialog>
</div>
左边树样式
/* 树形结构样式 */
.el-tree /deep/ .node_box {
width: 100%;
height: 30px;
line-height: 30px;
margin: 2px 0;
overflow: hidden;
font-size: 13px;
}
.el-tree /deep/ .tree_node_op {
float: left;
margin-left: 60px;
display: none;
}
.el-tree /deep/ .node_box:hover .tree_node_op {
color: #ce1e1b;
display: block;
}
.el-tree /deep/ .node_box:hover .tree_node_op > i {
margin-right: 4px;
}
.el-tree /deep/ .node_box:hover .el-icon-document {
color: #ce1e1b;
}
.el-tree /deep/ .el-tree-node__children .el-tree-node__content .tree_node_op {
/* display: none; */
}
.tree-line {
height: 500px;
overflow: scroll;
}
.el-table__fixed-right-patch {
background-color: white !important;
}
核心js代码
搜索
watch: {
filterText(val) {
this.$refs.tree.filter(val);
},
},
左边树里的操作
//新增子事业群
append(store, node, data) {
// console.log(store,'store')
// console.log(node,'node')
// console.log(data,'data')
console.log(data, "新增子事业群");
this.titleChild = "新增子事业群";
this.isChangeChild = false;
this.addChildForm.pid = data.value;
// this.addChildForm.parent_id = data.id;
this.dialogAddChildFormVisible = true;
},
//编辑子事业群
nodeEdit(store, node, data) {
console.log(data, "修改事业群");
// this.editMainId = data;
this.addChildForm = {
};
this.title = "修改事业群";
this.groupDialogVisible = true;
this.isChange = true;
getGroupInfo({
group_id: data.value }).then((res) => {
console.log(res, "详情数据");
this.groupForm.name = res.data.name;
this.groupForm.pid = res.data.pid;
this.groupForm.group_id = res.data.id;
this.groupForm.remark = res.data.remark;
});
// this.editForm.code=this.editMainId.code
// this.titleChild = "修改子事业群";
// this.isChangeChild = true;
// this.dialogAddChildFormVisible = true;
},
// 左侧树形结构操作
// 结构树操作group node,
showOrEdit(data) {
if (data.isEdit) {
return (
<input
type="text"
value={
data.label}
on-blur={
(ev) => this.edit_sure(ev, data)}
/>
);
} else {
return <span className="node_labe">{
data.label}</span>;
}
},
changeNodeTree(e, node) {
console.log(e, "eee");
console.log(node, "node");
this.formInline.group_id = e.value;
// if (this.searchData.parent_id == undefined) {
// this.searchData.parent_id = "";
// }
// if (Array.isArray(node.parent.data) == true) {
// this.searchData.type_id = "";
// this.searchData.parent_id = e.id;
// } else {
// this.searchData.type_id = e.id;
// this.searchData.parent_id = node.parent.data.id;
// }
this.getList();
},
filterNode(value, data) {
// console.log(value,'filterNode的')
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
renderContent(h, {
node, data, store }) {
return (
<span class="node_box">
<span class="el-icon-document">{
this.showOrEdit(data)}</span>
<div class="tree_node_op" style=" float: right;margin-left:60px;">
<i
class="el-icon-edit"
on-click={
(ev) => this.nodeEdit(ev, store, data)}
></i>
<i
class="el-icon-plus"
on-click={
() => this.append(store, node, data)}
></i>
</div>
</span>
);
},
边栏推荐
- Jerry added the process of turning off the touch module before turning it off [chapter]
- Le module minidom écrit et analyse XML
- Kubeadm初始化报错:[ERROR CRI]: container runtime is not running
- Sorting and sharing of selected papers, systems and applications related to the most comprehensive mixed expert (MOE) model in history
- [leetcode] 17. Letter combination of telephone number
- 【C語言】符號的深度理解
- Jerry's ad series MIDI function description [chapter]
- 一文掌握数仓中auto analyze的使用
- Open3d surface normal vector calculation
- Jerry's ad series MIDI function description [chapter]
猜你喜欢

IIC (STM32)
![[early knowledge of activities] list of recent activities of livevideostack](/img/14/d2cdae45a18a5bba7ee1ffab903af2.jpg)
[early knowledge of activities] list of recent activities of livevideostack
![[leetcode] 17. Letter combination of telephone number](/img/be/7f456c092f7cda5ebabc2f1cce292e.png)
[leetcode] 17. Letter combination of telephone number

How to implement Devops with automatic tools

Daily question-leetcode556-next larger element iii-string-double pointer-next_ permutation

Redis03 - network configuration and heartbeat mechanism of redis
![Jerry's ad series MIDI function description [chapter]](/img/28/e0f9b41db597ff3288af431c677001.png)
Jerry's ad series MIDI function description [chapter]

At the right time, the Guangzhou station of the city chain science and Technology Strategy Summit was successfully held

ArcGIS 10.2.2 | solution to the failure of ArcGIS license server to start

创客思维在高等教育中的启迪作用
随机推荐
numpy vstack 和 column_stack
How to implement Devops with automatic tools
Lambdaquerywrapper usage
minidom 模块写入和解析 XML
MongoDB聚合操作总结
TCP三次握手,四次挥手,你真的了解吗?
redis03——Redis的网络配置与心跳机制
GTEST from ignorance to proficiency (4) how to write unit tests with GTEST
redis管道
Redis03 - network configuration and heartbeat mechanism of redis
AcWing 2022 每日一题
Operation of adding material schedule in SolidWorks drawing
哈希表(Hash Tabel)
Interviewer: what is XSS attack?
Liu Jincheng won the 2022 China e-commerce industry innovation Figure Award
案例分享|金融业数据运营运维一体化建设
Daily question-leetcode556-next larger element iii-string-double pointer-next_ permutation
每日一题-LeetCode556-下一个更大元素III-字符串-双指针-next_permutation
MYSQL 用!=查询不出等于null的数据,解决办法
How was MP3 born?