<!-- 基础信息 -->
<template>
  <div>
    <div class="cont-table">
      <el-table
        :data="dingzhiData"
        stripe
        style="width: 100%"
        :cell-style="{ color: '#000',cursor:'pointer' }"
        @row-click="svSendRowClick3"
        :highlight-current-row="true"
        ref="myTable5"
      >
        <el-table-column type="index" label="序号" width="80" />
        <el-table-column prop="accesspoint_name" label="访问点" width="180" />
        <el-table-column label="数据集名称">
          <template #default="scope">
            {{ `${scope.row.ld_desc}(${scope.row.ld_name})` }}
          </template>
        </el-table-column>
        <el-table-column prop="dataset_desc" label="数据集描述" />
      </el-table>
      <div class="title">
        定值条目列表详情(共<span v-if="gooseList">{{ gooseList.length }}</span
        >条)
      </div>
      <el-table
        :data="dingzhiDataChild"
        style="width: 100%"
        stripe
        :cell-style="{ color: '#000' }"
      >
        <el-table-column type="index" label="序号" width="80" />
        <el-table-column prop="doi_desc" label="条目描述" width="180" />
        <el-table-column label="最大值" prop="da_maxval"/>
        <el-table-column label="最小值" prop="da_minval"/>
        <el-table-column prop="da_units" label="单位" />
        <el-table-column prop="da_stepsize" label="步长" />
        <el-table-column prop="da_datatype" label="数据类型" />
        <el-table-column prop="short_addr" label="内部地址" />
      </el-table>
    </div>
  </div>
</template>
<script setup>
import { onMounted, watch, ref, nextTick, defineEmits, inject } from "vue";
import {
  getDingzhis
} from "@/api/iedNetwork";
const props = defineProps({
  checkData: {
    type: Object,
    default: () => {},
  },
  isPhoto: {
    type: String,
    default: "",
  },
  svInfo: {
    type: Array,
    default: [],
  },
});
const scdIdValue = inject("scdId");
const dingzhiData = ref(null);
const dingzhiDataChild = ref(null);
const myTable5 = ref(null);
const getDingzhisList = async () => {
  const dingRes= await getDingzhis({
    scd_id: scdIdValue,
    ied_name: props.checkData.ied_name,
  })
  if(dingRes.data.length>0){
    dingzhiData.value = dingRes.data;
    dingzhiDataChild.value = dingRes.data[0].list
  }

  myTable5.value.setCurrentRow(dingzhiData.value[0]);
}
const svSendRowClick3 = (row, column) => {
  dingzhiDataChild.value = row.list
}
watch(
  () => props.checkData,
  (newValue) => {
    dingzhiData.value = [];
    dingzhiDataChild.value = [];
    if (newValue != null) {
      getDingzhisList()
    }
  }
);
onMounted(() => {
  getDingzhisList()
});
</script>
<style scoped lang="scss">
.cont-table {
  height: 65vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
:deep(.el-table) {
  flex-basis: 45%;
}
.title {
  margin: 16px;
  color: #51637f;
}
</style>