Newer
Older
smartwell_front / src / views / home / pipeline / components / detailInfoDialog.vue
lyg on 13 Nov 8 KB 底图和需求修改
<!--
  Description: 场站管理-信息窗体
  Author: 李亚光
  Date: 2024-07-18
 -->
<script lang="ts" setup name="infoWindow">
import { getPipelineDetail } from '@/api/home/pipeline/pipeline'
import { getGasData } from '@/api/home/well/well'
import gasDialog from '@/views/home/well/components/gasDialog.vue'
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: 'deptName',
    align: 'center',
  },
  {
    text: '厂商',
    value: 'manufactureName',
    align: 'center',
  },
  {
    text: '压力级制',
    value: 'pressType',
    align: 'center',
  },
  {
    text: '管径(mm)',
    value: 'pipeDiameter',
    align: 'center',
  },
  {
    text: '材质',
    value: 'material',
    align: 'center',
  },
  {
    text: '建设年代',
    value: 'constructEra',
    align: 'center',
  },
  {
    text: '详细位置',
    value: 'position',
    align: 'center',
  },
  {
    text: '',
    value: '',
    align: 'center',
  },
  {
    text: '安装位号',
    value: 'tagNumber',
    align: 'center',
  },
  {
    text: '负责人',
    value: '',
    align: 'center',
  },
  {
    text: '在用状态',
    value: 'onState',
    align: 'center',
  },
  {
    text: '监控状态',
    value: 'monitorState',
    align: 'center',
  },
  {
    text: '设备运行状态',
    value: 'status',
    align: 'center',
  },
  {
    text: '',
    value: '',
    align: 'center',
  },
  // {
  //   text: '设备编号',
  //   value: 'devcode',
  //   align: 'center',
  // },
  // {
  //   text: '设备类型',
  //   value: 'typeName',
  //   align: 'center',
  // },
  // {
  //   text: '设备型号',
  //   value: 'modelName',
  //   align: 'center',
  // },
  // {
  //   text: '管理方式',
  //   value: 'manageType',
  //   align: 'center',
  // },

])
// 初始化
const gasData = ref<any[]>([])
const rowData = ref()
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
  rowData.value = e.info.row
  loading.value = true
  if (rowData.value.deviceTypeName.includes('燃气智能监测终端')) {
    if (descriptionsList.value[descriptionsList.value.length - 1].text === '燃气浓度') { return }
    descriptionsList.value.push({
      text: '燃气浓度',
      value: 'manageType',
      align: 'center',
    })
  }
  else {
    descriptionsList.value = descriptionsList.value.filter((item: any) => item.text !== '燃气浓度')
  }
  console.log(e.info.row, 'e.info.row')
  getPipelineDetail({
    id: e.info.row.id,
    devcode: e.info.row.deviceCode,
  }).then((res) => {
    loading.value = false
    detailInfo.value = res.data
    if (!(rowData.value.deviceTypeName.includes('燃气智能监测终端'))) {
      return
    }
    gasData.value = []
    // 获取燃气浓度
    getGasData({
      wellId: rowData.value.id,
      devCode: rowData.value.deviceCode,
    }).then((res) => {
      // console.log(res.data, '123321')
      for (const i in res.data) {
        if (i.includes('燃气')) {
          // console.log(i, 'iiiiiiiii')
          gasData.value.push({
            name: i,
            devcode: res.data[i].devcode,
            state: res.data[i].state,
            value: res.data[i].value,
            text: i.includes('燃气') ? '燃气浓度' : i.includes('液位') ? '液位状态' : i.includes('井盖') ? '井盖状态' : '',
            unit: i.includes('燃气') ? '%LEL' : '',
            stateName: res.data[i].state === '1' ? '正常' : res.data[i].state === '0' ? '离线' : res.data[i].state === '2' ? '报警' : '',
          })
        }
      }
    })
  }).catch(() => {
    loading.value = false
  })
}

// 关闭
const close = () => {
  infoWindow.value?.close()
}
// 详情
const $router = useRouter()
const goDetail = () => {
  $router.push({
    name: 'PipelineMonitorDetail',
    query: {
      id: rowData.value.id,
      deviceCode: rowData.value.deviceCode,
      typeName: rowData.value.deviceTypeName,
    },
  })
}
// 燃气数据-更多
const gasRef = ref()
const more = () => {
  gasRef.value.initDialog(rowData.value.id)
}
defineExpose({ initDialog, close })
</script>

<template>
  <div v-show="dialogFormVisible" class="container clearfix" @mouseleave="() => { }">
    <gas-dialog ref="gasRef" />
    <div class="header">
      <div style="display: flex;align-items: center;">
        <el-tooltip
          class="box-item" effect="dark" :content="`${baseInfo.deviceCode} | ${baseInfo.deviceTypeName}`"
          placement="top"
        >
          <span class="title">{{ baseInfo.deviceCode }} | {{ baseInfo.deviceTypeName }} </span>
        </el-tooltip>
        <el-button style="margin-left: 10px;" size="small" @click="goDetail">
          详情
        </el-button>
      </div>
      <span class="close" @click="close">x</span>
    </div>
    <div class="body">
      <div class="descriptions">
        <div v-for="item in descriptionsList" :key="item.text" class="descriptions-item">
          <div class="label">
            {{ item.text }}
          </div>
          <div v-if="item.text !== '燃气浓度'" class="value" :title="detailInfo[item.value] || ''">
            {{ detailInfo[item.value] || '' }}
          </div>

          <div v-if="item.text === '燃气浓度' && gasData.length" class="value" style="width: 80%;">
            <div v-for="item in gasData" v-show="item.text" :key="item.name">
              {{ item.text }} :
              <span :class="`${item.state === '1' ? '' : 'error'}`"> {{ item.name.includes('燃气') || item.name.includes('哨兵') ? item.value
                : item.stateName }}</span>
              <span v-if="item.name.includes('燃气')" :class="`${item.state === '1' ? '' : 'error'}`"> {{ item.unit
              }}</span>
              <el-button v-if="item.name.includes('燃气')" size="small" style="margin-left: 10px;" @click="more">
                更多
              </el-button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.error {
  color: red !important;
}

.container {
  width: 600px;
  background: #fff;
  position: relative;
  border-radius: 8px;
  border: 1px solid #e4e7ed;
  overflow: hidden;
  box-shadow: 0 0 12px rgb(0 0 0 / 12%);

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

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

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

      &:hover {
        cursor: pointer;
        color: #ccc;
      }
    }
  }

  .body {
    width: 100%;
    padding-left: 10px;

    .descriptions {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      box-sizing: border-box;
      padding: 6px 0;

      .descriptions-item {
        width: 48%;
        margin: 4px 5px;
        box-sizing: border-box;
        display: flex;
        padding: 0 3px;

        .label-no {
          width: 28% !important;
        }

        .label {
          width: 34%;
          box-sizing: border-box;
          padding: 0 1px;
          font-size: 15px;
          text-align: justify;
          text-align-last: justify;
        }

        .value {
          padding-left: 5px;
          width: 68%;
          box-sizing: border-box;
          white-space: nowrap;
          font-size: 14px;
          color: #a39f9f;

          /* 确保文本在一行内显示 */
          overflow: hidden;

          /* 超出容器部分隐藏 */
          text-overflow: ellipsis;

          /* 文字溢出显示省略号 */
        }
      }
    }
  }
}
</style>