Skip to content

Commit 7c20497

Browse files
committed
feat: implement search functionality for industry and pay type selections in FlowEditDialog and index.client.vue
1 parent dc1489f commit 7c20497

File tree

2 files changed

+75
-17
lines changed

2 files changed

+75
-17
lines changed

components/dialog/FlowEditDialog.vue

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@
3737
:items="[]"
3838
:hide-no-data="false"
3939
ref="industryTypeCombobox"
40+
@update:search="industryTypeSearchText = $event"
4041
>
4142
<template v-slot:no-data>
4243
<div class="tw-p-4 tw-max-w-md">
4344
<div class="tw-text-sm tw-text-gray-600 tw-mb-2">点击选择类型:</div>
4445
<div class="tw-flex tw-flex-wrap tw-gap-2">
4546
<v-chip
46-
v-for="item in industryTypeOptions"
47+
v-for="item in filteredIndustryTypeOptions"
4748
:key="item"
4849
variant="outlined"
4950
color="green"
@@ -76,13 +77,14 @@
7677
:items="[]"
7778
:hide-no-data="false"
7879
ref="payTypeCombobox"
80+
@update:search="payTypeSearchText = $event"
7981
>
8082
<template v-slot:no-data>
8183
<div class="tw-p-4 tw-max-w-md">
8284
<div class="tw-text-sm tw-text-gray-600 tw-mb-2">点击选择支付方式:</div>
8385
<div class="tw-flex tw-flex-wrap tw-gap-2">
8486
<v-chip
85-
v-for="item in payTypeOptions"
87+
v-for="item in filteredPayTypeOptions"
8688
:key="item"
8789
variant="outlined"
8890
color="blue"
@@ -176,7 +178,7 @@
176178
import { VDateInput } from "vuetify/labs/VDateInput";
177179
import { showFlowEditDialog } from "~/utils/flag";
178180
import { dateFormater, miniFullscreen } from "@/utils/common";
179-
import { onMounted, ref, watch } from "vue";
181+
import { onMounted, ref, watch, computed } from "vue";
180182
import { getIndustryType, getPayType } from "~/utils/apis";
181183
182184
const { title, flow, successCallback } = defineProps([
@@ -254,19 +256,27 @@ const changeFlowTypes = () => {
254256
};
255257
changeFlowTypes();
256258
257-
const searchPayType = ref("");
258-
const searchType = ref("");
259-
watch(searchPayType, (val) => {
260-
// console.log(val)
261-
if (val && !industryTypeOptions.value.includes(val)) {
262-
industryTypeOptions.value.push(val);
259+
// 添加筛选相关的响应式变量
260+
const industryTypeSearchText = ref("");
261+
const payTypeSearchText = ref("");
262+
263+
// 计算属性:筛选后的选项
264+
const filteredIndustryTypeOptions = computed(() => {
265+
if (!industryTypeSearchText.value) {
266+
return industryTypeOptions.value;
263267
}
268+
return industryTypeOptions.value.filter(item =>
269+
item.toLowerCase().includes(industryTypeSearchText.value.toLowerCase())
270+
);
264271
});
265-
watch(searchType, (val) => {
266-
// console.log(val)
267-
if (val && !payTypeOptions.value.includes(val)) {
268-
payTypeOptions.value.push(val);
272+
273+
const filteredPayTypeOptions = computed(() => {
274+
if (!payTypeSearchText.value) {
275+
return payTypeOptions.value;
269276
}
277+
return payTypeOptions.value.filter(item =>
278+
item.toLowerCase().includes(payTypeSearchText.value.toLowerCase())
279+
);
270280
});
271281
272282
// 提交表单(新增或修改)

pages/flows/index.client.vue

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,14 @@
244244
:items="[]"
245245
:hide-no-data="false"
246246
ref="filterIndustryTypeSelect"
247+
@update:search="industryTypeSearchText = $event"
247248
>
248249
<template v-slot:no-data>
249250
<div class="tw-p-4 tw-max-w-md">
250251
<div class="tw-text-sm tw-text-gray-600 tw-mb-2">点击选择类型:</div>
251252
<div class="tw-flex tw-flex-wrap tw-gap-2">
252253
<v-chip
253-
v-for="item in industryTypeOptions"
254+
v-for="item in filteredIndustryTypeOptions"
254255
:key="item"
255256
variant="outlined"
256257
color="green"
@@ -284,13 +285,14 @@
284285
:items="[]"
285286
:hide-no-data="false"
286287
ref="filterPayTypeSelect"
288+
@update:search="payTypeSearchText = $event"
287289
>
288290
<template v-slot:no-data>
289291
<div class="tw-p-4 tw-max-w-md">
290292
<div class="tw-text-sm tw-text-gray-600 tw-mb-2">点击选择支付方式:</div>
291293
<div class="tw-flex tw-flex-wrap tw-gap-2">
292294
<v-chip
293-
v-for="item in payTypeOptions"
295+
v-for="item in filteredPayTypeOptions"
294296
:key="item"
295297
variant="outlined"
296298
color="blue"
@@ -488,13 +490,14 @@
488490
:items="[]"
489491
:hide-no-data="false"
490492
ref="batchIndustryTypeSelect"
493+
@update:search="batchIndustryTypeSearchText = $event"
491494
>
492495
<template v-slot:no-data>
493496
<div class="tw-p-4 tw-max-w-md">
494497
<div class="tw-text-sm tw-text-gray-600 tw-mb-2">点击选择类型:</div>
495498
<div class="tw-flex tw-flex-wrap tw-gap-2">
496499
<v-chip
497-
v-for="item in industryTypeOptions"
500+
v-for="item in filteredBatchIndustryTypeOptions"
498501
:key="item"
499502
variant="outlined"
500503
color="green"
@@ -529,13 +532,14 @@
529532
:items="[]"
530533
:hide-no-data="false"
531534
ref="batchPayTypeSelect"
535+
@update:search="batchPayTypeSearchText = $event"
532536
>
533537
<template v-slot:no-data>
534538
<div class="tw-p-4 tw-max-w-md">
535539
<div class="tw-text-sm tw-text-gray-600 tw-mb-2">点击选择支付方式:</div>
536540
<div class="tw-flex tw-flex-wrap tw-gap-2">
537541
<v-chip
538-
v-for="item in payTypeOptions"
542+
v-for="item in filteredBatchPayTypeOptions"
539543
:key="item"
540544
variant="outlined"
541545
color="blue"
@@ -619,6 +623,7 @@ import FlowCustomImportDialog from "~/components/dialog/FlowCustomImport.vue";
619623
import { dateFormater } from "@/utils/common";
620624
621625
import { getIndustryType, getPayType } from "~/utils/apis";
626+
import { computed } from "vue";
622627
623628
const flowQuery = ref<FlowQuery>({
624629
pageNum: 1,
@@ -1463,6 +1468,49 @@ const selectBatchPayType = (item: string) => {
14631468
batchPayTypeSelect.value.blur();
14641469
}
14651470
};
1471+
1472+
// 添加筛选相关的响应式变量
1473+
const industryTypeSearchText = ref("");
1474+
const payTypeSearchText = ref("");
1475+
const batchIndustryTypeSearchText = ref("");
1476+
const batchPayTypeSearchText = ref("");
1477+
1478+
// 计算属性:筛选后的选项
1479+
const filteredIndustryTypeOptions = computed(() => {
1480+
if (!industryTypeSearchText.value) {
1481+
return industryTypeOptions.value;
1482+
}
1483+
return industryTypeOptions.value.filter(item =>
1484+
item.toLowerCase().includes(industryTypeSearchText.value.toLowerCase())
1485+
);
1486+
});
1487+
1488+
const filteredPayTypeOptions = computed(() => {
1489+
if (!payTypeSearchText.value) {
1490+
return payTypeOptions.value;
1491+
}
1492+
return payTypeOptions.value.filter(item =>
1493+
item.toLowerCase().includes(payTypeSearchText.value.toLowerCase())
1494+
);
1495+
});
1496+
1497+
const filteredBatchIndustryTypeOptions = computed(() => {
1498+
if (!batchIndustryTypeSearchText.value) {
1499+
return industryTypeOptions.value;
1500+
}
1501+
return industryTypeOptions.value.filter(item =>
1502+
item.toLowerCase().includes(batchIndustryTypeSearchText.value.toLowerCase())
1503+
);
1504+
});
1505+
1506+
const filteredBatchPayTypeOptions = computed(() => {
1507+
if (!batchPayTypeSearchText.value) {
1508+
return payTypeOptions.value;
1509+
}
1510+
return payTypeOptions.value.filter(item =>
1511+
item.toLowerCase().includes(batchPayTypeSearchText.value.toLowerCase())
1512+
);
1513+
});
14661514
</script>
14671515

14681516
<style scoped>

0 commit comments

Comments
 (0)