Newer
Older
Nanping_sponge_SJJC / src / views / dataAnalysis / dataCapability / repairdata / repaircontrast.vue
@liyingjing liyingjing on 25 Oct 2023 11 KB 数据检测
<template>
  <!-- 数据优化成果评价 -->
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="" prop="st">
        <el-select v-model="queryParams.st" filterable placeholder="请选择站点">
          <el-option
            v-for="dict in searchSiteList"
            :key="dict.stCode"
            :label="`${dict.stName}-${dict.stCode}`"
            :value="dict.stCode"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="dateRange">
        <el-date-picker
          v-model="queryParams.dateRange"
          value-format="YYYY-MM-DD"
          type="daterange"
          range-separator="-"
          start-placeholder="开始周期"
          end-placeholder="结束周期"
        ></el-date-picker>
      </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="loading" :data="rtuSiteInfoList" border @selection-change="handleSelectionChange">
      <!-- <el-table-column type="selection" width="55"  /> -->
      <el-table-column label="序号" type="index" width="55" />

      <el-table-column label="站点编号" prop="st" show-overflow-tooltip width="120" />
      <el-table-column label="站点名称" prop="stName" show-overflow-tooltip />
      <el-table-column label="优化启动时间" prop="createDatetime" width="200"> </el-table-column>
      <el-table-column label="故障误报去除率(%)">
        <template #default="scope">
          <el-table-column label="优化前" width="80">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['faultReportRateBefore'] : '' }}</template
            >
          </el-table-column>
          <el-table-column label="优化后" width="80">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['faultReportRateAfter'] : '' }}</template
            >
          </el-table-column>
        </template>
      </el-table-column>
      <el-table-column label="数据在线率提升(%)">
        <template #default="scope">
          <el-table-column label="优化前" width="80">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['onlineRateBefore'] : '' }}</template
            >
          </el-table-column>
          <el-table-column label="优化后" width="80">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['onlineRateAfter'] : '' }}</template
            >
          </el-table-column>
        </template>
      </el-table-column>
      <el-table-column label="重复预警削减率(%)">
        <template #default="scope">
          <el-table-column label="优化前" width="80">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['repeatWarnRateBefore'] : '' }}</template
            >
          </el-table-column>
          <el-table-column label="优化后" width="80">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['repeatWarnRateAfter'] : '' }}</template
            >
          </el-table-column>
        </template>
      </el-table-column>
      <el-table-column label="数据清洗&AI成果">
        <template #default="scope">
          <el-table-column label="日均修正数" width="90">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['dailyAvgRepairOptimizeCount'] : '' }}</template
            >
          </el-table-column>
          <el-table-column label="日均脏数据剔除数" width="130">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['dailyAvgAbnormalRepairCount'] : '' }}</template
            >
          </el-table-column>
        </template>
      </el-table-column>
      <el-table-column label="可用率(%)">
        <template #default="scope">
          <el-table-column label="优化前" width="80">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['availableRateBefore'] : '' }}</template
            >
          </el-table-column>
          <el-table-column label="优化后" width="80">
            <template #default="scope">
              {{ scope.row.repairStatistic ? scope.row.repairStatistic['availableRateAfter'] : '' }}</template
            >
          </el-table-column>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup>
import {
  pageRepairSite,
  listRuleEngine,
  listSite,
  listRepairAllSite,
  listSiteSupportedProperty,
  siteconfigdetail_by_st,
  addRtuRepairConfig,
  updateRtuRepairConfig,
} from '@/api/dataAnalysis/repairdata';
const { proxy } = getCurrentInstance();
const rtuSiteInfoList = ref([]);
const open = ref(false);
const loading = ref(false);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref('');
const currentRow = ref({});
const searchSiteList = ref([]); //站点搜索列表
const isconfigAdd = ref(true); //修改/新增判断按钮
const isliuliangzhan = ref(false);
const ruleList = ref([]); //规则下拉框
const yulianglist = ref([]); //雨量站下拉框
const liulianglist = ref([]); //流量站下拉框
const guanwanglist = ref([]); //雨水管网下拉框
const xiufulist = ref([]); //修复因子下拉
const data = reactive({
  form: {
    siteRepairPropertyConfigList: [
      {
        id: '',
        isEnable: 1,
        maxValue: '',
        minValue: '',
        property: '',
        propertyName: '',
        siteRepairConfigId: '',
        st: '',
        type: '',
      },
    ],
  },
  queryParams: {
    pageNo: 1,
    pageSize: 10,
    st: null,
    platformCode: 111211,
    dateRange: [proxy.moment(new Date()).subtract(1, 'days').format('YYYY-MM-DD'), proxy.moment().format('YYYY-MM-DD')],
  },
  rules: {
    ruleId: [
      {
        required: true,
        message: '请选择规则引擎',
        trigger: 'blur',
      },
    ],
    referRainStationSt: [
      {
        required: true,
        message: '请选择关联雨量站',
        trigger: 'blur',
      },
    ],
    isEnable: [
      {
        required: true,
        message: '请选择是否启用',
        trigger: 'blur',
      },
    ],
  },
});

const { queryParams, form, rules } = toRefs(data);
watch(
  () => form.value.siteRepairPropertyConfigList,
  (v1, v2) => {
    let propertys = form.value.siteRepairPropertyConfigList.map(item => {
      return item.property;
    });
    isliuliangzhan.value = propertys.includes('va');
    form.value.referFlowStationSt = isliuliangzhan.value ? form.value.referFlowStationSt : [];
  }
);
/** 查询RTU站点列表 */
function getList() {
  loading.value = true;
  let params = { ...queryParams.value };
  params.startDatetime = queryParams.value.dateRange[0] + ' 00:00:00';
  params.endDatetime = queryParams.value.dateRange[1] + ' 23:59:59';
  pageRepairSite(params).then(response => {
    if (response.code == 200) {
      rtuSiteInfoList.value = response.data;
      total.value = response.total;
      loading.value = false;
    }
  });
}

//获取站点列表
function getSearchSiteList() {
  listRepairAllSite({ platformCode: 111211 }).then(res => {
    searchSiteList.value = res.data;
  });
}

//获取下拉数据
function selectionList(row) {
  //获取规则引擎下拉
  listRuleEngine().then(res => {
    ruleList.value = res.data;
  });
  //流量站下拉
  listSite({ samePlatformSt: row.st, existProperty: 'sbl1' }).then(res => {
    liulianglist.value = res.data;
  });
  //雨量站下拉
  listSite({ samePlatformSt: row.st, existProperty: 'pj' }).then(res => {
    yulianglist.value = res.data;
  });
  //雨水管网下拉
  listSite({ samePlatformSt: row.st, existProperty: 'z' }).then(res => {
    guanwanglist.value = res.data;
  });
  //修复因子下拉
  listSiteSupportedProperty(row.st).then(res => {
    xiufulist.value = res.data;
  });
  //获取修复详情
  siteconfigdetail_by_st(row.st).then(res => {
    if (res.data) {
      //  修改
      isconfigAdd.value = false;
      res.data.referFlowStationSt = res.data.referFlowStationSt ? res.data.referFlowStationSt.split(',') : [];
      res.data.referRainPipeSt = res.data.referRainPipeSt ? res.data.referRainPipeSt.split(',') : [];
      res.data.referRainStationSt = res.data.referRainStationSt ? res.data.referRainStationSt.split(',') : [];
      form.value = res.data;
    } else {
      //新增
      isconfigAdd.value = true;
    }
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    id: '',
    ruleId: '', //规则引擎
    st: '', //站点编号
    isEnable: 1, //	是否启用(0否 1是)
    referRainStationSt: [], //关联雨量站点(可多选,用,隔开)
    referRainPipeSt: [], //关联雨水管网(可多选,用,隔开)
    referFlowStationSt: [], //关联雨水管网(可多选,用,隔开)
    siteRepairPropertyConfigList: [
      {
        property: '', //修复因子
        isEnable: 1, //是否启用(0否 1是)
        minValue: 0, //正常范围最小值
        maxValue: 0, //	正常范围最大值
      },
    ],
  };
  proxy.resetForm('configFormRef');
}
//设置修复因子
function handleSet(row) {
  reset();
  currentRow.value = row;
  const _id = row.id || ids.value;
  title.value = '修复因子';
  open.value = true;
  selectionList(row);
}

//批量添加修复因子
function addCofig() {
  form.value.siteRepairPropertyConfigList.push({
    property: '', //修复因子
    isEnable: 1, //是否启用(0否 1是)
    minValue: 0, //正常范围最小值
    maxValue: 0, //	正常范围最大值
  });
}

//删除修复因子
function delCofig(index) {
  form.value.siteRepairPropertyConfigList.splice(index, 1);
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNo = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs['configFormRef'].validate(valid => {
    if (valid) {
      form.value.referFlowStationSt = form.value.referFlowStationSt.join(',');
      form.value.referRainPipeSt = form.value.referRainPipeSt.join(',');
      form.value.referRainStationSt = form.value.referRainStationSt.join(',');
      form.value.st = currentRow.value.st;
      if (isconfigAdd.value) {
        addRtuRepairConfig(form.value).then(response => {
          proxy.$modal.msgSuccess('新增成功');
          open.value = false;
          getList();
        });
      } else {
        updateRtuRepairConfig(form.value).then(response => {
          proxy.$modal.msgSuccess('修改成功');
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value;
  proxy.$modal
    .confirm('是否确认删除?')
    .then(function () {
      return delrtuSiteInfo(_ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}
getList();
getSearchSiteList();
</script>
<style lang="scss" scoped></style>