<template>
  <Panel :title="'药品耗材'">
    <div class="content">
      <div class="list">
        <ul>
          <li class="item" v-for="(item, index) in list" :key="index">
            <span class="index">{{ index + 1 }}</span>
            <span class="name">{{ item.name }}</span>
            <span class="unit">{{ item.selectedNum || 0 }}{{ item.selectedUnit }}</span>
            <span class="price">￥{{ item.selectedPrice || '0' }}元</span>
          </li>
        </ul>
      </div>
      <div class="search">
        <span style="margin-left: 24px">合计</span>
        <span style="margin-right: 24px">￥{{ list.reduce((acc, cur) => acc + cur.selectedNum*cur.selectedPrice, 0) }}元</span>
      </div>
    </div>
  </Panel>
</template>
<script setup lang="ts">
import Panel from "@/components/common/Panel.vue";

const list = defineModel<any[]>({default: () => []});
</script>

<style scoped lang="scss">
.content {
  display: flex;
  flex-direction: column;

  .list {
    flex: 1;
    min-height: 0;

    .item {
      height: 30px;
      border-top: 1px solid #EAEAEC;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .index {
        height: 100%;
        width: 50px;
        text-align: center;
        line-height: 30px;
        border-right: 1px solid #EAEAEC;
      }

      .name {
        flex: 1;
        margin-left: 10px;
        border-right: 1px solid #EAEAEC;
        height: 100%;
        line-height: 30px;
      }

      .type {
        flex: 1;
        margin-left: 10px;
        border-right: 1px solid #EAEAEC;
        height: 100%;
        line-height: 30px;
      }

      .unit {
        flex: 1;
        margin-left: 10px;
        border-right: 1px solid #EAEAEC;
        height: 100%;
        line-height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .price {
        height: 100%;
        width: 200px;
        line-height: 30px;
        border-right: 1px solid #EAEAEC;
        text-align: center;
      }
    }
  }

  .search {
    height: 64px;
    border-top: 1px solid #EAEAEC;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
</style>