Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: resolve block search exceptions" #1015

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
<div class="block-add-content">
<div class="block-add-content-title">区块列表</div>
<block-group-filters :filters="state.filters" @search="searchBlocks"></block-group-filters>
<block-group-transfer :blockList="filteredBlocks">
<block-group-transfer v-model:blockList="state.blockList">
<template #search>
<tiny-search class="transfer-order-search" v-model="state.searchValue" placeholder="请输入关键词">
<tiny-search
class="transfer-order-search"
v-model="state.searchValue"
placeholder="请输入关键词"
@update:modelValue="searchBlocks"
>
<template #prefix>
<tiny-icon-search />
</template>
Expand All @@ -24,7 +29,7 @@
</plugin-setting>
</template>
<script>
import { nextTick, reactive, watch, provide, inject, ref, computed } from 'vue'
import { nextTick, 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 All @@ -37,7 +42,6 @@ import {
getMetaApi,
META_SERVICE
} from '@opentiny/tiny-engine-meta-register'
import { utils } from '@opentiny/tiny-engine-utils'
import BlockGroupTransfer from './BlockGroupTransfer.vue'
import BlockGroupFilters from './BlockGroupFilters.vue'

Expand Down Expand Up @@ -81,8 +85,6 @@ export default {
const blockUsers = ref([])
provide('blockUsers', blockUsers)

const { escapeRegExp } = utils

const state = reactive({
searchValue: '',
blockList: [],
Expand All @@ -107,19 +109,6 @@ export default {
]
})

const filteredBlocks = computed(() => {
if (!state.searchValue) {
return state.blockList
}

const searchValue = state.searchValue.trim()
const pattern = new RegExp(escapeRegExp(searchValue), 'i')

return state.blockList.filter((block) => {
return pattern.test(block?.name_cn) || pattern.test(block?.label) || pattern.test(block?.description)
})
})

const addBlocks = () => {
const groupId = selectedGroup.value.groupId
fetchGroupBlocksById({ groupId })
Expand Down Expand Up @@ -271,7 +260,6 @@ export default {
selectedGroup,
state,
panel,
filteredBlocks,
closeGroupPanel,
addBlocks,
searchBlocks
Expand Down
Loading