Newer
Older
KaiFengPC / src / views / floodSys / assetManage / floodYL.vue
@zhangdeliang zhangdeliang 18 days ago 9 KB update
<template>
  <!-- 18个易涝积水点管理 -->
  <div class="publicContainer">
    <!-- 搜索区域 -->
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="易涝点名称" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入" clearable @keyup.enter="handleQuery" style="width: 200px" />
      </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 v-loading="tableLoading" :data="tableData" max-height="650">
      <el-table-column label="易涝点名称" prop="name" />
      <el-table-column label="易涝原因" prop="originTypeName" />
      <el-table-column label="所属道路" prop="waterloggingName" />
      <el-table-column label="治理措施" prop="solution" show-overflow-tooltip />
      <el-table-column label="治理前图片" prop="beforeSolutionPhotos">
        <template #default="scope">
          <ImagePreview
            :src="scope.row.beforeSolutionPhotos.length > 0 ? scope.row.beforeSolutionPhotos[0].url : ''"
            :width="50"
            :height="50"
          ></ImagePreview>
        </template>
      </el-table-column>
      <el-table-column label="施工中图片" prop="constructionPhotos">
        <template #default="scope">
          <ImagePreview
            :src="scope.row.constructionPhotos.length > 0 ? scope.row.constructionPhotos[0].url : ''"
            :width="50"
            :height="50"
          ></ImagePreview>
        </template>
      </el-table-column>
      <el-table-column label="治理后图片" prop="afterSolutionPhotos">
        <template #default="scope">
          <ImagePreview
            :src="scope.row.afterSolutionPhotos.length > 0 ? scope.row.afterSolutionPhotos[0].url : ''"
            :width="50"
            :height="50"
          ></ImagePreview>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" prop="updateTime" />
      <el-table-column label="操作" width="160" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" 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="110px" class="publicForm flex50">
        <el-form-item label="易涝点名称" prop="name">
          <el-input v-model="formData.name" controls-position="right" placeholder="请输入易涝点名称" />
        </el-form-item>
        <el-form-item label="易涝点位置" prop="address">
          <el-input v-model="formData.address" controls-position="right" placeholder="请输入易涝点位置" />
        </el-form-item>
        <el-form-item label="经度" prop="longitude">
          <el-input v-model="formData.longitude" controls-position="right" placeholder="请输入经度" />
        </el-form-item>
        <el-form-item label="纬度" prop="latitude">
          <el-input v-model="formData.latitude" controls-position="right" placeholder="请输入纬度" />
        </el-form-item>
        <el-form-item label="关联管网监测点" prop="stCodes">
          <el-select v-model="formData.stCodes" placeholder="请选择" clearable multiple filterable>
            <el-option v-for="item in pipeListM" :key="item.stCode" :label="item.stName" :value="item.stCode" />
          </el-select>
        </el-form-item>
        <el-form-item label="易涝原因" prop="originType">
          <el-select v-model="formData.originType" placeholder="请选择" clearable>
            <el-option v-for="item in waterlogging_origin" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="治理措施" prop="solution" style="width: 100%">
          <el-input v-model="formData.solution" type="textarea" :rows="3" placeholder="请输入治理措施" />
        </el-form-item>
        <el-form-item label="治理前图片" prop="beforeSolutionPhotos">
          <ImageFileUpload
            :limit="3"
            :saveFileArr="formData.beforeSolutionPhotos"
            :listType="'picture-card'"
            :refType="'beforeSolutionPhotos'"
            :refField="'beforeSolutionPhotos'"
          ></ImageFileUpload>
        </el-form-item>
        <el-form-item label="施工中图片" prop="constructionPhotos">
          <ImageFileUpload
            :limit="3"
            :saveFileArr="formData.constructionPhotos"
            :listType="'picture-card'"
            :refType="'constructionPhotos'"
            :refField="'constructionPhotos'"
          ></ImageFileUpload>
        </el-form-item>
        <el-form-item label="治理后图片" prop="afterSolutionPhotos">
          <ImageFileUpload
            :limit="3"
            :saveFileArr="formData.afterSolutionPhotos"
            :listType="'picture-card'"
            :refType="'afterSolutionPhotos'"
            :refField="'afterSolutionPhotos'"
          ></ImageFileUpload>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="info" @click="cancelForm">取 消</el-button>
          <el-button type="primary" @click="submitForm">确 定</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="18个易涝积水点管理">
import { floodYLPage, floodYLEdit, floodYLAdd, floodYLDetail, floodYLDelete } from '@/api/longoPeration/WaterloggingPoint';
import { listrtuSiteInfo } from '@/api/dataAnalysis/rtuSiteInfo';
import ImageFileUpload from '@/components/ImageFileUpload/index.vue'; //图片文件上传

const { proxy } = getCurrentInstance();
const { waterlogging_origin } = proxy.useDict('waterlogging_origin'); // 易涝点原因 字典数据

const tableData = ref([]);
const tableLoading = ref(true);
const total = ref(0);
const dialogShow = ref(false);
const dialogTitle = ref('');
const showSearch = ref(true);
const pipeListM = ref([]);

const allData = reactive({
  formData: {
    name: '',
    address: '',
    longitude: '',
    latitude: '',
    originType: '',
    solution: '',
    stCodes: [],
    beforeSolutionPhotos: [],
    constructionPhotos: [],
    afterSolutionPhotos: [],
  },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    name: undefined,
  },
  rulesForm: {
    longitude: [{ required: true, message: '请输入', trigger: 'blur' }],
    latitude: [{ required: true, message: '请输入', trigger: 'blur' }],
    name: [{ required: true, message: '请输入', trigger: 'blur' }],
  },
});
const { queryParams, formData, rulesForm } = toRefs(allData);

/** 获取搜索数据列表 */
function getDataList() {
  tableLoading.value = true;
  floodYLPage(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'); //清空表单
  dialogShow.value = true;
  dialogTitle.value = '添加易涝点';
}
/** 修改按钮操作 */
function handleUpdate(row) {
  const postId = row.id;
  floodYLDetail(postId).then(response => {
    dialogShow.value = true;
    dialogTitle.value = '修改易涝点';
    nextTick(() => {
      formData.value = response.data;
      formData.value.stCodes = formData.value.stCodes ? formData.value.stCodes.split(',') : [];
    });
  });
}
/** 提交按钮 */
function submitForm() {
  proxy.$refs['formRef'].validate(valid => {
    if (valid) {
      if (dialogTitle.value == '修改易涝点') {
        formData.value.stCodes = formData.value.stCodes.join(',');
        floodYLEdit(formData.value).then(response => {
          proxy.$modal.msgSuccess('修改成功');
          dialogShow.value = false;
          getDataList();
        });
      } else {
        if (formData.value.id) delete formData.value.id;
        floodYLAdd(formData.value).then(response => {
          proxy.$modal.msgSuccess('新增成功');
          dialogShow.value = false;
          getDataList();
        });
      }
    }
  });
}
/** 删除按钮操作 */
function handleDelete(row) {
  const postIds = row.id;
  proxy.$modal
    .confirm('是否确认删除该数据项?')
    .then(function () {
      return floodYLDelete(postIds);
    })
    .then(() => {
      getDataList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}
// 获取监测管网站点
async function getPipeSelect() {
  let res = await listrtuSiteInfo({ monitorTargetType: 'pipeline' });
  if (res && res.code == 200) {
    pipeListM.value = res.data || [];
  }
}

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