| | |
| | | v-model="TreeForm" |
| | | :data="TreeData" |
| | | :option="TreeOption" |
| | | node-key="id" |
| | | :default-checked-keys="[5]" |
| | | @check-change="checkChange"> |
| | | </avue-tree> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <div slot="footer" class="dialog-footer" style="height: 50px;line-height: 50px"> |
| | | <el-button icon="el-icon-plus" size="small" type="primary" @click="empower">授 权</el-button> |
| | | <el-button icon="el-icon-close" size="small" type="danger">重 置</el-button> |
| | |
| | | return { |
| | | checkAll: {}, |
| | | ParentList: [], |
| | | ParentRemoveList: [], |
| | | //避免缓存 |
| | | reload: Math.random(), |
| | | TreeLoading: false, |
| | |
| | | }, |
| | | } |
| | | }, |
| | | |
| | | created() { |
| | | }, |
| | | methods: { |
| | | empower() { |
| | | batchAddSave(this.checkAll.oid, this.checkAll.id, this.ParentList).then(res => { |
| | | console.log(res) |
| | | if(res.data.data.code === 200){ |
| | | this.$message.success(res.data.data.msg) |
| | | this.dialogVisible=false; |
| | | } |
| | | }) |
| | | }, |
| | | //分类授权多选回调 |
| | | checkChange(row, checked) { |
| | | if (checked) { |
| | | if (!row.parentId && row.children) { |
| | | if (!row.parentId) { |
| | | const parentRecord = { |
| | | oid: row.oid, |
| | | classifyId: row.attributes.classifyId, |
| | |
| | | classParentOid: row.parentId, |
| | | }; |
| | | this.ParentList.push(parentRecord); |
| | | // 如果row的children不为空,继续循环children中的每个对象 |
| | | // 如果row的children不为空 继续循环children中的每个对象 |
| | | if (row.children && row.children.length > 0) { |
| | | for (let child of row.children) { |
| | | const childRecord = { |
| | |
| | | classParentOid: child.parentId, |
| | | }; |
| | | this.ParentList.push(childRecord); |
| | | // 如果子对象的children不为空,继续循环获取数据 |
| | | // 如果子对象的children不为空 继续循环获取数据 |
| | | if (child.children && child.children.length > 0) { |
| | | for (let subChild of child.children) { |
| | | const subRecord = { |
| | |
| | | } |
| | | } |
| | | } |
| | | console.log(this.ParentList); |
| | | } |
| | | }else { |
| | | this.ParentList = this.ParentList.filter(res => res.classifyId !== row.classifyId); |
| | | console.log(this.ParentList); |
| | | } else { |
| | | // 取消勾选的节点是父节点 |
| | | if (!row.parentId) { |
| | | // 找到父节点在ParentList中的索引 |
| | | const parentIndex = this.ParentList.findIndex(item => item.oid === row.oid); |
| | | if (parentIndex !== -1) { |
| | | const parentOid = this.ParentList[parentIndex].classifyOid; |
| | | |
| | | // 查找所有需要删除的子节点的索引 |
| | | const childIndexes = this.ParentList.reduce((indexes, item, index) => { |
| | | if (item.classParentOid === parentOid && item.classifyOid !== parentOid) { |
| | | indexes.push(index); |
| | | } |
| | | return indexes; |
| | | }, []); |
| | | |
| | | // 从后往前删除子节点的数据,保证索引的正确性 |
| | | for (let i = childIndexes.length - 1; i >= 0; i--) { |
| | | this.ParentList.splice(childIndexes[i], 1); |
| | | } |
| | | |
| | | // 删除父节点的数据 |
| | | this.ParentList.splice(parentIndex, 1); |
| | | } |
| | | } else { |
| | | // 取消勾选的节点是子节点 |
| | | const childIndex = this.ParentList.findIndex(item => item.oid === row.oid); |
| | | if (childIndex !== -1) { |
| | | // 删除子节点的数据 |
| | | this.ParentList.splice(childIndex, 1); |
| | | } |
| | | } |
| | | } |
| | | console.log(this.ParentList); |
| | | }, |
| | | //分类授权 |
| | | classifyHandler(row) { |
| | |
| | | this.checkAll = row |
| | | sysInfoTree({systemOid: row.oid, systemId: row.id}).then(res => { |
| | | this.TreeData = res.data; |
| | | var List=[] |
| | | this.TreeData.forEach((item,index)=>{ |
| | | const parentRecord = { |
| | | label: item.text, |
| | | children: [], // 初始化children为空数组 |
| | | }; |
| | | List.push(parentRecord); |
| | | // 如果item的children不为空 继续循环children中的每个对象 |
| | | if (item.children && item.children.length > 0) { |
| | | for (let child of item.children) { |
| | | const childRecord = { |
| | | label: child.text, // 使用child的text属性作为label |
| | | children: [], // 初始化children为空数组 |
| | | }; |
| | | parentRecord.children.push(childRecord); // 将childRecord添加到parentRecord的children数组中 |
| | | // 如果子对象的children不为空 继续循环获取数据 |
| | | if (child.children && child.children.length > 0) { |
| | | for (let subChild of child.children) { |
| | | const subRecord = { |
| | | label: subChild.text, // 使用subChild的text属性作为label |
| | | children: [], // 初始化children为空数组 |
| | | }; |
| | | childRecord.children.push(subRecord); // 将subRecord添加到childRecord的children数组中 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | console.log('list',List) |
| | | this.ModifyProperties(this.TreeData, 'text', 'label'); |
| | | // 根据 this.TreeData 的长度计算延迟时间 |
| | | const delayTime = this.TreeData.length * 1; |