ll
liukangdong
2025-03-10 2bc4a739db642494accbf5be1fa55793f4652f44
h5/pages/staff/vehicle/shiwai.vue
@@ -21,10 +21,10 @@
          <text>*</text>
          <text>预计用车时段</text>
        </view>
        <view class="value" @click="isShowDate = true">
        <view class="value" @click="showDate">
          <text
            class="mr6"
            :style="{ color: param.startTime ? '#999999' : '#999999' }"
            :style="{ color: param.startTime ? '#000000' : '#999999' }"
          >
            <template v-if="param.startTime">
              {{ param.startHours }}至{{ param.endHours }}
@@ -36,13 +36,13 @@
      </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="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.startTime.slice(5, 16) }} 至 {{
              item.endTime.slice(5, 16)
            }}</text
          >
@@ -61,16 +61,19 @@
        </view>
        <view class="line">
          <text>申请人</text>
          <text>{{ item.memberName }} {{ item.memberMobile}}</text>
          <text>{{ item.memberName }} {{ item.memberMobile }}</text>
        </view>
      </view>
    </view>
    <view class="main_footer">
      <text>已选择:</text>
      <text class="sel" v-if="param.startTime"
        >{{ param.startHours }}至{{ param.endHours }}</text
      >
      <text class="btn" @click="onSubmit">确认预约</text>
      <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>
    <!--  -->
    <!-- 选择车辆 -->
@@ -83,7 +86,7 @@
      @confirm="seletedCar"
      @cancel="isShowCar = false"
    ></u-picker>
    <u-datetime-picker
   <!-- <u-datetime-picker
      mode="datetime"
      :show="isShowDate"
      :filter="timeFilter"
@@ -93,12 +96,24 @@
      :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"
      :filter="timeFilter"
      title="结束时间"
         :formatter="formatter"
      :minDate="new Date(param.startTime || null).getTime()"
      @close="endtimeClose"
      :closeOnClickOverlay="true"
@@ -121,20 +136,44 @@
      carsList: [],
      info: [],
      minDate: ''
      minDate: '',
         placeStr: ''
    }
  },
  onLoad() {
    this.minDate = new Date(dayjs().format('YYYY-MM-DD HH:') + '00:00').getTime()
    // 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()
      uni.setStorageSync('vehicleAppForm', {})
  },
  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 uni.showToast({
        title: '请重新选择时间段',
        icon: 'none'
      })
      if (info.length > 0) return
      if (!param.startTime) return uni.showToast({
        title: '请先选择用车时间段',
        icon: 'none'
@@ -191,6 +230,12 @@
      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() {
@@ -206,7 +251,7 @@
    },
    initData() {
      getCarsList({
        type: 1
        type: 0
      }).then(res => {
        this.carsList = [res.data]
      })
@@ -217,7 +262,7 @@
<style lang="scss">
.have_info {
   padding: 0 0 200rpx;
  padding: 0 0 200rpx;
  .tit {
    color: #ed4545;
    margin: 40rpx 0 24rpx;
@@ -226,10 +271,10 @@
    background: #f7f7f7;
    border-radius: 16rpx;
    padding: 30rpx 30rpx 10rpx;
      margin-bottom: 20rpx;
    margin-bottom: 20rpx;
    .card {
      margin-bottom: 30rpx;
      font-weight: 500;
      font-weight: 600;
      font-size: 32rpx;
      color: #222222;
      background: #f7f7f7;
@@ -317,13 +362,16 @@
  position: fixed;
  width: 100%;
  left: 0;
   background-color: #fff;
  background-color: #fff;
  bottom: 0;
  padding: 20rpx 30rpx 84rpx;
  padding: 20rpx 30rpx 62rpx;
  box-shadow: 0rpx -3rpx 6rpx 0rpx #eeeeee;
  display: flex;
  align-items: center;
  justify-content: space-between;
   .df_sb{
      display: flex;
      align-items: center;
      justify-content: space-between;
   }
  .btn {
    width: 184rpx;
    height: 72rpx;
@@ -339,5 +387,8 @@
    color: $uni-color-primary;
    flex: 1;
  }
   .disable{
      background: #CCCCCC;
   }
}
</style>