Newer
Older
KaiFengPC / src / views / publicService / sponge / baseInfo.vue
@zhangdeliang zhangdeliang on 3 Sep 5 KB update
<template>
  <!-- 排水防涝子系统 公众服务  海绵项目基础信息-->
  <div class="publicContainer">
    <!-- 搜索区域 -->
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="项目名称" prop="projectName">
        <el-input v-model="queryParams.projectName" placeholder="请输入" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="项目类别" prop="projectTypeId">
        <el-select v-model="queryParams.projectTypeId" placeholder="请选择" clearable>
          <el-option v-for="item in projectType" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="建设类别" prop="buildCategory">
        <el-select v-model="queryParams.buildCategory" placeholder="请选择" clearable>
          <el-option v-for="item in build_category" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </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">
      <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="projectName" />
      <el-table-column label="项目类型" prop="projectTypeName"></el-table-column>
      <el-table-column label="项目编码" prop="projectNo" />
      <el-table-column label="项目库类型" prop="projectLibraryType">
        <template #default="scope">
          <dict-tag :options="project_library_type" :value="scope.row.projectLibraryType" />
        </template>
      </el-table-column>
      <el-table-column label="建设类别" prop="buildCategory">
        <template #default="scope">
          <dict-tag :options="build_category" :value="scope.row.buildCategory" />
        </template>
      </el-table-column>
      <el-table-column label="所属排水分区" prop="drainagePartition"></el-table-column>
      <el-table-column label="项目起止日期" prop="projectTime" width="140" />
      <el-table-column label="填报时间" prop="createTime" width="120" />
      <el-table-column label="任务类型" prop="taskType">
        <template #default="scope">
          <dict-tag :options="task_type" :value="scope.row.taskType" />
        </template>
      </el-table-column>
      <el-table-column label="建设进度" prop="projectProgress" />
      <el-table-column label="是否置顶" prop="topOrder">
        <template #default="scope">
          <span :class="scope.row.topOrder == 1 ? 'green' : 'red'">{{ scope.row.topOrder == 1 ? '已置顶' : '未置顶' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="80" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="warning" @click="handleTop(scope.row)" v-if="scope.row.topOrder == 1"> 取消置顶 </el-button>
          <el-button link type="warning" @click="handleTop(scope.row)" v-else> 置顶 </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>
</template>

<script setup name="项目基础信息">
import { projectInfoList, projectInfoTop } from '@/api/publicService/index';
import { projectTypeList } from '@/api/project/xmlxwh.js'; //获取项目类型

const { proxy } = getCurrentInstance();
const { build_category, project_library_type, task_type } = proxy.useDict('build_category', 'project_library_type', 'task_type');
const tableData = ref([]);
const tableLoading = ref(true);
const total = ref(0);
const showSearch = ref(true);
const projectType = ref([]);

const allData = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    projectTypeId: undefined,
    buildCategory: undefined,
    projectName: undefined,
  },
});
const { queryParams } = toRefs(allData);

/** 获取搜索数据列表 */
function getDataList() {
  tableLoading.value = true;
  projectInfoList(queryParams.value).then(response => {
    tableData.value = response.data;
    total.value = response.total;
    tableLoading.value = false;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getDataList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}
/** 置顶 */
function handleTop(row) {
  let forms = new FormData();
  forms.append('projectNo', row.projectNo);
  projectInfoTop(forms).then(res => {
    proxy.$modal.msgSuccess('置顶成功');
    getDataList();
  });
}
// 获取项目类别
const projectTypeGet = async () => {
  let { data } = await projectTypeList();
  data.map(item => {
    projectType.value.push({
      value: item.id,
      label: item.projectTypeName,
    });
  });
};

onMounted(() => {
  projectTypeGet();
  handleQuery();
});
</script>