Newer
Older
KaiFengPC / src / views / floodSys / assetManage / WaterloggingPoint.vue
@鲁yixuan 鲁yixuan on 12 Jun 8 KB update
<template>
  <div class="publicContainer">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="排水分区" prop="belongPartition">
        <el-select clearable v-model="queryParams.belongPartition" placeholder="请选择排水分区">
          <el-option v-for="dict in road_partition_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="handleQuery">搜索</el-button>
        <el-button type="primary" icon="Plus" @click="handleAdd">新增</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <el-table :data="dataList" :span-method="objectSpanMethod" v-loading="loading" stripe :max-height="580">
      <el-table-column type="index" label="序号" width="60" />
      <el-table-column label="排水分区" prop="belongPartition">
        <template #default="scope">
          <span>{{
            scope.row.belongPartition == '1'
              ? '老城区排水分区'
              : scope.row.belongPartition == '2'
              ? '东部排水分区'
              : scope.row.belongPartition == '3'
              ? '西部排水分区'
              : scope.row.belongPartition == '4'
              ? '南部排水分区'
              : scope.row.belongPartition == '5'
              ? '北部排水分区'
              : scope.row.belongPartition == '6'
              ? '示范区排水分区'
              : scope.row.belongPartition == '7'
              ? '正在整治积水点'
              : ''
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="道路名称" prop="roadName" />
      <el-table-column label="积水点位置" prop="address" />
      <el-table-column label="已采取工程措施" prop="alreadyMeasure" width="400" />
      <el-table-column label="应急处置措施" prop="emergencyMeasure" width="400" />
      <el-table-column label="责任单位" prop="responsibilityUnit" />
      <el-table-column label="操作" width="280">
        <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="handleDelete(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="getList"
    />
    <!-- 新增弹窗 -->
    <el-dialog :title="title" v-model="open" width="800px" append-to-body :close-on-click-modal="false">
      <el-form ref="roleRef" :model="form" :rules="rules" label-width="130px" :disabled="multiple">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="排水分区" prop="belongPartition">
              <el-select clearable v-model="form.belongPartition" placeholder="请选择排水分区" style="width: 100%">
                <el-option v-for="dict in road_partition_type" :key="dict.value" :label="dict.label" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="道路名称:" prop="roadName">
              <el-input v-model="form.roadName" 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="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="responsibilityUnit">
              <el-input v-model="form.responsibilityUnit" placeholder="请输入责任单位" clearable style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="已采取工程措施:" prop="alreadyMeasure">
              <el-input
                type="textarea"
                :rows="5"
                v-model="form.alreadyMeasure"
                placeholder="请输入已采取工程措施"
                clearable
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="应急处置措施:" prop="emergencyMeasure">
              <el-input
                type="textarea"
                :rows="5"
                v-model="form.emergencyMeasure"
                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">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
<script setup name="WaterloggingPoint">
import { waterloggedRoadpage, waterloggedRoadedit, waterloggedRoadadd, waterloggedRoaddelete } from '@/api/longoPeration/WaterloggingPoint';
const { proxy } = getCurrentInstance();
const { road_partition_type } = proxy.useDict('road_partition_type'); // 排水分区字典数据
console.log(road_partition_type, 'road_partition_type');
const showSearch = ref(true);
const title = ref('');
const multiple = ref(false);
const open = ref(false);
const loading = ref(true);
const total = ref(0);
const AllData = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    belongPartition: '',
  },
  rules: {
    belongPartition: [{ required: true, message: '请选择排水分区', trigger: 'blur' }],
    roadName: [{ required: true, message: '请输入道路名称', trigger: 'blur' }],
    address: [{ required: true, message: '请输入积水点位置', trigger: 'blur' }],
    responsibilityUnit: [{ required: true, message: '请输入责任单位', trigger: 'blur' }],
    alreadyMeasure: [{ required: true, message: '请输入已采取工程措施', trigger: 'blur' }],
    emergencyMeasure: [{ required: true, message: '请输入应急处置措施', trigger: 'blur' }],
  },
});
const { queryParams, rules, form } = toRefs(AllData);
const dataList = ref([]);
//搜索
function handleQuery() {
  getList();
}
//重置
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}
// 新增
function handleAdd() {
  title.value = '新增积水点';
  open.value = true;
  form.value = {};
  multiple.value = false;
}
// 新增中取消事件
function cancel() {
  open.value = false;
  proxy.resetForm('roleRef');
}
//查看详情操作
function handleDetail(row) {
  open.value = true;
  multiple.value = true;
  title.value = '查看积水点';
  form.value = { ...row };
}
// 修改按钮操作
function handleUpdate(row) {
  open.value = true;
  title.value = '修改积水点';
  multiple.value = false;
  form.value = { ...row };
}

/** 查询列表 */
const getList = async () => {
  loading.value = true;
  let res = await waterloggedRoadpage(queryParams.value);
  dataList.value = res.data;
  total.value = res.total;
  loading.value = false;
};
/** 新增弹框 修改弹框 提交按钮 */
async function submitForm() {
  proxy.$refs['roleRef'].validate(valid => {
    if (valid) {
      if (form.value.id != undefined) {
        waterloggedRoadedit(form.value).then(() => {
          proxy.$modal.msgSuccess('修改成功');
          open.value = false;
          getList();
        });
      } else {
        waterloggedRoadadd(form.value).then(() => {
          proxy.$modal.msgSuccess('新增成功');
          open.value = false;
          getList();
        });
      }
    }
  });
}
// 表格删除
function handleDelete(row) {
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await waterloggedRoaddelete(row.id);
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getList();
    })
    .catch(() => {});
}
onMounted(() => {
  getList();
});
</script>