Skip to content

输入选择

代码事例
vue
<template>
	<fk-space direction="vertical">
		<h3>输入组件</h3>
		<fk-space>
			<SelectInput v-model="vm.single" :local-search="true" :multiple="true" :data-source-api="skuOptions" />
			<SelectInput v-model="vm.multiple" :multiple="true" :data-source-api="options" />
		</fk-space>
		<h3>直接调用弹窗</h3>
		<fk-space>
			<fk-button type="primary" @click="handleMultipleSelect">多选</fk-button>
			<fk-button type="primary" @click="handleSingleSelect">单选</fk-button>
		</fk-space>
		<h3>自定义底部按钮</h3>
		<fk-space>
			<fk-button type="primary" @click="handleCustomButton">自定义底部按钮</fk-button>
		</fk-space>
        <h3>本地搜索</h3>
		<fk-space>
			<fk-button type="primary" @click="handleLocalSearch" >本地搜索</fk-button>
		</fk-space>
	</fk-space>
	<fk-row>
		<JsonViewer :data="vm" />
	</fk-row>
</template>

<script lang="ts" setup>
import { reactive } from 'vue';
import { cloneDeep } from 'lodash-es';
import { SelectInput, formatOptionData, http, selectInputPop } from '@erp/biz';
import data from '/biz/shop.json';

const options = () => {
	return cloneDeep(data.data);
};

const skuOptions = () => {
    return http.post('/spuGroup/index', { page: 1, page_size: 9999, is_children: 12 }).then(res => {
        return formatOptionData(res.list, {
            label: 'spu_name',
            value: 'id',
            children: 'spus'
        });
    })
}

const vm = reactive({
	single: '',
	multiple: [],
	result: '',
});

const handleMultipleSelect = () => {
	selectInputPop({
		modelValue: [93],
		dataSourceApi: options,
		multiple: true,
		popTitle: '选择商品标签',
		popTip: '每个标签最多展示50个标签值,如下面列表未显示你想找的标签,请使用搜索查找',
	}).then(res => {
		vm.result = res;
	});
};

const handleSingleSelect = () => {
	selectInputPop({
		modelValue: 93,
		dataSourceApi: options,
		multiple: false,
		popTip: '每个标签最多展示50个标签值,如下面列表未显示你想找的标签,请使用搜索查找',
	}).then(res => {
		vm.result = res;
	});
};
const handleLocalSearch = () => {
	selectInputPop({
		modelValue: 93,
		dataSourceApi: options,
		multiple: true,
        // 本地搜索
        localSearch: true,
		popTip: '每个标签最多展示50个标签值,如下面列表未显示你想找的标签,请使用搜索查找',
	}).then(res => {
		vm.result = res;
	});
};

const handleCustomButton = () => {
	selectInputPop({
		modelValue: 93,
		dataSourceApi: options,
		multiple: true,
		popButtons: [
			{
				code: 'add',
				type: 'primary',
				label: '添加标签到订单',
			},
			{
				code: 'delete',
				type: 'primary',
				label: '从订单中移除标签',
				status: 'danger',
			},
		],
		popTip: '每个标签最多展示50个标签值,如下面列表未显示你想找的标签,请使用搜索查找',
        popButtonClick(button, selected) {
            return new Promise(resolve => {
                setTimeout(() => {
                    resolve(true);
                }, 2000)
            })
        }
	}).then(res => {
		vm.result = res;
	});
};
</script>
<style lang="less" scoped>
:deep(.fk-input-tag) {
	min-width: 200px;
}
:deep(.fk-btn) {
	min-width: 100px;
}
</style>

API

<select-input> Props

参数名描述类型默认值
popup-container弹出框的挂载容器union'body'
on-close对话框关闭后(动画结束)触发TSFunctionType-
on-cancel点击取消按钮的回调函数TSFunctionType-
on-ok点击确定按钮的回调函数TSFunctionType-
biz-params业务无关的参数Record-
biz-model操作的数据模型Record-
biz-type操作的业务类型string-
biz-id业务ID 用于编辑、查询string-
title标题string-
model-value (v-model) (必填)输入框绑定值union-
options输入框选项union-
multiple是否多选booleanfalse
disabled是否禁用booleanfalse
placeholder输入框占位符string'请选择'
pop-placeholder搜索框占位符string-
pop-title弹窗标题string-
pop-width弹窗宽度union-
pop-tip弹窗提示内容string-
pop-buttons弹窗按钮Array-
echo-label-api回显labelAPITSFunctionType-
data-source-api弹窗数据源TSFunctionType-
pop-button-clickpop自定义点击事件TSFunctionType-
local-search是否本地搜索booleanfalse

<select-input-pop> Props

参数名描述类型默认值
popup-container弹出框的挂载容器union'body'
on-close对话框关闭后(动画结束)触发TSFunctionType-
on-cancel点击取消按钮的回调函数TSFunctionType-
on-ok点击确定按钮的回调函数TSFunctionType-
biz-params业务无关的参数Record-
biz-model操作的数据模型Record-
biz-type操作的业务类型string-
biz-id业务ID 用于编辑、查询string-
title标题string-
model-value (v-model) (必填)输入框绑定值union-
options输入框选项union-
multiple是否多选booleanfalse
disabled是否禁用booleanfalse
placeholder输入框占位符string-
pop-placeholder搜索框占位符string'请输入关键字,回车搜索'
pop-title弹窗标题string'选择'
pop-width弹窗宽度union800
pop-tip弹窗提示内容string-
pop-buttons弹窗按钮Array-
echo-label-api回显labelAPITSFunctionType-
data-source-api弹窗数据源TSFunctionType-
pop-button-clickpop自定义点击事件TSFunctionType-
local-search是否本地搜索booleanfalse

SelectInputPopProps

参数名描述类型默认值
modelValue (v-model)输入框绑定值(TagData | SelectInputValue)[] | TagData | SelectInputValue-
options输入框选项OptionData[] | (() => OptionData[]) | Promise<OptionData[]>-
multiple是否多选booleanfalse
disabled是否禁用booleanfalse
placeholder输入框占位符string-
popPlaceholder搜索框占位符string-
popTitle弹窗标题string-
popWidth弹窗宽度string | number-
popTip弹窗提示内容string-
popButtons弹窗按钮FormButtonType[]-
echoLabelApi回显labelAPI(values: SelectInputValue[]) => SelectInputOptionData[] | Promise<SelectInputOptionData[]>-
dataSourceApi弹窗数据源(params?: { search?: string }) => SelectInputOptionData[] | Promise<SelectInputOptionData[]>-
popButtonClickpop自定义点击事件(button, selected: SelectInputOptionData[]) => boolean | Promise<boolean>-
localSearch是否本地搜索booleanfalse

SelectInputOptionData

参数名描述类型默认值
value选项值SelectInputValue-
label选项labelstring-
checked是否选中booleanfalse
indeterminate是否半选booleanfalse
children子选项SelectInputOptionData[]-

基于 MIT 许可发布