<script lang="ts" setup>
import { computed } from 'vue'
import type { PackageListItem } from '/#/workorder'

defineOptions({ name: 'ListItem' })

const props = defineProps({
  selected: {
    type: Boolean,
    default: false,
  },
  listItem: {
    type: Object as PropType<PackageListItem>,
    required: true,
  },
})

const svgName = computed(() => {
  return props.selected ? 'taskpack-select' : 'taskpack'
})
</script>

<template>
  <div class="list-item" :class="{ 'list-item-selected': selected }">
    <div class="list-item-header">
      <div style="display: flex;">
        <SvgIcon :name="svgName" size="28" />
        <span class="list-item-header-name" :class="{ 'list-item-header-selected': selected }">
          {{ listItem.packagename }}
        </span>
        <span class="list-item-header-selected">({{ listItem.pictureno }})</span>
      </div>
      <SvgIcon v-show="selected" size="14" name="more-ver" />
    </div>
    <ul class="list-item-detail">
      <li>筛选时间：{{ listItem.createTime }}</li>
      <li>执行人：{{ listItem.createBy }}</li>
    </ul>
    <div class="list-item-divider" />
  </div>
</template>

<style lang="less" scoped>
.list-item {
  padding: 12px 0px 12px 16px;
  position: relative;

  &-header {
    display: flex;
    align-items: center;

    &-name {
      font-size: 16px;
      font-weight: bold;
      color: #333333;
      line-height: 22px;
      margin: 0px 0px 8px 8px;
    }

    &-selected {
      color: #507AFD;
    }
  }

  &-selected {
    background-color: #f2f5fe;
  }

  &-detail {
    margin-left: 36px;

    li {
      font-size: 13px;
      color: #666666;
      line-height: 18px;
      margin-bottom: 8px;
    }
  }

  &-divider {
    width: 100%;
    height: 1px;
    background-color: #e8e8e8;
    position: absolute;
    bottom: 0px;
  }

}
</style>
../types
