linwe
2024-08-08 3c738f4fe2762bba8087e5a22fc0dc06560eab0e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<template>
    
    <view class="">
        <u-popup :show="isShowPopup" :closeable="true"   @close="isShowPopup = false">
            <view class="popup">
                <view class="popup-title f-30 fw">
                    时间筛选
                </view>
                <view class="popup-content flex j-c-s-a a-i-c f-28">
                    <view class="select-box" @click="startTimePicker = true">
                        <text v-if="!startTime" class="c-99">开始时间</text>
                        <text v-if="startTime">{{startTime}}</text>
                    </view>
                    <view class="c-99">
                        ——
                    </view>
                    <view class="select-box" @click="endTimePicker = true">
                        <text v-if="!endTime" class="c-99">结束时间</text>
                        <text v-if="endTime">{{endTime}}</text>
                    </view>
                </view>
                <view class="popup-btn flex j-c-s-b a-i-c">
                    <button class="popup-btn-item f-30 c-main" @click="restDate">重置</button>
                    <button class="popup-btn-item bgc-main c-ff f-30"  @click="comfirmFilterDate">确定</button>
                </view>
            </view>
        </u-popup>
          <u-datetime-picker  :show="startTimePicker" v-model="currentTime" mode="date"
              @confirm="comfirmStartDate" @cancel="startTimePicker = false"></u-datetime-picker>
          <u-datetime-picker :show="endTimePicker" v-model="currentTime" mode="date"
                  @confirm="comfirmEndDate" @cancel="endTimePicker = false"></u-datetime-picker>
    </view>
    
</template>
 
<script>
    export default {
        name:"dateRangeModal",
        data(){
            return {
                isShowPopup: false,
                startTime:"",
                endTime:"",
                startTimePicker:false,
                endTimePicker:false,
                currentTime: Number(new Date()),
            }
        },
        methods:{
            open(){
                this.isShowPopup = true;
            },
            close(){
                this.isShowPopup = false;
            },
            comfirmStartDate(e){
                this.startTime = this.$u.timeFormat(e.value, 'yyyy-mm-dd');
                this.startTimePicker = false;
            },
            comfirmEndDate(e){
                this.endTime = this.$u.timeFormat(e.value, 'yyyy-mm-dd');
                this.endTimePicker = false;
            },
            comfirmFilterDate(){
                if(!this.startTime) return;
                if(!this.endTime) return;
                this.selectDate = [this.startTime,this.endTime]
                this.$emit("comfirm",[this.startTime,this.endTime])
                this.isShowPopup = false;
            },
            restDate() {
                this.startTime = "";
                this.endTime ="";
                this.$emit("rest");
            },
            
        }
    }
</script>
 
<style  lang="scss" scoped>
    .popup-title {
        padding: 30rpx;
        text-align: center;
    }
    
    .popup-content {
        padding: 30rpx 20rpx 20rpx;
    
        .select-box {
            width: 280rpx;
            height: 78rpx;
            border-radius: 35rpx;
            background-color: #F5F5F5;
            text-align: center;
            line-height: 78rpx;
        }
    }
    
    .popup-btn {
        padding: 30rpx;
    
        .popup-btn-item {
            width: 310rpx;
            height: 78rpx;
            line-height: 78rpx;
            border-radius: 10rpx;
            border: none;
            margin: 0;
        }
    
        .popup-btn-item:first-child {
            border: 1px solid currentColor;
            background-color: rgb(236, 244, 255);
        }
    
        .popup-btn-item::after {
            border: none;
        }
    }
    
</style>