Newer
Older
KaiFengPC / src / views / floodSys / scada / realAlarm / reportService.vue
@zhangdeliang zhangdeliang on 10 Sep 4 KB update
<template>
  <!-- 告警服务 实时告警 -->
  <div class="publicContainer realAlarmSS">
    <el-form :model="pagParms" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="站点名称" prop="dataType">
        <el-select clearable filterable v-model="pagParms.stCode" placeholder="搜索站点">
          <el-option v-for="dict in rtuSiteInfo" :key="dict.stationCode" :label="dict.stationName" :value="dict.stationCode"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="告警级别" prop="warnLevel">
        <el-select clearable v-model="pagParms.warnLevel" placeholder="告警级别">
          <el-option v-for="dict in dataTypes" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="tableLoading" :data="tableData" @selection-change="handleSelectionChange" max-height="620">
      <el-table-column label="序号" type="index" width="55" />
      <el-table-column label="告警类型" prop="warnType">
        <template #default="scope">
          <span>{{ getChangeType(scope.row.warnType) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="告警级别" prop="warnLevel">
        <template #default="{ row }">
          <span>{{ row.warnLevel == 'warn' ? '告警' : '预警' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="告警站点" prop="stName" width="200" show-overflow-tooltip />
      <el-table-column label="告警因子" prop="warnFactorName" show-overflow-tooltip />
      <el-table-column label="告警公式" prop="warnFormulaName" width="200" show-overflow-tooltip></el-table-column>
      <el-table-column label="时间阈值(分钟)" prop="timeThreshold"></el-table-column>
      <el-table-column label="告警时间" prop="warnDatetime" width="180"></el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="pagParms.pageNum"
      v-model:limit="pagParms.pageSize"
      @pagination="searchData"
    />
  </div>
</template>
<script setup name="realAlarm">
import { plcWarnRecordRealtimePage } from '@/api/scada/realAlarm';
import { getInfolist } from '@/api/scada/stationInfo';
import { reactive } from 'vue';
const props = defineProps({
  checkedKey: String,
});
const { proxy } = getCurrentInstance();
const showSearch = ref(true);
const tableData = ref([]);
const tableLoading = ref(false);
const total = ref(0);
const dataTypes = reactive([
  { label: '告警 ', value: 'warn ' },
  { label: '预警  ', value: 'early_warn' },
]);
const rtuSiteInfo = ref([]);
const pagParms = ref({ warnType: '', stCode: '', warnLevel: '', pageSize: 10, pageNum: 1 });
// 获取站点
async function getSiteSelectListM() {
  let { data } = await getInfolist();
  rtuSiteInfo.value = data;
}
//分页搜索
async function searchData() {
  tableLoading.value = true;
  let params = { ...pagParms.value };
  let { data, total: totals } = await plcWarnRecordRealtimePage(params);
  tableLoading.value = false;
  tableData.value = data;
  total.value = totals;
}

const typeList = [
  {
    dictValue: 'water_level',
    dictLabel: '水位',
  },
  {
    dictValue: 'flow',
    dictLabel: '流量',
  },
  {
    dictValue: 'rain',
    dictLabel: '降雨 ',
  },
  {
    dictValue: 'quality',
    dictLabel: '水质 ',
  },
  {
    dictValue: 'other',
    dictLabel: '其它 ',
  },
];
function getChangeType(e) {
  for (var i = 0; i < typeList.length; i++) {
    if (typeList[i].dictValue == e) {
      //dictValue,dictLabel保持和上面定义一致
      return typeList[i].dictLabel;
    }
  }
}

/** 搜索按钮操作 */
function handleQuery() {
  pagParms.value.pageNum = 1;
  searchData();
}

/** 重置按钮操作 */
function resetQuery() {
  pagParms.value.stCode = '';
  pagParms.value.warnLevel = '';
  searchData();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
watch(
  () => props.checkedKey,
  val => {
    pagParms.value.warnType = val;
    searchData();
  }
);
// 初始化
onMounted(() => {
  getSiteSelectListM();
  searchData();
});
</script>
<style lang="scss" scoped></style>