pointPlan.vue
4.13 KB
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
<template>
<div class="point-plan-container">
<el-table
:data="pointPlanInfo.plans"
border
style="width: 100%; margin-top: 20px;"
v-loading="loading"
>
<el-table-column prop="inspectionPlanName" :label="$t('pointPlan.table.planName')" align="center" />
<el-table-column prop="inspectionRouteName" :label="$t('pointPlan.table.routeName')" align="center" />
<el-table-column prop="inspectionPlanPeriodName" :label="$t('pointPlan.table.planPeriod')" align="center" />
<el-table-column prop="signTypeName" :label="$t('pointPlan.table.signType')" align="center" />
<el-table-column :label="$t('pointPlan.table.dateRange')" align="center">
<template slot-scope="scope">
{{ scope.row.startDate }} ~ {{ scope.row.endDate }}
</template>
</el-table-column>
<el-table-column :label="$t('pointPlan.table.timeRange')" align="center">
<template slot-scope="scope">
{{ scope.row.startTime }} ~ {{ scope.row.endTime }}
</template>
</el-table-column>
<el-table-column prop="beforeTime" :label="$t('pointPlan.table.beforeTime')" align="center" />
<el-table-column prop="createUserName" :label="$t('pointPlan.table.creator')" align="center" />
<el-table-column prop="createTime" :label="$t('pointPlan.table.createTime')" align="center" />
<el-table-column :label="$t('pointPlan.table.staffs')" align="center">
<template slot-scope="scope">
<div v-for="(staff, index) in scope.row.staffs" :key="index">
{{ staff.staffName }}
</div>
</template>
</el-table-column>
<el-table-column :label="$t('pointPlan.table.state')" align="center">
<template slot-scope="scope">
<el-tag :type="getStateTagType(scope.row.state)">
{{ scope.row.stateName }}
</el-tag>
</template>
</el-table-column>
</el-table>
<el-pagination
class="margin-top"
:current-page.sync="page.current"
:page-sizes="[10, 20, 30, 50]"
:page-size="page.size"
:total="page.total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</template>
<script>
import { queryPointInspectionPlan } from '@/api/inspection/inspectionPointApi'
import { getCommunityId } from '@/api/community/communityApi'
export default {
name: 'PointPlan',
data() {
return {
pointPlanInfo: {
plans: [],
inspectionId: ''
},
page: {
current: 1,
size: 10,
total: 0
},
loading: false,
communityId: ''
}
},
created() {
this.communityId = getCommunityId()
},
methods: {
loadData(point) {
if (!point) return
this.pointPlanInfo.inspectionId = point.inspectionId
this._loadPointPlanData(this.page.current, this.page.size)
},
async _loadPointPlanData(page, size) {
this.loading = true
try {
const params = {
communityId: this.communityId,
inspectionId: this.pointPlanInfo.inspectionId,
page: page,
row: size
}
const response = await queryPointInspectionPlan(params)
this.pointPlanInfo.plans = response.data
this.page.total = response.total
} catch (error) {
console.error('获取巡检计划失败:', error)
this.$message.error(this.$t('pointPlan.fetchError'))
} finally {
this.loading = false
}
},
getStateTagType(state) {
// 根据状态返回不同的标签类型
if (state === 'active') return 'success'
if (state === 'inactive') return 'danger'
if (state === 'pending') return 'warning'
return 'info'
},
handleSizeChange(size) {
this.page.size = size
this._loadPointPlanData(this.page.current, size)
},
handleCurrentChange(page) {
this.page.current = page
this._loadPointPlanData(page, this.page.size)
}
}
}
</script>
<style scoped>
.point-plan-container {
padding: 0px;
}
.margin-top {
margin-top: 20px;
}
</style>