Parcourir la Source

设备管理页面调接口

chenxr3 4 ans auparavant
Parent
commit
bc2c654965

+ 6 - 0
ebc-middle-platform/src/conf/services.js

@ -146,6 +146,12 @@ export default {
146 146
    DEL_MAP_TAG: '/mapTag/deleteMapTagXyInfo', // 删除地图标记信息
147 147
    UPD_MAP_TAG: '/mapTag/queryMapTagforModifyInfo' // 查询地图标记信息用作修改
148 148
  },
149
  equipment: {
150
    GET_EQUIPMENT: '/equipment/queryEquipmentInfo', // 查询设备管理信息
151
    ADD_EQUIPMENT: '/equipment/modifyEquipmentInfo', // 新增/修改设备管理信息
152
    DEL_EQUIPMENT: '/equipment/deleteEquipmentInfo', // 删除设备管理信息
153
    REPETITION_EQUIPMENT: '/equipment/verifyEquipmentInfoRepetition' // 删除设备管理信息
154
  },
149 155
  history: {
150 156
    GET_HISTORICAL_ALARM: '/history/queryHistoricalAlarm' // 查询历史报警信息
151 157
  },

+ 317 - 118
ebc-middle-platform/src/modules/system-management/equipment-management.vue

@ -5,37 +5,39 @@
5 5
        <div>
6 6
          <div class="label">设备类型:</div>
7 7
          <div class="input-rule">
8
            <t-select v-model="queryCondition.equipmentType" width="200" placeholder="请输入...">
9
              <t-option>风机</t-option>
10
              <t-option>升压站</t-option>
11
              <t-option>船舶</t-option>
8
            <t-select v-model="queryCondition.equipmentType" style="width: 200px" clearable placeholder="请输入...">
9
              <t-option value="1">风机</t-option>
10
              <t-option value="2">升压站</t-option>
11
              <t-option value="3">船舶</t-option>
12 12
            </t-select>
13 13
          </div>
14 14
        </div>
15 15
        <div>
16 16
          <div class="label">设备名称:</div>
17 17
          <div class="input-rule">
18
            <t-select v-model="queryCondition.equipmentName" filterable clearable :loading.sync="currentLoading" @load="$_onLoad" width="200">
19
              <t-option v-for="item in searchResult"
20
                        :key="item.value"
21
              >{{ item.label }}</t-option>
22
            </t-select>
18
            <t-input v-model="queryCondition.equipmentName" style="width: 200px" placeholder="请输入..." clearable></t-input>
19
<!--            <t-select v-model="queryCondition.equipmentName" filterable clearable :loading.sync="currentLoading" @load="$_onLoad" width="200">-->
20
<!--              <t-option v-for="item in searchResult"-->
21
<!--                        :key="item.value"-->
22
<!--              >{{ item.FACILITY_NAME }}</t-option>-->
23
<!--            </t-select>-->
23 24
          </div>
24 25
        </div>
25 26
        <div>
26 27
          <div class="label">设备编号:</div>
27 28
          <div class="input-rule">
28
            <t-select filterable
29
                      clearable
30
                      :loading.sync="currentLoading_n"
31
                      @load="$_onLoad_n"
32
                      v-model="queryCondition.equipmentNumber"
33
                      width="200"
34
            >
35
              <t-option v-for="item in searchResult_n"
36
                        :key="item.value"
37
              >{{ item.label }}</t-option>
38
            </t-select>
29
            <t-input v-model="queryCondition.equipmentNumber" style="width: 200px" placeholder="请输入..." clearable></t-input>
30
<!--            <t-select filterable-->
31
<!--                      clearable-->
32
<!--                      :loading.sync="currentLoading_n"-->
33
<!--                      @load="$_onLoad_n"-->
34
<!--                      v-model="queryCondition.equipmentNumber"-->
35
<!--                      width="200" id="ccc"-->
36
<!--            >-->
37
<!--              <t-option v-for="item in searchResult_n"-->
38
<!--                        :key="item.value"-->
39
<!--              >{{ item.FACILITY_CODE }}</t-option>-->
40
<!--            </t-select>-->
39 41
          </div>
40 42
        </div>
41 43
        <div class="btns">
@ -55,11 +57,23 @@
55 57
    </div>
56 58
    <div>
57 59
      <t-table :data="table.data">
58
        <t-table-column prop="name" label="设备名称"></t-table-column>
59
        <t-table-column prop="number" label="设备编号"></t-table-column>
60
        <t-table-column prop="type" label="设备类型"></t-table-column>
61
        <t-table-column prop="long" label="经度"></t-table-column>
62
        <t-table-column prop="lat" label="纬度"></t-table-column>
60
        <t-table-column prop="FACILITY_NAME" label="设备名称"></t-table-column>
61
        <t-table-column prop="FACILITY_CODE" label="设备编号"></t-table-column>
62
        <t-table-column prop="FACILITY_TYPE" label="设备类型">
63
          <template slot-scope="scope">
64
            <div v-if="scope.row.FACILITY_TYPE==1">
65
              <span >风机</span>
66
            </div>
67
            <div v-if="scope.row.FACILITY_TYPE==2">
68
              <span>升压站</span>
69
            </div>
70
            <div v-if="scope.row.FACILITY_TYPE==3">
71
              <span>船舶</span>
72
            </div>
73
          </template>
74
        </t-table-column>
75
        <t-table-column prop="LONGITUDE" label="经度"></t-table-column>
76
        <t-table-column prop="LATITUDE" label="纬度"></t-table-column>
63 77
        <t-table-column
64 78
            fixed="right"
65 79
            label="操作"
@ -106,6 +120,42 @@
106 120
        <t-button class="submit-button" @click="submit">保存</t-button>
107 121
      </div>
108 122
    </t-modal>
123
    <t-modal :visibled.sync="updateModal" title="编辑设备" >
124
      <t-form ref="updateRow" :model="updateRow" :rules="updateRowValidate" :label-width="80" label-position="left">
125
<!--        <t-form-item label="设备类型" prop="type">-->
126
<!--          <template v-if="updateRow.FACILITY_TYPE==1">-->
127
<!--            风机-->
128
<!--          </template>-->
129
<!--          <template v-if="updateRow.FACILITY_TYPE==2">-->
130
<!--            升压站-->
131
<!--          </template>-->
132
<!--          <template v-if="updateRow.FACILITY_TYPE==3">-->
133
<!--            船舶-->
134
<!--          </template>-->
135
<!--        </t-form-item>-->
136
        <t-form-item label="设备类型" prop="FACILITY_TYPE">
137
          <t-select v-model="updateRow.FACILITY_TYPE" placeholder="请选择设备类型" clearable>
138
            <t-option v-for="(item, index) in typeList" :value="item.value" :key="index">{{ item.label }}</t-option>
139
          </t-select>
140
        </t-form-item>
141
        <t-form-item label="设备名称" prop="FACILITY_NAME">
142
          <t-input v-model="updateRow.FACILITY_NAME" placeholder="请输入风机名称"></t-input>
143
        </t-form-item>
144
        <t-form-item label="设备编号" prop="FACILITY_CODE">
145
          {{updateRow.FACILITY_CODE }}
146
        </t-form-item>
147
        <t-form-item label="经度" prop="LONGITUDE">
148
          <t-input v-model="updateRow.LONGITUDE" placeholder="请输入数字"></t-input>
149
        </t-form-item>
150
        <t-form-item label="纬度" prop="LATITUDE">
151
          <t-input v-model="updateRow.LATITUDE" placeholder="请输入数字"></t-input>
152
        </t-form-item>
153
      </t-form>
154
      <div slot="footer">
155
        <t-button @click="cancel">取消</t-button>
156
        <t-button class="submit-button" @click="updateSubmit">保存</t-button>
157
      </div>
158
    </t-modal>
109 159
  </div>
110 160
</template>
111 161
<script>
@ -114,32 +164,12 @@ import services from '../../conf/services'
114 164
export default {
115 165
  data() {
116 166
    return {
117
      currentLoading: false,
118
      searchResult: [],
119
      demoDataA: [
120
        {
121
          label: 'aacc',
122
          value: 'a001'
123
        },
124
        {
125
          label: 'ccce',
126
          value: 'a002'
127
        }
128
      ],
129
      currentLoading_n: false,
130
      searchResult_n: [],
131
      demoDataA_n: [
132
        {
133
          label: 'aacc',
134
          value: 'a001'
135
        },
136
        {
137
          label: 'ccce',
138
          value: 'a002'
139
        }
140
      ],
141
142
167
      // currentLoading: false,
168
      // searchResult: [],
169
      // demoDataA: [],
170
      // currentLoading_n: false,
171
      // searchResult_n: [],
172
      // demoDataA_n: [],
143 173
      typeList: [
144 174
        {
145 175
          value: '1',
@ -151,25 +181,11 @@ export default {
151 181
        },
152 182
        {
153 183
          value: '3',
154
          label: '测风塔'
184
          label: '船舶'
155 185
        }
156 186
      ],
157 187
      table: {
158 188
        data: [
159
          {
160
            name: '1#风机',
161
            number: 'FJ0001',
162
            type: '风机',
163
            long: '113.445454',
164
            lat: '23.157919'
165
          },
166
          {
167
            name: '1#风机',
168
            number: 'FJ0001',
169
            type: '风机',
170
            long: '113.445454',
171
            lat: '23.157919'
172
          }
173 189
        ],
174 190
        pager: {
175 191
          currentPage: 1,
@ -185,6 +201,14 @@ export default {
185 201
      },
186 202
      rangeDate: '',
187 203
      modal: false,
204
      updateModal: false,
205
      updateRow: {
206
        FACILITY_TYPE: '',
207
        FACILITY_NAME: '',
208
        FACILITY_CODE: '',
209
        LONGITUDE: '',
210
        LATITUDE: ''
211
      },
188 212
      formValidate: {
189 213
        type: '',
190 214
        name: '',
@ -211,6 +235,8 @@ export default {
211 235
              // TODO 判断编号重复
212 236
              if (false) {
213 237
                callback(rule.message)
238
              }else {
239
                return true
214 240
              }
215 241
            }
216 242
          }
@ -232,6 +258,8 @@ export default {
232 258
                if (false) {
233 259
                  rule.message = '编号重复'
234 260
                  callback(rule.message)
261
                }else {
262
                  return true
235 263
                }
236 264
              }
237 265
            }
@ -249,6 +277,8 @@ export default {
249 277
            validator: function(rule, value, callback) {
250 278
              if (isNaN(value)) {
251 279
                callback(rule.message)
280
              }else {
281
                return true
252 282
              }
253 283
            }
254 284
          }
@ -265,6 +295,70 @@ export default {
265 295
            validator: function(rule, value, callback) {
266 296
              if (isNaN(value)) {
267 297
                callback(rule.message)
298
              }else {
299
                return true
300
              }
301
            }
302
          }
303
        ]
304
      },
305
      updateRowValidate: {
306
        FACILITY_TYPE: [{
307
          required: true,
308
          message: '设备类型不能为空',
309
          trigger: 'change'
310
        }],
311
        FACILITY_NAME: [
312
          {
313
            required: true,
314
            message: '设备名称不能为空',
315
            trigger: 'blur'
316
          },
317
          {
318
            message: '设备名称重复',
319
            trigger: 'blur',
320
            validator: function(rule, value, callback) {
321
              // TODO 判断编号重复
322
              if (false) {
323
                callback(rule.message)
324
              }else {
325
                return true
326
              }
327
            }
328
          }
329
        ],
330
        LONGITUDE: [
331
          {
332
            required: true,
333
            message: '经度不能为空',
334
            trigger: 'blur'
335
          },
336
          {
337
            message: '请输入数字',
338
            trigger: 'blur',
339
            validator: function(rule, value, callback) {
340
              if (isNaN(value)) {
341
                callback(rule.message)
342
              }else {
343
                return true
344
              }
345
            }
346
          }
347
        ],
348
        LATITUDE: [
349
          {
350
            required: true,
351
            message: '经度不能为空',
352
            trigger: 'blur'
353
          },
354
          {
355
            message: '请输入数字',
356
            trigger: 'blur',
357
            validator: function(rule, value, callback) {
358
              if (isNaN(value)) {
359
                callback(rule.message)
360
              }else {
361
                return true
268 362
              }
269 363
            }
270 364
          }
@ -273,74 +367,176 @@ export default {
273 367
    }
274 368
  },
275 369
  mounted() {
276
    this.getList(1, 10, '')
370
    this.getList(1, 10, '', '', '')
277 371
  },
278 372
  methods: {
279 373
280
    $_onLoad(filterValue) {
281
      this.queryCondition.equipmentName = filterValue
282
      window.setTimeout(() => {
283
        let d = this.demoDataA.concat()
284
        this.searchResult = d
285
        this.currentLoading = false
286
      }, 1000)
287
    },
288
    $_onLoad_n(filterValue) {
289
      this.queryCondition.equipmentNumber = filterValue
290
      window.setTimeout(() => {
291
        let d = this.demoDataA_n.concat()
292
        this.searchResult_n = d
293
        this.currentLoading_n = false
294
      }, 1000)
295
    },
296
    getList(pageNum, pageSize, params) {
297
      this.table.data = this.table.data.concat(this.table.data)
298
      this.table.pager.total = this.table.data.length
299
      // var params = new FormData()
300
      // params.append('data', JSON.stringify({
301
      //   params: {
302
      //     pageNum: pageNum,
303
      //     pageSize: pageSize,
304
      //     MAP_TAG_NAME: MAP_TAG_NAME
305
      //   }
306
      // }))
307
      // this.$test.post(services.mapTag.GET_MAP_TAG, params
308
      // ).then(res => {
309
      //   // 请求成功处理...
310
      //   this.table.data = res.data.result.list
311
      //   this.table.pager.total = res.data.result.total
312
      //   this.table.pager.currentPage = res.data.result.pageNum
313
      // }).catch(res => {
314
      //   // 请求失败处理...
315
      // })
374
    // $_onLoad(filterValue) {
375
    //   this.queryCondition.equipmentName = filterValue
376
    //   window.setTimeout(() => {
377
    //     var params = new FormData()
378
    //     params.append('data', JSON.stringify({
379
    //       params: {
380
    //         FACILITY_NAME: filterValue
381
    //       }
382
    //     }))
383
    //     this.$test.post(services.equipment.GET_EQUIPMENT, params
384
    //     ).then(res => {
385
    //       // 请求成功处理...
386
    //       let d = res.data.result.list.concat()
387
    //       this.searchResult = d
388
    //       this.currentLoading = false
389
    //     }).catch(res => {
390
    //       // 请求失败处理...
391
    //     })
392
    //   }, 1000)
393
    // },
394
    // $_onLoad_n(filterValue) {
395
    //   this.queryCondition.equipmentNumber = filterValue
396
    //   window.setTimeout(() => {
397
    //     var params = new FormData()
398
    //     params.append('data', JSON.stringify({
399
    //       params: {
400
    //         FACILITY_CODE: filterValue
401
    //       }
402
    //     }))
403
    //     this.$test.post(services.equipment.GET_EQUIPMENT, params
404
    //     ).then(res => {
405
    //       // 请求成功处理...
406
    //       let d = res.data.result.list.concat()
407
    //       this.searchResult_n = d
408
    //       this.currentLoading_n = false
409
    //     }).catch(res => {
410
    //       // 请求失败处理...
411
    //     })
412
    //   }, 1000)
413
    // },
414
    getList(pageNum, pageSize, type, name, number) {
415
      var params = new FormData()
416
      params.append('data', JSON.stringify({
417
        params: {
418
          pageNum: pageNum,
419
          pageSize: pageSize,
420
          FACILITY_CODE: number,
421
          FACILITY_TYPE: type,
422
          FACILITY_NAME: name
423
        }
424
      }))
425
      this.$test.post(services.equipment.GET_EQUIPMENT, params
426
      ).then(res => {
427
        // 请求成功处理...
428
        this.table.data = res.data.result.list
429
        this.table.pager.total = res.data.result.total
430
        this.table.pager.currentPage = res.data.result.pageNum
431
      }).catch(res => {
432
        // 请求失败处理...
433
      })
316 434
    },
317 435
    onChange(value) {
318 436
      console.log('date change:' + value)
319 437
    },
320 438
    onReset() {
321
439
      this.queryCondition.equipmentType = ''
440
      this.queryCondition.equipmentName = ''
441
      this.queryCondition.equipmentNumber = ''
442
      this.searchResult = [
443
        {
444
          FACILITY_CODE: '',
445
          FACILITY_ID: '',
446
          FACILITY_NAME: '',
447
          FACILITY_TYPE: '',
448
          LATITUDE: '',
449
          LONGITUDE: ''
450
        }
451
      ]
452
      this.searchResult_n = [
453
        {
454
          FACILITY_CODE: '',
455
          FACILITY_ID: '',
456
          FACILITY_NAME: '',
457
          FACILITY_TYPE: '',
458
          LATITUDE: '',
459
          LONGITUDE: ''
460
        }
461
      ]
462
      this.onSearch()
322 463
    },
323 464
    onSearch() {
324
465
      console.log(this.queryCondition.equipmentType)
466
      console.log(this.queryCondition.equipmentName)
467
      this.getList(1, this.table.pager.size, this.queryCondition.equipmentType, this.queryCondition.equipmentName, this.queryCondition.equipmentNumber)
325 468
    },
326 469
    toExport() {
327 470
328 471
    },
329 472
    onPagerChange(page) {
330
473
      this.getList(page, this.table.pager.size, '', '', '')
331 474
    },
332 475
    onSizeChange(number) {
333
476
      this.getList(1, number, '', '', '')
334 477
    },
335 478
    cancel() {
336 479
      this.modal = false
480
      this.updateModal = false
481
      this.formValidate.type = ''
482
      this.formValidate.name = ''
483
      this.formValidate.number = ''
484
      this.formValidate.lng = ''
485
      this.formValidate.lat = ''
486
      this.getList(this.table.pager.currentPage, this.table.pager.size, this.queryCondition.equipmentType, this.queryCondition.equipmentName, this.queryCondition.equipmentNumber)
337 487
    },
338 488
    submit() {
339 489
      debugger
340 490
      this.$refs.formValidate.validate(valid => {
341 491
        console.log(valid)
342 492
        if (valid) {
343
          this.$Message.success('提交成功!')
493
          var params = new FormData()
494
          params.append('data', JSON.stringify({
495
            params: {
496
              FACILITY_TYPE: this.formValidate.type,
497
              FACILITY_NAME: this.formValidate.name,
498
              FACILITY_CODE: this.formValidate.number,
499
              LONGITUDE: this.formValidate.lng,
500
              LATITUDE: this.formValidate.lat
501
            }
502
          }))
503
          this.$test.post(services.equipment.ADD_EQUIPMENT, params
504
          ).then(res => {
505
            // 请求成功处理...
506
            this.$Message.success('提交成功!')
507
            this.cancel()
508
            // this.getList(this.table.pager.currentPage, this.table.pager.size, this.queryCondition.equipmentType, this.queryCondition.equipmentName, this.queryCondition.equipmentNumber)
509
          }).catch(res => {
510
            // 请求失败处理...
511
          })
512
        } else {
513
          this.$Message.danger('表单验证失败!')
514
        }
515
      })
516
    },
517
    updateSubmit() {
518
      debugger
519
      this.$refs.updateRow.validate(valid => {
520
        console.log(valid)
521
        if (valid) {
522
          var params = new FormData()
523
          params.append('data', JSON.stringify({
524
            params: {
525
              FACILITY_ID: this.updateRow.FACILITY_ID,
526
              FACILITY_TYPE: this.updateRow.FACILITY_TYPE,
527
              FACILITY_NAME: this.updateRow.FACILITY_NAME,
528
              LONGITUDE: this.updateRow.LONGITUDE,
529
              LATITUDE: this.updateRow.LATITUDE
530
            }
531
          }))
532
          this.$test.post(services.equipment.ADD_EQUIPMENT, params
533
          ).then(res => {
534
            // 请求成功处理...
535
            this.$Message.success('提交成功!')
536
            this.cancel()
537
          }).catch(res => {
538
            // 请求失败处理...
539
          })
344 540
        } else {
345 541
          this.$Message.danger('表单验证失败!')
346 542
        }
@ -350,7 +546,8 @@ export default {
350 546
      this.modal = true
351 547
    },
352 548
    handleClick(row) {
353
      this.modal = true
549
      this.updateModal = true
550
      this.updateRow = row
354 551
    },
355 552
    remove(row) {
356 553
      let that = this
@ -360,16 +557,18 @@ export default {
360 557
        ok: function () {
361 558
          var params = new FormData()
362 559
          params.append('data', JSON.stringify({
363
            MAP_TAG_ID: row.MAP_TAG_ID
560
            params: {
561
              FACILITY_ID: row.FACILITY_ID
562
            }
364 563
          }))
365
          // this.$test.post(services.mapTag.DEL_MAP_TAG, params
366
          // ).then(res => {
367
          //   // 请求成功处理...
368
          this.$Message.success('操作成功')
369
          //   that.getList(that.table.pager.currentPage, that.table.pager.size, that.queryCondition.userName)
370
          // }).catch(res => {
371
          //   // 请求失败处理...
372
          // })
564
          this.$test.post(services.equipment.DEL_EQUIPMENT, params
565
          ).then(res => {
566
            // 请求成功处理...
567
            that.$Message.success('操作成功')
568
            that.getList(that.table.pager.currentPage, that.table.pager.size, that.queryCondition.equipmentType, that.queryCondition.equipmentName, that.queryCondition.equipmentNumber)
569
          }).catch(res => {
570
            // 请求失败处理...
571
          })
373 572
        }
374 573
      }
375 574
      this.$Confirm.confirm(confirm)