Newer
Older
KaiFengPC / src / views / floodSys / assetManage / WaterSupplyWaterPlants.vue
@鲁yixuan 鲁yixuan on 2 Sep 9 KB updata
<template>
  <!-- 水厂管理 -->
  <div class="publicContainer">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="水厂名称:" prop="plantName">
        <el-input v-model="queryParams.plantName" placeholder="请输入水厂名称" clearable style="width: 180px" />
      </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-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getDataList"></right-toolbar>
    </el-row>
    <!-- 表格 -->
    <el-table :data="tableData" v-loading="tableLoading" stripe :max-height="580">
      <el-table-column type="index" width="55" label="序号" />
      <el-table-column label="水厂名称" prop="plantName" />
      <el-table-column label="编码" prop="plantCode" />
      <el-table-column label="现状规模(万 m³/d)" prop="currentScale" />
      <el-table-column label="水源情况" prop="waterSource" />
      <el-table-column label="经度" prop="lon" />
      <el-table-column label="纬度" prop="lat" />
      <el-table-column label="位置" prop="address" />
      <el-table-column label="建设时间" prop="buildTime" />
      <el-table-column label="投入使用时间" prop="useTime" />
      <el-table-column label="覆盖人口" prop="coverPeople" />
      <el-table-column label="覆盖面积" prop="coverArea" />
      <el-table-column label="供水范围" prop="waterSupplyArea" />
      <el-table-column label="操作" width="240">
        <template #default="scope">
          <el-button link icon="View" type="primary" @click="handleDetail(scope.row, 'view')">详情</el-button>
          <el-button link type="warning" icon="Edit" @click="handleUpdate(scope.row, 'view')">修改</el-button>
          <el-button link type="danger" icon="Delete" @click="deleteData(scope.row, 'view')">删除</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"
    />
    <!-- 新增弹窗 -->
    <el-dialog :title="title" v-model="showDialog" width="800px" append-to-body :close-on-click-modal="false">
      <el-form ref="ruleForm" :model="form" :rules="rules" label-width="130px" :disabled="isDisab">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="水厂名称:" prop="plantName">
              <el-input v-model="form.plantName" placeholder="请输入水厂名称" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="编码:" prop="plantCode">
              <el-input v-model="form.plantCode" placeholder="请输入编码" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="现状规模(万 m³/d):" prop="currentScale">
              <el-input v-model="form.currentScale" placeholder="请输入现状规模(万 m³/d)" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="水源情况:" prop="waterSource">
              <el-input v-model="form.waterSource" placeholder="请输入水源情况" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="经度:" prop="lon">
              <el-input-number v-model="form.lon" placeholder="请输入" style="width: 100%" controls-position="right" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="纬度:" prop="lat">
              <el-input-number v-model="form.lat" placeholder="请输入" style="width: 100%" controls-position="right" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="位置:" prop="address">
              <el-input v-model="form.address" placeholder="请输入位置" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供水范围:" prop="waterSupplyArea">
              <el-input v-model="form.waterSupplyArea" placeholder="请输入供水范围" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="建设时间" prop="buildTime">
              <el-date-picker
                type="day"
                v-model="form.buildTime"
                value-format="YYYY-MM-DD"
                placeholder="请选择建设时间"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="投入使用时间" prop="useTime">
              <el-date-picker
                type="day"
                v-model="form.useTime"
                value-format="YYYY-MM-DD"
                placeholder="请选择投入使用时间"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="覆盖人口:" prop="coverPeople">
              <el-input v-model="form.coverPeople" placeholder="请输入覆盖人口" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="覆盖面积:" prop="coverArea">
              <el-input v-model="form.coverArea" placeholder="请输入覆盖面积" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
        </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>
</template>
<script setup name="WaterSupplyWaterPlants">
import { waterCompPage, waterCompAdd, waterCompEdit, waterCompDelete } from '@/api/longoPeration/RiverSection';
const { proxy } = getCurrentInstance();
const showDialog = ref(false);
const showSearch = ref(true);
const tableLoading = ref(true);
const total = ref(0);
const title = ref('');
const tableData = ref([]);
const isDisab = ref(false);
const AllData = reactive({
  id: '',
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    plantName: '',
  },
  rules: {
    plantName: [{ required: true, message: '请输入', trigger: 'blur' }],
    plantCode: [{ required: true, message: '请输入', trigger: 'blur' }],
  },
});
const { queryParams, form, rules } = toRefs(AllData);
//搜索
function handleQuery() {
  getDataList();
}
//获取列表数据
const getDataList = async () => {
  tableLoading.value = true;
  const res = await waterCompPage(queryParams.value);
  tableLoading.value = false;
  tableData.value = res.data;
  total.value = res.total;
};
//重置
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}
// 新增
function handleAdd() {
  isDisab.value = false;
  title.value = '新增供水厂';
  showDialog.value = true;
  form.value = {};
}
async function submitForm() {
  proxy.$refs['ruleForm'].validate(valid => {
    if (valid) {
      if (form.value.id != undefined) {
        waterCompEdit(form.value).then(() => {
          proxy.$modal.msgSuccess('修改成功');
          showDialog.value = false;
          getDataList();
        });
      } else {
        waterCompAdd(form.value).then(() => {
          proxy.$modal.msgSuccess('新增成功');
          showDialog.value = false;
          getDataList();
        });
      }
    }
  });
}
// 新增中取消事件
function cancel() {
  showDialog.value = false;
  proxy.resetForm('ruleForm');
}

//查看详情操作
function handleDetail(row) {
  isDisab.value = true;
  showDialog.value = true;
  title.value = '查看供水厂';
  form.value = row;
}
// 修改按钮操作
function handleUpdate(row) {
  isDisab.value = false;
  showDialog.value = true;
  title.value = '修改供水厂';
  form.value = { ...row };
}
function deleteData(row) {
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await waterCompDelete(row.id);
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getDataList();
    })
    .catch(() => {});
}

onMounted(() => {
  getDataList();
});
</script>
<style scoped lang="scss"></style>