Skip to content

Commit

Permalink
remove clearFilters in BlockGroupFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
gene9831 committed Jan 10, 2025
1 parent 3bb553e commit faab411
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,10 @@ export default {
emit('search', state.filterValues)
}
const clearFilters = () => {
state.filterValues = initFilterValues()
}
return {
state,
selectOptions,
handleValueChange,
clearFilters
handleValueChange
}
}
}
Expand Down
62 changes: 33 additions & 29 deletions packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<div class="block-add-content">
<div class="block-add-content-title">区块列表</div>
<block-group-filters
ref="groupFiltersRef"
v-if="panel.show"
:key="selectedGroupId"
:filters="state.filters"
@search="searchBlocks"
></block-group-filters>
Expand All @@ -33,7 +34,7 @@
</plugin-setting>
</template>
<script>
import { nextTick, reactive, watch, provide, inject, ref } from 'vue'
import { reactive, watch, provide, inject, ref } from 'vue'
import { Search } from '@opentiny/vue'
import { iconSearch } from '@opentiny/vue-icon'
import { PluginSetting } from '@opentiny/tiny-engine-common'
Expand Down Expand Up @@ -114,16 +115,24 @@ export default {
filterValues: {}
})
const groupFiltersRef = ref(null)
const selectedGroupId = ref(selectedGroup.value.groupId)
watch(
() => selectedGroup.value.groupId,
(groupId) => {
if (groupId && !isDefaultGroupId(groupId)) {
selectedGroupId.value = groupId
}
}
)
const clearSearchParams = () => {
state.searchValue = ''
state.filterValues = {}
groupFiltersRef.value?.clearFilters()
}
const addBlocks = () => {
const groupId = selectedGroup.value.groupId
const groupId = selectedGroupId.value
fetchGroupBlocksById({ groupId })
.then((data) => {
const resData =
Expand Down Expand Up @@ -195,25 +204,24 @@ export default {
const searchBlocks = (filters) => {
state.filterValues = filters
nextTick(() => {
const params = {
groupId: selectedGroup.value.groupId,
label_contains: state.searchValue.trim(),
tag: filters?.tag,
publicType: filters?.publicType,
author: filters?.author
}
fetchAvailableBlocks(params)
.then((data) => {
state.blockList = selectedBlockFilter(data)
})
.catch((error) => {
message({
message: `区块搜索失败: ${error.message || error}`,
status: 'error'
})
const params = {
groupId: selectedGroupId.value,
label_contains: state.searchValue.trim(),
tag: filters?.tag,
publicType: filters?.publicType,
author: filters?.author
}
fetchAvailableBlocks(params)
.then((data) => {
state.blockList = selectedBlockFilter(data)
})
.catch((error) => {
message({
message: `区块搜索失败: ${error.message || error}`,
status: 'error'
})
})
})
}
const fetchBlocks = (groupId) => {
Expand Down Expand Up @@ -255,15 +263,11 @@ export default {
})
}
watch([() => panel.show, () => selectedGroup.value.groupId], ([show, groupId]) => {
watch([() => panel.show, selectedGroupId], ([show, groupId]) => {
if (!show) {
return
}
if (!groupId || isDefaultGroupId(groupId)) {
return
}
panelState.isBlockGroupPanel = true
clearSearchParams()
fetchBlocks(groupId)
Expand All @@ -272,8 +276,8 @@ export default {
return {
selectedGroup,
selectedGroupId,
state,
groupFiltersRef,
panel,
closeGroupPanel,
addBlocks,
Expand Down

0 comments on commit faab411

Please sign in to comment.