zhuguifei
2025-09-02 9dfbc038667839631578c12ff748534e5939bc82
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<template>
    <view>
        <cu-custom bgColor="bg-gradual-blue" :isBack="true">
            <block slot="content">生产记录分析</block>
        </cu-custom>
 
 
        <view class="card-box dynamic shadow">
            <view class="title-box">
                <view class="left">
                    <uni-text class="cuIcon-titles text-blue"></uni-text>
                    <view class="title">日期</view>
                </view>
            </view>
 
 
            <u-form labelPosition="left" :model="model" ref="form">
                <view class="input-box padding-lr userinfo-box">
 
                    <u-form-item label="开始日期" labelWidth="80" prop="date1" @click="show1 = true;" borderBottom>
                        <u--input v-model="model.date1" disabled disabledColor="#ffffff" placeholder="请选择开始日期"
                            border="none"></u--input>
                        <u-icon slot="right" name="arrow-right"></u-icon>
                        <u-datetime-picker :show="show1" @confirm="confirm1" @cancel="cancel1" @close="close1"  mode="date" ref="date1">
                        </u-datetime-picker>
                    </u-form-item>
 
                    <u-form-item label="结束日期" labelWidth="80" prop="date2"  @click="show2 = true;"
                        borderBottom>
                        <u--input v-model="model.date2" disabled disabledColor="#ffffff" placeholder="请选择结束日期"
                            border="none"></u--input>
                        <u-icon slot="right" name="arrow-right"></u-icon>
                        <u-datetime-picker :show="show2" @confirm="confirm2" @cancel="cancel2" @close="close2" mode="date" ref="date2">
                        </u-datetime-picker>
                    </u-form-item>
 
                </view>
 
                <view class="padding margin-top-xs">
                    <button @click="submit" class="cu-btn block bg-blue margin-tb-sm lg">查询分析</button>
                </view>
            </u-form>
 
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                show1: false,
                show2: false,
                model: {
                    date1: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
                    date2: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
                },
                rules: {
                    'date1': {
                        type: 'string',
                        required: true,
                        message: '请选择开始日期',
                        trigger: ['change']
                    },
                    'date2': {
                        type: 'string',
                        required: true,
                        message: '请选择结束日期',
                        trigger: ['change']
                    },
                },
            }
        },
        methods: {
            submit(){
            this.$refs.form.validate().then(res => {
                uni.$u.toast('校验通过')
                uni.navigateTo({
                    url:"/packageA/pages/analy/analyList"
                })
             
            }).catch(errors => {
                uni.$u.toast('校验失败')
            })
            },
            confirm1(e) {
                const timeFormat = uni.$u.timeFormat
                let date1 = timeFormat(e.value, 'yyyy-mm-dd')
                this.model.date1 = date1
                this.show1 = false
 
            },
            confirm2(e) {
                const timeFormat = uni.$u.timeFormat
                let date2 = timeFormat(e.value, 'yyyy-mm-dd')
                this.model.date2 = date2
                this.show2 = false
 
            },
            cancel1() {
                this.show1 = false
            },
            cancel2() {
                this.show2 = false
            },
            close1() {
                this.show1 = false
            },
            close2() {
                this.show2 = false
            },
        },
        onReady() {
            //onReady 为uni-app支持的生命周期之一
            this.$refs.form.setRules(this.rules)
 
        },
    }
</script>
 
<style lang="scss" scoped>
    .card-box {
        margin: 20rpx;
        padding: 20rpx;
        box-sizing: border-box;
        background-color: white;
        border-radius: 20rpx;
        font-family: Helvetica Neue, Helvetica, sans-serif;
 
        .left {
            display: flex;
            align-items: center;
 
            .title {
                margin: 0 10rpx;
                font-size: 34rpx;
                font-weight: bold;
            }
        }
 
    }
</style>