fix: 修改车辆日期选择框无法限制的问题

This commit is contained in:
kun 2024-06-13 11:15:22 +08:00
parent 98b39610d4
commit 0dcad1dd74
3 changed files with 36 additions and 16 deletions

View File

@ -1,7 +1,7 @@
//基础请求地址,需要根据自己的需求切换 //基础请求地址,需要根据自己的需求切换
// 开发环境 // 开发环境
export const BASE_URL = "http://42.180.188.17:9809" // 鞍钢正式环境 // export const BASE_URL = "http://42.180.188.17:9809" // 鞍钢正式环境
// export const BASE_URL = "http://42.180.188.17:19098" // 鞍钢线上测试环境 export const BASE_URL = "http://42.180.188.17:19098" // 鞍钢线上测试环境
// export const BASE_URL = "http://47.93.215.234:9809" // 鞍钢正式环境(弃用) // export const BASE_URL = "http://47.93.215.234:9809" // 鞍钢正式环境(弃用)
// export const BASE_URL = "http://47.93.215.234:19098" // 鞍钢线上测试环境(弃用) // export const BASE_URL = "http://47.93.215.234:19098" // 鞍钢线上测试环境(弃用)
// export const BASE_URL = "http://47.93.215.234:19097" // export const BASE_URL = "http://47.93.215.234:19097"

View File

@ -1,10 +1,14 @@
<template> <template>
<view class="w-form-timePicker" hover-class="w-click-hover" v-if="!readonly"> <view class="w-form-timePicker" hover-class="w-click-hover" v-if="!readonly">
<template v-if="format.length > 9"> <template v-if="format.length > 9">
<uni-datetime-picker v-if="format === 'yyyy-mm-dd hh:mm'" class="w-form-input" <!-- <uni-datetime-picker v-if="format === 'yyyy-mm-dd hh:mm'" class="w-form-input" :border="false"
:border="false" type="datetime" :clear-icon="false" v-model="_value" /> type="datetime" :clear-icon="false" v-model="_value" ref="uniDateTime" @change="changeTime"/>
<uni-datetime-picker v-else class="w-form-input" :border="false" type="date" :clear-icon="false" <uni-datetime-picker v-else class="w-form-input" :border="false" type="date" ref="uniDateTime"
v-model="_value" /> :clear-icon="false" v-model="_value" @change="changeTime"/> -->
<uni-datetime-picker v-if="format === 'yyyy-mm-dd hh:mm'" class="w-form-input" :border="false"
type="datetime" :clear-icon="false" v-model="_value" ref="uniDateTime" @change="changeTime"/>
<uni-datetime-picker v-else class="w-form-input" :border="false" type="date" ref="uniDateTime"
:clear-icon="false" v-model="_value" @change="changeTime"/>
<uni-icons type="right" :size="20" color="#999999"></uni-icons> <uni-icons type="right" :size="20" color="#999999"></uni-icons>
</template> </template>
<template v-else-if="props.formProps.format === 'yyyy-mm'"> <template v-else-if="props.formProps.format === 'yyyy-mm'">
@ -24,9 +28,13 @@
</template> </template>
<script setup> <script setup>
import { computed } from 'vue' import {
computed,
watch,
ref
} from 'vue'
import ClickInput from '@/components/ClickInput.vue' import ClickInput from '@/components/ClickInput.vue'
const uniDateTime = ref();
const props = defineProps({ const props = defineProps({
formProps: { formProps: {
type: Object, type: Object,
@ -37,7 +45,6 @@
modelValue: String, modelValue: String,
readonly: Boolean readonly: Boolean
}) })
const _value = computed({ const _value = computed({
get() { get() {
return props.modelValue return props.modelValue
@ -49,7 +56,6 @@
emits('update:modelValue', val) emits('update:modelValue', val)
} }
}) })
const format = computed(() => { const format = computed(() => {
return (props.formProps.format || '').toLocaleLowerCase() return (props.formProps.format || '').toLocaleLowerCase()
}) })
@ -89,9 +95,18 @@
return [range.value[0].indexOf(props.modelValue)] return [range.value[0].indexOf(props.modelValue)]
} }
}) })
const emits = defineEmits(['update:modelValue']) const emits = defineEmits(['update:modelValue'])
const timeVal = ref();
const changeTime = (e) => {
// watch
setTimeout(function(){
console.log(timeVal.value,222333)
if(!props.modelValue){
// uniDateTime.value.clear();
uniDateTime.value.displayValue = ""
}
},100)
}
function timeChange(e) { function timeChange(e) {
const indexs = e.detail.value const indexs = e.detail.value
if (Array.isArray(indexs)) { if (Array.isArray(indexs)) {
@ -100,6 +115,11 @@
_value.value = `${range.value[0][indexs]}` _value.value = `${range.value[0][indexs]}`
} }
} }
watch(() => props.modelValue, (newVal) => {
timeVal.value = newVal;
}, {
deep: true
})
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

View File

@ -1,8 +1,8 @@
{ {
"hash": "0f0fbf16", "hash": "6ab18a53",
"configHash": "5bd87843", "configHash": "87e744e2",
"lockfileHash": "33a33614", "lockfileHash": "2ddd0eeb",
"browserHash": "a13cd6b4", "browserHash": "9b038b87",
"optimized": {}, "optimized": {},
"chunks": {} "chunks": {}
} }