| | |
| | | <el-container> |
| | | <el-aside> |
| | | <basic-container style="height: 85vh; max-height: 155vh; overflow-y: scroll;"> |
| | | <avue-tree ref="tree" v-model="CloneTreeAvueform" v-loading="loading" :data="CloneTreedata" :defaultExpandAll="false" |
| | | <avue-tree ref="tree" v-model="CloneTreeAvueform" v-loading="loading" :data="Treedata" :defaultExpandAll="false" |
| | | :option="Treeoption" |
| | | style="height: 80.5vh;padding-top: 5px;padding-bottom: 30px" |
| | | @node-click=" nodeClick" |
| | | @check-change="checkChange" |
| | | ></avue-tree> |
| | | </basic-container> |
| | | </el-aside> |
| | | <el-main> |
| | | <TableCrud></TableCrud> |
| | | <TableCrud :page="this.page" :templateOid="this.templateOid" :codeClassifyOid="this.codeClassifyOid"></TableCrud> |
| | | </el-main> |
| | | </el-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import {getAtrrList, TreeCheckDel, TreeDel, TreeSave} from "@/api/template/templateAttr"; |
| | | |
| | | import {getTreeList} from "@/api/MasterData/master" |
| | | export default { |
| | | name: "items.vue", |
| | | data(){ |
| | | return{ |
| | | // 分页 |
| | | page: { |
| | | total: 0, |
| | | currentPage: 1, |
| | | pageSize: 10, |
| | | pageSizes: [10, 30, 50, 100, 200], |
| | | }, |
| | | templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F", |
| | | codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3", |
| | | CloneTreeAvueform:{}, |
| | | loading:false, |
| | | CloneTreedata:[], |
| | | Treedata:[], |
| | | Treeoption: { |
| | | addBtn: false, |
| | | editBtn: false, |
| | | delBtn: false, |
| | | defaultExpandAll: false, |
| | | menu: false, |
| | | // //这个是多选 |
| | | // multiple: true, |
| | | lazy: true, |
| | | // treeLoad:function (node,resolve){ |
| | | // console.log(node) |
| | | // console.log(resolve) |
| | | // } |
| | | treeLoad:function (node, resolve){ |
| | | if(node.loading){ |
| | | const parentId = (node.level === 0) ? 0 : node.data.oid; |
| | | const parentBtmName = node.data.attributes.btmname |
| | | getTreeList({parentOid:parentId,parentBtmName:parentBtmName}).then(res=>{ |
| | | console.log(res) |
| | | }) |
| | | } |
| | | }, |
| | | }, |
| | | nodeClickList: "", |
| | | } |
| | | }, |
| | | created() { |
| | | this.getAttr() |
| | | // this.getAttr() |
| | | this.getTreeList() |
| | | }, |
| | | methods:{ |
| | | getAttr() { |
| | | getAtrrList().then(res => { |
| | | this.Treedata = res.data; |
| | | this.CloneTreedata = res.data; |
| | | this.Treedata.forEach((item) => { |
| | | for (let i = 0; i < this.Treedata.length; i++) { |
| | | this.Treedata[i].value = i; |
| | | } |
| | | }) |
| | | //调用修改属性名方法 |
| | | this.ModifyProperties(this.CloneTreedata, 'name', 'label'); |
| | | }).catch(res => { |
| | | this.$message.error(res) |
| | | getTreeList(){ |
| | | getTreeList({'conditionMap[id]': 'wupin'}).then(res=>{ |
| | | this.Treedata=res.data |
| | | this.ModifyProperties(this.Treedata, 'text', 'label'); |
| | | console.log(this.Treedata) |
| | | }).catch(res=>{ |
| | | console.log(res) |
| | | }) |
| | | }, |
| | | |
| | | //定义一个修改数据属性名的方法 |
| | | ModifyProperties(obj, oldName, newName) { |
| | | for (let key in obj) { |
| | |
| | | } |
| | | }, |
| | | //树节点添加按钮 |
| | | TreeAdd() { |
| | | this.TreeAddFormVisible = true; |
| | | // 判断当前是否有点击子项 |
| | | if (this.nodeClickList !== "") { |
| | | this.TreeFlag = true |
| | | } |
| | | }, |
| | | //树节点添加事件 |
| | | TreeAddHandler() { |
| | | const data = this.TreeAddform |
| | | this.$set(data, "parentCodeClassifyOid", this.nodeClickList.oid) |
| | | TreeSave(data).then(() => { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '添加成功!' |
| | | }); |
| | | this.getAttr(); |
| | | this.TreeAddFormVisible = false |
| | | this.TreeAddform = "" |
| | | }).catch(res => { |
| | | this.$message({ |
| | | type: 'warning', |
| | | message: res |
| | | }); |
| | | }) |
| | | }, |
| | | // TreeAdd() { |
| | | // this.TreeAddFormVisible = true; |
| | | // // 判断当前是否有点击子项 |
| | | // if (this.nodeClickList !== "") { |
| | | // this.TreeFlag = true |
| | | // } |
| | | // }, |
| | | // //树节点添加事件 |
| | | // TreeAddHandler() { |
| | | // const data = this.TreeAddform |
| | | // this.$set(data, "parentCodeClassifyOid", this.nodeClickList.oid) |
| | | // TreeSave(data).then(() => { |
| | | // this.$message({ |
| | | // type: 'success', |
| | | // message: '添加成功!' |
| | | // }); |
| | | // this.getAttr(); |
| | | // this.TreeAddFormVisible = false |
| | | // this.TreeAddform = "" |
| | | // }).catch(res => { |
| | | // this.$message({ |
| | | // type: 'warning', |
| | | // message: res |
| | | // }); |
| | | // }) |
| | | // }, |
| | | //树节点删除按钮 |
| | | TreeDel() { |
| | | this.$confirm('是否删除当前选择的分类,将会把子分类一并删除,如果存在编码数据将不能被删除,是否继续?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | customClass: 'my-messagebox', |
| | | }).then(() => { |
| | | TreeCheckDel(this.nodeClickList).then(res => { |
| | | if (res.data.data) { |
| | | TreeDel(this.nodeClickList).then(() => { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '删除成功!' |
| | | }); |
| | | this.getAttr(); |
| | | }).catch(res => { |
| | | this.$message({ |
| | | type: 'warning', |
| | | message: res |
| | | }); |
| | | }) |
| | | } else { |
| | | this.$confirm('当前数据包含有下级数据,要删除的话会和下级数据一起删除,你确认继续?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | customClass: 'my-messageboxs', |
| | | }).then(() => { |
| | | TreeDel(this.nodeClickList).then(() => { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '删除成功!' |
| | | }); |
| | | this.getAttr(); |
| | | }).catch(res => { |
| | | this.$message({ |
| | | type: 'warning', |
| | | message: res |
| | | }); |
| | | }) |
| | | }).catch(() => { |
| | | this.$message({ |
| | | type: 'info', |
| | | message: '已取消删除' |
| | | }); |
| | | }); |
| | | } |
| | | }) |
| | | }).catch(() => { |
| | | this.$message({ |
| | | type: 'info', |
| | | message: '已取消删除' |
| | | }); |
| | | }); |
| | | }, |
| | | // TreeDel() { |
| | | // this.$confirm('是否删除当前选择的分类,将会把子分类一并删除,如果存在编码数据将不能被删除,是否继续?', '提示', { |
| | | // confirmButtonText: '确定', |
| | | // cancelButtonText: '取消', |
| | | // type: 'warning', |
| | | // customClass: 'my-messagebox', |
| | | // }).then(() => { |
| | | // TreeCheckDel(this.nodeClickList).then(res => { |
| | | // if (res.data.data) { |
| | | // TreeDel(this.nodeClickList).then(() => { |
| | | // this.$message({ |
| | | // type: 'success', |
| | | // message: '删除成功!' |
| | | // }); |
| | | // this.getAttr(); |
| | | // }).catch(res => { |
| | | // this.$message({ |
| | | // type: 'warning', |
| | | // message: res |
| | | // }); |
| | | // }) |
| | | // } else { |
| | | // this.$confirm('当前数据包含有下级数据,要删除的话会和下级数据一起删除,你确认继续?', '提示', { |
| | | // confirmButtonText: '确定', |
| | | // cancelButtonText: '取消', |
| | | // type: 'warning', |
| | | // customClass: 'my-messageboxs', |
| | | // }).then(() => { |
| | | // TreeDel(this.nodeClickList).then(() => { |
| | | // this.$message({ |
| | | // type: 'success', |
| | | // message: '删除成功!' |
| | | // }); |
| | | // this.getAttr(); |
| | | // }).catch(res => { |
| | | // this.$message({ |
| | | // type: 'warning', |
| | | // message: res |
| | | // }); |
| | | // }) |
| | | // }).catch(() => { |
| | | // this.$message({ |
| | | // type: 'info', |
| | | // message: '已取消删除' |
| | | // }); |
| | | // }); |
| | | // } |
| | | // }) |
| | | // }).catch(() => { |
| | | // this.$message({ |
| | | // type: 'info', |
| | | // message: '已取消删除' |
| | | // }); |
| | | // }); |
| | | // }, |
| | | nodeClick(data){ |
| | | this.nodeClickList = data |
| | | console.log(data) |