Newer
Older
sensorHubPlusFront / src / layouts / components / Tools / alarmDialog.vue
liyaguang 8 days ago 8 KB 系统基础修改
<script lang="ts" setup name="EditArea">
import { alarmValue } from '@/views/home/alarm/current/components/dict'
const dialogFormVisible = ref(false) // 对话框是否显示
const dataForm = ref({
}) // 表单

// 重置表单

const className = ref('')
const info = ref<any>({})
const resetForm = () => {
  info.value = {
  }
}
const initDialog = (row: any) => {
  dialogFormVisible.value = true
  const grade = `grade-${row.alarmLevel === '报警' || row.alarmLevel === '一级' ? '1' : row.alarmLevel === '预警' || row.alarmLevel === '二级' ? '2'  : 'other'}`
  className.value = grade
  resetForm()
  info.value = JSON.parse(JSON.stringify(row))
  if (!info.value.alarmType.includes('浓度')) {
    // console.log(info.value.value, 'info.value.value')
    info.value.value = alarmValue[info.value.value] ? alarmValue[info.value.value] : '其他'
  }
  else {
    info.value.value = `${info.value.value}${info.value.typeName.includes('燃气') || info.value.typeName.includes('哨兵') ? '%LEL' : ''}`
  }
  // const row = {
  //   alarmNoteMethod: '1', // 消息提醒 1:弹窗,2:消息提醒
  //   isSound: '1', // 报警音效,1:开,0:关
  //   isSend: '1', // 报警推送,1:开,0:关
  //   isText: '1', // 报警短息,1:开,0:关
  //   alarmType: '浓度超限',
  //   tagNumber: 'NX5702',
  //   alarmTime: '2024-09-09',
  //   value: '20',
  //   typeName: '燃气智能终端',
  //   alarmLevel: '一级',
  // }
}
// 关闭
const close = () => {
  dialogFormVisible.value = false
}
// 关闭声音
const { proxy } = getCurrentInstance() as any
const closeSound = () => {
  proxy.pauseAudio()
  localStorage.setItem('eventAudio', 'pause')
}
// 查看
const $router = useRouter()
const detail = () => {
  dialogFormVisible.value = false
  $router.push({
    name: 'AlarmCurrent',
    query: {
      row: JSON.stringify({ ...info.value, id: info.value.alarmIds, type: 'alarm-dialog' }),
      type: 'alarm-dialog'
    },
  })
}
defineExpose({
  initDialog,
})
</script>

<template>
  <el-dialog v-model="dialogFormVisible" title="" append-to-body class="warning-dialog" :show-close="false"
    width="600px"
    :class="`${className.includes('2') ? 'grade-2' : className.includes('3') ? 'grade-3' : className.includes('1') ? 'grade-1' : 'grade-other'}`"
    :close-on-click-modal="false">
    <div class="title">
      {{ info.alarmType }}
    </div>
    <div class="container-dialog">
      <el-row :gutter="24" style="margin-top: 30px;">
        <el-col :span="4" style="text-align: justify;text-align-last: justify;display: flex;align-items: center;">
          报警类型
        </el-col>
        <el-col :span="8" class="value" :title="info.alarmType">
          {{ info.alarmType }}
        </el-col>
        <el-col :span="4" style="text-align: justify;text-align-last: justify;display: flex;align-items: center;">
          设备类型
        </el-col>
        <el-col :span="8" class="value" :title="info.typeName">
          {{ info.typeName }}
        </el-col>
      </el-row>
      <el-row :gutter="24" style="margin-top: 15px;">
        <el-col :span="4" style="text-align: justify;text-align-last: justify;display: flex;align-items: center;">
          闸井位号
        </el-col>
        <el-col :span="8" class="value" :title="info.tagNumber">
          {{ info.tagNumber }}
        </el-col>
        <el-col :span="4" style="text-align: justify;text-align-last: justify;display: flex;align-items: center;">
          闸井名称
        </el-col>
        <el-col :span="8" class="value" :title="info.tagName">
          {{ info.tagName }}
        </el-col>
      </el-row>
      <el-row :gutter="24" style="margin-top: 15px;">
        <el-col :span="4" style="text-align: justify;text-align-last: justify;display: flex;align-items: center;">
          报警等级
        </el-col>
        <el-col :span="8" class="value" :title="info.alarmLevel">
          {{ info.alarmLevel }}
        </el-col>
        <el-col :span="4" style="text-align: justify;text-align-last: justify;display: flex;align-items: center;">
          <!-- 报警值 -->
          {{ info.alarmType.includes('浓度') ? '报警值' : '报警原因' }}
        </el-col>
        <el-col :span="8" style="font-size: 20px;font-weight: 700;display: flex;align-items: center;" class="value" :title="info.value" >
          {{ info.value }}
        </el-col>
      </el-row>
      <el-row :gutter="24" style="margin-top: 15px;">
        <el-col :span="4" style="text-align: justify;text-align-last: justify;display: flex;align-items: center;">
          报警时间
        </el-col>
        <el-col :span="20" class="value" :title="info.alarmTime">
          {{ info.alarmTime }}
          <span style="opacity: 0;">占位</span>
        </el-col>
      </el-row>
      <!-- <div style="display: flex;justify-content: space-between;">
        <div class="content">
          <div class="name">
            报警类型:
          </div>
          <div class="value">
            {{ info.alarmType }}
          </div>
        </div>
        <div class="content">
          <div class="name">
            设备类型:
          </div>
          <div class="value">
            {{ info.typeName }}
          </div>
        </div>
      </div>
      <div style="display: flex;justify-content: space-between;">
        <div class="content">
          <div class="name">
            闸井位号:
          </div>
          <div class="value">
            {{ info.tagNumber }}
          </div>
        </div>
        <div class="content">
          <div class="name">
            闸井名称:
          </div>
          <div class="value">
            {{ info.tagNumber }}
          </div>
        </div>
      </div>
      <div class="content">
        <div class="name">
          报警等级:
        </div>
        <div class="value">
          {{ info.alarmLevel }}
        </div>
      </div>
      <div class="content">
        <div class="name">
          报警值:
        </div>
        <div class="value">
          {{ info.value }}
          {{ info.typeName.includes('燃气') ? '%vol' : '' }}
        </div>
      </div>
      <div class="content">
        <div class="name">
          报警时间:
        </div>
        <div class="value">
          {{ info.alarmTime }}
        </div>
      </div> -->
    </div>
    <template #footer>
      <div class="dialog-footer">
        <div v-if="proxy.hasPerm('/alarm/current')" class="btn primary" @click="detail">
          查看
        </div>
        <div v-if="info.isSound === '1'" class="btn normal" @click="closeSound">
          关闭声音
        </div>
        <div class="btn info" @click="close">
          关闭
        </div>
        <!-- <el-button :loading="btnLoading" type="primary" @click="saveData">
          保存
        </el-button>
        <el-button @click="cancel">
          取消
        </el-button> -->
      </div>
    </template>
  </el-dialog>
</template>

<!-- <style lang="scss" scoped></style> -->

<style>
.warning-dialog {
  background-color: #0000;
  background-image: url("@/assets/global_images/warningDialog_one.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  box-shadow: none;
}

.grade-2 {
  background-image: url("@/assets/global_images/warningDialog_two.png");
}

.grade-3 {
  background-image: url("@/assets/global_images/warningDialog_three.png");
}

.grade-other {
  background-image: url("@/assets/global_images/warningDialog_other.png");
}
</style>

<style lang="scss" scoped>
.value {
  overflow: hidden;

  /* 确保超出的内容会被裁剪 */
  white-space: nowrap;

  /* 确保文本在一行内显示 */
  text-overflow: ellipsis;
  vertical-align: middle;

  // display: flex;
  // align-items: center;
}

.title {
  position: absolute;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  top: 8px;
  left: 75px;
}

.container-dialog {
  width: 90%;
  margin: 0 auto;
  margin-top: 10px;
  // margin: 0 auto;
  // padding-left: 30px;
  color: #f1eded;
  font-size: 16px;
  font-weight: 600;

  .content {
    display: flex;
    margin: 10px 0;

    .value {
      padding-left: 10px;
      vertical-align: middle;
    }
  }
}

.dialog-footer {
  width: 100%;
  display: flex;
  justify-content: space-evenly;
  margin-bottom: 10px;
  margin-top: 25px;
  padding: 0 40px;

  .btn {
    width: 24%;
    border: 1px solid #f1eded;
    text-align: center;
    height: 30px;
    line-height: 30px;
    color: #faf5f5;

    &:hover {
      cursor: pointer;
      color: rgb(115 184 240);
    }
  }

  .primary {
    background-color: #dc0000;
    border-radius: 6px;
    border-color: #dc0000;

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

  .normal {
    background-color: #fff;
    border-color: #dc0000;
    border-radius: 6px;
    color: #dc0000;

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

  .info {
    background-color: #999;
    border-radius: 6px;
    border-color: #999;
    color: #fff;

    &:hover {
      cursor: pointer;
      color: #fff;
    }
  }
}
</style>