refactor: 优化壁纸分类组件参数处理
This commit is contained in:
@ -83,9 +83,9 @@
|
||||
return props.type === 1 ? '图纸' : props.type === 3 ? '模型' : '文本'
|
||||
})
|
||||
|
||||
const handleParentId = (type?: string) => {
|
||||
const handleParentId = () => {
|
||||
if (level?.value?.length > 1) {
|
||||
if (type === 'init' && level.value.find((c: any) => c.isChildren)) {
|
||||
if (level.value.find((c: any) => c.isChildren)) {
|
||||
return level.value[level.value.length - 2].id || '' // 获取最后一个元素的 id 或 defaul
|
||||
}
|
||||
return level.value[level.value.length - 1].id || '' // 获取最后一个元素的 id 或 defaul
|
||||
@ -130,11 +130,9 @@
|
||||
console.log('breadList', breadList);
|
||||
|
||||
|
||||
/** 是否是初始化 */
|
||||
const queryType = ref('init')
|
||||
/**获取分类下拉框 */
|
||||
const { data: projectTypeList, refresh } = useAsyncData(`projectType-draw-${props.type}-${Date.now()}`, async () => {
|
||||
const res = await parent({ type: 1, parentId: handleParentId(queryType.value) })
|
||||
const res = await parent({ type: 1, parentId: handleParentId() })
|
||||
const all = [{ id: '-1', name: '全部' }]
|
||||
return [...all, ...res.data]
|
||||
})
|
||||
@ -159,7 +157,6 @@
|
||||
} else {
|
||||
level.value.push({ id: row.id, name: row.name })
|
||||
// getParent()
|
||||
queryType.value = ''
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
@ -169,7 +166,6 @@
|
||||
query.value.title = ''
|
||||
query.value.projectType = row.id
|
||||
// getParent()
|
||||
queryType.value = ''
|
||||
refresh()
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user