<script lang="ts" setup>
import type { PackageListItem } from '/#/workorder'
import ListItem from './ListItem.vue'
import { useWorkOrder } from '@/store/modules/workOrder'

defineOptions({ name: 'WorkSheetList' })

defineProps({
  activeId: {
    type: String,
    required: true,
  },
  data: {
    type: Object as PropType<PackageListItem[]>,
    required: true,
  },
})

const workStore = useWorkOrder()

function selectHandler(id: string, index: number) {
  workStore.setActive(index)
}
</script>

<template>
  <n-scrollbar>
    <ListItem
      v-for="(item, index) in data" :key="item.id" :selected="activeId === item.id" :list-item="item"
      @click="selectHandler(item.id, index)"
    />
  </n-scrollbar>
</template>

<style lang="less" scoped>
</style>
../types
