licp
2024-12-19 97c857f75a9ef32489678e8dd5925472e9c7a9d1
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<template>
    <div class="flex_column">
        <div>
            <TableCard title="年度计划表">
                <template v-slot:form>
                    <div class="items_center">
                        <span>编制人</span>
                        <el-input v-model="yearForm.organizationPerson" class="search" placeholder="请输入"
                            size="small"></el-input>
                        <el-button size="small" type="primary" @click="getYearPlanList">查询</el-button>
                        <el-button size="small" @click="clearYear">清空</el-button>
                    </div>
                    <UploadExcel @upload="getYearPlanList"></UploadExcel>
                </template>
                <template v-slot:table>
                    <ZTTable
                        ref="yearTable"
                        :column="yearColumnData"
                        :height="'calc(100vh - 38em)'"
                        :highlightCurrentRow="true"
                        :rowClick="rowClick"
                        :table-data="yearTableData"
                        :table-loading="yearLoading"
                        style="margin-top: 0.5em;
                        padding: 0 15px;"
                    >
                    </ZTTable>
                    <el-divider></el-divider>
                    <!-- 分页 -->
                    <div class="pagination">
                        <div></div>
                        <el-pagination :page-size="yearPage.pageSize" :page-sizes="[10, 20, 30, 40]"
                            :total="yearPage.total" layout="total, sizes, prev, pager, next, jumper"
                            @current-change="handleYearCurrent" @size-change="handleYearSizeChange">
                        </el-pagination>
                    </div>
                </template>
            </TableCard>
        </div>
        <div style="width: 100%; height: 0.5em; background-color: #f5f7fb;"></div>
        <div>
            <TableCard title="年度计划明细表">
                <template v-slot:form>
                    <div class="items_center">
                        <span>监督日期</span>
                        <el-date-picker v-model="yearDetailForm.date" class="date_box" format="yyyy-MM-dd" placeholder="选择日期"
                            size="small" type="date" value-format="yyyy-MM-dd">
                        </el-date-picker>
                        <span>监督项目</span>
                        <el-input v-model="yearDetailForm.project" class="search" placeholder="请输入" size="small"></el-input>
                        <el-button size="small" type="primary" @click="getYearDetailPlanList">查询</el-button>
                        <el-button size="small" @click="clearDetail">清空</el-button>
                    </div>
                    <div>
                        <el-button v-if="isOperation" size="small" type="primary" @click="showDialog('add')">新增</el-button>
                    </div>
                </template>
                <template v-slot:table>
                    <ZTTable :column="yearDetailColumnData" :height="'calc(100vh - 38em)'" :table-data="yearDetailTableData"
                        :table-loading="yearDetailLoading" style="margin-top: 18px; padding: 0 15px;">
                    </ZTTable>
                    <el-divider></el-divider>
                    <!-- 分页 -->
                    <div class="pagination">
                        <div></div>
                        <el-pagination :page-size="yearDeatilPage.pageSize" :page-sizes="[10, 20, 30, 40]"
                            :total="yearDeatilPage.total" layout="total, sizes, prev, pager, next, jumper"
                            @current-change="handleYearDetailCurrent" @size-change="handleYearDetailSizeChange">
                        </el-pagination>
                    </div>
                </template>
            </TableCard>
        </div>
        <PlanAdd ref="planModal" :planId="planId"  @submit="handleForm"></PlanAdd>
    </div>
</template>
<script>
import TableCard from "../../../TableCard/index.vue"
import PlanAdd from "./Add.vue"
import ZTTable from '../../../ZTTable/index.vue'
import UploadExcel from "./UploadExcel.vue"
import { yearPlanListApi, yearDetailPlanListApi, delYearPlanApi, delYearPlanDetailApi, yearPlanDetailApprovalApi, exportSuperVisePlanApi} from "../../../../../assets/api/api"
 
export default {
    components: {
        TableCard,
        PlanAdd,
        ZTTable,
        UploadExcel
    },
    data() {
        return {
            planId: undefined,
            yearForm: {
                organizationPerson: undefined,
            },
            yearTableData: [],  // 年表
            yearPage: {
                curent: 1,
                pageSize: 20,
                total: 0
            },
            yearColumnData: [
                {
                    label: '文件名称',
                    prop: 'fileName',
                    minWidth: '150px'
                }, {
                    label: '编制人',
                    prop: 'organizationPerson',
                    minWidth: '100'
                }, {
                    label: '编制日期',
                    prop: 'organizationDate',
                    minWidth: '160'
                }, {
                    label: '批准人',
                    prop: 'approvalName',
                    minWidth: '100'
                }, {
                    label: '批准日期',
                    prop: 'approvalDate',
                    minWidth: '160'
                }, {
                    label: '审核人',
                    prop: 'examine'
                }, {
                    dataType: 'tag',
                    label: '批准状态',
                    prop: 'approvalStatus',
                    minWidth: '130',
                    formatData: (params) => {
                        if (params == 1) {
                            return '批准'
                        } else {
                            return '不批准'
                        }
                    },
                    formatType: (params) => {
                        if (params == 1) {
                            return 'success'
                        } else {
                            return 'danger'
                        }
                    }
                }, {
                    label: '创建日期',
                    prop: 'createTime',
                    minWidth: '160'
                }, {
                    label: '创建人',
                    prop: 'createName',
                    minWidth: '100'
                }, {
                    dataType: 'action',
                    minWidth: '160',
                    label: '操作',
                  fixed: 'right',
                    operation: [
                      {
                        name: '导出',
                        type: 'text',
                        clickFun: (row) => {
                          this.downLoadPost(row)
                        }
                      },
                      {
                        name: '批准',
                        type: 'text',
                        disabled: (row) => {
                          if (row.approvalStatus == 1) {
                            return true
                          } else {
                            return false
                          }
                        },
                        clickFun: (row) => {
                          this.approvalYearPlan(row)
                        }
                      },
                      {
                        name: '删除',
                        type: 'text',
                        color: '#f56c6c',
                        clickFun: (row) => {
                          this.delYearPlan(row.id)
                        }
                      }
                    ]
                }],
            yearLoading: false,
            yearDetailForm: {
                date: undefined,
                project: undefined
            },
            yearDetailTableData: [],    // 年明细表
            yearDeatilPage: {
                curent: 1,
                pageSize: 20,
                total: 0
            },
            yearDetailColumnData: [
                {
                    label: '监督日期',
                    prop: 'superviseDate'
                }, {
                    label: '监督目的',
                    prop: 'superviseDes'
                }, {
                    label: '被监督人员',
                    prop: 'supervisePerson'
                }, {
                    label: '备注',
                    prop: 'remarks'
                }, {
                    label: '培训日期',
                    prop: 'trainDate'
                }, {
                    label: '创建',
                    prop: 'createBy'
                }, {
                    dataType: 'action',
                    width: '180',
                    label: '操作',
                    operation: [
                        {
                            name: '编辑',
                            type: 'text',
                            clickFun: (row) => {
                                this.$refs.planModal.showDialog(row, true)
                            }
                        },
                        {
                            name: '删除',
                            type: 'text',
                            color: '#f56c6c',
                            clickFun: (row) => {
                                this.delYearPlanDetail(row.id)
                            }
                        }
                    ]
                }
            ],
            yearDetailLoading: false,
          isOperation: false,
        }
    },
    mounted() {
        this.getYearPlanList()
        // this.getYearDetailPlanList()
    },
    methods: {
        /**
         * @desc 查询年度计划列表
         */
        async getYearPlanList() {
            this.yearLoading = true
            const { code, data } = await this.$axios({
                method: 'get',
                url: yearPlanListApi,
                params: {
                    current: this.yearPage.curent,
                    size: this.yearPage.pageSize,
                    organizationPerson: this.yearForm.organizationPerson
                }
            })
            if (code == 200) {
                this.yearTableData = data.records
                this.yearPage.total = data.total
              if (this.yearTableData.length > 0) {
                this.rowClick(this.yearTableData[0])
              }
            }
            this.yearLoading = false
        },
        // 年计划分页
        handleYearCurrent(page) {
            this.yearPage.curent = page
            this.getYearPlanList()
        },
        handleYearSizeChange(size) {
            this.yearPage.pageSize = size
            this.getYearPlanList()
        },
        // 年度计划表格,点击行数据后刷新详情
        rowClick(row) {
          const now = new Date();
          const currentYear = now.getFullYear();
          if (row.createTime.slice(0,4) == currentYear) {
            this.isOperation = true;
          } else {
            this.isOperation = false;
          }
            this.planId = row.id
            this.getYearDetailPlanList()
        },
        // 新增|编辑完成后做什么
        handleForm() {
            this.getYearDetailPlanList()
        },
        // 清除年
        clearYear() {
            this.$refs.yearTable.setCurrent()
            this.yearForm.organizationPerson = undefined
            this.getYearPlanList()
        },
        // 清除明细
        clearDetail() {
            this.yearDetailForm.date = undefined
            this.yearDetailForm.project = undefined
            this.getYearDetailPlanList()
        },
 
        /**
         * @desc 查询年度计划明细
         */
        async getYearDetailPlanList() {
            this.yearDetailLoading = true
            const { code, data } = await this.$axios({
                method: 'get',
                url: yearDetailPlanListApi,
                params: {
                    planId: this.planId,
                    current: this.yearDeatilPage.curent,
                    size: this.yearDeatilPage.pageSize,
                    date: this.yearDetailForm.date,
                    project: this.yearDetailForm.project
                }
            })
            if (code == 200) {
                this.yearDetailTableData = data.records
                this.yearDeatilPage.total = data.total
            }
            this.yearDetailLoading = false
        },
        showDialog(operationType,row, type = false) {
          if (operationType === 'add') {
            if (!this.planId) {
              this.$message.warning('请选择一条计划进行新增')
              return
            }
          }
          this.$refs.planModal.showDialog({planId:this.planId,...row}, type)
        },
 
 
 
        // 年明细计划分页
        handleYearDetailCurrent(page) {
            this.yearDeatilPage.curent = page
            this.getYearDetailPlanList()
        },
        handleYearDetailSizeChange(size) {
            this.yearDeatilPage.pageSize = size
            this.getYearDetailPlanList()
        },
        // 删除年计划
        delYearPlan(id) {
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async () => {
                const { code } = await this.$axios({
                    method: 'delete',
                    url: delYearPlanApi,
                    params: { id }
                })
                if (code == 200) {
                    this.$message.success('删除成功')
                    this.getYearPlanList()
                    this.getYearDetailPlanList()
                } else {
                    this.$message.error('删除失败')
                }
            })
        },
        // 删除年计划明细
        delYearPlanDetail(id) {
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async () => {
                const { code } = await this.$axios({
                    method: 'delete',
                    url: delYearPlanDetailApi,
                    params: { id }
                })
                if (code == 200) {
                    this.$message.success('删除成功')
                    this.getYearDetailPlanList()
                } else {
                    this.$message.error('删除失败')
                }
            })
        },
        // 批准年度计划
        approvalYearPlan(row) {
            this.$confirm('确认批准该年度计划?', '提示', {
                confirmButtonText: '批准',
                cancelButtonText: '不批准',
                type: 'info'
            }).then(() => {
                this.approvalYearPlanFun(1, row.id)
            }).catch(action => {
              this.approvalYearPlanFun(0, row.id)
            })
        },
      // 年度计划表-下载
      downLoadPost(row) {
        this.$axios.get(exportSuperVisePlanApi + '?id=' + row.id,{responseType: "blob"}).then(res => {
          this.outLoading = false
          this.$message.success('导出成功')
          const blob = new Blob([res],{ type: 'application/msword' });
          const url = URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = url;
          link.download = row.fileName + '.docx';
          link.click();
        })
      },
      async approvalYearPlanFun(approvalStatus, rowId) {
        const { code } = await this.$axios({
          method: 'get',
          url: yearPlanDetailApprovalApi,
          params: {
            id: rowId,
            approvalStatus: approvalStatus
          },
        })
        if (code == 200) {
          this.$message.success('操作成功!')
          this.getYearPlanList()
        } else {
          this.$message.error('操作成功!')
        }
      }
    }
}
</script>
<style scoped>
.flex_column {
    display: flex;
    height: 80vh;
    flex-direction: column;
    overflow: auto;
    justify-content: space-between;
}
 
.pagination {
    display: flex;
    justify-content: space-between
}
 
.items_center {
    display: flex;
    align-items: center;
}
 
.date_box {
    margin: 0 5px;
}
 
.search {
    width: 150px;
    padding: 0 16px;
}
</style>