<script lang="ts" setup>
import { format } from "date-fns";
import { computed } from "vue";

defineOptions({ name: "ListItem" });

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

const svgName = computed(() => {
  return props.selected ? "task-select" : "task";
});
</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 }"
        >
          任务ID:{{ listItem.fromtaskname }}
        </span>
      </div>
      <SvgIcon v-show="selected" size="14" name="more-ver" />
    </div>
    <ul class="list-item-detail">
      <li>
        审批状态：<span
          class="list-item-status"
          :class="
            listItem.statshisText == '通过'
              ? 'list-item-success'
              : listItem.statshisText == '不通过'
              ? 'list-item-error'
              : 'list-item-watting'
          "
          >{{ listItem.statshisText }}</span
        >
      </li>
      <li>审批节点：{{ listItem.tasknamehis }}</li>
      <li>
        提交时间：{{ format(listItem.createdate, "yyyy-MM-dd HH:mm:ss") }}
      </li>
      <li>提报人：{{ listItem.fromUserName }}</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;
  }

  &-status {
    display: inline-block;
    display: flex;
    align-items: center;
  }
  &-error {
    &:before {
      content: "";
      width: 6px;
      height: 6px;
      background: #e45656;
      border-radius: 50%;
      display: inline-block;
      margin-left: 8px;
      margin-right: 4px;
    }
  }
  &-success {
    &:before {
      content: "";
      width: 6px;
      height: 6px;
      background: #53c21d;
      border-radius: 50%;
      display: inline-block;
      margin-left: 8px;
      margin-right: 4px;
    }
  }
  &-watting {
    &:before {
      content: "";
      width: 6px;
      height: 6px;
      background: #398ade;
      border-radius: 50%;
      display: inline-block;
      margin-left: 8px;
      margin-right: 4px;
    }
  }

  &-detail {
    margin-left: 36px;

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

  &-divider {
    width: 100%;
    height: 1px;
    background-color: #e8e8e8;
    position: absolute;
    bottom: 0px;
  }
}
</style>
../types
