<template>
  <div class="dustMonitor">
    <customHeader>束管日报表</customHeader>
    <a-table :columns="columns" :data-source="tableData" size="small" :scroll="{ y: 500 }" class="tableW"> </a-table>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { columns } from './bundle-table.data';
import { getBundleInfoList } from './bundle-table.api';
import customHeader from '/@/components/vent/customHeader.vue';

let tableData = ref<any[]>([]);

//获取粉尘监测结果数据
async function getTableList() {
  let res = await getBundleInfoList({ type: 'bundle' });
  console.log('API 返回的数据:', res); // 打印 API 返回的完整数据
  if (res && res.result && typeof res.result.content === 'string') {
    try {
      let content = JSON.parse(res.result.content);
      if (Array.isArray(content)) {
        content.forEach((element) => {
          element.zygx = '生产\n检修'; // 新增 zygx 字段
        });
        tableData.value = content;
      } else {
        console.error('解析后的 content 不是一个数组:', content);
      }
    } catch (error) {
      console.error('解析 content 字符串时出错:', error);
    }
  }
}

onMounted(() => {
  getTableList();
});
</script>

<style lang="less" scoped>
@import '/@/design/theme.less';

.dustMonitor {
  width: 100%;
  height: 100%;
  padding: 80px 10px 15px 10px;
  box-sizing: border-box;
  position: relative;
}

:deep(.zxm-table-thead > tr > th:last-child) {
  border-right: 1px solid #91e9fe !important;
}

:deep(.zxm-picker-input > input) {
  color: #fff;
}

:deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  border: 1px solid var(--vent-form-item-border) !important;
  background-color: #ffffff00 !important;
}

:deep(.zxm-select-selection-item) {
  color: #fff !important;
}
</style>
