luohairen
2024-11-27 80cd0d5cc25176c3efe771aa40a7150c75331953
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<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">
              <div style="margin-bottom: 10px">
                <span style="font-size: 20px; font-weight: bold;">月度计划</span>
                <el-button type="primary" size="small" style="float: right" @click="handleAddMonthPlan">新增</el-button>
              </div>
              <el-table :data="monthRecords" style="width: 100%">
                <!-- 表头 -->
                <el-table-column prop="id" label="序号" align="center"></el-table-column>
                <el-table-column prop="projectName" label="项目名称" align="center"></el-table-column>
                <el-table-column prop="projectCode" label="项目代码" align="center"></el-table-column>
                <el-table-column label="计划期" align="center">
                  <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="创建时间" align="center"></el-table-column>
                <el-table-column fixed="right" label="操作" align="center">
                  <template slot-scope="scope">
                    <el-button type="primary" size="small" :disabled="scope.row.reportStatus === 0" @click="handlePlanInfo(scope.row)">编辑上报</el-button>
                    <el-button type="danger" size="small" v-show="scope.row.reportStatus === 1" @click="handleDeletePlanRecord(scope.row.id)">删除</el-button>
                    <el-button type="danger" size="small" v-show="scope.row.reportStatus === 0" @click="handleCheckPlanInfo(scope.row)">查看</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col :span="24" class="mb-4" style="margin-top: 20px">
              <div style="margin-bottom: 10px">
                <span style="font-size: 20px; font-weight: bold;">季度计划</span>
                <el-button type="primary" size="small" style="float: right" @click="handleAddSeasonPlan">新增</el-button>
              </div>
              <el-table  :data="seasonRecords" style="width: 100%">
                <!-- 表头 -->
                <el-table-column prop="id" label="序号" align="center"></el-table-column>
                <el-table-column prop="projectName" label="项目名称" align="center"></el-table-column>
                <el-table-column prop="projectCode" label="项目代码" align="center"></el-table-column>
                <el-table-column label="计划期" align="center">
                  <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="创建时间" align="center"></el-table-column>
                <el-table-column fixed="right" label="操作" align="center">
                  <template slot-scope="scope">
                    <el-button type="primary" size="small" :disabled="scope.row.reportStatus === 0" @click="handlePlanInfo(scope.row)">编辑上报</el-button>
                    <el-button type="danger" size="small" v-show="scope.row.reportStatus === 1" @click="handleDeletePlanRecord(scope.row.id)">删除</el-button>
                    <el-button type="danger" size="small" v-show="scope.row.reportStatus === 0" @click="handleCheckPlanInfo(scope.row)">查看</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col :span="24" class="mb-4" style="margin-top: 20px">
              <div style="margin-bottom: 10px">
                <span style="font-size: 20px; font-weight: bold;">年度计划</span>
                <el-button type="primary" size="small" style="float: right" @click="handleAddYearPlan">新增</el-button>
              </div>
              <el-table  :data="yearRecords" style="width: 100%">
                <!-- 表头 -->
                <el-table-column prop="id" label="序号" align="center"></el-table-column>
                <el-table-column prop="projectName" label="项目名称" align="center"></el-table-column>
                <el-table-column prop="projectCode" label="项目代码" align="center"></el-table-column>
                <el-table-column label="计划期" align="center">
                  <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="创建时间" align="center"></el-table-column>
                <el-table-column fixed="right" label="操作" align="center">
                  <template slot-scope="scope">
                    <el-button type="primary" size="small" :disabled="scope.row.reportStatus === 0" @click="handlePlanInfo(scope.row)">编辑上报</el-button>
                    <el-button type="danger" size="small" v-show="scope.row.reportStatus === 1" @click="handleDeletePlanRecord(scope.row.id)">删除</el-button>
                    <el-button type="danger" size="small" v-show="scope.row.reportStatus === 0" @click="handleCheckPlanInfo(scope.row)">查看</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
        </el-card>
      </el-main>
    </el-container>
  </div>
</template>
 
<script>
import {addRecord, getPlanRecordList, deletePlanRecord} from "@/api/projectPlan/index";
 
export default {
  name: "planRecord",
  data() {
    return {
      // 接收传递过来的项目计划数据
      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);
        this.getPlanRecordData(this.planInfoData.id);
      }
    },
    // 获取项目计划记录数据
    getPlanRecordData(id) {
      getPlanRecordList(id).then(res => {
        this.monthRecords = res.data.monthRecords;
        // 获取季度计划数据
        this.seasonRecords = res.data.seasonRecords;
        // 获取年度计划数据
        this.yearRecords = res.data.yearRecords;
      })
    },
    // 新增月度计划记录
    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();
      });
    },
    /** 修改项目计划项 */
    handlePlanInfo(row) {
      this.$router.push({
        name: 'PlanInfo',
        query: {
          data: JSON.stringify(row),
          planInfoData: this.planInfoData
        }
      })
    },
    // 删除项目计划记录
    handleDeletePlanRecord(id) {
      deletePlanRecord(id).then(res => {
        this.search();
      });
    },
    // 查看项目计划项
    handleCheckPlanInfo(row) {
      this.$router.push({
        path: '/projectManage/planInfoCheck',
        query: {
          data: JSON.stringify(row),
        }
      })
    }
  },
  created() {
    this.getPlanInfoData();
  },
};
</script>
 
<style scoped>
.header-title {
  font-size: 24px; /* 根据需要调整字体大小 */
  text-align: center; /* 居中对齐 */
  line-height: 64px; /* 如果需要与 header 高度对齐 */
}
</style>