<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.itemName }}</span>
              <span class="code">{{ item.itemSocialCode }}</span>
              <span class="unit">{{item.selectedNum}}{{ item.selectedUnit }}</span>
              <span class="price">￥{{ item.selectedPrice }}元</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";
import {onMounted} from "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;
        border-right: 1px solid #EAEAEC;
        line-height: 30px;
      }
      .name{
        flex: 1;
        margin-left: 10px;
        border-right: 1px solid #EAEAEC;
        height: 100%;
        line-height: 30px;
      }
      .code{
        flex: 1;
        margin-left: 10px;
        border-right: 1px solid #EAEAEC;
        height: 100%;
        line-height: 30px;
      }
      .unit{
        width: 60px;
        margin-left: 10px;
        border-right: 1px solid #EAEAEC;
        height: 100%;
        line-height: 30px;
        text-align: 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>