|
@ -6,21 +6,21 @@ |
|
|
<div class="head-container"> |
|
|
<div class="head-container"> |
|
|
<crudOperation :permission="permission"> |
|
|
<crudOperation :permission="permission"> |
|
|
<template v-slot:left> |
|
|
<template v-slot:left> |
|
|
<el-button size="mini" :disabled="currentNodeLevel===3 || crud.selections[0].type !== 1" @click="toAddOrEdit('add')"> |
|
|
|
|
|
|
|
|
<el-button size="mini" :disabled="currentNodeLevel===3 || (crud.selections[0] && crud.selections[0].type !== 1)" @click="toAddOrEdit('add')"> |
|
|
<i class="iconfont icon-xinzeng" /> |
|
|
<i class="iconfont icon-xinzeng" /> |
|
|
新增 |
|
|
新增 |
|
|
</el-button> |
|
|
</el-button> |
|
|
<el-button :disabled="crud.selections.length !== 1 || crud.selections[0].id === 0" size="mini" @click="toAddOrEdit('edit')"> |
|
|
|
|
|
|
|
|
<el-button :disabled="crud.selections.length !== 1 || (crud.selections[0] && crud.selections[0].id === 0)" size="mini" @click="toAddOrEdit('edit')"> |
|
|
<i class="iconfont icon-bianji" /> |
|
|
<i class="iconfont icon-bianji" /> |
|
|
编辑 |
|
|
编辑 |
|
|
</el-button> |
|
|
</el-button> |
|
|
</template> |
|
|
</template> |
|
|
<template v-slot:right> |
|
|
<template v-slot:right> |
|
|
<el-button :disabled="crud.selections.length === 0 || crud.selections[0].id === 0" size="mini" :loading="crud.delAllLoading" @click="toDelete(crud.selections)"> |
|
|
|
|
|
|
|
|
<el-button :disabled="crud.selections.length === 0 || (crud.selections[0] && crud.selections[0].id === 0)" size="mini" :loading="crud.delAllLoading" @click="toDelete(crud.selections)"> |
|
|
<i class="iconfont icon-shanchu" /> |
|
|
<i class="iconfont icon-shanchu" /> |
|
|
删除 |
|
|
删除 |
|
|
</el-button> |
|
|
</el-button> |
|
|
<el-button icon="el-icon-sort" size="mini" :loading="sortLoading" :disabled="brotherNodeNum <= 1 || crud.selections[0].id === 0" @click="toSort(crud.selections)">排序</el-button> |
|
|
|
|
|
|
|
|
<el-button icon="el-icon-sort" size="mini" :loading="sortLoading" :disabled="brotherNodeNum <= 1 || (crud.selections[0] && crud.selections[0].id === 0)" @click="toSort(crud.selections)">排序</el-button> |
|
|
</template> |
|
|
</template> |
|
|
</crudOperation> |
|
|
</crudOperation> |
|
|
</div> |
|
|
</div> |
|
@ -273,13 +273,17 @@ export default { |
|
|
]), |
|
|
]), |
|
|
filteredSelectOptions() { |
|
|
filteredSelectOptions() { |
|
|
if (this.btnType === 'edit') { |
|
|
if (this.btnType === 'edit') { |
|
|
return this.selectOptions.map(item => ({ |
|
|
|
|
|
...item, |
|
|
|
|
|
disabled: this.currentNodeLevel === 2 && !([2, 3].includes(item.value)) |
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
// return this.selectOptions.map(item => ({ |
|
|
|
|
|
// ...item, |
|
|
|
|
|
// disabled: this.currentNodeLevel === 2 && !([2, 3].includes(item.value)) |
|
|
|
|
|
// })) |
|
|
|
|
|
if (this.currentNodeLevel === 3) { |
|
|
|
|
|
return this.selectOptions.filter(item => [2, 3].includes(item.value)) |
|
|
|
|
|
} else if (this.currentNodeLevel === 2 && this.selectedMenu.children.length !== 0) { |
|
|
|
|
|
return this.selectOptions.filter(item => [1].includes(item.value)) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (this.currentNodeLevel === 2) { |
|
|
|
|
|
|
|
|
if (this.btnType === 'add' && this.currentNodeLevel === 2) { |
|
|
return this.selectOptions.filter(item => [2, 3].includes(item.value)) |
|
|
return this.selectOptions.filter(item => [2, 3].includes(item.value)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -426,22 +430,31 @@ export default { |
|
|
console.log(`当前节点层级:${node.level}`) |
|
|
console.log(`当前节点层级:${node.level}`) |
|
|
}, |
|
|
}, |
|
|
changeType(val) { |
|
|
changeType(val) { |
|
|
const currentSelected = this.form.queryTopicList |
|
|
|
|
|
let savedData = [] |
|
|
|
|
|
if (this.form.queryMenu.type === 2) { |
|
|
|
|
|
savedData = currentSelected ? [currentSelected] : [] |
|
|
|
|
|
|
|
|
const currentSelected = this.form.queryTopicList // 当前选中的栏目数据 |
|
|
|
|
|
let savedData = [] // 暂存处理后的数据(统一用数组过渡,避免类型混乱) |
|
|
|
|
|
|
|
|
|
|
|
// 1. 统一处理当前选中数据,转为数组格式(无论之前是单选/多选) |
|
|
|
|
|
if (currentSelected === null || currentSelected === undefined) { |
|
|
|
|
|
savedData = [] // 无选中数据时,初始化为空数组 |
|
|
|
|
|
} else if (Array.isArray(currentSelected)) { |
|
|
|
|
|
savedData = [...currentSelected] // 多选(数组):直接浅拷贝 |
|
|
} else { |
|
|
} else { |
|
|
savedData = currentSelected || [] |
|
|
|
|
|
|
|
|
savedData = [currentSelected] // 单选(单个对象):转为数组,便于统一处理 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 2. 根据目标类型(val),赋值为对应格式(单选:单个对象 / 多选:数组) |
|
|
if (val === 2) { |
|
|
if (val === 2) { |
|
|
|
|
|
// 目标类型:栏目显示(单选)- 取数组第一个元素,无则为null |
|
|
this.form.queryTopicList = savedData.length > 0 ? savedData[0] : null |
|
|
this.form.queryTopicList = savedData.length > 0 ? savedData[0] : null |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
// 目标类型:栏目列表/其他(多选)- 直接赋值数组,空则为空数组 |
|
|
this.form.queryTopicList = [...savedData] |
|
|
this.form.queryTopicList = [...savedData] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 3. 强制刷新下拉框组件(解决切换类型后选项不更新的问题) |
|
|
this.selectKey = Math.random() |
|
|
this.selectKey = Math.random() |
|
|
|
|
|
|
|
|
|
|
|
// 4. 按需加载对应类型的栏目数据(type=2加载特定类型,其他加载全部) |
|
|
this.$nextTick(() => { |
|
|
this.$nextTick(() => { |
|
|
this.getInitQueryTopic(val === 2 ? 1 : null) |
|
|
this.getInitQueryTopic(val === 2 ? 1 : null) |
|
|
}) |
|
|
}) |
|
@ -558,7 +571,13 @@ export default { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
toSort(data) { |
|
|
toSort(data) { |
|
|
this.$refs.sort.sortTableData = this.$refs.tree.getNode(data[0].parentId).data.children |
|
|
|
|
|
|
|
|
console.log(data) |
|
|
|
|
|
if (data[0].parentId === null) { |
|
|
|
|
|
this.$refs.sort.sortTableData = this.crud.data[0].children |
|
|
|
|
|
} else { |
|
|
|
|
|
this.$refs.sort.sortTableData = this.$refs.tree.getNode(data[0].parentId).data.children |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.$refs.sort.sortVisible = true |
|
|
this.$refs.sort.sortVisible = true |
|
|
}, |
|
|
}, |
|
|
treeNodeSort(data) { |
|
|
treeNodeSort(data) { |
|
|