<template>
  <div class="window-container">
    <div class="info">
      <div class="item-header">
        <!-- {{ datainfo.dwmc }} -->
      </div>
      <div
        class="item"
        v-for="(item, index) in detailDataArr"
        :key="index"
        v-show="item.name || item.value"
      >
        <div class="item-title">
          {{ item.name != '' && item.name != null && item.name != 'null' ? item.name : '暂无属性' }}
        </div>
        <div class="item-value">
          {{
            item.value != '' && item.value != null && item.value != 'null' ? item.value : '无数据'
          }}
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
  import { ref, watch } from 'vue';
  const emits = defineEmits(['closeAttributeWindow']);
  const props = defineProps({
    showAttributeFeature: { type: Object },
    initNameList: { type: Object },
  });

  // 详细信息
  const detailDataArr: any = ref([]);

  watch(
    () => props.showAttributeFeature,
    () => {
      setDetailDataArr();
    },
    {
      immediate: true,
    },
  );

  // 设置属性
  function setDetailDataArr() {
    let detailData = props.showAttributeFeature;
    detailDataArr.value = [];
    for (let key in detailData) {
      if (!['id'].includes(key)) {
        let detail: any = {};
        let enObj = props.initNameList?.find((item) => {
          return item.itemValue.toLowerCase() == key.toLowerCase();
        });
        if (enObj) {
          if (enObj.enabledMark == 1) {
            detail.name = enObj.itemName ? enObj.itemName : '';
          } else if (enObj.enabledMark == 0) {
            // 停用
            detail.name = '暂无属性名' + '（' + enObj.itemValue + '）';
          }
        } else {
          detail.name = '暂无属性名' + '（' + key + '）';
        }
        detail.value = detailData[key];
        detailDataArr.value.push(detail);
      }
    }
  }
</script>
<style lang="less" scoped>
  .window-container {
    width: 100%;
    height: 100%;
  }

  .info {
    width: 100%;
    padding: 12px;
    box-sizing: border-box;
    height: 500px;
    overflow: auto;
    // background: rgba(6, 16, 64, 0.7);
  }

  .item-header {
    width: 100%;
    // height: 30px;
    // background: rgba(0, 157, 255, 0.4);
    // line-height: 30px;
    // color: #fff;
    // text-indent: 8px;
    border-bottom: 1px solid #088eda;
  }
  .item {
    width: calc(100% - 2px);
    height: 30px;
    line-height: 30px;
    // color: #fff;
    border-bottom: 1px solid #088eda;
    border-left: 1px solid #088eda;
    text-indent: 6px;
  }
  .item .item-title {
    width: 40%;
    float: left;
    font-size: 12px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
  .item .item-value {
    width: calc(60%);
    float: left;
    font-size: 12px;
    border-left: 1px solid #088eda;
    border-right: 1px solid #088eda;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
</style>
