<template>

  <div class="backinfo-container">
    <div class="headClass" style="">
      <h3>群体成员画像</h3>
    </div>
    <div style="display: flex;">
      <div  style="width: 50%;"><PieChart :chartData="ywlbtj" title="业务类型"/></div>
      <div style="width: 50%;"><BarChart :chartData="gkjbtj" title="管控级别分布"/></div>

    </div>
    <div style="display: flex;">
      <div style="width: 50%;"><PieChart :chartData="qytj" title="区域分布"/></div>
      <div  style="width: 50%;"><BarChart :chartData="zyfbtj" title="管控级别分布"/></div>


    </div>
    <div  style="display: flex;">
      <div style="width: 50%;"><LineChart :chartData="nlfbtj" title="年龄分布"/></div>
      <div style="width: 50%;"><PieChart :chartData="whcdtj" title="文化程度分布"/></div></div>
  </div>
</template>

<script setup>
import { ref ,watch} from "vue";
import { zdryGkjbtj ,zdryYwlbtj,zdryQytj,zdryNldtj,zdryZclbtj,zdryWhcdtj,tbGsxtZdqtSave} from '@/api/qt.js'
import BarChart from "../component/BarChart.vue"
import PieChart from "../component/PieChart.vue"
import LineChart from "../component/LineChart.vue"
const props = defineProps({
  dataList: {
    type: Object,
    default: () => { },
  }, disabled: {
    type: Boolean,
    default: false
  },
  showBut: {
    type: Boolean,
    default: false
  },
})
const listData=ref()
watch(()=>props.dataList,(val)=>{
  if (val) {
    listData.value = val
    funAll()
  }
}, { deep: true })
const ywlbtj=ref()
const gkjbtj = ref({
  xAxisData: [],
  seriesData:[]
})
const qytj = ref()
const zyfbtj = ref({
  xAxisData: [],
  seriesData:[]
})
const nlfbtj = ref({
  xAxisData: [],
  seriesData:[]
})
const whcdtj=ref()
const funAll = () => {
  const params = {
    qtid: listData.value.id
  }
  getzdryYwlbtj(params)
  getzdryGkjbtj(params)
  getzdryQytj(params)
  getzdryZclbtj(params)
  getzdryNldtj(params)
  getzdryWhcdtj(params)
}
// 业务类型
const getzdryYwlbtj = (val) => {
  zdryYwlbtj(val).then((res) => {
    ywlbtj.value = {
      seriesData: res.map(item => {
      return {
        name: item.mc,
        value: item.sl
      }
    })
    }
  }).catch((err) => {

  });
}
// 管控级别分布
const getzdryGkjbtj = (val) => {
  zdryGkjbtj(val).then(res => {
    gkjbtj.value.xAxisData=res.map(item=>item.mc)
    gkjbtj.value.seriesData = [{
      name: '管控级别',
      data: res.map(item => item.sl),
      color: '#409EFF'
    }]
  })
}
// 区域分布
const getzdryQytj = (val) => {
  zdryQytj(val).then(res => {
    qytj.value = {
      seriesData: res.map(item => {
        return {
          name: item.ssbm,
          value: item.number
        }
      })
    }
  })
}
// 职业分布
const getzdryZclbtj = (val) => {
  zdryZclbtj(val).then(res => {
    zyfbtj.value.xAxisData = res.map(item => item.mc)
    zyfbtj.value.seriesData = [{
      name: '职业分布',
      data: res.map(item => item.sl),
      color: '#409EFF'
    }]
  })
}
// 年龄分布
const getzdryNldtj = (val) => {
  zdryNldtj(val).then(res => {
    console.log(res);
    nlfbtj.value.xAxisData = res.map(item => item.mc)
    nlfbtj.value.seriesData = [{
      name: '年龄分布',
      data: res.map(item => item.sl),
      color: '#409EFF'
    }]
  })
}
// 文化程度统计
const getzdryWhcdtj = (val) => {
  zdryWhcdtj(val).then(res => {
    whcdtj.value = {
      seriesData: res.map(item => {
        return {
          name: item.mc,
          value: item.sl
        }
      })
    }
  })
}
</script>

<style lang="scss" scoped>
@import "~@/assets/css/layout.scss";
@import "~@/assets/css/element-plus.scss";

.backinfo-container {
  padding: 10px;
}

.background-info-input {
  width: 100%;
  margin-bottom: 15px;
}

.file-attachment-section {
  margin-top: 15px;
}

.section-title {
  font-size: 14px;
  font-weight: 500;
  color: #303133;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid #ebeef5;
}

.file-list-container {
  max-height: 100px;
  overflow-y: auto;
  border: 1px solid #ebeef5;
  border-radius: 4px;
  background-color: #ffffff;
  margin-bottom: 10px;
}

/* 自定义滚动条样式 */
.file-list-container::-webkit-scrollbar {
  width: 6px;
}

.file-list-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.file-list-container::-webkit-scrollbar-thumb {
  background: #c0c4cc;
  border-radius: 3px;
}

.file-list-container::-webkit-scrollbar-thumb:hover {
  background: #909399;
}

.empty-file-list {
  padding: 20px;
  text-align: center;
  color: #909399;
  font-size: 12px;
}

.file-list {
  padding: 5px;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 2px;
  background-color: #f8f9fa;
  border-radius: 4px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.file-item:hover {
  background-color: #e6f7ff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.file-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
}

.file-name {
  flex: 1;
  font-size: 12px;
  color: #303133;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 11px;
  color: #909399;
  min-width: 60px;
}

.file-time {
  font-size: 11px;
  color: #909399;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: 10px;
}

.file-actions .el-button {
  padding: 0 5px;
  margin: 0;
  color: #606266;
  transition: color 0.3s ease;
}

.file-actions .el-button:hover {
  color: #409eff;
}

.delete-btn:hover {
  color: #f56c6c !important;
}

.upload-btn-container {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.headClass {
  font-size: 18px;
  font-weight: 600;
  color: #303133;
  margin: 0 0 10px 0;
  padding-bottom: 10px;
  border-bottom: 2px solid #409eff;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.headClass::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 60px;
  height: 2px;
  background-color: #409eff;
}

h3 {
  margin: 0;
}
</style>
