Newer
Older
KaiFengPC / src / views / floodSys / scada / alertService / components / reportService.vue
@zhangdeliang zhangdeliang on 23 May 7 KB 初始化项目
<template>
  <div class="publicContainer reportService">
    <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 type="primary" plain icon="Plus" @click="handleAdd(_, 1)">新增</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="status">
        <template #default="scope">
          <el-tag effect="dark" class="ml-2" :type="scope.row.status == 1 ? 'success' : 'danger'">
            {{ scope.row.status == 1 ? '启用 ' : '停用' }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" prop="createTime" width="180">
        <template #default="scope">
          <span>{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>

      <el-table-column label="操作" width="200" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="handleAdd(scope.row, 2)" v-hasPermi="['newfiber-scada-base:rtuSiteInfo:edit']">
            修改
          </el-button>
          <el-button
            link
            type="danger"
            icon="Delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['newfiber-scada-base:rtuSiteInfo:remove']"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="totals > 0"
      :total="totals"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="rtuWarnConfigPageM(queryParams)"
    />
    <!-- 新增修改弹窗 -->
    <el-dialog v-model="dialogShow" :title="dialogTitle" width="800px" append-to-body class="equipmentDialog">
      <abilityAnalysis @closeEd="closeEd" :infoList="infoList" :key="keyLit"></abilityAnalysis>
    </el-dialog>
  </div>
</template>
<script setup name="syntheticData">
import bus from '@/bus';
import { plcWarnConfigPage, plcWarnConfigInfo, plcWarnConfigDelete } from '@/api/scada/AlertService';
import { getInfolist } from '@/api/scada/stationInfo';
import { reactive } from 'vue';
import abilityAnalysis from './abilityAnalysis.vue'; //基本信息查看更多
const { proxy } = getCurrentInstance();
const showSearch = ref(true);
const tableData = ref([]);
const tableLoading = ref(false);
const dialogShow = ref(false);
const dialogTitle = ref('新增告警');
const totals = ref(0);
// 变量声明
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    dataType: '',
    dateTime: [],
  },
});
const { queryParams, form } = toRefs(data);
const dataTypes = reactive([
  { label: '告警 ', value: 'warn' },
  { label: '预警  ', value: 'early_warn' },
]);
const rtuSiteInfo = ref([]);
const pagParms = ref({ pageNum: 1, pageSize: 10 });
// 方法
//获取站点下拉
async function getSiteSelectListM(p) {
  const res = await getInfolist();
  rtuSiteInfo.value = res.data;
}
//分页查询告警规则
async function rtuWarnConfigPageM(p) {
  let { data, total } = await plcWarnConfigPage(p);
  tableLoading.value = false;
  tableData.value = data;
  totals.value = total;
}

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() {
  queryParams.value.pageNum = 1;
  tableLoading.value = true;
  rtuWarnConfigPageM(pagParms.value);
}

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

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
//获取详情接口
const keyLit = ref(0);
const infoList = ref({});
function handleAdd({ id }, t) {
  dialogShow.value = true;

  if (t == 2) {
    dialogTitle.value = '修改告警';
    plcWarnConfigInfo(id).then(({ data }) => {
      infoList.value = data;
      keyLit.value++;
    });
  } else {
    dialogTitle.value = '新增告警';
    infoList.value = {};
    keyLit.value++;
  }
  infoList.value.type = t;
}
function closeEd() {
  dialogShow.value = false;
  rtuWarnConfigPageM(pagParms.value);
}
//删除成功
function handleDelete(row) {
  console.log(row, 999);
  // const _ids = row.id || ids.value;
  proxy.$modal
    .confirm('是否确认删除?')
    .then(function () {
      plcWarnConfigDelete(row.id).then(({ code }) => {
        if (code == 200) {
          rtuWarnConfigPageM(pagParms.value);
        }
      });
    })
    .then(() => {
      // getList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}
// 初始化
onMounted(() => {
  bus.on('mapPointClick3', type => {
    tableLoading.value = true;
    pagParms.value.warnType = type;
    rtuWarnConfigPageM(pagParms.value);
  });
  getSiteSelectListM();
});
// 页面销毁
onBeforeUnmount(() => {
  bus.off('mapPointClick3');
});
</script>
<style lang="scss" scoped></style>