Newer
Older
KaiFengPC / src / views / floodSys / scada / pumpStationInformation / index.vue
@zhangdeliang zhangdeliang on 9 Aug 23 KB update
<template>
  <!-- 泵站信息管理 -->
  <div class="water-analysis-page">
    <div class="top">
      <el-form ref="queryRef" inline :model="queryParams" v-show="showSearch">
        <el-form-item label="站点:" prop="pumpCode">
          <el-select clearable filterable v-model="queryParams.pumpCode" placeholder="请选择">
            <el-option v-for="item in tableData" :key="item.pumpCode" :label="item.pumpName" :value="item.pumpCode" />
          </el-select>
        </el-form-item>
        <el-form-item label="泵站类型:" prop="pumpType">
          <el-select clearable v-model="queryParams.pumpType" placeholder="请选择">
            <el-option v-for="dict in pump_type" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="searchForm"> 查询</el-button>
          <el-button icon="Refresh" @click="resectClcik"> 重置</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <el-button type="primary" plain icon="Plus" @click="addData">新增</el-button>
        <right-toolbar v-model:showSearch="showSearch" @queryTable="searchForm"></right-toolbar>
      </el-row>
    </div>
    <!-- 表格 -->
    <el-table :data="tableData" v-loading="tableLoading" :max-height="650">
      <el-table-column type="index" width="70" label="序号" />
      <el-table-column label="泵站编号" prop="pumpCode" />
      <el-table-column label="泵站名称" prop="pumpName" />
      <el-table-column label="泵站类型" prop="pumpType">
        <template #default="{ row }">
          <dict-tag :options="pump_type" :value="row.pumpType"></dict-tag>
        </template>
      </el-table-column>
      <!-- <el-table-column label="设计规模" prop="designScale">
        <template #default="{ row }">
          {{ getUnitName(row) }}
        </template>
      </el-table-column> -->

      <el-table-column label="泵站地址" prop="address" />
      <el-table-column label="格栅机" prop="grilleMachine" />
      <el-table-column label="开启数量" prop="openNumber" />
      <el-table-column label="总流量m³/s" prop="totalFlow" />
      <el-table-column label="建设单位" prop="unitDep" />
      <el-table-column label="联系人" prop="dutyUserName" />
      <el-table-column label="联系人电话" prop="dutyUserPhone" />
      <el-table-column label="操作" show-overflow-tooltip width="250">
        <template #default="{ row }">
          <el-button link icon="View" type="primary" @click="checkDetail(row)">详情</el-button>
          <el-button link icon="Edit" type="warning" @click="editData(row)">修改</el-button>
          <el-button link icon="Delete" type="danger" @click="deleteData(row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getDataList"
    />
    <div class="water-analysis-page">
      <!-- 添加 修改 查看彈框 -->
      <el-dialog :title="dialogTitle" v-model="showDialog" width="70%" :close-on-click-modal="false">
        <el-form ref="ruleForm" :model="formData" :rules="formRules" :disabled="isDisab" label-width="180px">
          <el-row>
            <el-form-item label="泵站名称:" prop="pumpName" style="width: 45%">
              <el-input v-model="formData.pumpName" placeholder="请输入" clearable />
            </el-form-item>
            <el-form-item label="泵站编码:" prop="pumpCode" style="width: 45%">
              <el-input v-model="formData.pumpCode" placeholder="请输入" clearable :disabled="hiddentext" />
            </el-form-item>
            <el-form-item label="泵站类型:" prop="pumpType" style="width: 45%">
              <el-select
                clearable
                v-model="formData.pumpType"
                class="m-2"
                placeholder="请选择"
                style="width: 100%"
                @change="pumpTypechange"
              >
                <el-option v-for="item in pump_type" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="收水范围(gis):" prop="geometrys" style="width: 45%">
              <el-input v-model="formData.geometrys" placeholder="请输入收水范围(gis)" clearable />
            </el-form-item>
            <el-divider content-position="left" v-if="formData.pumpType == 'confluence'">雨水泵站信息</el-divider>
            <!-- 下拉框雨污水合建泵站-->
            <el-form-item label="雨水设计规模(m³/s):" prop="a" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.rainpump.designScaleSecond" placeholder="请输入雨水设计规模(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="雨水单台流量(m³/s):" prop="b" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.rainpump.singleFlowSccond" placeholder="请输入雨水单台流量(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="雨水泵机台数:" prop="c" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.rainpump.deviceCount" placeholder="请输入雨水泵机台数" clearable />
            </el-form-item>
            <el-form-item label="雨水收水出路:" prop="collectionOut" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.rainpump.collectionOut" placeholder="请输入雨水收水出路" clearable />
            </el-form-item>
            <el-form-item label="雨水收水范围:" prop="c" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.rainpump.collectionRange" placeholder="请输入雨水收水范围" clearable />
            </el-form-item>
            <el-divider content-position="left" v-if="formData.pumpType == 'confluence'">污水泵站信息</el-divider>
            <el-form-item label="污水设计规模(m³/s):" prop="designScaleSecond" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.sweagepump.designScaleSecond" placeholder="请输入污水设计规模(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="污水单台流量(m³/s):" prop="singleFlowSccond" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.sweagepump.singleFlowSccond" placeholder="请输入污水单台流量(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="污水泵机台数:" prop="deviceCount" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.sweagepump.deviceCount" placeholder="请输入污水泵机台数" clearable />
            </el-form-item>
            <el-form-item label="污水收水出路:" prop="collectionOut" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.sweagepump.collectionOut" placeholder="请输入污水收水出路" clearable />
            </el-form-item>
            <el-form-item label="污水收水范围:" prop="collectionRange" style="width: 45%" v-if="formData.pumpType == 'confluence'">
              <el-input v-model="formData.sweagepump.collectionRange" placeholder="请输入污水收水范围" clearable />
            </el-form-item>

            <!--雨水泵站数据  -->
            <el-divider content-position="left" v-if="formData.pumpType == 'rain_water'">雨水泵站信息</el-divider>
            <el-form-item label="设计规模(m³/s):" prop="designScaleSecond" style="width: 45%" v-if="formData.pumpType == 'rain_water'">
              <el-input v-model="formData.rainpump.designScaleSecond" placeholder="请输入设计规模(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="单台流量(m³/s):" prop="singleFlowSccond" style="width: 45%" v-if="formData.pumpType == 'rain_water'">
              <el-input v-model="formData.rainpump.singleFlowSccond" placeholder="请输入单台流量(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="泵机台数:" prop="deviceCount" style="width: 45%" v-if="formData.pumpType == 'rain_water'">
              <el-input v-model="formData.rainpump.deviceCount" placeholder="请输入泵机台数" clearable />
            </el-form-item>
            <el-form-item label="收水出路:" prop="collectionOut" style="width: 45%" v-if="formData.pumpType == 'rain_water'">
              <el-input v-model="formData.rainpump.collectionOut" placeholder="请输入收水出路" clearable />
            </el-form-item>
            <el-form-item label="收水范围:" prop="collectionRange" style="width: 45%" v-if="formData.pumpType == 'rain_water'">
              <el-input v-model="formData.rainpump.collectionRange" placeholder="请输入收水范围" clearable />
            </el-form-item>

            <!--污水泵站数据  -->
            <el-divider content-position="left" v-if="formData.pumpType == 'sewage_water'">污水泵站信息</el-divider>
            <el-form-item label="设计规模(m³/s):" prop="designScaleSecond" style="width: 45%" v-if="formData.pumpType == 'sewage_water'">
              <el-input v-model="formData.sweagepump.designScaleSecond" placeholder="请输入设计规模(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="单台流量(m³/s):" prop="singleFlowSccond" style="width: 45%" v-if="formData.pumpType == 'sewage_water'">
              <el-input v-model="formData.sweagepump.singleFlowSccond" placeholder="请输入单台流量(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="泵机台数:" prop="deviceCount" style="width: 45%" v-if="formData.pumpType == 'sewage_water'">
              <el-input v-model="formData.sweagepump.deviceCount" placeholder="请输入泵机台数" clearable />
            </el-form-item>
            <el-form-item label="收水出路:" prop="collectionOut" style="width: 45%" v-if="formData.pumpType == 'sewage_water'">
              <el-input v-model="formData.sweagepump.collectionOut" placeholder="请输入收水出路" clearable />
            </el-form-item>
            <el-form-item label="收水范围:" prop="collectionRange" style="width: 45%" v-if="formData.pumpType == 'sewage_water'">
              <el-input v-model="formData.sweagepump.collectionRange" placeholder="请输入收水范围" clearable />
            </el-form-item>

            <!--污水处理  -->
            <el-divider content-position="left" v-if="formData.pumpType == 'sewage_handle'">污水处理信息</el-divider>
            <el-form-item label="设计规模(m³/s):" prop="designScaleSecond" style="width: 45%" v-if="formData.pumpType == 'sewage_handle'">
              <el-input v-model="formData.handlepump.designScaleSecond" placeholder="请输入设计规模(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="单台流量(m³/s):" prop="singleFlowSccond" style="width: 45%" v-if="formData.pumpType == 'sewage_handle'">
              <el-input v-model="formData.handlepump.singleFlowSccond" placeholder="请输入单台流量(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="泵机台数:" prop="deviceCount" style="width: 45%" v-if="formData.pumpType == 'sewage_handle'">
              <el-input v-model="formData.handlepump.deviceCount" placeholder="请输入泵机台数" clearable />
            </el-form-item>
            <el-form-item label="收水出路:" prop="collectionOut" style="width: 45%" v-if="formData.pumpType == 'sewage_handle'">
              <el-input v-model="formData.handlepump.collectionOut" placeholder="请输入收水出路" clearable />
            </el-form-item>
            <el-form-item label="收水范围:" prop="collectionRange" style="width: 45%" v-if="formData.pumpType == 'sewage_handle'">
              <el-input v-model="formData.handlepump.collectionRange" placeholder="请输入收水范围" clearable />
            </el-form-item>

            <!--临时泵    -->
            <el-divider content-position="left">临时泵站信息</el-divider>
            <el-form-item label="是否有临时泵:" prop="haveTemporary" style="width: 45%">
              <el-select clearable v-model="formData.haveTemporary" class="m-2" placeholder="请选择" style="width: 100%">
                <el-option v-for="item in pumpingData" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="设计规模(m³/s):" prop="designScaleSecond" style="width: 45%" v-if="formData.haveTemporary == '1'">
              <el-input v-model="formData.temporarypump.designScaleSecond" placeholder="请输入设计规模(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="单台流量(m³/s):" prop="singleFlowSccond" style="width: 45%" v-if="formData.haveTemporary == '1'">
              <el-input v-model="formData.temporarypump.singleFlowSccond" placeholder="请输入单台流量(m³/s)" clearable />
            </el-form-item>
            <el-form-item label="泵机台数:" prop="deviceCount" style="width: 45%" v-if="formData.haveTemporary == '1'">
              <el-input v-model="formData.temporarypump.deviceCount" placeholder="请输入泵机台数" clearable />
            </el-form-item>
            <el-form-item label="收水出路:" prop="collectionOut" style="width: 45%" v-if="formData.haveTemporary == '1'">
              <el-input v-model="formData.temporarypump.collectionOut" placeholder="请输入收水出路" clearable />
            </el-form-item>
            <el-form-item label="收水范围:" prop="collectionRange" style="width: 45%" v-if="formData.haveTemporary == '1'">
              <el-input v-model="formData.temporarypump.collectionRange" placeholder="请输入收水范围" clearable />
            </el-form-item>

            <!--  -->
            <el-divider content-position="left"></el-divider>
            <el-form-item label="泵站地址:" prop="address" style="width: 45%">
              <el-input v-model="formData.address" placeholder="请输入泵站地址" clearable />
            </el-form-item>
            <el-form-item label="经度:" prop="lon" style="width: 45%">
              <el-input v-model="formData.lon" placeholder="请输入经度" clearable />
            </el-form-item>
            <el-form-item label="纬度:" prop="lat" style="width: 45%">
              <el-input v-model="formData.lat" placeholder="请输入纬度" clearable />
            </el-form-item>
            <el-form-item label="格栅机:" prop="grilleMachine" style="width: 45%">
              <el-input v-model="formData.grilleMachine" placeholder="请输入格栅机" clearable />
            </el-form-item>
            <el-form-item label="开启数量:" prop="openNumber" style="width: 45%">
              <el-input v-model="formData.openNumber" placeholder="请输入开启数量" clearable />
            </el-form-item>
            <el-form-item label="总流量m³/s:" prop="totalFlow" style="width: 45%">
              <el-input v-model="formData.totalFlow" placeholder="请输入总流量m³/s" clearable />
            </el-form-item>
            <el-form-item label="建设单位:" prop="unitDep" style="width: 45%">
              <el-input v-model="formData.unitDep" placeholder="请输入建设单位" clearable />
            </el-form-item>
            <el-form-item label="占地面积(㎡):" prop="buildArea" style="width: 45%">
              <el-input v-model="formData.buildArea" placeholder="请输入占地面积(㎡)" clearable />
            </el-form-item>
            <el-form-item label="联系人:" prop="dutyUserName" style="width: 45%">
              <el-input v-model="formData.dutyUserName" placeholder="请输入联系人" clearable />
            </el-form-item>
            <el-form-item label="联系人电话:" prop="dutyUserPhone" style="width: 45%">
              <el-input v-model="formData.dutyUserPhone" placeholder="请输入联系人电话" clearable />
            </el-form-item>
          </el-row>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="submitForm" v-show="!isDisab">保 存</el-button>
            <el-button @click="cancel">关闭</el-button>
          </div>
        </template>
      </el-dialog>
    </div>
  </div>
</template>

<script setup>
import { stationInfolist } from '@/api/scada/areaInfo';
import { facilityPumpPage, facilityPumpAdd, facilityPumpEdit, facilityPumpDelete } from '@/api/scada/pumpStationInformation';
const { proxy } = getCurrentInstance();
const hiddentext = ref(false);
const isDisab = ref(false);
const showSearch = ref(true);
const showDialog = ref(false);
const tableLoading = ref(true);
const total = ref(0);
const tableData = ref([]);
let typeList = ref([]);
const dialogTitle = ref('');
const { pump_type } = proxy.useDict('pump_type');
console.log(pump_type, 'pump_type');
const pumpingData = ref([
  { label: '是', value: '1' },
  { label: '否', value: '0' },
]);
let AllData = reactive({
  formData: { rainpump: {}, temporarypump: {}, sweagepump: {}, handlepump: {} },
  queryParams: { pumpCode: '', pumpType: '', pageNum: 1, pageSize: 10 },
  formRules: {
    pumpName: [{ required: true, message: '请输入泵站名称', trigger: 'blur' }],
    pumpCode: [{ required: true, message: '请输入泵站编码', trigger: 'blur' }],
    pumpType: [{ required: true, message: '请选择泵站类型', trigger: 'blur' }],
    dutyUserPhone: [
      {
        pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
        message: '请输入正确的手机号码',
        trigger: 'blur',
      },
    ],
  },
});
let { queryParams, formData, formRules } = toRefs(AllData);
/** 表单重置 */
function resetForm() {
  formData.value = {};
  proxy.resetForm('ruleForm');
}
//搜索
const searchForm = () => {
  queryParams.value.pageNum = 1;
  getDataList();
};
//重置按钮
const resectClcik = () => {
  queryParams.value.pumpCode = '';
  queryParams.value.pumpType = '';
  getDataList();
};

//获取列表数据
const getDataList = async () => {
  tableLoading.value = true;
  const res = await facilityPumpPage(queryParams.value);
  tableLoading.value = false;
  tableData.value = res.data;

  total.value = res.total;
};

// 下拉框
function pumpTypechange(val) {
  if (formData.value.pumpType == 'rain_water') {
    // formData.value.rainpump = {};
    formData.value.temporarypump = {};
    formData.value.sweagepump = {};
    formData.value.handlepump = {};
    formData.value.haveTemporary = pumpingData.value[1].value;
  } else if (formData.value.pumpType == 'sewage_water') {
    // formData.value.sweagepump = {};
    formData.value.temporarypump = {};
    formData.value.rainpump = {};
    formData.value.handlepump = {};
    formData.value.haveTemporary = pumpingData.value[1].value;
  } else if (formData.value.pumpType == 'sewage_handle') {
    // formData.value.handlepump = {};
    formData.value.temporarypump = {};
    formData.value.rainpump = {};
    formData.value.sweagepump = {};
    formData.value.haveTemporary = pumpingData.value[1].value;
  } else {
    formData.value.temporarypump = {};
    formData.value.handlepump = {};
    formData.value.rainpump = {};
    formData.value.haveTemporary = pumpingData.value[1].value;
  }
}

//新增按钮
const addData = () => {
  resetForm();
  isDisab.value = false;
  showDialog.value = true;
  hiddentext.value = false;
  dialogTitle.value = '新增泵站信息';
  formData.value.temporarypump = {};
  formData.value.rainpump = {};
  formData.value.sweagepump = {};
  formData.value.handlepump = {};
  formData.value.haveTemporary = pumpingData.value[1].value;
  formData.value.pumpType = pump_type._object.pump_type[0].value;
};
/** 取消按钮 */
function cancel() {
  showDialog.value = false;
  resetForm();
}
/** 新增弹框 修改弹框 提交按钮 */
async function submitForm() {
  proxy.$refs['ruleForm'].validate(valid => {
    if (valid) {
      if (formData.value.id != undefined) {
        facilityPumpEdit(formData.value).then(() => {
          proxy.$modal.msgSuccess('修改成功');
          showDialog.value = false;
          getDataList();
        });
      } else {
        formData.value.pumpType = formData.value.pumpType;
        if (formData.value.pumpType == 'rain_water') {
          formData.value.rainpump.pumpType = formData.value.pumpType;
          formData.value.temporarypump.pumpType = 'temporary';
        } else if (formData.value.pumpType == 'sewage_water') {
          formData.value.sweagepump.pumpType = formData.value.pumpType;
          formData.value.temporarypump.pumpType = 'temporary';
        } else if (formData.value.pumpType == 'sewage_handle') {
          formData.value.handlepump.pumpType = formData.value.pumpType;
          formData.value.temporarypump.pumpType = 'temporary';
        } else {
          formData.value.sweagepump.pumpType = formData.value.pumpType;
          formData.value.rainpump.pumpType = formData.value.pumpType;
          formData.value.temporarypump.pumpType = 'temporary';
        }
        console.log(formData.value, 'formData.value');
        facilityPumpAdd(formData.value).then(() => {
          proxy.$modal.msgSuccess('新增成功');
          showDialog.value = false;
          getDataList();
        });
      }
    }
  });
}

//表格修改
function editData(row) {
  dialogTitle.value = '修改泵站信息';
  isDisab.value = false;
  showDialog.value = true;
  hiddentext.value = true;
  formData.value = { ...row };
}
// 表格删除
function deleteData(row) {
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await facilityPumpDelete(row.id);
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getDataList();
    })
    .catch(() => {});
}
//详情按钮
function checkDetail(row) {
  dialogTitle.value = '查看泵站信息';
  isDisab.value = true;
  showDialog.value = true;
  formData.value = { ...row };
  console.log(formData.value, 'formData.value');

  // formData.value.designHead = Number(row.designHead);
  // formData.value.dayLarge = Number(row.dayLarge);
  // formData.value.designPower = Number(row.designPower);
  // formData.value.deviceCount = Number(row.deviceCount);
  // formData.value.maxWaterlevel = Number(row.maxWaterlevel);
  // formData.value.modelValue = Number(row.modelValue);
  // formData.value.large = Number(row.large);
  // console.log(formData.value.pumpType, 'formData.value.pumpType');
}

function getUnitName(row) {
  let unitName = '';
  switch (row.pumpType) {
    case 'rain_water':
      unitName = 'm³/s';
      break;
    case 'sewage_water':
      unitName = 'm³/s';
      break;
    case 'drain_flooded':
      unitName = 'm³/s';
      break;
  }

  return `${row.designScale}${unitName}`;
}

onMounted(() => {
  getDataList();
  stationInfolistM();
});
</script>

<style lang="scss" scoped>
.water-analysis-page {
  padding: 20px;
  overflow-y: hidden;
}
</style>