Blame view

src/components/inspection/pointPlan.vue 4.13 KB
1d73dc48   wuxw   继续晚上巡检功能
1
  <template>
48ea9c43   wuxw   巡检开发完成
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
    <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"
      />
1d73dc48   wuxw   继续晚上巡检功能
52
53
54
55
    </div>
  </template>
  
  <script>
48ea9c43   wuxw   巡检开发完成
56
  import { queryPointInspectionPlan } from '@/api/inspection/inspectionPointApi'
1d73dc48   wuxw   继续晚上巡检功能
57
58
59
60
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'PointPlan',
1d73dc48   wuxw   继续晚上巡检功能
61
62
63
64
    data() {
      return {
        pointPlanInfo: {
          plans: [],
48ea9c43   wuxw   巡检开发完成
65
66
67
68
69
70
          inspectionId: ''
        },
        page: {
          current: 1,
          size: 10,
          total: 0
1d73dc48   wuxw   继续晚上巡检功能
71
        },
48ea9c43   wuxw   巡检开发完成
72
73
        loading: false,
        communityId: ''
1d73dc48   wuxw   继续晚上巡检功能
74
75
      }
    },
48ea9c43   wuxw   巡检开发完成
76
77
    created() {
      this.communityId = getCommunityId()
1d73dc48   wuxw   继续晚上巡检功能
78
79
    },
    methods: {
48ea9c43   wuxw   巡检开发完成
80
81
82
83
84
85
86
87
88
89
      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
        
1d73dc48   wuxw   继续晚上巡检功能
90
        try {
1d73dc48   wuxw   继续晚上巡检功能
91
          const params = {
48ea9c43   wuxw   巡检开发完成
92
93
94
95
            communityId: this.communityId,
            inspectionId: this.pointPlanInfo.inspectionId,
            page: page,
            row: size
1d73dc48   wuxw   继续晚上巡检功能
96
97
          }
          
48ea9c43   wuxw   巡检开发完成
98
99
100
          const response = await queryPointInspectionPlan(params)
          this.pointPlanInfo.plans = response.data
          this.page.total = response.records
1d73dc48   wuxw   继续晚上巡检功能
101
        } catch (error) {
48ea9c43   wuxw   巡检开发完成
102
103
104
105
          console.error('获取巡检计划失败:', error)
          this.$message.error(this.$t('pointPlan.fetchError'))
        } finally {
          this.loading = false
1d73dc48   wuxw   继续晚上巡检功能
106
107
108
        }
      },
      
48ea9c43   wuxw   巡检开发完成
109
110
111
112
113
114
      getStateTagType(state) {
        // 根据状态返回不同的标签类型
        if (state === 'active') return 'success'
        if (state === 'inactive') return 'danger'
        if (state === 'pending') return 'warning'
        return 'info'
1d73dc48   wuxw   继续晚上巡检功能
115
116
      },
      
48ea9c43   wuxw   巡检开发完成
117
118
119
      handleSizeChange(size) {
        this.page.size = size
        this._loadPointPlanData(this.page.current, size)
1d73dc48   wuxw   继续晚上巡检功能
120
121
      },
      
48ea9c43   wuxw   巡检开发完成
122
123
124
      handleCurrentChange(page) {
        this.page.current = page
        this._loadPointPlanData(page, this.page.size)
1d73dc48   wuxw   继续晚上巡检功能
125
126
127
      }
    }
  }
48ea9c43   wuxw   巡检开发完成
128
129
130
131
132
133
134
135
136
137
138
  </script>
  
  <style scoped>
  .point-plan-container {
    padding: 20px;
  }
  
  .margin-top {
    margin-top: 20px;
  }
  </style>