Browse Source

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

zhangyufei 5 years ago
parent
commit
f43cc6f67e

+ 23 - 3
src/packages/datepicker/datepicker.vue

@@ -23,6 +23,10 @@ export default {
             type: String,
             default: 'date'
         },
+        isSetSecond: {
+            type: Boolean,
+            default: false
+        },
         isVisible: {
             type: Boolean,
             default: true
@@ -39,6 +43,10 @@ export default {
             type: Number,
             default: 1
         },
+        secondStep: {
+            type: Number,
+            default: 1
+        },
         isShowChinese: {
             type: Boolean,
             default: true
@@ -83,7 +91,7 @@ export default {
             updateDay: null,
             updateHour: null,
             use12Hours: ['上午', '下午'], 
-            chinese: !this.isShowChinese ? new Array(5).fill('') : this.type == 'time' ? ['时', '分', ''] : ['年', '月', '日', '时', '分']
+            chinese: !this.isShowChinese ? new Array(6).fill('') : this.type == 'time' ? (this.isUse12Hours ? ['时', '分', ''] : ['时', '分', '秒']) : ['年', '月', '日', '时', '分']
         };
     },
     components: {
@@ -151,6 +159,8 @@ export default {
                     this.cacheListData = [...[this.getHours(), this.getMinutes()]];
                     if (this.isUse12Hours) {
                         this.cacheListData = [...this.cacheListData, this.use12Hours];
+                    } else {
+                        this.cacheListData = this.isSetSecond ? [...this.cacheListData, this.getSeconds()] : [...this.cacheListData];
                     }
                     break;
             }            
@@ -162,7 +172,7 @@ export default {
             if (!this.defaultValue || !Utils.isDateString(this.defaultValue)) { 
                 switch (this.type) {
                     case 'time': 
-                        cacheDefaultValue = `00:00`;
+                        cacheDefaultValue = this.isSetSecond ? `00:00:00` :`00:00`;
                         break;
                     case 'date': 
                     case 'datetime': 
@@ -190,6 +200,7 @@ export default {
                 this.updateHour =  this.cacheDefaultData[3];  
             }
             this.defaultValueData = [...this.cacheDefaultData];
+           
         },
 
         getCacheData(data) {
@@ -327,6 +338,15 @@ export default {
             return minutes.filter(item => item);
         },
 
+        getSeconds() {
+            let seconds = Array.from(Array(60), (v,k) => {
+                if (k == 0 || k % this.secondStep == 0) {
+                    return `${k}${this.type=='time' ? this.chinese[2] : this.chinese[5]}`;
+                }
+            });
+            return seconds.filter(item => item);
+        },
+
         setChooseValue(chooseData) {
             let cacheChooseData = [];
             chooseData.map((item , index) => {
@@ -348,7 +368,7 @@ export default {
                 let week = Utils.getWhatDay(cacheChooseData[0], cacheChooseData[1], cacheChooseData[2]);
                 cacheChooseData.push(week);
             } else {
-                cacheChooseData.push(`${cacheChooseData[0]}:${cacheChooseData[1]}`);
+                cacheChooseData.push(`${cacheChooseData[0]}:${cacheChooseData[1]}${this.isSetSecond ? ':' + cacheChooseData[2] : ''}`);
             }
             this.$emit('choose', cacheChooseData)
         },

+ 5 - 4
src/packages/datepicker/demo.vue

@@ -109,9 +109,10 @@
       title="请选择时间"
       startHour="8"
       endHour="18"
-      defaultValue="09:06"
+      :default-value="time1"
       @close="switchPicker('isVisible4')"
       @choose="setChooseValue4"
+      :is-set-second = "true"
     ></nut-datepicker>
     <!-- demo4-->
     <nut-datepicker
@@ -119,7 +120,7 @@
       type="time"
       title="请选择时间"
       :minute-step="5"
-      defaultValue="10:30"
+      :default-value="time2"
       @close="switchPicker('isVisible5')"
       @choose="setChooseValue5"
     ></nut-datepicker>
@@ -140,7 +141,7 @@ export default {
       date1: null,
       datetime: "2018-11-02 11:08",
       time: "01:07",
-      time1: "09:06",
+      time1: "09:06:02",
       time2: "10:30",
       amOrPm: "PM"
     };
@@ -163,7 +164,7 @@ export default {
       this.time = param[3];
     },
     setChooseValue4(param) {
-      this.time1 = param[2];
+      this.time1 = param[3];
     },
     setChooseValue5(param) {
       this.time2 = param[2];

+ 1 - 0
src/packages/datepicker/doc.md

@@ -156,6 +156,7 @@ export default {
 | endDate | 结束日期 | String | 今天
 | startHour | 开始小时 | Number | 1
 | endHour | 结束小时 | Number | 23
+|isSetSecond| 是否支持秒,仅限type类型为'time'时支持 | Boolean | false
 
 ## Event
 

+ 1 - 1
src/packages/scroller/horizontal-scroll.vue

@@ -157,7 +157,7 @@ export default {
 
         touchEnd(event) {
             event.stopPropagation();
-            let changedTouches = event.changedTouches[0];
+            let changedTouches = event.changedTouches[0];       
             this.touchParams.lastTime = event.timestamp || Date.now();
             let moveTime = this.touchParams.lastTime - this.touchParams.startTime;
             this.touchEvent(changedTouches, (move, maxMove) => {

+ 1 - 1
src/packages/scroller/scroller.scss

@@ -10,7 +10,7 @@
     height: 100%;
     width: 100%;
     overflow: hidden;
-    //touch-action: none; 
+    touch-action: none; 
     .nut-hor-list{
         height: 100%;
         width: auto;