vue|vue 组件化开发(三)elementui el-tree 实现可编辑树
【vue|vue 组件化开发(三)elementui el-tree 实现可编辑树】如图:
文章图片
html :
{{ data.NAME }}
添加该序列下存在岗位,删除后岗位所属序列为空,是否删除?取 消
确 定
数据定义:
data() {
return {
runParam: {},
treeData: null,
isAdd: false,
dialogVisible: false,
renderNode: null,
renderData: null,
savePostUrl: "",
delPostUrl: "",
getAll: "",
sortOrder: "",
checkName: "",
defaultProps: {
children: "CHILDREN",
label: "NAME"
}
};
},
methods 部分:
confirm: function() {
this.delTreeNode(this.renderNode, this.renderData);
},
addNode() {
if (this.dialogName == "gwjb" && !this.selectSquence) return;
this.runParam.oldData = https://www.it610.com/article/JSON.parse(JSON.stringify(this.treeData));
this.runParam.parentNode = null;
this.runParam.level = 0;
this.treeData.push({
NAME:"",
CHILDREN: [],
STATUS: 1,
ID: null
});
},
append(node, data) {
if (node.level >= this.maxLevel) return;
this.runParam.oldData = https://www.it610.com/article/JSON.parse(JSON.stringify(this.treeData));
if (!data.CHILDREN) this.$set(data,"CHILDREN", []);
this.runParam.parentNode = JSON.parse(JSON.stringify(data));
this.isAdd = true;
const newChild = { ID: null, NAME: "", CHILDREN: [], STATUS: 1 };
data.CHILDREN.push(newChild);
},
remove(node, data) {
this.dialogVisible = true;
this.renderNode = node;
this.renderData = https://www.it610.com/article/data;
},
blurEdit(data, node) {
if (data.NAME =="") this.treeData = https://www.it610.com/article/JSON.parse(JSON.stringify(this.runParam.oldData));
else this.checkRepeatName(data, node);
},
dbEdit(node, data) {
this.runParam.oldData = JSON.parse(JSON.stringify(this.treeData));
this.runParam.parentNode = data.PID ? data.PID : null;
this.$set(data,"STATUS", 1);
this.isAdd = false;
this.$forceUpdate();
},
collapse(moveNode, inNode, type) {
if (moveNode.level == 1 && inNode.level == 1) return type == "prev";
if (moveNode.level == 2 && inNode.level == 2 && moveNode.parent.ID == inNode.parent.ID) return type == "prev";
},
nodeDropEnd() {
let _this = this;
let par = {
serviceName: "pos",
servicePath: this.sortOrder,
LIST: _this.treeData
};
this.$nextTick(function() {
_this
.$request(par)
.then(() => {
_this.$store.dispatch(_this.dishpatch, JSON.parse(JSON.stringify(_this.treeData)));
})
.catch(msg => _this.$message.error(msg));
});
},
推荐阅读
- parallels|parallels desktop 解决网络初始化失败问题
- 第326天
- 牛人进化+|牛人进化+ 按自己的意愿过一生
- vue-cli|vue-cli 3.x vue.config.js 配置
- 2020-04-07vue中Axios的封装和API接口的管理
- MongoDB,Wondows下免安装版|MongoDB,Wondows下免安装版 (简化版操作)
- 松软可口易消化,无需烤箱超简单,新手麻麻也能轻松成功~
- 为什么孩子一定要学会可视化思维!
- 试论化院的学生自组织
- 【变化】我的青椒学习之旅