fix: update types

This commit is contained in:
Qiuxia Fan 2022-02-15 15:31:51 +08:00
parent 895bed9ab2
commit 832521af9d
2 changed files with 10 additions and 9 deletions

View File

@ -118,9 +118,9 @@ limitations under the License. -->
v-for="(i, j) in local.months" v-for="(i, j) in local.months"
@click=" @click="
is($event) && is($event) &&
((state.showMonths = m === 'M'), ((state.showMonths = state.m === 'M'),
(state.month = j), (state.month = j),
m === 'M' && ok('m')) state.m === 'M' && ok('m'))
" "
:class="[ :class="[
status( status(
@ -142,7 +142,7 @@ limitations under the License. -->
v-for="(i, j) in years" v-for="(i, j) in years"
@click=" @click="
is($event) && is($event) &&
((state.showYears = m === 'Y'), ((state.showYears = state.m === 'Y'),
(state.year = i), (state.year = i),
state.m === 'Y' && ok('y')) state.m === 'Y' && ok('y'))
" "
@ -278,6 +278,7 @@ limitations under the License. -->
<script lang="ts" setup> <script lang="ts" setup>
import { computed, onMounted, watch, reactive } from "vue"; import { computed, onMounted, watch, reactive } from "vue";
import type { PropType } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
/*global defineProps, defineEmits */ /*global defineProps, defineEmits */
const emit = defineEmits(["input", "setDates", "ok"]); const emit = defineEmits(["input", "setDates", "ok"]);
@ -286,7 +287,7 @@ const props = defineProps({
value: { type: Date }, value: { type: Date },
left: { type: Boolean, default: false }, left: { type: Boolean, default: false },
right: { type: Boolean, default: false }, right: { type: Boolean, default: false },
dates: { default: [] }, dates: { type: Array as PropType<number[] | string[]>, default: () => [] },
disabledDate: { type: Function, default: () => false }, disabledDate: { type: Function, default: () => false },
format: { format: {
type: String, type: String,
@ -353,10 +354,10 @@ const parse = (num: number): number => {
return Math.floor(num / 1000); return Math.floor(num / 1000);
}; };
const start = computed(() => { const start = computed(() => {
return parse(props.dates[0]); return parse(Number(props.dates[0]));
}); });
const end = computed(() => { const end = computed(() => {
return parse(props.dates[1]); return parse(Number(props.dates[1]));
}); });
const ys = computed(() => { const ys = computed(() => {
return Math.floor(state.year / 10) * 10; return Math.floor(state.year / 10) * 10;
@ -550,7 +551,7 @@ const ok = (info: any) => {
emit("setDates", _time); emit("setDates", _time);
} }
emit("input", _time); emit("input", _time);
ok(info === "h"); emit("ok", info === "h");
}; };
onMounted(() => { onMounted(() => {
const is = (c: string) => props.format.indexOf(c) !== -1; const is = (c: string) => props.format.indexOf(c) !== -1;

View File

@ -149,7 +149,7 @@ import DateCalendar from "./DateCalendar.vue";
const datepicker = ref(null); const datepicker = ref(null);
const { t } = useI18n(); const { t } = useI18n();
const show = ref<boolean>(false); const show = ref<boolean>(false);
const dates = ref<Date[]>([]); const dates = ref<Date | string[] | any>([]);
const props = defineProps({ const props = defineProps({
position: { type: String, default: "bottom" }, position: { type: String, default: "bottom" },
name: [String], name: [String],
@ -244,7 +244,7 @@ const range = computed(() => {
const text = computed(() => { const text = computed(() => {
const val = props.value; const val = props.value;
const txt = dates.value const txt = dates.value
.map((date) => tf(date)) .map((date: Date) => tf(date))
.join(` ${props.rangeSeparator} `); .join(` ${props.rangeSeparator} `);
if (Array.isArray(val)) { if (Array.isArray(val)) {
return val.length > 1 ? txt : ""; return val.length > 1 ? txt : "";