Blame view

src/components/inspection/pointPlan.vue 4.09 KB
1d73dc48   wuxw   继续晚上巡检功能
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
  <template>
    <div class="margin-top">
      <el-row class="margin-top-lg">
        <el-col :span="8" class="text-right"></el-col>
      </el-row>
      <div class="margin-top">
        <el-table :data="pointPlanInfo.plans" style="width: 100%">
          <el-table-column prop="inspectionPlanName" :label="$t('inspectionPlan.planName')" align="center"></el-table-column>
          <el-table-column prop="inspectionRouteName" :label="$t('inspectionPlan.planRoute')" align="center"></el-table-column>
          <el-table-column prop="inspectionPlanPeriodName" :label="$t('inspectionPlan.planPeriod')" align="center"></el-table-column>
          <el-table-column prop="signTypeName" :label="$t('inspectionPlan.signType')" align="center"></el-table-column>
          <el-table-column :label="$t('inspectionPlan.dateRange')" align="center">
            <template slot-scope="scope">
              {{ scope.row.startDate }}~{{ scope.row.endDate }}
            </template>
          </el-table-column>
          <el-table-column :label="$t('inspectionPlan.timeRange')" align="center">
            <template slot-scope="scope">
              {{ scope.row.startTime }}~{{ scope.row.endTime }}
            </template>
          </el-table-column>
          <el-table-column prop="beforeTime" :label="$t('inspectionPlan.taskAhead')" align="center"></el-table-column>
          <el-table-column prop="createUserName" :label="$t('inspectionPlan.creator')" align="center"></el-table-column>
          <el-table-column prop="createTime" :label="$t('inspectionPlan.createTime')" align="center"></el-table-column>
          <el-table-column :label="$t('inspectionPlan.inspector')" align="center">
            <template slot-scope="scope">
              <div v-for="(staff, i) in scope.row.staffs" :key="i">{{ staff.staffName }}</div>
            </template>
          </el-table-column>
          <el-table-column prop="stateName" :label="$t('inspectionPlan.status')" align="center"></el-table-column>
        </el-table>
        
        <el-row class="margin-top">
          <el-col :span="4"></el-col>
          <el-col :span="20" class="text-right">
            <el-pagination
              @current-change="handlePageChange"
              :current-page.sync="currentPage"
              :page-size="pageSize"
              layout="prev, pager, next, jumper"
              :total="total">
            </el-pagination>
          </el-col>
        </el-row>
      </div>
    </div>
  </template>
  
  <script>
  import { queryPointInspectionPlan } from '@/api/inspection/pointPlanApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'PointPlan',
    props: {
      inspectionId: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        pointPlanInfo: {
          plans: [],
          planUserName: '',
          inspectionStartTime: '',
          inspectionEndTime: ''
        },
        currentPage: 1,
        pageSize: 10,
        total: 0
      }
    },
    watch: {
      inspectionId(newVal) {
        if (newVal) {
          this._loadPointPlanData(this.currentPage, this.pageSize)
        }
      }
    },
    methods: {
      async _loadPointPlanData(page, row) {
        try {
          const communityId = getCommunityId()
          const params = {
            communityId,
            inspectionId: this.inspectionId,
            planUserName: this.pointPlanInfo.planUserName,
            inspectionStartTime: this.pointPlanInfo.inspectionStartTime,
            inspectionEndTime: this.pointPlanInfo.inspectionEndTime,
            page,
            row
          }
          
          const res = await queryPointInspectionPlan(params)
          this.pointPlanInfo.plans = res.data
          this.total = res.total
        } catch (error) {
          console.error('加载计划数据失败:', error)
        }
      },
      
      handlePageChange(currentPage) {
        this._loadPointPlanData(currentPage, this.pageSize)
      },
      
      refresh() {
        this.currentPage = 1
        this._loadPointPlanData(this.currentPage, this.pageSize)
      },
      
      setPlanUserName(name) {
        this.pointPlanInfo.planUserName = name
      },
      
      setDateRange(startTime, endTime) {
        this.pointPlanInfo.inspectionStartTime = startTime
        this.pointPlanInfo.inspectionEndTime = endTime
      }
    }
  }
  </script>