doum
2026-06-11 d9c657aa78cf0ebe31933a87e63ca92edd8a8da3
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
<template>
  <TableLayout :permissions="['business:collectionDockDevice:query', 'business:collectionStation:query']">
    <div ref="QueryFormRef" slot="search-form">
      <el-form ref="searchForm" :model="searchForm" label-width="100px" inline>
        <el-form-item label="采集站" prop="stationId">
          <el-select v-model="searchForm.stationId" placeholder="全部" clearable filterable @change="search">
            <el-option v-for="item in stationOptions" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="设备名称" prop="deviceName">
          <el-input v-model="searchForm.deviceName" placeholder="设备名称" @keypress.enter.native="search" />
        </el-form-item>
        <el-form-item label="序列号" prop="shortSerialNumber">
          <el-input v-model="searchForm.shortSerialNumber" placeholder="短序列号" @keypress.enter.native="search" />
        </el-form-item>
        <section>
          <el-button type="primary" @click="search">搜索</el-button>
          <el-button @click="reset">重置</el-button>
        </section>
      </el-form>
    </div>
 
    <template v-slot:table-wrap>
      <ul class="toolbar">
        <li>
          <el-button type="primary" v-permissions="['business:collectionStation:sync']" @click="handleSyncAll">同步全部采集站</el-button>
        </li>
        <li>
          <el-button v-permissions="['business:collectionStation:sync']" :disabled="!searchForm.stationId" @click="handleSyncOne">同步当前采集站</el-button>
        </li>
      </ul>
      <el-table :height="tableHeightNew" v-loading="isWorking.search" :data="tableData.list" stripe>
        <el-table-column label="序号" width="55"><template slot-scope="scope">{{ scope.$index + 1 }}</template></el-table-column>
        <el-table-column prop="stationName" label="采集站" min-width="120" />
        <el-table-column prop="deviceName" label="设备名称" min-width="140" show-overflow-tooltip />
        <el-table-column prop="deviceId" label="设备ID" min-width="120" show-overflow-tooltip />
        <el-table-column prop="shortSerialNumber" label="短序列号" min-width="140" />
        <el-table-column prop="accessDeviceId" label="平台注册ID" min-width="140" show-overflow-tooltip />
        <el-table-column prop="networkedDevice" label="联网设备" width="90">
          <template slot-scope="{row}">
            <span v-if="row.networkedDevice === 1">是</span>
            <span v-else-if="row.networkedDevice === 0">否</span>
          </template>
        </el-table-column>
        <el-table-column prop="lastSyncTime" label="最近同步" min-width="160" />
        <el-table-column prop="createDate" label="创建时间" min-width="160" />
      </el-table>
      <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination" />
    </template>
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import { list as fetchStationList, syncDevices, syncDevice } from '@/api/business/collectionStation'
 
export default {
  name: 'CollectionDockDevice',
  extends: BaseTable,
  components: { TableLayout, Pagination },
  data () {
    return {
      stationOptions: [],
      searchForm: {
        stationId: null,
        deviceName: '',
        shortSerialNumber: ''
      }
    }
  },
  created () {
    const stationId = this.$route.query.stationId ? parseInt(this.$route.query.stationId) : null
    if (stationId) {
      this.searchForm.stationId = stationId
    }
    this.config({
      module: '执法记录仪',
      api: '/business/collectionDockDevice',
      'field.id': 'id',
      'field.main': 'deviceName'
    })
    this.loadStations()
    this.search()
  },
  methods: {
    loadStations () {
      fetchStationList({ status: 1 }).then(res => {
        this.stationOptions = res || []
      })
    },
    handleSyncAll () {
      syncDevices().then(res => {
        this.$message.success(res.data || '同步完成')
        this.search()
      })
    },
    handleSyncOne () {
      syncDevice(this.searchForm.stationId).then(res => {
        this.$message.success(res.data || '同步成功')
        this.search()
      })
    }
  }
}
</script>