<template>
  <div style="flex: 1">
    <Container name="重点工作/三大攻坚战" icon="cockpitItemIcon" size="bottomBasic" topSize="basic">
      <!-- 1. 移除 .kpi-content 的固定高度，改为自适应 -->
      <div class="kpi-content"
        style="padding: 14px 16px; display: flex;flex-direction: column; width: 100%;height: 280px;">
        <div class="bottom"
          style="display: flex;padding: 14px 16px;flex-direction: column; background-color: rgba(249, 252, 255, 1);">
          <div class="legend-group" style="justify-content: end;">
            <div class="legend-item">
              <span class="legend-dot done"></span>
              <span class="legend-text">已完成</span>
            </div>
            <div class="legend-item">
              <span class="legend-dot pending"></span>
              <span class="legend-text">未完成</span>
            </div>
          </div>
          <base-table style="height: 180px;" :page="1" :limit="10" :show-index="true" :beilv="1" :tableConfig="tableProps"
            :table-data="maintenanceTasks" />

        </div>
      </div>
    </Container>
  </div>
</template>
<script>
import Container from './container.vue'
// import * as echarts from 'echarts'
import topItem from './top-product-item.vue'
import coreBottomBar from './productBottomBar.vue'
import baseTable from './baseTable.vue'
import finishDiv from './finishDiv.vue'


export default {
  name: 'ProductionStatus',
  components: { Container, topItem, coreBottomBar, baseTable },
  // mixins: [resize],
  props: {
    leftEqInfoData: {  // 接收父组件传递的设备数据数组
      type: Array,
      default: () => []  // 默认空数组，避免报错
    },
    productionOverviewVo: { // 恢复生产概览数据（原代码注释了，需根据实际需求保留）
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      maintenanceTasks: [
        {
          id: 1, eqName: '应收账款（亿元）', taskName: '10', monthlyActual: '12.45', accumulated: '12.45', status: 'done' }, // 已完成-绿色

        { id: 2, eqName: '存货/亿元', taskName: '0.57', monthlyActual: '0.72', accumulated: '0.72', status: 'pending' }, // 未完成-橙色
        { id: 3, eqName: '三年以上应收款/亿元', taskName: '0.57', monthlyActual: '0.72', accumulated: '0.72', status: 'done' },
        { id: 4, eqName: '非经营性资产处置到账金额/万元', taskName: '11000', monthlyActual: '0', accumulated: '0', status: 'pending' },
        { id: 1, eqName: '研发经费入强度/%', taskName: '3.07', monthlyActual: '2.37', accumulated: '3.14', status: 'done' }, // 已完成-绿色
        { id: 4, eqName: '研发经费投入/万元', taskName: '19500', monthlyActual: '1084', accumulated: '2797', status: 'pending' },
        { id: 4, eqName: '经营性现金流/万元', taskName: '2898', monthlyActual: '13472', accumulated: '-30490', status: 'pending' },

        // { id: 2, eqName: '螺杆挤出', taskName: '例行维护', },

      ],
      tableProps: [
        // { prop: 'id', label: '序号', width: 50, align: 'center' },
        { prop: 'eqName', label: '攻坚指标', align: 'center' },
        { prop: 'taskName', label: '攻坚目标', align: 'center' },
        { prop: 'taskName', label: '当月实际', align: 'center' },
        { prop: 'taskName', label: '累计', align: 'center', subcomponent: finishDiv },

      ]
    }
  },
  watch: {
    productionOverviewVo: {
      handler(newValue, oldValue) {
        this.updateChart()
      },
      deep: true // 若对象内属性变化需触发，需加 deep: true
    }
  },
  mounted() {
    // 初始化图表（若需展示图表，需在模板中添加对应 DOM）
    // this.$nextTick(() => this.updateChart())
  },
  beforeDestroy() {
    // 销毁图表，避免内存泄漏
  },
  methods: {
  }
}
</script>

<style lang='scss' scoped>
.legend-group {
  display: flex;
  align-items: center;
  gap: 10px;
  /* 两个图例项之间的间距 */
}

/* 单个图例项 */
.legend-item {
  display: flex;
  align-items: center;
}

/* 图例小方块 */
.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border-radius: 2px;
  /* 可选：轻微圆角 */
}

/* 已完成（绿色） */
.legend-dot.done {
  background-color: #4CAF50;
  /* 绿色，可根据需求调整色值 */
}

/* 未完成（橙色） */
.legend-dot.pending {
  background-color: #FF9800;
  /* 橙色，可根据需求调整色值 */
}

/* 图例文字 */
.legend-text {
  font-size: 14px;
  color: #333;
}

</style>
