From 07d73df3d817d01ce47f6c7b7a8d8514cd389295 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期四, 13 三月 2025 10:19:44 +0800 Subject: [PATCH] release: @life-payment/core v0.0.3 --- packages/components/src/components/Input/ChooseInputWithAreaPicker.vue | 62 +++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) diff --git a/packages/components/src/components/Input/ChooseInputWithAreaPicker.vue b/packages/components/src/components/Input/ChooseInputWithAreaPicker.vue new file mode 100644 index 0000000..19f5866 --- /dev/null +++ b/packages/components/src/components/Input/ChooseInputWithAreaPicker.vue @@ -0,0 +1,62 @@ +<template> + <ChooseInput :modelValue="inputValue" @click="handleOpen()" v-bind="$attrs"></ChooseInput> + <NutPopup v-model:visible="visible" position="bottom"> + <NutPicker + :modelValue="modelValue" + :columns="columns" + :fieldNames="fieldNames" + :title="title" + @cancel="visible = false" + @confirm="handleConfirm" + > + </NutPicker> + </NutPopup> +</template> + +<script setup lang="ts"> +// import { useAllAreaList } from '../../hooks/area'; +import ChooseInput from './ChooseInput.vue'; +import { Popup as NutPopup, Picker as NutPicker } from '@nutui/nutui-taro'; +import { computed, ref } from 'vue'; + +defineOptions({ + name: 'ChooseInputWithAreaPicker', +}); + +// const { findAreaNameFromCode } = useAllAreaList(); + +type Props = { + fieldNames?: object; + columns: API.AreaTreeNode[]; + modelValue: Array<string | number>; + title?: string; +}; + +const props = withDefaults(defineProps<Props>(), { + title: '閫夋嫨鍦板潃', + fieldNames: () => ({ + text: 'areaName', + value: 'areaName', + children: 'children', + }), +}); +const inputValue = computed(() => props.modelValue.join(',')); + +const emit = defineEmits<{ + (e: 'update:modelValue', val: Array<string | number>): void; +}>(); + +const visible = ref(false); + +function handleOpen() { + visible.value = true; +} + +function handleConfirm({ selectedValue, selectedOptions }) { + emit( + 'update:modelValue', + selectedOptions.map((x) => x.areaName) + ); + visible.value = false; +} +</script> -- Gitblit v1.9.1