提交
This commit is contained in:
1 parent
771f010a39
commit
ee4abd361e
102 files changed
+8021
-4094
No files matched your search
@@ -70,7 +70,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="upload-hint">支持图片、视频、文档等,单文件不超过 20MB。</p>
|
||||
<p class="upload-hint">支持图片、视频、文档等。</p>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
@@ -158,11 +158,6 @@
|
||||
async function handleAttachmentChange(uploadFile: { raw?: File }) {
|
||||
const file = uploadFile.raw
|
||||
if (!file) return
|
||||
const maxSizeMb = 20
|
||||
if (file.size / 1024 / 1024 > maxSizeMb) {
|
||||
ElMessage.error(`文件大小不能超过 ${maxSizeMb}MB`)
|
||||
return
|
||||
}
|
||||
const tempId = `temp_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`
|
||||
const uploading: FinanceAttachmentItem = {
|
||||
id: tempId,
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<el-input
|
||||
v-model="displayText"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
:clearable="clearable"
|
||||
style="width: 100%"
|
||||
@focus="handleFocus"
|
||||
@blur="handleBlur"
|
||||
@input="handleInput"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
formatMoneyDisplay,
|
||||
parseMoneyToNumber,
|
||||
sanitizeMoneyInput,
|
||||
} from '@/utils/money-format'
|
||||
|
||||
defineOptions({ name: 'AmountInput' })
|
||||
|
||||
interface Props {
|
||||
modelValue: number | null
|
||||
min?: number
|
||||
max?: number
|
||||
precision?: number
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
clearable?: boolean
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
min: undefined,
|
||||
max: undefined,
|
||||
precision: 2,
|
||||
placeholder: '',
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: number | null]
|
||||
change: [value: number | null]
|
||||
}>()
|
||||
|
||||
const displayText = ref('')
|
||||
const isFocused = ref(false)
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => {
|
||||
if (!isFocused.value) {
|
||||
displayText.value = formatMoneyDisplay(val, props.precision)
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function handleFocus() {
|
||||
isFocused.value = true
|
||||
displayText.value = sanitizeMoneyInput(displayText.value, props.precision)
|
||||
}
|
||||
|
||||
function handleInput(val: string) {
|
||||
displayText.value = sanitizeMoneyInput(val, props.precision)
|
||||
}
|
||||
|
||||
function handleBlur() {
|
||||
isFocused.value = false
|
||||
let num = parseMoneyToNumber(displayText.value, props.precision)
|
||||
if (num !== null) {
|
||||
if (props.min !== undefined && num < props.min) num = props.min
|
||||
if (props.max !== undefined && num > props.max) num = props.max
|
||||
}
|
||||
emit('update:modelValue', num)
|
||||
emit('change', num)
|
||||
displayText.value = formatMoneyDisplay(num, props.precision)
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user