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

const props = defineProps({
  orderId: {
    type: String,
    default: '',
  },
})
const emits = defineEmits(['openPopup'])

const operatorStore = useOperatorStore()
const popupRef_add = ref<any>(null)
const table_tr_list = ref<any>([
  {
    title: '车辆编号',
    key: 'bikeCode',
    width: '100',
  },
  {
    title: '响铃',
    key: 'findBike',
    width: '50',
  },
  {
    title: '操作',
    key: 'actions',
    width: '50',
  },
])

// 一键添加
function onClickBike() {
  operatorStore.dispatchVehicles({
    isOneKey: true,
    sucsuess: () => {

    },
    fail: () => {

    },
  })
}

function handleAdd(item: any) {
  operatorStore.dispatchVehicles({
    bikeInfo: item,
    sucsuess: () => {

    },
    fail: () => {

    },
  })
}

async function handleDelete(item: any) {
  operatorStore.cancelDispatchOrder(item)
}
</script>

<template>
  <view class="contanir">
    <view class="title_bar">
      <view class="left">
        {{ props.orderId ? '剩余待调度数量:' : '检测到待调度数量:' }}
      </view>
      <view class="right">
        <text class="add1" @click="onClickBike">一键添加</text>
        <text class="text1">{{ operatorStore.initialDispathBikeList.length }}辆</text>
        <view class="text2" @click="() => emits('openPopup')">
          查看
          <uv-icon name="arrow-right" size="14" />
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped>
.contanir {
  width: 100%;

  .title_bar {
    width: 100%;
    display: flex;
    justify-content: space-between;

    .left {
    }

    .right {
      display: flex;
      align-items: center;
      .add1 {
        color: #007aff;
      }

      .text1 {
        margin: 0 20rpx;
      }

      .text2 {
        display: flex;
        align-items: center;
      }
    }
  }
}

.popup_content {
  width: 100%;

  .header_bar {
    position: relative;
    height: 100rpx;
    width: 100%;
    text-align: center;

    .title {
      font-size: 32rpx;
      line-height: 100rpx;
      font-weight: bold;
      color: #222222;
    }
  }

  .content_bar {
    padding: 20rpx 30rpx;
    width: calc(100% - 60rpx);
  }
}
</style>
