当前位置:网站首页>El tree combined with El table, tree adding and modifying operations
El tree combined with El table, tree adding and modifying operations
2022-07-04 21:50:00 【Colorful cat worm】
design sketch
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"
> New business group </el-button
>
</div>
<!-- <div slot="searchCon">
<el-button @click="searchBtn" icon="el-icon-search" type="primary" size="small"></el-button>
</div> -->
<!-- search criteria -->
<div slot="searchBox"> Asset type management </div>
<!-- The form section -->
<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=" Enter keywords to filter "
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=" Serial number " width="120"
><template slot-scope="scope">
<span>{
{
(page - 1) * limit + scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column prop="name" label=" Business group name " width="260">
</el-table-column>
<el-table-column prop="pid_name" label=" Superior business group ">
</el-table-column>
<el-table-column prop="remark" label=" remarks ">
</el-table-column>
<el-table-column fixed="right" label=" operation " 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"> modify </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>
<!-- New category -->
<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=" Business group name :" prop="name">
<el-input
v-model="groupForm.name"
placeholder=" Please enter the business group name "
></el-input>
</el-form-item>
<el-form-item label=" Superior business group :" prop="pid">
<!-- <el-select v-model="groupForm.pid" placeholder=" Please select the superior business group " 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=" Please choose a business group "
:show-all-levels="false"
:options="groupList"
:props="{ checkStrictly: true, emitPath: false }"
style="width: 100%"
></el-cascader>
</el-form-item>
<el-form-item label=" remarks :" prop="remark">
<el-input
v-model="groupForm.remark"
placeholder=" Please enter comments "
></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="groupDialogVisible = false"> take eliminate </el-button>
<el-button type="primary" @click="addGroupSubmit" v-if="!isChange"
> indeed set </el-button
>
<el-button type="primary" @click="editSubmit" v-if="isChange"
> indeed set </el-button
>
</span>
</el-dialog>
<!-- New sub business groups -->
<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=" Business group name :" prop="name">
<el-input
v-model="addChildForm.name"
placeholder=" Please enter the business group name "
></el-input>
</el-form-item>
<el-form-item label=" Superior business group :" prop="pid">
<!-- <el-select v-model="groupForm.pid" placeholder=" Please select the superior business group " 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=" Please select the superior business group "
:show-all-levels="false"
:options="groupList"
:props="{ checkStrictly: true, emitPath: false }"
style="width: 100%"
></el-cascader>
</el-form-item>
<el-form-item label=" remarks :" prop="remark">
<el-input
v-model="addChildForm.remark"
placeholder=" Please enter comments "
></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogAddChildFormVisible = false"> take eliminate </el-button>
<el-button
type="primary"
@click="addChildGroupSubmit"
v-if="!isChangeChild"
> indeed set </el-button
>
<el-button type="primary" @click="editChildSubmit" v-if="isChangeChild"
> indeed set </el-button
>
</span>
</el-dialog>
</div>
Left tree style
/* Tree structure style */
.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;
}
The core js Code
Search for
watch: {
filterText(val) {
this.$refs.tree.filter(val);
},
},
Operations in the tree on the left
// New sub business groups
append(store, node, data) {
// console.log(store,'store')
// console.log(node,'node')
// console.log(data,'data')
console.log(data, " New sub business groups ");
this.titleChild = " New sub business groups ";
this.isChangeChild = false;
this.addChildForm.pid = data.value;
// this.addChildForm.parent_id = data.id;
this.dialogAddChildFormVisible = true;
},
// Edit sub business group
nodeEdit(store, node, data) {
console.log(data, " Modify the business group ");
// this.editMainId = data;
this.addChildForm = {
};
this.title = " Modify the business group ";
this.groupDialogVisible = true;
this.isChange = true;
getGroupInfo({
group_id: data.value }).then((res) => {
console.log(res, " Details ");
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 = " Modify the sub business group ";
// this.isChangeChild = true;
// this.dialogAddChildFormVisible = true;
},
// Left tree structure operation
// Structure tree operation 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 Of ')
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>
);
},
边栏推荐
- Redis bloom filter
- redis管道
- Use of class methods and class variables
- Compréhension approfondie du symbole [langue C]
- MongoDB中的索引操作总结
- Drop down selection of Ehlib database records
- Cloudcompare & open3d DBSCAN clustering (non plug-in)
- Redis pipeline
- Jerry's ad series MIDI function description [chapter]
- In the release version, the random white screen does not display the content after opening the shutter
猜你喜欢
QT—绘制其他问题
Operation of adding material schedule in SolidWorks drawing
迈动互联中标北京人寿保险
Application practice | Shuhai supply chain construction of data center based on Apache Doris
每日一题-LeetCode1200-最小绝对差-数组-排序
Daily question-leetcode556-next larger element iii-string-double pointer-next_ permutation
[ 每周译Go ] 《How to Code in Go》系列文章上线了!!
Jerry's ad series MIDI function description [chapter]
创客思维在高等教育中的启迪作用
MP3是如何诞生的?
随机推荐
Cadeus has never stopped innovating. Decentralized edge rendering technology makes the metauniverse no longer far away
Methods of improving machine vision system
淘宝商品评价api接口(item_review-获得淘宝商品评论API接口),天猫商品评论API接口
Monitor the shuttle return button
Go language loop statement (3 in Lesson 10)
解析互联网时代的创客教育技术
__ init__ () missing 2 required positive arguments
Keep on fighting! The city chain technology digital summit was grandly held in Chongqing
Daily question-leetcode556-next larger element iii-string-double pointer-next_ permutation
开户哪家券商比较好?网上开户安全吗
Flink1.13 SQL basic syntax (I) DDL, DML
QT—绘制其他问题
哈希表(Hash Tabel)
Jerry's ad series MIDI function description [chapter]
什么是商业智能(BI),就看这篇文章足够了
【C語言】符號的深度理解
[optimtool.unconstrained] unconstrained optimization toolbox
How was MP3 born?
一文掌握数仓中auto analyze的使用
Le module minidom écrit et analyse XML