Blame view

src/views/inspection/inspectionItemManageList.vue 5.73 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
c7a5a78f   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
    <div class="inspection-item-manage-container">
      <!-- 查询条件 -->
      <el-card class="search-card">
        <div slot="header" class="flex justify-between">
          <span>{{ $t('inspectionItemManage.searchCondition') }}</span>
        </div>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-input v-model="searchForm.itemId" :placeholder="$t('inspectionItemManage.itemIdPlaceholder')" clearable />
          </el-col>
          <el-col :span="6">
            <el-input v-model="searchForm.itemName" :placeholder="$t('inspectionItemManage.itemNamePlaceholder')"
              clearable />
          </el-col>
          <el-col :span="6">
            <el-button type="primary" @click="handleSearch">
              {{ $t('inspectionItemManage.searchBtn') }}
            </el-button>
            <el-button @click="handleReset">
              {{ $t('inspectionItemManage.resetBtn') }}
            </el-button>
          </el-col>
        </el-row>
      </el-card>
  
      <!-- 巡检项目列表 -->
      <el-card>
        <div slot="header" class="flex justify-between">
          <span>{{ $t('inspectionItemManage.inspectionItems') }}</span>
          <div style="float: right;">
57c370b2   wuxw   v1.9 优化巡检地图展示问题
32
            <!-- <el-button type="primary" size="small" @click="handleShowDoc">
c7a5a78f   wuxw   加入巡检工鞥你
33
34
              <i class="el-icon-document"></i>
              {{ $t('inspectionItemManage.doc') }}
57c370b2   wuxw   v1.9 优化巡检地图展示问题
35
            </el-button> -->
c7a5a78f   wuxw   加入巡检工鞥你
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
            <el-button type="primary" size="small" @click="openAddModal">
              <i class="el-icon-plus"></i>
              {{ $t('inspectionItemManage.addBtn') }}
            </el-button>
          </div>
        </div>
  
        <el-table v-loading="loading" :data="tableData" border style="width: 100%">
          <el-table-column prop="itemId" :label="$t('inspectionItemManage.id')" align="center" />
          <el-table-column prop="itemName" :label="$t('inspectionItemManage.itemName')" align="center" />
          <el-table-column prop="createTime" :label="$t('inspectionItemManage.createTime')" align="center" />
          <el-table-column prop="remark" :label="$t('inspectionItemManage.remark')" align="center" />
          <el-table-column :label="$t('inspectionItemManage.operation')" align="center" width="300">
            <template slot-scope="scope">
              <el-button size="mini" @click="openEditModal(scope.row)">
                {{ $t('inspectionItemManage.edit') }}
              </el-button>
              <el-button size="mini" type="danger" @click="openDeleteModal(scope.row)">
                {{ $t('inspectionItemManage.delete') }}
              </el-button>
              <el-button size="mini" type="success" @click="handleToQuestion(scope.row)">
                {{ $t('inspectionItemManage.question') }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
  
        <el-pagination class="pagination" :current-page="pagination.current" :page-sizes="[10, 20, 30, 50]"
          :page-size="pagination.size" :total="pagination.total" layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange" @current-change="handlePageChange" />
      </el-card>
  
      <!-- 子组件 -->
      <add-inspection-item ref="addModal" @success="handleSuccess" />
      <edit-inspection-item ref="editModal" @success="handleSuccess" />
      <delete-inspection-item ref="deleteModal" @success="handleSuccess" />
    </div>
  </template>
  
  <script>
  import { listInspectionItem } from '@/api/inspection/inspectionItemManageApi'
  import AddInspectionItem from '@/components/inspection/AddInspectionItem'
  import EditInspectionItem from '@/components/inspection/EditInspectionItem'
  import DeleteInspectionItem from '@/components/inspection/DeleteInspectionItem'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'InspectionItemManageList',
    components: {
      AddInspectionItem,
      EditInspectionItem,
      DeleteInspectionItem
    },
    data() {
      return {
        loading: false,
        searchForm: {
          itemId: '',
          itemName: '',
          communityId: ''
        },
        tableData: [],
        pagination: {
          current: 1,
          size: 10,
          total: 0
        }
      }
    },
    created() {
      this.searchForm.communityId = getCommunityId()
      this.getList()
    },
    methods: {
      async getList() {
        this.loading = true
        try {
          const params = {
            ...this.searchForm,
            page: this.pagination.current,
            row: this.pagination.size
          }
          const res = await listInspectionItem(params)
          this.tableData = res.data
          this.pagination.total = res.total
        } catch (error) {
          console.error('获取巡检项目列表失败:', error)
          this.$message.error(this.$t('inspectionItemManage.fetchError'))
        } finally {
          this.loading = false
        }
      },
      handleSearch() {
        this.pagination.current = 1
        this.getList()
      },
      handleReset() {
        this.searchForm.itemId = ''
        this.searchForm.itemName = ''
        this.handleSearch()
      },
      handleSizeChange(size) {
        this.pagination.size = size
        this.getList()
      },
      handlePageChange(page) {
        this.pagination.current = page
        this.getList()
      },
      handleShowDoc() {
        // 显示文档逻辑
        console.log('显示文档')
      },
      handleToQuestion(item) {
        this.$router.push(`/views/inspection/inspectionItemTitleManage?itemId=${item.itemId}`)
      },
      openAddModal() {
        this.$refs.addModal.open()
      },
      openEditModal(item) {
        this.$refs.editModal.open(item)
      },
      openDeleteModal(item) {
        this.$refs.deleteModal.open(item)
      },
      handleSuccess() {
        this.getList()
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .inspection-item-manage-container {
    padding: 20px;
  
    .search-card {
      margin-bottom: 20px;
    }
  
    .pagination {
      margin-top: 20px;
      text-align: right;
    }
  }
  </style>