Newer
Older
KaiFengPC / src / views / floodSys / scada / historyGj / reportService.vue
@zhangdeliang zhangdeliang on 23 May 4 KB 初始化项目
<template>
  <!-- 历史告警 -->
  <div class="publicContainer historyGJLS">
    <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" border @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(pagParms)"
    />
  </div>
</template>
<script setup name="historyCJ">
import { getInfolist } from '@/api/scada/stationInfo';
import { warnRecordHistoryPage } from '@/api/scada/historyGj';
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() {
  const res = await getInfolist();
  rtuSiteInfo.value = res.data;
}
//分页查询告警规则
async function searchData() {
  tableLoading.value = true;
  let params = { ...pagParms.value };
  let { data, total: totas } = await warnRecordHistoryPage(params);
  tableLoading.value = false;
  tableData.value = data;
  total.value = totas;
}
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();
}
/** 重置按钮操作 */
const 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();
});
</script>
<style lang="scss" scoped></style>