MrShi
2024-03-28 e2bc832dedd3a54d770526786e4db30470e0f57b
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<template>
    <view class="box">
        <view class="box_hz" :style="{backgroundImage: 'url(' + backgroundImg + ')'}">
            <view class="box_hz_title">加减保申请</view>
            <view class="box_hz_info">请按要求填写以下内容</view>
            <view class="box_hz_list">
                <u--form
                    labelPosition="top"
                    :model="model"
                    :rules="rules"
                    ref="uForm"
                >
                    <u-form-item
                        labelWidth="150"
                        label="选择保单号:"
                        prop="code"
                        @click="show = true"
                        borderBottom
                    >
                        <u--input v-model="model.code" disabled disabledColor="#ffffff" placeholder="请选择" border="none"></u--input>
                        <u-icon slot="right" name="arrow-right"></u-icon>
                    </u-form-item>
                    <u-form-item
                        labelWidth="200"
                        label="选择期望批单生效期:"
                        prop="startDate"
                        @click="show1 = true"
                    >
                        <u--input v-model="model.startDate" disabled disabledColor="#ffffff" placeholder="请选择" border="none"></u--input>
                        <u-icon slot="right" name="arrow-right"></u-icon>
                    </u-form-item>
                </u--form>
            </view>
            <view class="box_hz_footer">
                <u-button type="primary" shape="circle" color="#437CB3" text="下一步" @click="submit"></u-button>
            </view>
        </view>
        <!-- 选择保单号 -->
        <u-picker
            :immediateChange="true"
            :show="show"
            :columns="columns"
            keyName="label"
            confirmColor="#437CB3"
            @confirm="confirm"
            @cancel="show = false" />
        <!-- 期望保险生效时间 -->
        <u-datetime-picker
            :show="show1"
            mode="date"
            :minDate="minDate"
            :maxDate="maxDate"
            @cancel="show1 = false"
            @confirm="confirm1" />
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                show: false,
                show1: false,
                columns: [],
                minDate: '',
                maxDate: '',
                id: '',   // 保单id
                backgroundImg: require('@/static/background/toubao_bg@2x.png'),
                model: {
                    id: '',        // 方案id
                    code: '',
                    startDate: '',
                    cyclePrice: ''
                },
                rules: {
                    'programmeName': {
                        type: 'string',
                        required: true,
                        message: '请选择保险方案',
                        trigger: ['blur', 'change']
                    },
                    'startDate': {
                        type: 'string',
                        required: true,
                        message: '请选择保险生效开始日期',
                        trigger: ['blur', 'change']
                    }
                }
            };
        },
        onLoad() {
            this.getCodeList()
        },
        methods: {
            getCodeList() {
                this.$u.api.insuranceApplyFindListByDTO({
                    status: 5,
                    isEffective: 0
                }).then(res => {
                    if (res.code === 200) {
                        res.data.forEach(item => {
                            item.label = item.code
                        })
                        this.columns = [res.data]
                    }
                })
            },
            confirm(e) {
                this.model.id = e.value[0].solutionId
                this.model.code = e.value[0].code
                this.id = e.value[0].id
                if ([1,3].includes(this.compareDates(this.getDate(), e.value[0].startTime)) && !e.value[0].lastChangeDate) {
                    // 当前日期大于等于生效日期并且最后一次操作时间等于空
                    this.minDate = new Date(this.getTomorrow()).getTime()
                    this.maxDate = new Date(e.value[0].endTime).getTime()
                } else if (this.compareDates(this.getDate(), e.value[0].startTime) === 2 && !e.value[0].lastChangeDate) {
                    // 当前日期小于生效日期并且最后一次操作时间等于空
                    this.minDate = new Date(e.value[0].startTime).getTime()
                    this.maxDate = new Date(e.value[0].endTime).getTime()
                } else if (e.value[0].lastChangeDate) {
                    // 最后一次操作时间有值
                    if ([1,3].includes(this.compareDates(this.getDate(), e.value[0].lastChangeDate))) {
                        // 当前日期大于最后一次操作时间
                        this.minDate = new Date(this.getTomorrow()).getTime()
                        this.maxDate = new Date(e.value[0].endTime).getTime()
                    } else if (this.compareDates(this.getDate(), e.value[0].lastChangeDate) === 2) {
                        // 当前时间小于最后一次操作时间
                        this.minDate = new Date(e.value[0].lastChangeDate).getTime()
                        this.maxDate = new Date(e.value[0].endTime).getTime()
                    }
                }
                this.show = false
            },
            // 选择时间
            confirm1(e) {
                this.model.startDate = uni.$u.timeFormat(e.value, 'yyyy-mm-dd') + ' 00:00:00'
                this.$u.api.getChangeCountCyclePriceVO({
                    applyId: this.model.id,
                    validTime: this.model.startDate
                }).then(res => {
                    if (res.code === 200) {
                        this.model.cyclePrice = res.data.cyclePrice
                        this.show1 = false
                    }
                })
            },
            // 获取明天日期
            getTomorrow() {
                var today = new Date();
                today.setDate(today.getDate() + 1);
                var year = today.getFullYear();
                var month = today.getMonth() + 1;
                var day = today.getDate();
                return year + "-" + month + "-" + day + ' 00:00:00';
            },
            // 对比时间
            compareDates(date1, date2) {
                if (new Date(date1).getTime() > new Date(date2).getTime()) {
                    return 1
                } else if (new Date(date1).getTime() < new Date(date2).getTime()) {
                    return 2
                } else {
                    return 3
                }
            },
            // 获取当前时间
            getDate() {
                let currentDate = new Date();
                let year = currentDate.getFullYear(); // 获取当前年份
                let month = currentDate.getMonth() + 1; // 获取当前月份,注意月份从0开始,所以要加1
                let day = currentDate.getDate(); // 获取当前日期
                return `${year}-${month}-${day}`
            },
            submit() {
                this.$refs.uForm.validate().then(res => {
                    uni.navigateTo({
                        url: `/pages/addition_subtraction/addition_subtraction?id=${this.model.id}&codeId=${this.id}&cyclePrice=${this.model.cyclePrice}&startDate=${this.model.startDate}&code=${this.model.code}`
                    })
                }).catch(errors => {
                    
                })
            }
        }
    }
</script>
<style>
    page {
        background-color: #f7f7f7;
    }
</style>
<style lang="scss" scoped>
    .box {
        width: 100%;
        .box_hz {
            width: 100%;
            height: 440rpx;
            padding: 0 30rpx;
            box-sizing: border-box;
            background-repeat: no-repeat;
            background-size: 100% 100%;
            padding-top: 48rpx;
            .box_hz_title {
                font-weight: 600;
                font-size: 48rpx;
                color: #FFFFFF;
                font-style: normal;
            }
            .box_hz_info {
                font-weight: 400;
                font-size: 28rpx;
                color: #FFFFFF;
                font-style: normal;
                margin-top: 16rpx;
            }
            .box_hz_list {
                width: 100%;
                padding: 32rpx 30rpx;
                box-sizing: border-box;
                background-color: #FFFFFF;
                margin-top: 48rpx;
                border-radius: 16rpx;
            }
            .box_hz_footer {
                width: 100%;
                margin-top: 60rpx;
            }
        }
    }
</style>