<template>
  <div class="collapseStyle">
    <el-scrollbar style="border: 1px solid #ebeef5" :height="tableHeight">
      <el-collapse accordion v-model="activeNames">
        <el-collapse-item v-for="(item, index) in materialsData" :key="index" :title="item.opName" :name="index">
          <el-table :data="item.children"  border>
            <el-table-column prop="label" label="记录项名称" />
            <el-table-column prop="inputValue" label="记录项值" />
            <el-table-column prop="created" label="录入时间" />
          </el-table>
        </el-collapse-item>
      </el-collapse>
      <Empty v-if="materialsData.length < 1" />
    </el-scrollbar>
    <Pagination position="right" :page="page" :limit="limit" :total="total" @pagination="getPagination" />
  </div>
</template>

<script lang="ts" setup>
import { useProcessStore } from "@/store";
import { getRecordInfo } from "@/api/process/traceability";
const store = useProcessStore();
const page = ref(1);
const activeNames = ref([0]);
const limit = ref(10);
const total = ref(10);
const materialsData = ref([]);
const tableHeight = ref(null);
const getPagination = async () => {
  const { data } = await getRecordInfo({
    pageNo: page.value,
    pageSize: limit.value,
    seqNo: store.useSeqNo,
    workOrderCode: store.odersData.workOrderCode,
  });
  total.value = data.totalCount;
  materialsData.value = data.records;
};
//动态控制高度
const setTableHeight = () => {
  tableHeight.value =
    Number(document.getElementById("tabBox").offsetHeight) - 70;
};
onMounted(() => {
  getPagination();
  setTableHeight();
});
</script>

<style lang="scss" scoped>

</style>
