<script lang="ts" setup>
import { useAppStore } from '@/store'

const props = defineProps({
  data: {
    type: Object,
    default: () => ({}),
  },

})

const appStore = useAppStore()

function getIcon(value: string | number) {
  let icon = ''
  switch (value) {
    case 1:
      icon = 'xunjiandian'
      break
    case 2:
      icon = 'huandianjilu'
      break
    case 3:
      icon = 'yingjitiaodu'
      break
    case 4:
      icon = 'weixiu1'
      break
    default:
      icon = ''
      break
  }
  return icon
}

function goDetail(type: number) {
  let url = ''
  switch (type) {
    case 1:
      url = '/pages-sub/warehouse/polling/polling'
      break
    case 2:
      url = '/pages-sub/changebatteries/changebatteries'
      break
    case 3:
      url = ''
      break
    case 4:
      url = '/pages-sub/work/inspectionWorkOrder/inspectionWorkOrder'
      break
  }
  uni.navigateTo({
    url: `${url}?bikeCode=${props.data.bikeCode}`,
  })
}
</script>

<template>
  <view class="container" @click="goDetail(props.data?.orderType)">
    <view style="margin-right: 5rpx;" class="icon_bar">
      <uv-icon
        :name="getIcon(props.data?.orderType)"
        custom-prefix="custom-icon"
        size="20"
        color="#ffffff"
      />
    </view>
    <!-- 信息 -->
    <view class="info">
      <view class="title">
        {{ appStore.translateDictValue(props.data?.orderType, 'orderType') || '--' }}
      </view>
      <view class="location text-ellipsis-2">
        <!-- TUDO: 地址 -->
      </view>
      <view class="info-item">
        车辆编号：
        <text style="color: #1f7ff5;"> {{ props.data.bikeCode || '--' }}</text>
      </view>
      <view class="info-item">
        创建时间：
        <text style="color: #3a3839;">{{ props.data.createdAt || '--' }}</text>
      </view>
    </view>
    <view style="margin-left: 5rpx;">
      <uv-icon name="arrow-right" size="14" />
    </view>
  </view>
</template>

<style lang="scss" scoped>
.container {
  padding: 20rpx;
  width: calc(100% - 40rpx);
  background-color: white;
  border-radius: 10rpx;
  box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  margin-bottom: 30rpx;
  display: flex;
  justify-content: space-between;

  .icon_bar {
    width: 50rpx;
    height: 50rpx;
    border-radius: 8rpx;
    background-color: orange;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .info {
    flex: 1; /* 占据剩余空间 */
    max-width: calc(100% - 100rpx); /* 限制最大宽度 */
    .title {
      font-size: 32rpx;
      font-weight: bold;
      margin-bottom: 10rpx;
    }

    .location {
      font-size: 28rpx;
      margin-bottom: 25rpx;
      color: #a4a4a4;
    }

    .info-item {
      font-size: 30rpx;
      margin-bottom: 10rpx;
      color: #999999;
    }
  }
}
</style>
