<!--
    清单页头部个数组件
-->
<template>
    <div id="listHeader">
        <div class="border-main">
            <!-- <p class="list-name"><span style="padding-right: 12px;">项目名称</span>{{mess.perjectName}}</p> -->
            <div class="card-view">
                <span class="card" v-for="(i,index) in mess.name" :key="index">
                    <span>{{index == 1 ? "已对应" : "全部"}}{{i.key}}</span>
                    <span class="num">{{i.num |numFormat}}</span>
                </span>
            </div>
        </div>
    </div>
</template>
<script>
export default {
  props: {
    mess: {
      type: Object,
      default: function() {
        return {
          perjectName: "风雅苑",
          name: [
            {
              key: "测试",
              num: 1548514
            },
            {
              key: "测试",
              num: 154852145
            }
          ]
        };
      }
    }
  },
  data() {
    return {};
  },
  methods: {
  },
  filters: {
    numFormat(num) {
      if (num && num != null) {
        num = String(num);
        var left = num.split(".")[0],
          right = num.split(".")[1];
        right = right
          ? right.length >= 2
            ? "." + right.substr(0, 2)
            : "." + right + "0"
          : "";
        var temp = left
          .split("")
          .reverse()
          .join("")
          .match(/(\d{1,3})/g);
        return (
          (Number(num) < 0 ? "-" : "") +
          temp
            .join(",")
            .split("")
            .reverse()
            .join("") +
          right
        );
      } else if (num === 0) {
        // 注意===在这里的使用，如果传入的num为0,if中会将其判定为boolean类型，故而要另外做===判断
        return "0";
      } else {
        return "--";
      }
    }
  }
};
</script>
<style lang="less" scoped>
#listHeader {
  background-color: #fff;
//   width: calc(100% - 20px);
//   height: 120px;
//   margin: 10px;
  .border-main {
    // width: 100%;
    height: 100%;
    border: 1px solid #dfe6ec;
    // border-radius: 5px;
    padding-left: 10px;
    .list-name {
      line-height: 28px;
      font-size: 14px;
      margin-top: 10px;
    }
    .card-view {
      // height: 80px;
      // overflow: hidden;
      display: flex;           
      margin-top: 10px;
      background-color: #e4e4e4;
      margin-right: 10px;
      .card {
          padding: 10px 0 10px 20px;
          width: 140px;
          text-align: left;
        span {
          color: #797979;
          font-size: 13px;
        }
        span.num {
          color: #3d3d3d;
          font-size: 17px;
          padding-left: 8px;
        }
      }
    }
  }
}
</style>
