Blame view

src/views/machine/equipmentAccountList.vue 11.2 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
439c1b56   wuxw   开发完成设备台账功能
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    <div class="equipment-account-container">
      <el-card class="box-card">
        <div class="operation-wrapper text-left">
          <el-button type="primary" size="small" @click="openAddEquipmentAccountModal">
            <i class="el-icon-plus"></i>{{ $t('equipmentAccount.addEquipment') }}
          </el-button>
          <el-button type="primary" size="small" @click="printEquipmentAccounts">
            <i class="el-icon-printer"></i>{{ $t('equipmentAccount.batchPrint') }}
          </el-button>
        </div>
      </el-card>
  
      <el-row :gutter="20" class="margin-top">
        <el-col :span="4" class="tree-container">
          <machine-type-tree ref="machineTypeTree" @switchType="handleSwitchType"></machine-type-tree>
        </el-col>
        <el-col :span="20">
          <el-card class="box-card text-left">
            <div slot="header" class="">
              <span>{{ $t('equipmentAccount.searchCondition') }}</span>
439c1b56   wuxw   开发完成设备台账功能
22
23
            </div>
            <el-form :inline="true" :model="equipmentAccountInfo.conditions" class="search-form">
27918d40   wuxw   v1.9 测试完成设备下的功能
24
              <el-form-item >
439c1b56   wuxw   开发完成设备台账功能
25
26
27
                <el-input v-model.trim="equipmentAccountInfo.conditions.machineName"
                  :placeholder="$t('equipmentAccount.machineNamePlaceholder')"></el-input>
              </el-form-item>
27918d40   wuxw   v1.9 测试完成设备下的功能
28
              <el-form-item >
439c1b56   wuxw   开发完成设备台账功能
29
30
31
                <el-input v-model.trim="equipmentAccountInfo.conditions.machineCode"
                  :placeholder="$t('equipmentAccount.machineCodePlaceholder')"></el-input>
              </el-form-item>
27918d40   wuxw   v1.9 测试完成设备下的功能
32
              <el-form-item >
439c1b56   wuxw   开发完成设备台账功能
33
34
35
36
37
38
39
                <el-select v-model="equipmentAccountInfo.conditions.state" style="width:100%">
                  <el-option :label="$t('equipmentAccount.selectState')" value=""></el-option>
                  <el-option v-for="item in equipmentAccountInfo.useStatus" :key="item.statusCd" :label="item.name"
                    :value="item.statusCd">
                  </el-option>
                </el-select>
              </el-form-item>
27918d40   wuxw   v1.9 测试完成设备下的功能
40
              <el-form-item >
439c1b56   wuxw   开发完成设备台账功能
41
42
43
44
45
46
47
                <el-select v-model="equipmentAccountInfo.conditions.importanceLevel" style="width:100%">
                  <el-option :label="$t('equipmentAccount.selectImportanceLevel')" value=""></el-option>
                  <el-option v-for="item in equipmentAccountInfo.importanceLevels" :key="item.statusCd" :label="item.name"
                    :value="item.statusCd">
                  </el-option>
                </el-select>
              </el-form-item>
27918d40   wuxw   v1.9 测试完成设备下的功能
48
49
50
51
              <el-form-item>
                <el-button type="primary" @click="queryEquipmentAccountMethod">{{ $t('common.search') }}</el-button>
                <el-button @click="resetEquipmentAccountMethod">{{ $t('common.reset') }}</el-button>
              </el-form-item>
439c1b56   wuxw   开发完成设备台账功能
52
            </el-form>
27918d40   wuxw   v1.9 测试完成设备下的功能
53
  
439c1b56   wuxw   开发完成设备台账功能
54
55
          </el-card>
  
9086f965   wuxw   测试完成保养功能
56
          <el-card class="box-card margin-top">
439c1b56   wuxw   开发完成设备台账功能
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
            <el-table :data="equipmentAccountInfo.equipmentAccounts" border style="width: 100%"   @selection-change="handleSelectionChange">
              <el-table-column type="selection" width="55" align="center"></el-table-column>
              <el-table-column prop="machineName" :label="$t('equipmentAccount.machineName')"
                align="center"></el-table-column>
              <el-table-column prop="machineCode" :label="$t('equipmentAccount.machineCode')"
                align="center"></el-table-column>
              <el-table-column prop="brand" :label="$t('equipmentAccount.brand')" align="center"></el-table-column>
              <el-table-column prop="model" :label="$t('equipmentAccount.model')" align="center"></el-table-column>
              <el-table-column prop="locationDetail" :label="$t('equipmentAccount.locationDetail')"
                align="center"></el-table-column>
              <el-table-column prop="firstEnableTime" :label="$t('equipmentAccount.firstEnableTime')"
                align="center"></el-table-column>
              <el-table-column prop="warrantyDeadline" :label="$t('equipmentAccount.warrantyDeadline')"
                align="center"></el-table-column>
              <el-table-column prop="usefulLife" :label="$t('equipmentAccount.usefulLife')"
                align="center"></el-table-column>
              <el-table-column prop="levelName" :label="$t('equipmentAccount.importanceLevel')"
                align="center"></el-table-column>
              <el-table-column prop="stateName" :label="$t('equipmentAccount.state')" align="center"></el-table-column>
              <el-table-column prop="purchasePrice" :label="$t('equipmentAccount.purchasePrice')"
                align="center"></el-table-column>
              <el-table-column prop="netWorth" :label="$t('equipmentAccount.netWorth')" align="center"></el-table-column>
              <el-table-column :label="$t('common.operation')" align="center" width="300">
                <template slot-scope="scope">
                  <el-button-group>
                    <el-button size="mini" @click="printEquipmentAccount(scope.row)">{{ $t('common.print') }}</el-button>
                    <el-button size="mini" @click="openEquipmentAccountDetail(scope.row)">{{ $t('common.detail')
                    }}</el-button>
                    <el-button size="mini" @click="openEditEquipmentAccountModel(scope.row)">{{ $t('common.edit')
                    }}</el-button>
                    <el-button size="mini" type="danger" @click="openDeleteEquipmentAccountModel(scope.row)">{{
                      $t('common.delete') }}</el-button>
                  </el-button-group>
                </template>
              </el-table-column>
            </el-table>
  
            <el-row class="pagination-wrapper">
              <el-col :span="12">
                <div>{{ $t('equipmentAccount.stateDescription') }}</div>
              </el-col>
              <el-col :span="12">
                <el-pagination :current-page.sync="equipmentAccountInfo.currentPage" :page-sizes="[10, 20, 30, 50]"
                  :page-size="10" layout="total, sizes, prev, pager, next, jumper" :total="equipmentAccountInfo.total"
                  @size-change="handleSizeChange" @current-change="handleCurrentChange">
                </el-pagination>
              </el-col>
            </el-row>
          </el-card>
        </el-col>
      </el-row>
  
      <!-- 子组件 -->
9086f965   wuxw   测试完成保养功能
110
      <delete-equipment-account ref="deleteEquipmentAccount" @success="listEquipmentAccounts"></delete-equipment-account>
439c1b56   wuxw   开发完成设备台账功能
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
      <view-equipment-account ref="viewEquipmentAccount"></view-equipment-account>
      <print-equipment-account ref="printEquipmentAccount"></print-equipment-account>
      <import-equipment ref="importEquipment"></import-equipment>
    </div>
  </template>
  
  <script>
  import { getDict } from '@/api/community/communityApi'
  import { getCommunityId } from '@/api/community/communityApi'
  import { listEquipmentAccount } from '@/api/machine/equipmentAccountApi'
  import MachineTypeTree from '@/components/machine/machineTypeTree'
  import DeleteEquipmentAccount from '@/components/machine/deleteEquipmentAccount'
  import ViewEquipmentAccount from '@/components/machine/viewEquipmentAccount'
  import PrintEquipmentAccount from '@/components/machine/printEquipmentAccount'
  import ImportEquipment from '@/components/machine/importEquipment'
  
  export default {
    name: 'EquipmentAccountList',
    components: {
      MachineTypeTree,
      DeleteEquipmentAccount,
      ViewEquipmentAccount,
      PrintEquipmentAccount,
      ImportEquipment
    },
    data() {
      return {
        communityId: '',
        equipmentAccountInfo: {
          currentPage: 1,
          equipmentAccounts: [],
          total: 0,
          moreCondition: false,
          machineIds: [],
          conditions: {
            machineName: '',
            machineCode: '',
            state: '',
            importanceLevel: '',
            typeId: ''
          },
          useStatus: [],
          importanceLevels: []
        }
      }
    },
    created() {
      this.communityId = getCommunityId()
      this.getDictData()
      this.listEquipmentAccounts()
    },
    methods: {
      async getDictData() {
        try {
          const stateData = await getDict('equipment_account', 'state')
          const levelData = await getDict('equipment_account', 'importance_level')
          this.equipmentAccountInfo.useStatus = stateData
          this.equipmentAccountInfo.importanceLevels = levelData
        } catch (error) {
          console.error('获取字典数据失败:', error)
        }
      },
      handleSelectionChange(selectedRows) {
      this.equipmentAccountInfo.machineIds = selectedRows.map(row => row.machineId)
    },
      async listEquipmentAccounts() {
        try {
          const params = {
            page: this.equipmentAccountInfo.currentPage,
            row: 10,
            communityId: this.communityId,
            ...this.equipmentAccountInfo.conditions
          }
          const { data, total } = await listEquipmentAccount(params)
          this.equipmentAccountInfo.equipmentAccounts = data
          this.equipmentAccountInfo.total = total
        } catch (error) {
          console.error('获取设备台账列表失败:', error)
        }
      },
      handleSwitchType(type) {
        this.equipmentAccountInfo.conditions.typeId = type.typeId
        this.listEquipmentAccounts()
      },
      openAddEquipmentAccountModal() {
        if (!this.equipmentAccountInfo.conditions.typeId) {
          this.$message.warning(this.$t('equipmentAccount.selectTypeFirst'))
          return
        }
        this.$router.push(`/views/machine/addEquipmentAccount?typeId=${this.equipmentAccountInfo.conditions.typeId}`)
      },
      openEditEquipmentAccountModel(row) {
        this.$router.push(`/views/machine/editEquipmentAccount?machineId=${row.machineId}`)
      },
      openEquipmentAccountDetail(row) {
        this.$router.push(`/views/machine/equipmentAccountDetail?machineId=${row.machineId}`)
      },
      openDeleteEquipmentAccountModel(row) {
        this.$refs.deleteEquipmentAccount.open(row)
      },
      printEquipmentAccount(row) {
        //this.$refs.printEquipmentAccount.open(row)
        window.open(`/#/views/resource/printEquipmentAccountLabel?machineId=${row.machineId}`)
  
      },
      printEquipmentAccounts() {
        if (this.equipmentAccountInfo.machineIds.length === 0) {
          this.$message.warning(this.$t('equipmentAccount.selectEquipmentFirst'))
          return
        }
        window.open(`/#/views/resource/printEquipmentAccountLabel?machineIds=${this.equipmentAccountInfo.machineIds}`)
      },
      queryEquipmentAccountMethod() {
        this.equipmentAccountInfo.currentPage = 1
        this.listEquipmentAccounts()
      },
      resetEquipmentAccountMethod() {
        this.equipmentAccountInfo.conditions = {
          machineName: '',
          machineCode: '',
          state: '',
          importanceLevel: '',
          typeId: this.equipmentAccountInfo.conditions.typeId
        }
        this.listEquipmentAccounts()
      },
      toggleMoreCondition() {
        this.equipmentAccountInfo.moreCondition = !this.equipmentAccountInfo.moreCondition
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.equipmentAccountInfo.currentPage = 1
        this.listEquipmentAccounts()
      },
      handleCurrentChange(val) {
        this.equipmentAccountInfo.currentPage = val
        this.listEquipmentAccounts()
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .equipment-account-container {
    padding: 20px;
  
    .operation-wrapper {
      margin-bottom: 0px;
    }
  
    .tree-container {
      padding-right: 0;
    }
  
    .search-form {
27918d40   wuxw   v1.9 测试完成设备下的功能
266
      margin-bottom: 0px;
439c1b56   wuxw   开发完成设备台账功能
267
268
269
270
271
272
273
274
275
    }
  
    .pagination-wrapper {
      margin-top: 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
  }</style>