Newer
Older
KaiFengPC / src / views / project / projectManage / projectReport.vue
@zhangdeliang zhangdeliang on 23 Jul 7 KB udpate
<template>
  <!-- 项目综合管控子系统 项目报告管理-->
  <div class="publicContainer">
    <!-- 搜索区域 -->
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="项目报告" prop="ggTitle">
        <el-input v-model="queryParams.ggTitle" placeholder="请输入" clearable />
      </el-form-item>
      <el-form-item label="报告类型" prop="ggType">
        <el-select v-model="queryParams.ggType" filterable clearable placeholder="请选择">
          <el-option label="月度报告" value="1" />
          <el-option label="季度点评报告" value="2" />
          <el-option label="年度考核报告" value="3" />
        </el-select>
      </el-form-item>
      <el-form-item label="发布时间" prop="ggDate">
        <el-date-picker
          type="daterange"
          v-model="queryParams.ggDate"
          value-format="YYYY-MM-DD"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          placeholder="请选择日期"
        >
        </el-date-picker>
      </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">新增</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getDataList"></right-toolbar>
    </el-row>
    <!-- 表格 -->
    <el-table v-loading="tableLoading" :data="tableData">
      <el-table-column label="项目报告" prop="ggTitle" />
      <el-table-column label="报告类型" prop="ggType" />
      <el-table-column label="公告内容" prop="ggCont" />
      <el-table-column label="相关文件" prop="workOrderType">
        <template #default="scope">
          <span
            class="filePreview"
            @click="
              previewPdf(
                'https://server1.wh-nf.cn:9000/newfiber-standard-kaifeng/2024/06/19/4-8-2 鼓楼区2023年老旧小区改造项目海绵城市专篇_20240619215154A022.pdf'
              )
            "
          >
            公告文件.pdf
          </span>
        </template>
      </el-table-column>
      <el-table-column label="发布时间" prop="startTime" />
      <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="500px" append-to-body>
      <el-form ref="formRef" :model="formData" :rules="rulesForm" label-width="130px" class="publicForm">
        <el-form-item label="报告类型" prop="ggType">
          <el-select v-model="formData.ggType" filterable clearable placeholder="请选择">
            <el-option label="月度报告" value="1" />
            <el-option label="季度点评报告" value="2" />
            <el-option label="年度考核报告" value="3" />
          </el-select>
        </el-form-item>
        <el-form-item label="报告标题" prop="ggTitle">
          <el-input v-model="formData.ggTitle" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="上传文件" prop="fileList">
          <ImageFileUpload
            :limit="1"
            :listType="'text'"
            :saveFileArr="formData.fileList"
            :refField="'coverPhotos'"
            :refType="'rtu_site_info'"
            :fileType="['pdf']"
          ></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="公告栏管理">
import ImageFileUpload from '@/components/ImageFileUpload/index.vue'; //图片文件上传
import { orderRemindPage, orderRemindAdd, orderRemindDel, orderRemindDetail, orderRemindEdit } from '@/api/floodSys/floodStation';

const { proxy } = getCurrentInstance();

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

const allData = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    ggType: '',
    ggTitle: '',
    ggDate: null,
  },
  formData: {
    ggType: '',
    ggTitle: '',
    fileList: [],
  },
  rulesForm: {
    ggType: [{ required: true, message: '请输入', trigger: 'change' }],
    ggTitle: [{ required: true, message: '请输入', trigger: 'blur' }],
    fileList: [{ required: true, message: '请输入', trigger: 'change', type: 'array' }],
  },
});
const { queryParams, formData, rulesForm } = toRefs(allData);

/** 获取查询数据列表 */
function getDataList() {
  tableLoading.value = true;
  orderRemindPage(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 handleSelectionChange(selection) {
  checkedIds.value = selection.map(item => item.id);
  multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
  proxy.resetForm('formRef'); //清空表单
  dialogShow.value = true;
  dialogTitle.value = '添加公告栏';
}
/** 修改按钮操作 */
function handleUpdate(row) {
  const postId = row.id || checkedIds.value;
  orderRemindDetail(postId).then(response => {
    nextTick(() => {
      let datas = response.data;
      formData.value = datas;
    });
    dialogShow.value = true;
    dialogTitle.value = '修改公告栏';
  });
}
/** 提交按钮 */
function submitForm() {
  proxy.$refs['formRef'].validate(valid => {
    if (valid) {
      if (dialogTitle.value == '修改公告') {
        orderRemindEdit(formData.value).then(response => {
          proxy.$modal.msgSuccess('修改成功');
          dialogShow.value = false;
          getDataList();
        });
      } else {
        orderRemindAdd(formData.value).then(response => {
          proxy.$modal.msgSuccess('新增成功');
          dialogShow.value = false;
          getDataList();
        });
      }
    }
  });
}
/** 删除按钮操作 */
function handleDelete(row) {
  const postIds = row.id || checkedIds.value;
  proxy.$modal
    .confirm('是否确认删除该数据项?')
    .then(function () {
      return orderRemindDel(postIds);
    })
    .then(() => {
      getDataList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}

// 文件预览
function previewPdf(url) {
  window.open(url);
}

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