From 53395007bb28117a1b13eb2f4926178be1586e88 Mon Sep 17 00:00:00 2001 From: Tory Date: Tue, 17 Nov 2026 20:45:38 +0800 Subject: [PATCH] =?UTF-8?q?Issue#6=C2=B7F3:=20ScSelect=20=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E4=B8=8B=E6=8B=89=E5=B0=81=E8=A3=85(=E5=A5=91?= =?UTF-8?q?=E7=BA=A6=20auto>5=20=E6=90=9C=E7=B4=A2=E9=98=88=E5=80=BC)?= =?UTF-8?q?=E2=80=94=E2=80=94options=20=E6=95=B0=E7=BB=84=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E9=80=89=E9=A1=B9>5=20=E8=87=AA=E5=8A=A8=20filterable?= =?UTF-8?q?(sub2api=20Select.vue=20L210=20=E5=90=8C=E6=BA=90=E8=AF=AD?= =?UTF-8?q?=E4=B9=89=20searchable=3Dauto);searchable=3Dfalse=20=E5=8F=AF?= =?UTF-8?q?=E5=85=B3/filterable=20=E6=98=BE=E5=BC=8F=E8=A6=86=E7=9B=96/slo?= =?UTF-8?q?t=20=E6=A8=A1=E5=BC=8F=E9=80=8F=E4=BC=A0;=E7=A4=BA=E8=8C=83?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=20downlink=20=E6=9D=A5=E6=BA=90(4=20?= =?UTF-8?q?=E9=A1=B9,=E6=97=A0=E6=90=9C=E7=B4=A2)=E4=B8=8E=E7=8A=B6?= =?UTF-8?q?=E6=80=81(6=20=E9=A1=B9,=E5=87=BA=E6=90=9C=E7=B4=A2)=E6=AD=A3?= =?UTF-8?q?=E5=8F=8D=E4=BE=8B;=E6=96=B0=E4=BB=A3=E7=A0=81=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E4=B8=80=E5=BE=8B=E7=94=A8=E6=9C=AC=E4=BB=B6,web-next?= =?UTF-8?q?=20=E5=B0=86=E7=9B=B4=E8=AF=91=20sub2api=20=E4=B8=A5=E6=A0=BC?= =?UTF-8?q?=E5=BD=A2=E6=80=81(=E9=9D=A2=E6=9D=BF=E9=A6=96=E9=A1=B9=3D?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=BE=93=E5=85=A5);sc-select.spec=204=20?= =?UTF-8?q?=E7=94=A8=E4=BE=8B(auto=20=E9=98=88=E5=80=BC/=E5=85=B3=E9=97=AD?= =?UTF-8?q?/=E8=A6=86=E7=9B=96/slot=20=E6=B8=B2=E6=9F=93);vitest=20186=20?= =?UTF-8?q?=E5=85=A8=E7=BB=BF+build=20=E2=9C=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/ScSelect.vue | 56 +++++++++++++++++++++ web/src/views/sms/downlink-detail/index.vue | 9 ++-- web/tests/sc-select.spec.ts | 27 ++++++++++ 3 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 web/src/components/ScSelect.vue create mode 100644 web/tests/sc-select.spec.ts diff --git a/web/src/components/ScSelect.vue b/web/src/components/ScSelect.vue new file mode 100644 index 00000000..293c17b6 --- /dev/null +++ b/web/src/components/ScSelect.vue @@ -0,0 +1,56 @@ + + + + diff --git a/web/src/views/sms/downlink-detail/index.vue b/web/src/views/sms/downlink-detail/index.vue index 268739d4..468744f1 100644 --- a/web/src/views/sms/downlink-detail/index.vue +++ b/web/src/views/sms/downlink-detail/index.vue @@ -28,9 +28,7 @@ - - - + @@ -38,9 +36,7 @@ - - - + @@ -126,6 +122,7 @@ import { onMounted, reactive, ref } from 'vue' import { useRoute, useRouter } from 'vue-router' import { ArrowDown } from '@element-plus/icons-vue' import { ElMessage } from 'element-plus' +import ScSelect from '@/components/ScSelect.vue' import { accountApi } from '@/api/account' import { channelApi } from '@/api/channel' import { diff --git a/web/tests/sc-select.spec.ts b/web/tests/sc-select.spec.ts new file mode 100644 index 00000000..e55156b6 --- /dev/null +++ b/web/tests/sc-select.spec.ts @@ -0,0 +1,27 @@ +// Issue#6·F3:ScSelect auto>5 搜索阈值(sub2api Select searchable='auto' 契约) +import { describe, expect, it } from 'vitest' +import { mount } from '@vue/test-utils' +import ScSelect from '@/components/ScSelect.vue' + +const opts = (n: number) => Array.from({ length: n }, (_, i) => ({ value: i, label: `选项${i}` })) + +describe('ScSelect auto 阈值', () => { + it('options>5 → filterable 生效(trigger 内可输入)', () => { + const w = mount(ScSelect, { props: { modelValue: '', options: opts(6) }, global: { stubs: { 'el-select': { template: '
', props: ['filterable','modelValue'] } } } }) + expect(w.find('[data-testid="f"]').exists()).toBe(true) + }) + it('options≤5 → 无 filterable', () => { + const w = mount(ScSelect, { props: { modelValue: '', options: opts(5) }, global: { stubs: { 'el-select': { template: '
', props: ['filterable','modelValue'] } } } }) + expect(w.find('[data-testid="f"]').exists()).toBe(false) + }) + it('searchable=false 关闭 auto;filterable 显式覆盖', () => { + const off = mount(ScSelect, { props: { modelValue: '', options: opts(9), searchable: false }, global: { stubs: { 'el-select': { template: '
', props: ['filterable'] } } } }) + expect(off.find('[data-testid="f"]').exists()).toBe(false) + const on = mount(ScSelect, { props: { modelValue: '', options: opts(2), filterable: true }, global: { stubs: { 'el-select': { template: '
', props: ['filterable'] } } } }) + expect(on.find('[data-testid="f"]').exists()).toBe(true) + }) + it('options 渲染到默认 slot(el-option 数=传入数)', () => { + const w = mount(ScSelect, { props: { modelValue: '', options: opts(4) }, global: { stubs: { 'el-select': { template: '
', props: ['modelValue'] }, 'el-option': { template: '
' } } } }) + expect(w.findAll('.opt').length).toBe(4) + }) +})