Skip to content

Commit

Permalink
Merge remote-tracking branch 'open/refactor/develop' into lx-ui-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanlid committed Jan 9, 2025
2 parents ea84775 + fee84e6 commit aa049bb
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@
<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 v-model:blockList="state.blockList">
<block-group-transfer :blockList="filteredBlocks">
<template #search>
<tiny-search
class="transfer-order-search"
v-model="state.searchValue"
placeholder="请输入关键词"
@update:modelValue="searchBlocks"
>
<tiny-search class="transfer-order-search" v-model="state.searchValue" placeholder="请输入关键词">
<template #prefix>
<tiny-icon-search />
</template>
Expand All @@ -29,7 +24,7 @@
</plugin-setting>
</template>
<script>
import { nextTick, reactive, watch, provide, inject, ref } from 'vue'
import { nextTick, reactive, watch, provide, inject, ref, computed } from 'vue'
import { Search } from '@opentiny/vue'
import { iconSearch } from '@opentiny/vue-icon'
import { PluginSetting } from '@opentiny/tiny-engine-common'
Expand All @@ -42,6 +37,7 @@ 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 @@ -85,6 +81,8 @@ export default {
const blockUsers = ref([])
provide('blockUsers', blockUsers)
const { escapeRegExp } = utils
const state = reactive({
searchValue: '',
blockList: [],
Expand All @@ -109,6 +107,19 @@ 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 @@ -260,6 +271,7 @@ export default {
selectedGroup,
state,
panel,
filteredBlocks,
closeGroupPanel,
addBlocks,
searchBlocks
Expand Down

0 comments on commit aa049bb

Please sign in to comment.