Newer
Older
smartwell_front / src / views / home / pipeline / components / detailInfoDialog.vue
<!--
  Description: 场站管理-信息窗体
  Author: 李亚光
  Date: 2024-07-18
 -->
<script lang="ts" setup name="infoWindow">
import { getPipelineDetail } from '@/api/home/pipeline/pipeline'
const dialogFormVisible = ref(false)
const overlay = ref()
const infoWindow = ref()
// 基本数据
const baseInfo = ref({
  deviceTypeName: '', // 场站编号
  deviceCode: '', // 场站名称
})
const loading = ref(true)
// 详细信息
const detailInfo = ref<{ [key: string]: string }>({})
// 描述列表数据
const descriptionsList = ref([
  {
    text: '安装位号',
    value: 'tagNumber',
    align: 'center',
  },
  {
    text: '设备编号',
    value: 'devcode',
    align: 'center',
  },
  {
    text: '设备类型',
    value: 'typeName',
    align: 'center',
  },
  {
    text: '设备型号',
    value: 'modelName',
    align: 'center',
  },
  {
    text: '管理单位',
    value: 'deptName',
    align: 'center',
  },
  {
    text: '详细位置',
    value: 'position',
    align: 'center',
  },
  {
    text: '管理方式',
    value: 'manageType',
    align: 'center',
  },
  {
    text: '压力级制',
    value: 'pressType',
    align: 'center',
  },
  {
    text: '建设年代',
    value: 'constructEra',
    align: 'center',
  },
  {
    text: '管径(mm)',
    value: 'pipeDiameter',
    align: 'center',
  },
  {
    text: '设备运行状态',
    value: 'status',
    align: 'center',
  },
  {
    text: '关联管线',
    value: 'pipeCode',
    align: 'center',
  },
])
// 初始化
const initDialog = (e: any) => {
  console.log(e, '信息窗体接收的数据')
  overlay.value = e.overlay
  infoWindow.value = e.infoWindow
  baseInfo.value = e.info.row
  dialogFormVisible.value = true
  if (e.map) {
    e.map.setZoom(15)
  }
  // 获取详细信息
  detailInfo.value = e.info.row
  loading.value = true
  getPipelineDetail({
    id: e.info.row.id,
    devcode: e.info.row.deviceCode,
  }).then((res) => {
    loading.value = false
    detailInfo.value = res.data
  }).catch(() => {
    loading.value = false
  })
}

// 关闭
const close = () => {
  infoWindow.value?.close()
}

defineExpose({ initDialog, close })
</script>

<template>
  <div v-show="dialogFormVisible" class="container clearfix" @mouseleave="() => { }">
    <div class="header">
      <el-tooltip
        class="box-item" effect="dark" :content="`${baseInfo.deviceTypeName} | ${baseInfo.deviceCode}`"
        placement="top"
      >
        <span class="title">{{ baseInfo.deviceTypeName }} | {{ baseInfo.deviceCode }}</span>
      </el-tooltip>
      <span class="close" @click="close">x</span>
    </div>
    <div class="body">
      <el-descriptions v-loading="loading" :column="2" border>
        <el-descriptions-item v-for="item in descriptionsList" :key="item.text" :align="item.align">
          <template #label>
            <span class="label">
              {{ item.text }}
            </span>
          </template>
          {{ detailInfo[item.value] || '' }}
        </el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>

<style lang="scss" scoped>
::v-deep(.el-descriptions__label) {
  width: 20%;
}

::v-deep(.el-descriptions__cell) {
  padding: 0 !important;
}

.container {
  // width: 500px;
  // padding: 0 10px;
  background: rgba($color: #feffff, $alpha: 95%);
  border: 1.5px solid #79b5e6;
  position: relative;

  .header {
    float: right;
    background-color: #ccc;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 2px 10px;
    align-items: center;

    .title {
      font-weight: 700;
      display: inline-block;
      width: 90%;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .close {
      color: #4875a0;
      font-size: 22px;
      font-weight: 700;
      text-align: right;
      padding-right: 10px;

      &:hover {
        cursor: pointer;
        color: #658eb4;
      }
    }
  }

  .body {
    // padding: 10px;
    // display: flex;
    // flex-wrap: wrap;
    width: 100%;

    .name {
      width: 30%;
    }

    .value {
      width: 70%;
    }
  }
}

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}
</style>