Browse Source

Merge branch 'v4' of https://github.com/jdf2e/nutui into v4

yangxiaolu3 3 years ago
parent
commit
c801bd2b80

+ 5 - 4
src/packages/__VUE/calendar/demo.vue

@@ -267,6 +267,7 @@ interface TestCalendarState extends TestCalendarStateVisible {
   date8: string;
 }
 interface TestCalendarStateVisible {
+  isVisible: boolean;
   isVisible1: boolean;
   isVisible2: boolean;
   isVisible3: boolean;
@@ -350,11 +351,11 @@ export default createDemo({
     const setChooseValue8 = (param: string) => {
       state.date8 = param[3];
     };
-    const clickBtn = (param: string) => {
+    const clickBtn = () => {
       let date = [Utils.date2Str(new Date()), Utils.getDay(6)];
       state.date5 = date;
     };
-    const clickBtn1 = (param: string) => {
+    const clickBtn1 = () => {
       let date = new Date();
       let year = date.getFullYear();
       let month: any = date.getMonth() + 1;
@@ -369,10 +370,10 @@ export default createDemo({
       }
     };
     const renderDate = (date: { date: Day }) => {
-      return date.date.day <= 9 ? '0' + date.date.day : date.date.day;
+      return +date.date.day <= 9 ? '0' + date.date.day : date.date.day;
     };
     const renderBottomDate = (date: { date: Day }) => {
-      return date.date ? (date.date.day <= 10 ? '' : date.date.day <= 20 ? translate('mid') : '') : '';
+      return date.date ? (+date.date.day <= 10 ? '' : +date.date.day <= 20 ? translate('mid') : '') : '';
     };
     return {
       ...toRefs(state),

+ 12 - 7
src/packages/__VUE/calendaritem/index.taro.vue

@@ -77,7 +77,7 @@ import Taro from '@tarojs/taro';
 import Utils from '@/packages/utils/date';
 import { useExpose } from '@/packages/utils/useExpose/index';
 import requestAniFrame from '@/packages/utils/raf';
-import { MonthInfo, Day, DateInfo } from './type';
+import { MonthInfo, Day } from './type';
 import NutScrollView from '../scrollView/index.taro.vue';
 import { isArray } from '@/packages/utils/util';
 const TARO_ENV = Taro.getEnv();
@@ -273,7 +273,7 @@ export default create({
     };
 
     // 选中数据
-    const chooseDay = (day: Day, month: MonthInfo, isFirst: boolean) => {
+    const chooseDay = (day: Day, month: MonthInfo, isFirst = false) => {
       if (getClass(day, month) != `${state.dayPrefix}--disabled`) {
         const { type } = props;
         let days = [...month.curData];
@@ -366,7 +366,7 @@ export default create({
       }
       return Array.from(Array(days), (v, k) => {
         return {
-          day: k + 1,
+          day: String(k + 1),
           type: type,
           year,
           month
@@ -377,7 +377,7 @@ export default create({
     const getPreDaysStatus = (
       days: number,
       type: string,
-      dateInfo: { year: number; month: number },
+      dateInfo: { year: string; month: string },
       preCurrMonthDays: number
     ) => {
       // 新增:自定义周起始日}, preCurrMonthDays: number) => {
@@ -390,7 +390,7 @@ export default create({
       }
       let months = Array.from(Array(preCurrMonthDays), (v, k) => {
         return {
-          day: k + 1,
+          day: String(k + 1),
           type: type,
           year,
           month
@@ -421,7 +421,12 @@ export default create({
         curData: curData,
         title: translate('monthTitle', title.year, title.month),
         monthData: [
-          ...(getPreDaysStatus(preMonthDays, 'prev', { month: preMonth, year: preYear }, preCurrMonthDays) as Day[]),
+          ...(getPreDaysStatus(
+            preMonthDays,
+            'prev',
+            { month: String(preMonth), year: String(preYear) },
+            preCurrMonthDays
+          ) as Day[]),
           ...(getDaysStatus(currMonthDays, 'curr', title) as Day[])
         ],
         cssHeight: 0,
@@ -714,7 +719,7 @@ export default create({
       }
     };
     // 是否有是当前日期
-    const isCurrDay = (dateInfo: DateInfo) => {
+    const isCurrDay = (dateInfo: Day) => {
       const date = `${dateInfo.year}-${dateInfo.month}-${
         Number(dateInfo.day) < 10 ? '0' + dateInfo.day : dateInfo.day
       }`;

+ 5 - 5
src/packages/__VUE/calendaritem/index.vue

@@ -72,7 +72,7 @@ import { createComponent } from '@/packages/utils/create';
 const { create, translate } = createComponent('calendar-item');
 import Utils from '@/packages/utils/date';
 import requestAniFrame from '@/packages/utils/raf';
-import { MonthInfo, Day, DateInfo } from './type';
+import { MonthInfo, Day } from './type';
 import { useExpose } from '@/packages/utils/useExpose/index';
 
 type StringArr = string[];
@@ -270,7 +270,7 @@ export default create({
     };
 
     // 选中数据
-    const chooseDay = (day: Day, month: MonthInfo, isFirst: boolean) => {
+    const chooseDay = (day: Day, month: MonthInfo, isFirst = false) => {
       if (getClass(day, month) != `${state.dayPrefix}--disabled`) {
         const { type } = props;
         let days = [...month.curData];
@@ -362,7 +362,7 @@ export default create({
       }
       return Array.from(Array(days), (v, k) => {
         return {
-          day: k + 1,
+          day: String(k + 1),
           type: type,
           year,
           month
@@ -380,7 +380,7 @@ export default create({
       }
       let months = Array.from(Array(preCurrMonthDays), (v, k) => {
         return {
-          day: k + 1,
+          day: String(k + 1),
           type: type,
           year,
           month
@@ -668,7 +668,7 @@ export default create({
       }
     };
     // 是否有 当前日期
-    const isCurrDay = (dateInfo: DateInfo) => {
+    const isCurrDay = (dateInfo: Day) => {
       const date = `${dateInfo.year}-${dateInfo.month}-${
         Number(dateInfo.day) < 10 ? '0' + dateInfo.day : dateInfo.day
       }`;

+ 3 - 1
src/packages/__VUE/calendaritem/type.ts

@@ -39,8 +39,10 @@ export interface CalendarTaroState extends CalendarState {
   containerHeight: string;
 }
 export interface Day {
-  day: string | number;
+  day: string;
   type: string;
+  year?: string;
+  month?: string;
 }
 
 export interface MonthInfo {

+ 1 - 1
src/packages/__VUE/range/demo.vue

@@ -85,7 +85,7 @@
 <script lang="ts">
 import { toRefs, reactive } from 'vue';
 import { createComponent } from '@/packages/utils/create';
-import Toast from '@/packages/nutui.vue';
+import { Toast } from '@/packages/nutui.vue';
 const { createDemo, translate } = createComponent('range');
 import { useTranslate } from '@/sites/assets/util/useTranslate';
 

+ 5 - 3
src/packages/__VUE/range/index.taro.vue

@@ -380,9 +380,11 @@ export default create({
       event.stopPropagation();
       event.preventDefault();
     };
-
-    const curValue = (idx?: number) => {
-      const value = typeof idx === 'number' ? (props.modelValue as number[])[idx] : props.modelValue;
+    const curValue = (idx?: number): number => {
+      const value =
+        Array.isArray(props.modelValue) && typeof idx === 'number'
+          ? (props.modelValue as number[])[idx]
+          : Number(props.modelValue);
       return value;
     };
     const refRandomId = Math.random().toString(36).slice(-8);

+ 6 - 2
src/packages/__VUE/range/index.vue

@@ -78,6 +78,7 @@ import { ref, toRefs, computed, PropType, CSSProperties } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 import { useTouch } from '@/packages/utils/useTouch';
 import { useRect } from '@/packages/utils/useRect';
+import { isArray } from '@vue/shared';
 const { componentName, create } = createComponent('range');
 
 export default create({
@@ -374,8 +375,11 @@ export default create({
       dragStatus.value = '';
     };
 
-    const curValue = (idx?: number) => {
-      const value = typeof idx === 'number' ? (props.modelValue as number[])[idx] : props.modelValue;
+    const curValue = (idx?: number): number => {
+      const value =
+        isArray(props.modelValue) && typeof idx === 'number'
+          ? (props.modelValue as number[])[idx]
+          : Number(props.modelValue);
       return value;
     };
 

+ 1 - 1
src/packages/__VUE/trendarrow/index.taro.vue

@@ -1,5 +1,5 @@
 <template>
-  <view :class="classes" @click="handleClick">
+  <view :class="classes">
     <span v-if="!arrowLeft" class="nut-trend-arrow-icon-before nut-trend-arrow-rate" :style="calcStyle">{{
       calcRate
     }}</span>

+ 1 - 1
src/packages/__VUE/trendarrow/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <view :class="classes" @click="handleClick">
+  <view :class="classes">
     <span v-if="!arrowLeft" class="nut-trend-arrow-icon-before nut-trend-arrow-rate" :style="calcStyle">{{
       calcRate
     }}</span>