Newer
Older
CloudBrainNew / src / views / mapViews / components / population / gridPopulation.vue
dutingting 4 days ago 4 KB pending
<!-- 人口分布 -->
<template>
    <div class="bottom" >
      <div class="block">
        <div class="title">网格人口分布</div>
        <div class="chart-wrapper">
          <div style="width: 100%;height:100%;padding:0.1rem;">
            <scroll-board :config="boardConfig"/>
          </div>
        </div>
      </div>
    </div>
</template>

<script>
import ScrollBoard from '@/components/board/ScrollBoard'
import { fetchMockData } from '@/api/map'
export default {
  name: 'areaPopulation',
  components: {ScrollBoard},
  data () {
    return {
      boardConfig: {
        header: ['', '网格名称', '所属区域', '总户数', '总人口', '户籍人口', '流动人口', '老年人(60岁以上)', '未成年人(18岁以下)', '劳动力人口(18-59岁)'],
        rowNum: 4,
        hoverColor: true,
        headerBGC: 'rgba(46,145,244,0.4)',
        oddRowBGC: 'transparent',
        evenRowBGC: '#030737',
        headerColor: '#00F0FF',
        rowColor: '#FFFFFF',
        headerFontSize: '0.072rem', // 表头字体大小
        rowFontSize: '0.07rem', // 行字体大小
        columnWidth: [220],
        data: [
          ['--', '--', '--', '--', '--', '--', '--', '--', '--', '--'],
          ['--', '--', '--', '--', '--', '--', '--', '--', '--', '--'],
          ['--', '--', '--', '--', '--', '--', '--', '--', '--', '--'],
          ['--', '--', '--', '--', '--', '--', '--', '--', '--', '--'],
          ['--', '--', '--', '--', '--', '--', '--', '--', '--', '--'],
          ['--', '--', '--', '--', '--', '--', '--', '--', '--', '--'],
          ['--', '--', '--', '--', '--', '--', '--', '--', '--', '--']
        ]
      }
    }
  },
  created () {
    this.initData()
  },
  methods: {
    initData () {
      console.log('请求网格人口数据')
      fetchMockData('population/grid').then(res => {
        if (res.code === 200) {
          console.log('请求网格人口数据', res.data)
          this.boardConfig.header = res.data.header
          this.boardConfig.data = res.data.table
        }
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.bottom {
  z-index: 111111111111;
  width: 9rem;
  height: 1.6rem;
  position: absolute;
  bottom: 10px;
  left: 0px;
  display: flex;
  // overflow: hidden;
  // padding: 0px 0px;
  gap: 10px; /* 新增:两个盒子之间的间距 */
  padding: 0 5px;
  box-sizing: border-box; /* 新增:避免padding增加总宽度 */

  .block {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    // flex-wrap: wrap;
    background: linear-gradient(to top left, rgba(5, 30, 61, 0.62), #0D3F7E9D);
    border-radius: 5px;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);
    // margin: 0px 5px;
    margin: 0; /* 移除原margin,用gap控制间距 */
  }
  .chart-wrapper {
    flex: 1;
    // padding: 0.1rem;
    box-sizing: border-box; /* 关键:padding不增加实际高度 */
  }
  .title {
    text-shadow: 0 0 5px #d1ffff;
    color: white;
    font-weight: bold;
    padding-top: 4px;
    padding-bottom: 4px;
    padding-left: 16px;
    font-family: 黑体;
    letter-spacing: 1px;
  }
}
.block-base {
  background: linear-gradient(to top left, rgba(5, 30, 61, 0.62), #0D3F7E9D);
  border-radius: 5px;
  box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
  // border-color: rgba(0, 0, 0, .05);
}

.ellipsis {
  white-space: nowrap;      /* 防止文本换行 */
  overflow: hidden;         /* 隐藏溢出的文本 */
  text-overflow: ellipsis;  /* 用省略号表示溢出的文本 */
}
.ellipsis-multiline {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; /* 限制显示的行数 */
  overflow: hidden;
  text-overflow: ellipsis;
}

    .info-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
      color: #fff;
      padding: 0.05rem 0.02rem;
      img {
        width: 0.14rem;
        height: 0.14rem;
      }
    }

    .info-item:last-child {
      border-bottom: none;
    }

    .info-icon {
      display: flex;
      align-items: center;
      // opacity: 0.8;
      white-space: nowrap;
      margin-right: 0.1rem;
    }

    .info-text {
      flex: 1;
      font-size: 0.1rem;
      text-align: left;
      white-space: nowrap;
    }

    .info-value {
      font-weight: 600;
      font-size: 0.125rem;
    }
</style>