|
|
@@ -1,8 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
|
-import type { UniPopupDialogInstance } from '@uni-helper/uni-types'
|
|
|
-import type { UniPopupInstance } from '@uni-helper/uni-ui-types'
|
|
|
-
|
|
|
-const props = withDefaults(defineProps<{
|
|
|
+withDefaults(defineProps<{
|
|
|
modelValue: string | number
|
|
|
placeholder?: string
|
|
|
suffix?: string
|
|
|
@@ -10,47 +7,18 @@ const props = withDefaults(defineProps<{
|
|
|
placeholder: '请输入内容',
|
|
|
})
|
|
|
|
|
|
-const emits = defineEmits<{
|
|
|
+defineEmits<{
|
|
|
'update:modelValue': [string | number]
|
|
|
}>()
|
|
|
-
|
|
|
-const uniPopupRef = ref<UniPopupInstance | null>(null)
|
|
|
-const uniPopupDialogRef = ref<UniPopupDialogInstance | null>(null)
|
|
|
-
|
|
|
-function dialogInputConfirm(value: any) {
|
|
|
- if (value === '') {
|
|
|
- uni.showToast({
|
|
|
- title: props.placeholder,
|
|
|
- icon: 'none',
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- emits('update:modelValue', value as (string | number))
|
|
|
- if (uniPopupRef.value && uniPopupRef.value.close) {
|
|
|
- uniPopupRef.value.close()
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function handleClick() {
|
|
|
- if (uniPopupRef.value && uniPopupRef.value.open) {
|
|
|
- uniPopupRef.value.open()
|
|
|
- }
|
|
|
-}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <view class="w-full" @click="handleClick">
|
|
|
- {{ modelValue }}
|
|
|
+ <view class="w-full flex items-center gap-2">
|
|
|
+ <input class="text-right" :value="modelValue" :placeholder="placeholder" @input="$emit('update:modelValue', modelValue)">
|
|
|
<text v-if="suffix">
|
|
|
{{ suffix }}
|
|
|
</text>
|
|
|
</view>
|
|
|
- <uni-popup ref="uniPopupRef" type="dialog">
|
|
|
- <uni-popup-dialog
|
|
|
- ref="uniPopupDialogRef" mode="input" title="输入内容" :value="modelValue" :placeholder="placeholder"
|
|
|
- @confirm="dialogInputConfirm"
|
|
|
- />
|
|
|
- </uni-popup>
|
|
|
</template>
|
|
|
|
|
|
<style scoped>
|