Blame view

src/components/inspection/ChooseInspectionRoutePoint.vue 4.79 KB
48ea9c43   wuxw   巡检开发完成
1
  <template>
d367e130   wuxw   巡检功能测试
2
    <el-dialog :title="$t('inspectionRoute.choosePointTitle')" :visible.sync="visible" width="70%" @close="handleClose">
48ea9c43   wuxw   巡检开发完成
3
4
      <el-row :gutter="20">
        <el-col :span="24">
d367e130   wuxw   巡检功能测试
5
  
48ea9c43   wuxw   巡检开发完成
6
7
8
            <el-row :gutter="20" class="margin-bottom">
              <el-col :span="18"></el-col>
              <el-col :span="6">
d367e130   wuxw   巡检功能测试
9
10
11
                <el-input v-model="chooseInspectionRoutePointInfo.inspectionName"
                  :placeholder="$t('inspectionRoute.pointNamePlaceholder')" clearable class="search-input">
                  <el-button slot="append" type="primary" @click="queryPoints">
48ea9c43   wuxw   巡检开发完成
12
13
                    <i class="el-icon-search"></i>
                  </el-button>
d367e130   wuxw   巡检功能测试
14
                  <el-button slot="append" type="primary" @click="resetPoints">
48ea9c43   wuxw   巡检开发完成
15
16
17
18
19
20
                    <i class="el-icon-refresh"></i>
                  </el-button>
                </el-input>
              </el-col>
            </el-row>
  
d367e130   wuxw   巡检功能测试
21
22
23
24
25
            <el-table :data="chooseInspectionRoutePointInfo.points" border style="width: 100%"
              @selection-change="handleSelectionChange">
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column prop="inspectionId" :label="$t('inspectionRoute.pointId')" align="center" />
              <el-table-column prop="inspectionName" :label="$t('inspectionRoute.pointName')" align="center" />
48ea9c43   wuxw   巡检开发完成
26
27
            </el-table>
  
d367e130   wuxw   巡检功能测试
28
29
            <el-pagination :current-page.sync="page.current" :page-size="page.size" :total="page.total"
              layout="total, prev, pager, next" @current-change="handlePageChange" />
48ea9c43   wuxw   巡检开发完成
30
31
32
33
34
  
            <div class="text-right margin-top">
              <el-button @click="handleClose">
                {{ $t('common.cancel') }}
              </el-button>
d367e130   wuxw   巡检功能测试
35
              <el-button type="primary" @click="_chooseInspectionRoutePoint">
48ea9c43   wuxw   巡检开发完成
36
37
38
                {{ $t('common.confirm') }}
              </el-button>
            </div>
48ea9c43   wuxw   巡检开发完成
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
        </el-col>
      </el-row>
    </el-dialog>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import { listInspectionPoints, saveInspectionRoutePoint } from '@/api/inspection/inspectionRouteApi'
  
  export default {
    name: 'ChooseInspectionRoutePoint',
    data() {
      return {
        visible: false,
        chooseInspectionRoutePointInfo: {
          points: [],
          inspectionName: '',
          inspectionRouteId: '',
          selectPoints: []
        },
        page: {
          current: 1,
          size: 10,
          total: 0
        },
        communityId: '',
        multipleSelection: []
      }
    },
    created() {
      this.communityId = getCommunityId()
    },
    methods: {
      open(params) {
        this.visible = true
        this.chooseInspectionRoutePointInfo.inspectionRouteId = params.inspectionRouteId
        this._loadAllPointsInfo(1, 10)
      },
      async _loadAllPointsInfo(page, row) {
        try {
          const params = {
            page,
            row,
            inspectionName: this.chooseInspectionRoutePointInfo.inspectionName,
            relationship: '0',
            inspectionRouteId: this.chooseInspectionRoutePointInfo.inspectionRouteId,
            communityId: this.communityId
          }
d367e130   wuxw   巡检功能测试
87
88
          const { inspectionPoints, total } = await listInspectionPoints(params)
          this.chooseInspectionRoutePointInfo.points = inspectionPoints
48ea9c43   wuxw   巡检开发完成
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
          this.page.total = total
        } catch (error) {
          console.error('获取巡检点列表失败:', error)
        }
      },
      async _chooseInspectionRoutePoint() {
        if (this.multipleSelection.length === 0) {
          this.$message.warning(this.$t('inspectionRoute.choosePointWarning'))
          return
        }
  
        try {
          const params = {
            communityId: this.communityId,
            inspectionRouteId: this.chooseInspectionRoutePointInfo.inspectionRouteId,
            points: this.multipleSelection.map(item => ({
              inspectionId: item.inspectionId,
              inspectionName: item.inspectionName
            }))
          }
          await saveInspectionRoutePoint(params)
          this.$message.success(this.$t('inspectionRoute.addSuccess'))
          this.$emit('success')
          this.handleClose()
        } catch (error) {
          console.error('添加巡检点失败:', error)
        }
      },
      queryPoints() {
        this._loadAllPointsInfo(1, 10)
      },
      resetPoints() {
        this.chooseInspectionRoutePointInfo.inspectionName = ''
        this._loadAllPointsInfo(1, 10)
      },
      handleSelectionChange(val) {
        this.multipleSelection = val
      },
      handlePageChange(currentPage) {
        this._loadAllPointsInfo(currentPage, 10)
      },
      handleClose() {
        this.visible = false
        this.chooseInspectionRoutePointInfo = {
          points: [],
          inspectionName: '',
          inspectionRouteId: '',
          selectPoints: []
        }
        this.multipleSelection = []
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .search-input {
    width: 100%;
  }
  
  .margin-bottom {
    margin-bottom: 20px;
  }
  
  .margin-top {
    margin-top: 20px;
  }
  </style>