jiangping
2025-02-26 4e2e52b766d87fc528d02bdebc1757c3dda8c596
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<template>
  <view class="main_app">
    <view class="main_wrap">
      <!--  -->
      <view class="line">
        <view class="label">
          <text>*</text>
          <text>选择车辆</text>
        </view>
        <view class="value" @click="isShowCar = true">
          <text
            class="mr6"
            :style="{ color: param.carCode ? '#000000' : '#999999' }"
            >{{ param.carCode ? param.carCode : "请选择" }}</text
          >
          <u-icon name="arrow-right" color="#CCCCCC" size="20"></u-icon>
        </view>
      </view>
      <view class="line">
        <view class="label">
          <text>*</text>
          <text>预计用车时段</text>
        </view>
        <view class="value" @click="showDate">
          <text
            class="mr6"
            :style="{ color: param.startTime ? '#000000' : '#999999' }"
          >
            <template v-if="param.startTime">
              {{ param.startHours }}至{{ param.endHours }}
            </template>
            <template v-else> 请选择 </template>
          </text>
          <u-icon name="arrow-right" color="#CCCCCC" size="20"></u-icon>
        </view>
      </view>
    </view>
    <view class="have_info" v-if="info && info.length > 0">
      <view class="tit">您申请的用车时段存在以下预约信息,无法预约</view>
      <view class="content" v-for="(item, i) in info" :key="i">
        <view class="card">{{ item.carCode }}</view>
        <view class="line">
          <text>用车时段</text>
          <text>
            {{ item.startTime.slice(5, 16) }} 至 {{
              item.endTime.slice(5, 16)
            }}</text
          >
        </view>
        <view class="line">
          <text>目的地</text>
          <text>{{ item.addr }}</text>
        </view>
        <view class="line">
          <text>乘车人数</text>
          <text>{{ item.memberIds.split(",").length }}人</text>
        </view>
        <view class="line">
          <text>用车事由</text>
          <text>{{ item.content }}</text>
        </view>
        <view class="line">
          <text>申请人</text>
          <text>{{ item.memberName }} {{ item.memberMobile }}</text>
        </view>
      </view>
    </view>
    <view class="main_footer">
      <view class="df_sb">
                <text>已选择:</text>
                <text class="sel" v-if="param.startTime"
                  >{{ param.startHours }}至{{ param.endHours }}</text
                >
                <text class="btn" :class="{disable: info && info.length > 0}" @click="onSubmit">确认预约</text>
            </view>
            <view class="red">{{placeStr}}</view>
    </view>
    <!--  -->
    <!-- 选择车辆 -->
    <u-picker
      keyName="code"
      :show="isShowCar"
      @close="isShowCar = false"
      :closeOnClickOverlay="true"
      :columns="carsList"
      @confirm="seletedCar"
      @cancel="isShowCar = false"
    ></u-picker>
   <!-- <u-datetime-picker
      mode="datetime"
      :show="isShowDate"
      :filter="timeFilter"
      title="开始时间"
      :minDate="minDate"
      @close="isShowDate = false"
      :closeOnClickOverlay="true"
      @confirm="seletedDate"
      @cancel="isShowDate = false"
    /> -->
        <u-datetime-picker
           mode="datetime"
           :show="isShowDate"
            ref="startPick"
           title="开始时间"
             :formatter="formatter"
           :minDate="minDate"
           @close="isShowDate = false"
           :closeOnClickOverlay="true"
           @confirm="seletedDate"
           @cancel="isShowDate = false"
         />
    <u-datetime-picker
      mode="datetime"
      :show="isShowEndDate"
      title="结束时间"
            :formatter="formatter"
      :minDate="new Date(param.startTime || null).getTime()"
      @close="endtimeClose"
      :closeOnClickOverlay="true"
      @confirm="seletedEndDate"
      @cancel="endtimeClose"
    />
  </view>
</template>
 
<script>
import { getCarsList, carUseBookList } from '@/api'
import dayjs from 'dayjs'
export default {
  data() {
    return {
      param: {},
      isShowCar: false,
      isShowDate: false,
      isShowEndDate: false,
      carsList: [],
      info: [],
 
      minDate: '',
            placeStr: ''
    }
  },
  onLoad() {
    // this.minDate = new Date(dayjs().format('YYYY-MM-DD HH:mm') + ':00').getTime()
    this.minDate = new Date().getTime() - (6 * 24 * 60 * 60 * 1000)
    this.initData()
  },
  methods: {
        formatter(type, value) {
            if (type === 'year') {
                return `${value}年`
            }
            if (type === 'month') {
                return `${value}月`
            }
            if (type === 'day') {
                return `${value}日`
            }
            if (type === 'hour') {
                return `${value}时`
            }
            if (type === 'minute') {
                return `${value}分`
            }
            return value
        },
        showDate() {
            this.isShowDate = true
            if (!this.param.startTime) {
                this.$refs.startPick.innerValue = new Date().getTime()
            }
        },
    onSubmit() {
      const { param, info } = this
      if (info.length > 0) return
      if (!param.startTime) return uni.showToast({
        title: '请先选择用车时间段',
        icon: 'none'
      })
      if (!param.carId) return uni.showToast({
        title: '请选择车辆',
        icon: 'none'
      })
      const obj = {
        carCode: param.carCode,
        carId: param.carId,
        startTime: param.startTime,
        endTime: param.endTime,
        type: '1'
      }
      uni.navigateTo({
        url: `/pages/staff/vehicle/apply?carCode=${obj.carCode}&carId=${obj.carId}&startTime=${obj.startTime}&endTime=${obj.endTime}&type=${obj.type}`
      })
      // this.$jump('/pages/staff/vehicle/apply')
    },
    getInfo() {
      const { param } = this
      carUseBookList({
        carId: param.carId,
        startTime: param.startTime,
        endTime: param.endTime,
      }).then(res => {
        if (res.code == 200) {
          this.info = res.data
        }
      })
    },
    seletedCar(e) {
      const item = e.value[0]
      this.$set(this.param, 'carCode', item.code)
      this.$set(this.param, 'carId', item.id)
      this.isShowCar = false
      if (this.param.carId && this.param.startTime) {
        this.getInfo()
      }
    },
    seletedDate(e) {
      this.param.startTime = dayjs(e.value).format('YYYY-MM-DD HH:mm:ss')
      this.param.startHours = dayjs(e.value).format('MM-DD HH:mm')
      console.log(this.param.startTime)
      this.isShowDate = false
      this.isShowEndDate = true
    },
    seletedEndDate(e) {
      this.param.endTime = dayjs(e.value).format('YYYY-MM-DD HH:mm:ss')
      this.param.endHours = dayjs(e.value).format('MM-DD HH:mm')
      console.log(this.param.endTime)
      this.isShowEndDate = false
      if (this.param.carId && this.param.startTime) {
        this.getInfo()
      }
            console.log(e);
            if(new Date(this.param.startTime).getTime() < new Date().getTime() - 60 * 1000){
                this.placeStr = '当前选择包含已经过去时间,请确认后再提交;'
            }else{
                this.placeStr = ''
            }
      this.$forceUpdate()
    },
    endtimeClose() {
      this.param.endTime = ''
      this.param.startTime = ''
      this.isShowEndDate = false
    },
    timeFilter(mode, options) {
      if (mode === 'minute') {
        return options.filter(option => option === '00' || option === '30' || option === '60')
      }
      return options
    },
    initData() {
      getCarsList({
        type: 0
      }).then(res => {
        this.carsList = [res.data]
      })
    },
  }
};
</script>
 
<style lang="scss">
.have_info {
  padding: 0 0 200rpx;
  .tit {
    color: #ed4545;
    margin: 40rpx 0 24rpx;
  }
  .content {
    background: #f7f7f7;
    border-radius: 16rpx;
    padding: 30rpx 30rpx 10rpx;
    margin-bottom: 20rpx;
    .card {
      margin-bottom: 30rpx;
      font-weight: 600;
      font-size: 32rpx;
      color: #222222;
      background: #f7f7f7;
      padding: 0;
    }
    .line {
      display: flex;
      margin-bottom: 20rpx;
      text {
        &:nth-of-type(1) {
          width: 150rpx;
          color: #888888;
        }
        &:nth-of-type(2) {
          flex: 1;
        }
      }
    }
  }
}
.main_wrap {
  .line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1rpx solid #e5e5e5;
    padding: 30rpx 0;
    .label {
      font-size: 30rpx;
      font-weight: 400;
      text {
        &:nth-child(1) {
          color: #e42d2d;
          margin-right: 4rpx;
        }
      }
    }
    .value {
      flex: 1;
      height: 100%;
      margin-left: 30rpx;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      input {
        width: 100%;
        height: 100%;
        text-align: right;
        font-size: 28rpx;
        font-weight: 400;
        color: #222222;
      }
    }
  }
  .upload_line {
    padding: 30rpx 0;
    textarea {
      margin-top: 12rpx;
      width: 100%;
      height: 180rpx;
      font-size: 28rpx;
      font-weight: 400;
      color: #222222;
    }
    .adduser_list_item_ipt1_upload {
      margin-top: 24rpx;
      width: 120rpx;
      height: 120rpx;
      border: 2rpx solid #e5e5e5;
      background: #f7f7f7;
      color: #666666;
      font-size: 22rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      image {
        width: 100%;
        height: 100%;
      }
    }
  }
}
.main_footer {
  position: fixed;
  width: 100%;
  left: 0;
  background-color: #fff;
  bottom: 0;
  padding: 20rpx 30rpx 62rpx;
  box-shadow: 0rpx -3rpx 6rpx 0rpx #eeeeee;
  
    .df_sb{
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
  .btn {
    width: 184rpx;
    height: 72rpx;
    line-height: 72rpx;
    text-align: center;
    background: $uni-color-primary;
    box-shadow: 0rpx -1rpx 0rpx 0rpx #eeeeee;
    border-radius: 36rpx;
    font-size: 30rpx;
    color: #ffffff;
  }
  .sel {
    color: $uni-color-primary;
    flex: 1;
  }
    .disable{
        background: #CCCCCC;
    }
}
</style>