Commit d0694349 by 李伟康

fix(dailyNewspaper): 修复表单验证和日期选择器问题

- 将默认最大日期从 2020-01-01 更新为 2099-12-31
- 修复输入框最大长度限制为 10 位数字
- 调整数字输入类型配置并添加失焦事件处理
- 在 OCR 识别过程中添加加载提示
- 修复日历组件月份切换按钮显示逻辑错误
- 防止超出日期范围时月份切换按钮被点击
1 parent bccdb1fa
...@@ -107,7 +107,7 @@ export default { ...@@ -107,7 +107,7 @@ export default {
item = this.currentItem item = this.currentItem
if (childrenRules && item.key) { if (childrenRules && item.key) {
let rules = childrenRules[item.key] let rules = childrenRules[item.key]
return rules?.maxDate ? dayjs(eval(rules.maxDate)).format('YYYY-MM-DD') : '2020-01-01' return rules?.maxDate ? dayjs(eval(rules.maxDate)).format('YYYY-MM-DD') : '2099-12-31'
} }
}, },
}, },
......
...@@ -97,10 +97,12 @@ ...@@ -97,10 +97,12 @@
:placeholder="item.placeholder || '请输入'" :placeholder="item.placeholder || '请输入'"
v-model="item.value" v-model="item.value"
class="input" class="input"
:maxlength="rules.maxLength || 11" :maxlength="rules.maxLength || 10"
placeholder-class="placeholderStyle" placeholder-class="placeholderStyle"
:type="rules.integer ? 'numeric' : 'decimal'" :type="rules.integer ? 'number' : 'digit'"
@input="numberInput" @input="numberInput"
@blur="numberBlur"
:key="numberViewKey"
/> />
</template> </template>
<template v-else-if="item.type == 'carBrandSelect'"> <template v-else-if="item.type == 'carBrandSelect'">
...@@ -169,6 +171,7 @@ export default { ...@@ -169,6 +171,7 @@ export default {
data () { data () {
return { return {
item: null, item: null,
numberViewKey: Date.now()
} }
}, },
mounted () { mounted () {
...@@ -208,14 +211,20 @@ export default { ...@@ -208,14 +211,20 @@ export default {
// 将图片转换为base64 // 将图片转换为base64
const tempFilePath = res.tempFilePaths[0] const tempFilePath = res.tempFilePaths[0]
try { try {
uni.showLoading({
title: '正在识别...',
mask: true
})
const base64 = await that.getBase64FromImagePath(tempFilePath) const base64 = await that.getBase64FromImagePath(tempFilePath)
that.orcRecogintion(base64) that.orcRecogintion(base64)
} catch (error) { } catch (error) {
uni.hideLoading()
console.error('转换base64失败:', error) console.error('转换base64失败:', error)
uni.showToast({ uni.showToast({
title: '图片转换失败', title: '图片转换失败',
icon: 'none' icon: 'none'
}) })
} }
} }
}) })
...@@ -261,8 +270,9 @@ export default { ...@@ -261,8 +270,9 @@ export default {
* type 3 : standNo 车架号 * type 3 : standNo 车架号
*/ */
const res = await uni.$api.commonApi.orcRecognition({ type: 3, imgBase64 }) const res = await uni.$api.commonApi.orcRecognition({ type: 3, imgBase64 })
uni.hideLoading()
console.log('进行 orc 识别', res) console.log('进行 orc 识别', res)
if(res.vin) this.$emit('onScanSuccess', res.vin) if (res.vin) this.$emit('onScanSuccess', res.vin)
else uni.showToast({ title: '识别失败', icon: 'none' }) else uni.showToast({ title: '识别失败', icon: 'none' })
}, },
numberInput (e) { numberInput (e) {
...@@ -331,12 +341,12 @@ export default { ...@@ -331,12 +341,12 @@ export default {
} }
this.$set(this.item, 'value', filtered) this.$set(this.item, 'value', filtered)
this.$emit('onInput', filtered) this.$emit('onInput', filtered)
this.$nextTick(() => {
this.$forceUpdate()
})
} }
}, },
numberBlur(){
this.numberViewKey = Date.now()
}
} }
} }
</script> </script>
......
...@@ -302,8 +302,8 @@ export default { ...@@ -302,8 +302,8 @@ export default {
}, },
showPreBtn () { showPreBtn () {
let { cale, startDate, nowDate } = this, let { cale, startDate, nowDate } = this,
minDate = cale.getDate(startDate, -1, 'month') minDate = cale.getDate(startDate, +1, 'month')
return !startDate ? true : cale.dateCompare(`${nowDate.year}/${nowDate.month}`, `${minDate.year}/${minDate.month}`) return !startDate ? true : cale.dateCompare(`${minDate.year}/${minDate.month}`,`${nowDate.year}/${nowDate.month}`)
} }
}, },
watch: { watch: {
...@@ -514,6 +514,7 @@ export default { ...@@ -514,6 +514,7 @@ export default {
* 上个月 * 上个月
*/ */
pre () { pre () {
if(!this.showPreBtn) return
const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate
this.setDate(preDate) this.setDate(preDate)
this.monthSwitch() this.monthSwitch()
...@@ -523,6 +524,7 @@ export default { ...@@ -523,6 +524,7 @@ export default {
* 下个月 * 下个月
*/ */
next () { next () {
if(!this.showNextBtn) return
let { showNextBtn } = this let { showNextBtn } = this
if (!showNextBtn) return if (!showNextBtn) return
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!