Newer
Older
KaiFengPC / src / views / floodSys / scada / sewage / index.vue
@鲁yixuan 鲁yixuan on 19 Aug 8 KB updata
<template>
  <div class="water-analysis-page">
    <div class="top">
      <el-form ref="queryRef" inline :model="queryParams" v-show="showSearch">
        <el-form-item label="污水处理厂名称:" prop="sewageName">
          <el-input v-model="queryParams.sewageName" placeholder="请输入" clearable style="width: 220px" />
        </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="sewageName" />
      <el-table-column label="污水处理厂编码" prop="sewageCode" />
      <el-table-column label="地址" prop="address" />
      <el-table-column label="设计来源" prop="dataSource">
        <template #default="{ row }">
          <dict-tag :options="Datasources" :value="row.dataSource" />
        </template>
      </el-table-column>
      <el-table-column label="排放水体" prop="intoWater" />
      <el-table-column label="纬度" prop="lat" />
      <el-table-column label="经度" prop="lon" />
      <el-table-column label="设计规模(万吨/日)" prop="planScale" />
      <el-table-column label="实际平均处理量(万吨/日)" prop="region" />
      <el-table-column label="工艺" prop="workmanship" />
      <el-table-column label="操作" show-overflow-tooltip width="220">
        <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="900px" :close-on-click-modal="false">
        <el-form ref="ruleForm" :model="formData" :rules="formRules" :disabled="isDisab" label-width="150px" class="flex50">
          <el-row>
            <el-form-item label="污水处理厂名称:" prop="sewageName">
              <el-input v-model="formData.sewageName" placeholder="请输入" clearable />
            </el-form-item>
            <el-form-item label="污水处理厂编码:" prop="sewageCode">
              <el-input v-model="formData.sewageCode" placeholder="请输入" clearable :disabled="hiddentext" />
            </el-form-item>
            <el-form-item label="地址:" prop="address">
              <el-input v-model="formData.address" placeholder="请输入" clearable />
            </el-form-item>
            <el-form-item label="设计来源:" prop="dataSource">
              <el-select clearable v-model="formData.dataSource" class="m-2" placeholder="请选择" style="width: 100%">
                <el-option v-for="item in Datasources" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="空间数据集:" prop="geometrys">
              <el-input v-model="formData.geometrys" placeholder="请输入" clearable />
            </el-form-item>
            <el-form-item label="排放水体:" prop="intoWater">
              <el-input v-model="formData.intoWater" placeholder="请输入" clearable />
            </el-form-item>
            <el-form-item label="经度:" prop="lon">
              <el-input-number v-model="formData.lon" placeholder="请输入" style="width: 100%" controls-position="right" />
            </el-form-item>
            <el-form-item label="纬度:" prop="lat">
              <el-input-number v-model="formData.lat" placeholder="请输入" style="width: 100%" controls-position="right" />
            </el-form-item>
            <el-form-item label="设计规模(万吨/日):" prop="planScale">
              <el-input-number v-model="formData.planScale" placeholder="请输入" style="width: 100%" controls-position="right" />
            </el-form-item>
            <el-form-item label="实际处理量(万吨/日):" prop="region">
              <el-input-number v-model="formData.region" placeholder="请输入" clearable style="width: 100%" controls-position="right" />
            </el-form-item>
            <el-form-item label="标准:" prop="standard">
              <el-input v-model="formData.standard" placeholder="请输入" clearable />
            </el-form-item>
            <el-form-item label="工艺:" prop="workmanship">
              <el-input v-model="formData.workmanship" 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 { facilitySewagePage, facilitySewageAdd, facilitySewageEdit, facilitySewageDelete } from '@/api/scada/sewage';
const { proxy } = getCurrentInstance();
const isDisab = ref(false);
const hiddentext = ref(false);
const showSearch = ref(true);
const showDialog = ref(false);
const tableLoading = ref(true);
const total = ref(0);
const tableData = ref([]);
const dialogTitle = ref('');
const Datasources = ref([
  { label: '设计院', value: '1' },
  { label: '待定', value: '2' },
]);
let AllData = reactive({
  formData: {},
  queryParams: { sewageName: '', pageNum: 1, pageSize: 10 },
  formRules: {
    sewageName: [{ required: true, message: '请输入', trigger: 'blur' }],
    sewageCode: [{ required: true, 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.sewageName = '';
  getDataList();
};

//获取列表数据
const getDataList = async () => {
  tableLoading.value = true;
  const res = await facilitySewagePage(queryParams.value);
  tableLoading.value = false;
  tableData.value = res.data;
  total.value = res.total;
};
//新增按钮
const addData = () => {
  resetForm();
  isDisab.value = false;
  showDialog.value = true;
  hiddentext.value = false;
  dialogTitle.value = '新增污水厂信息';
};
/** 取消按钮 */
function cancel() {
  showDialog.value = false;
  resetForm();
}
/** 新增弹框 修改弹框 提交按钮 */
async function submitForm() {
  proxy.$refs['ruleForm'].validate(valid => {
    if (valid) {
      if (formData.value.id != undefined) {
        facilitySewageEdit(formData.value).then(() => {
          proxy.$modal.msgSuccess('修改成功');
          showDialog.value = false;
          getDataList();
        });
      } else {
        facilitySewageAdd(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 };
  formData.value.lat = Number(row.lat);
  formData.value.lon = Number(row.lon);
}
// 表格删除
function deleteData(row) {
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await facilitySewageDelete(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 };
  formData.value.lat = Number(row.lat);
  formData.value.lon = Number(row.lon);
}

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

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