luohairen
2024-11-25 2d0dd4f12d0f58c45e8c1de919b689bd97b88b08
项目计划记录展示
3个文件已修改
1个文件已添加
234 ■■■■■ 已修改文件
src/api/project/plan/index.js 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/plan/index.vue 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/plan/planRecord.vue 204 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/project/plan/index.js
@@ -9,6 +9,14 @@
  })
}
// 查询月度计划列表
export function getPlanRecordList(id) {
  return request({
    url: '/api/project-plan-record/' + id,
    method: 'post'
  })
}
// 查询项目计划记录详细
export function getRecord(id) {
  return request({
@@ -20,7 +28,7 @@
// 新增项目计划记录
export function addRecord(data) {
  return request({
    url: '/plan/record',
    url: '/api/project-plan-record',
    method: 'post',
    data: data
  })
src/router/index.js
@@ -110,6 +110,13 @@
        component: () => import('@/views/project/plan/index'),
        name: 'Index',
        meta: { title: '项目计划' }
      },
      /** 项目计划记录 */
      {
        path: '/plan/planRecord',
        component: () => import('@/views/project/plan/planRecord'),
        name: 'PlanRecord',
        meta: { title: '项目计划记录' }
      }
    ]
  },
src/views/project/plan/index.vue
@@ -192,7 +192,7 @@
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            @click="handlePlanRecord(scope.row)"
          >查看</el-button>
          <el-button
            size="mini"
@@ -252,7 +252,7 @@
import { getList, getRecord, delRecord, addRecord, updateRecord } from "@/api/project/plan/index";
export default {
  name: "Record",
  name: "index",
  data() {
    return {
      // 遮罩层
@@ -385,6 +385,15 @@
      this.download('plan/record/export', {
        ...this.queryParams
      }, `record_${new Date().getTime()}.xlsx`)
    },
    /** 查看项目计划记录 */
    handlePlanRecord(row) {
      this.$router.push({
        path: '/plan/planRecord',
        query: {
          data: JSON.stringify(row)
        }
      })
    }
  }
};
src/views/project/plan/planRecord.vue
New file
@@ -0,0 +1,204 @@
<template>
  <div class="app-container">
    <el-container>
      <el-header v-show="planInfoData && planInfoData.projectName" class="header-title">项目名称:{{ planInfoData.projectName }}</el-header>
      <h4 v-show="planInfoData && planInfoData.projectCode" style="text-align: center">项目代码:{{ planInfoData.projectCode }}</h4>
      <el-main>
        <el-card shadow="hover">
          <el-row :gutter="20">
            <el-col :span="24" class="mb-4">
              <span>月度计划</span>
              <el-button type="primary" size="small" style="float: right" @click="handleAddMonthPlan">新增</el-button>
              <el-table :data="monthRecords" style="width: 100%">
                <!-- 表头 -->
                <el-table-column prop="id" label="序号"></el-table-column>
                <el-table-column prop="projectName" label="项目名称"></el-table-column>
                <el-table-column prop="projectCode" label="项目代码"></el-table-column>
                <el-table-column label="计划期">
                  <template slot-scope="scope">
                    <span>
                      {{ scope.row.planTime }}{{ scope.row.planTimeFlag === 0 ? '月度' : scope.row.planTimeFlag === 1 ? '季度' : '年度' }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column prop="createTime" label="创建时间"></el-table-column>
                <el-table-column fixed="right" label="操作">
                  <template slot-scope="scope">
                    <el-button type="primary" size="small" :disabled="scope.row.reportStatus === 0">编辑上报</el-button>
                    <el-button type="danger" size="small">删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col :span="24" class="mb-4" style="margin-top: 20px">
              <span>季度计划</span>
              <el-button type="primary" size="small" style="float: right" @click="handleAddSeasonPlan">新增</el-button>
              <el-table  :data="seasonRecords" style="width: 100%">
                <!-- 表头 -->
                <el-table-column prop="id" label="序号"></el-table-column>
                <el-table-column prop="projectName" label="项目名称"></el-table-column>
                <el-table-column prop="projectCode" label="项目代码"></el-table-column>
                <el-table-column label="计划期">
                  <template slot-scope="scope">
                    <span>
                      {{ scope.row.planTime }}{{ scope.row.planTimeFlag === 0 ? '月度' : scope.row.planTimeFlag === 1 ? '季度' : '年度' }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column prop="createTime" label="创建时间"></el-table-column>
                <el-table-column fixed="right" label="操作">
                  <template slot-scope="scope">
                    <el-button type="primary" size="small" :disabled="scope.row.reportStatus === 0">编辑上报</el-button>
                    <el-button type="danger" size="small">删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col :span="24" class="mb-4" style="margin-top: 20px">
              <span>年度计划</span>
              <el-button type="primary" size="small" style="float: right" @click="handleAddYearPlan">新增</el-button>
              <el-table  :data="yearRecords" style="width: 100%">
                <!-- 表头 -->
                <el-table-column prop="id" label="序号"></el-table-column>
                <el-table-column prop="projectName" label="项目名称"></el-table-column>
                <el-table-column prop="projectCode" label="项目代码"></el-table-column>
                <el-table-column label="计划期">
                  <template slot-scope="scope">
                    <span>
                      {{ scope.row.planTime }}{{ scope.row.planTimeFlag === 0 ? '月度' : scope.row.planTimeFlag === 1 ? '季度' : '年度' }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column prop="createTime" label="创建时间"></el-table-column>
                <el-table-column fixed="right" label="操作">
                  <template slot-scope="scope">
                    <el-button type="primary" size="small" :disabled="scope.row.reportStatus === 0">编辑上报</el-button>
                    <el-button type="danger" size="small">删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
        </el-card>
      </el-main>
    </el-container>
  </div>
</template>
<script>
import {addRecord, getPlanRecordList} from "@/api/project/plan/index";
export default {
  // name: "planRecord",
  data() {
    return {
      loading: true,
      // 接收传递过来的项目计划数据
      planInfoData: {},
      // 月度计划数据
      monthRecords: [],
      // 季度计划数据
      seasonRecords: [],
      // 年度计划数据
      yearRecords: [],
      // 新增计划
    }
  },
  methods: {
    // 页面加载
    search() {
      this.getPlanRecordData(this.planInfoData.id);
    },
    // 获取传递过来的项目计划详情
    getPlanInfoData() {
      // 从查询参数中获取数据
      if (this.$route.query.data) {
        this.planInfoData = JSON.parse(this.$route.query.data);
        console.log(JSON.parse(this.$route.query.data))
        this.getPlanRecordData(this.planInfoData.id);
      }
    },
    // 获取项目计划记录数据
    getPlanRecordData(id) {
      this.loading = true;
      getPlanRecordList(id).then(res => {
        this.monthRecords = res.data.monthRecords;
        // 获取季度计划数据
        this.seasonRecords = res.data.seasonRecords;
        // 获取年度计划数据
        this.yearRecords = res.data.yearRecords;
        console.log(this.monthRecords);
        this.loading = false;
      })
    },
    // 新增月度计划记录
    handleAddMonthPlan() {
      let planRecordData = {
        id: undefined,
        projectInfoId: this.planInfoData.id,
        planTimeFlag: 0
      }
      // 判断月度计划是否为空
      if (this.monthRecords.length === 0){
        planRecordData.id = 0;
      }else {
        planRecordData.id = this.monthRecords[this.monthRecords.length - 1].id;
      }
      // 新增一行记录
      addRecord(planRecordData).then(res => {
        this.search();
      });
    },
    // 新增季度计划记录
    handleAddSeasonPlan() {
      let planRecordData = {
        id: undefined,
        projectInfoId: this.planInfoData.id,
        planTimeFlag: 1
      }
      // 判断季度计划是否为空
      if (this.seasonRecords.length === 0){
        planRecordData.id = 0;
      }else {
        planRecordData.id = this.seasonRecords[this.seasonRecords.length - 1].id;
      }
      // 新增一行记录
      addRecord(planRecordData).then(res => {
        this.search();
      });
    },
    // 新增年度计划记录
    handleAddYearPlan() {
      let planRecordData = {
        id: undefined,
        projectInfoId: this.planInfoData.id,
        planTimeFlag: 2
      }
      // 判断年度计划是否为空
      if (this.yearRecords.length === 0){
        planRecordData.id = 0;
      }else {
        planRecordData.id = this.yearRecords[this.yearRecords.length - 1].id;
      }
      // 新增一行记录
      addRecord(planRecordData).then(res => {
        this.search();
      });
    },
  },
  created() {
    this.getPlanInfoData();
  },
};
</script>
<style scoped>
.header-title {
  font-size: 24px; /* 根据需要调整字体大小 */
  text-align: center; /* 居中对齐 */
  line-height: 64px; /* 如果需要与 header 高度对齐 */
}
</style>