Newer
Older
KaiFengPC / src / views / floodSys / assetManage / RiverSection.vue
@鲁yixuan 鲁yixuan on 19 Aug 11 KB updata
<template>
  <!-- 排水防涝子系统 公众服务  通知公告-->
  <div class="publicContainer">
    <!-- 搜索区域 -->
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="断面名称:" prop="sectionName" style="width: 250px">
        <el-input v-model="queryParams.sectionName" placeholder="请输入断面名称" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button type="success" 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" v-hasPermi="['floodSys:jing:add']">新增</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getDataList"></right-toolbar>
    </el-row>
    <!-- 表格 -->
    <el-table v-loading="tableLoading" :data="tableData" max-height="650">
      <el-table-column label="序号" type="index" width="55" />
      <el-table-column label="断面编码" prop="sectionCode" />
      <el-table-column label="断面名称" prop="sectionName"> </el-table-column>
      <el-table-column label="所属河道" prop="riverName" width="100" />
      <el-table-column label="断面面积" prop="sectionArea" width="150" />
      <el-table-column label="断面长度" prop="sectionLength"> </el-table-column>
      <el-table-column label="断面水质" prop="sectionQuality" />
      <el-table-column label="目标水质" prop="targetQuality" />
      <el-table-column label="设计洪峰流量(m³/s)">
        <el-table-column prop="twentyPercent" label="20%" />
        <el-table-column prop="tenPercent" label="10%" />
        <el-table-column prop="fivePercent" label="5%" />
        <el-table-column prop="twoPercent" label="2%" />
        <el-table-column prop="onePercent" label="1%" />
      </el-table-column>
      <el-table-column label="区属" prop="belongTo">
        <template #default="scope">
          <span>
            {{ scope.row.belongTo == '1' ? '市区' : scope.row.belongTo == '2' ? '郊区' : '' }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="空间数据" prop="geometrys" width="200" show-overflow-tooltip />
      <el-table-column label="操作" width="240" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link icon="View" type="primary" @click="handleDetail(scope.row)">详情</el-button>
          <el-button link type="warning" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
          <el-button link type="danger" icon="Delete" @click="handleDelete(scope.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"
    />

    <!-- 添加或修改弹窗 -->
    <el-dialog :title="dialogTitle" v-model="dialogShow" width="1100px" append-to-body>
      <el-form ref="formRef" :model="formData" :rules="rulesForm" label-width="220px" class="publicForm" :disabled="isDisab">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="断面编码:" prop="sectionCode">
              <el-input type="text" v-model="formData.sectionCode" placeholder="请输入断面编码" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="断面名称:" prop="sectionName">
              <el-input type="text" v-model="formData.sectionName" 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="riverCode">
              <el-select clearable v-model="formData.riverCode" style="width: 180px" placeholder="请选择所属河道">
                <el-option v-for="item in riverDate" :key="item.riverCode" :label="item.riverName" :value="item.riverCode" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="断面面积:" prop="sectionArea">
              <el-input type="text" v-model="formData.sectionArea" 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="sectionLength">
              <el-input type="text" v-model="formData.sectionLength" placeholder="请输入断面长度" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="断面水质:" prop="sectionQuality">
              <el-input type="text" v-model="formData.sectionQuality" 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="targetQuality">
              <el-input type="text" v-model="formData.targetQuality" placeholder="请输入河道宽度" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设计洪峰流量20%(m³/s):" prop="twentyPercent">
              <el-input
                type="text"
                v-model="formData.twentyPercent"
                placeholder="请输入设计洪峰流量20%(m³/s)"
                clearable
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="设计洪峰流量10%(m³/s):" prop="tenPercent">
              <el-input type="text" v-model="formData.tenPercent" placeholder="请输入设计洪峰流量10%(m³/s)" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设计洪峰流量5%(m³/s):" prop="fivePercent">
              <el-input type="text" v-model="formData.fivePercent" placeholder="请输入设计洪峰流量5%(m³/s)" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="设计洪峰流量2%(m³/s):" prop="twoPercent">
              <el-input type="text" v-model="formData.twoPercent" placeholder="请输入设计洪峰流量2%(m³/s)" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设计洪峰流量1%(m³/s):" prop="onePercent">
              <el-input type="text" v-model="formData.onePercent" placeholder="请输入设计洪峰流量1%(m³/s)" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="区属:" prop="belongTo">
              <el-select clearable v-model="formData.belongTo" style="width: 180px" placeholder="请选择区属">
                <el-option v-for="item in WaterDate" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="空间数据:" prop="geometrys">
              <el-input type="text" v-model="formData.geometrys" placeholder="请输入空间数据" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="info" @click="cancelForm">取 消</el-button>
          <el-button type="primary" @click="submitForm" v-show="!isDisab">确 定</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="河道断面信息管理">
import { riverSectionpage, riverSectionID, riverSectionedit, riverSectionadd, riverSectiondelete } from '@/api/longoPeration/RiverSection';
import { riverInfoNewlist } from '@/api/longoPeration/BasicRiver';

import bus from '@/utils/mitt';
const { proxy } = getCurrentInstance();
const isDisab = ref(false);
const tableData = ref([]);
const tableLoading = ref(true);
const total = ref(0);
const dialogShow = ref(false);
const dialogTitle = ref('');
const showSearch = ref(true);
const WaterDate = ref([
  { value: '1', label: '市区' },
  { value: '2', label: '郊区' },
]);
const riverDate = ref([]);
const allData = reactive({
  formData: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
  rulesForm: {
    sectionCode: [{ required: true, message: '请输入断面编码', trigger: 'blur' }],
    sectionName: [{ required: true, message: '请输入断面名称', trigger: 'blur' }],
  },
});
const { queryParams, formData, rulesForm } = toRefs(allData);

/** 获取搜索数据列表 */
function getDataList() {
  tableLoading.value = true;
  riverSectionpage(queryParams.value).then(response => {
    tableData.value = response.data;
    total.value = response.total;
    tableLoading.value = false;
  });
}
/** 取消按钮 */
function cancelForm() {
  dialogShow.value = false;
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getDataList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}
/** 新增按钮操作 */
function handleAdd() {
  proxy.resetForm('formRef'); //清空表单
  formData.value.content = ' ';
  dialogShow.value = true;
  isDisab.value = false;
  dialogTitle.value = '新增河道断面信息管理';
  handXlk();
}
/** 修改按钮操作 */
function handleUpdate(row) {
  riverSectionID(row.id).then(response => {
    dialogShow.value = true;
    isDisab.value = false;
    dialogTitle.value = '修改河道断面信息管理';
    nextTick(() => {
      formData.value = response.data;
      bus.emit('changeEdit', true);
    });
  });
}
//详情按钮
function handleDetail(row) {
  riverSectionID(row.id).then(response => {
    dialogShow.value = true;
    isDisab.value = true;
    dialogTitle.value = '查看河道断面信息管理';
    nextTick(() => {
      formData.value = response.data;
      bus.emit('changeEdit', false);
    });
  });
}
/** 提交按钮 */
function submitForm() {
  proxy.$refs['formRef'].validate(valid => {
    if (valid) {
      if (dialogTitle.value == '修改河道断面信息管理') {
        riverSectionedit(formData.value).then(response => {
          proxy.$modal.msgSuccess('修改成功');
          dialogShow.value = false;
          getDataList();
        });
      } else {
        if (formData.value.id) delete formData.value.id;
        riverSectionadd(formData.value).then(response => {
          proxy.$modal.msgSuccess('新增成功');
          dialogShow.value = false;
          getDataList();
        });
      }
    }
  });
}
/** 删除按钮操作 */
function handleDelete(row) {
  const postIds = row.id;
  proxy.$modal
    .confirm('是否确认删除该数据项?')
    .then(function () {
      return riverSectiondelete(postIds);
    })
    .then(() => {
      getDataList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}

// 下拉框
function handXlk() {
  riverInfoNewlist().then(response => {
    riverDate.value = response.data;
    console.log(riverDate.value, 'riverDate.value');
  });
}

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