zxl
2026-03-23 b924e4fe906c3e1b4e804ed9d073e09db76fc710
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
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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<template>
  <!-- 操作按钮区域 -->
  <div class="table-card" ref="tableCard" :bordered="false">
    <div class="table-operator">
      <a-form class="query-form" layout="inline" :form="queryParam" @keyup.enter.native="searchQuery">
        <a-form-item label="网关名称">
          <a-input style="width: 150px" placeholder="请输入网关名称" v-model="queryParam.searchKey"/>
        </a-form-item>
        <a-form-item label="状态">
          <j-dict-select-tag
            style="width: 150px"
            v-model="queryParam.status"
            placeholder="请选择"
            dictCode="online_status"
          />
        </a-form-item>
        <a-button @click="searchQuery" type="primary" icon="search">查询</a-button>
        <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
        <!--<a-upload-->
          <!--name="file"-->
          <!--:showUploadList="false"-->
          <!--:multiple="false"-->
          <!--:headers="tokenHeader"-->
          <!--:action="importExcelUrl"-->
          <!--@change="handleImportExcel"-->
        <!--&gt;-->
          <!--<a-button type="primary" icon="import">导入</a-button>-->
        <!--</a-upload>-->
      </a-form>
    </div>
    <!-- table区域-begin -->
    <div>
      <split-pane :min-precent="10" :default-percent="17" split="vertical">
        <template slot="paneL">
          <div class="organ_tree_ct">
            <organ-tree height="67vh" ref="orgTree" @tree-data-list="treeDataList"
                        @on-tree-node-select="onTreeNodeSelect"></organ-tree>
          </div>
        </template>
        <template slot="paneR">
          <a-table
            class="infoTable"
            ref="table"
            size="middle"
            rowKey="licenseNum"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            @change="handleTableChange"
          >
          <span slot="action" slot-scope="text, record">
              <a @click="handleEdit(record)">编辑</a>
              <a-divider type="vertical"/>
              <a @click="pullCamera(record)">终端同步</a>
              <a-divider type="vertical"/>
              <a-popconfirm title="删除网关后自动删除关联终端,确定删除么?" @confirm="() => handleDelete(record.id)">
                <a>删除</a>
              </a-popconfirm>
          </span>
            <span slot="status" slot-scope="text, record" :style="{'color': record.status==1?'green':'red'}">
              {{text}}
            </span>
          </a-table>
        </template>
      </split-pane>
    </div>
    <!-- table区域-end -->
    <device-modal ref="deviceModal" @ok="modalFormOk"></device-modal>
  </div>
</template>
<script>
import OrganTree from '../tools/OrganTree'
import {JeecgListMixin} from '@tievd/cube-block/lib/mixins/JeecgListMixin'
import splitPane from 'vue-splitpane'
import DeviceModal from "@views/jyz/modules/DeviceModal";
import _antDesignVue from "ant-design-vue";
import { getAction, putAction } from '@tievd/cube-block/lib/api/manage'
 
// 表头
const columns = [
  {
    title: '序号',
    dataIndex: '',
    key: 'rowIndex',
    width: 60,
    align: 'center',
    customRender: function (t, r, index) {
      return parseInt(index) + 1
    },
  },
  {
    title: '网关名称',
    align: "center",
    dataIndex: 'name',
  },
  {
    title: '网关类型',
    align: "center",
    dataIndex: 'deviceType_dictText',
  },
  {
    title: '序列号',
    align: 'center',
    dataIndex: 'sn',
  },
  {
    title: 'IP地址',
    align: "center",
    dataIndex: 'deviceIp',
  },
  {
    title: '所属机构',
    align: "center",
    dataIndex: 'orgCode_dictText',
  },
  {
    title: '关联终端',
    align: "center",
    dataIndex: '',
    customRender: function (t, r, index) {
      return r.cameraOnlineCount + "/" + r.cameraCount
    },
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status_dictText',
    scopedSlots: { customRender: 'status' }
  },
  {
    title: '操作',
    align: 'center',
    dataIndex: 'action',
    scopedSlots: {customRender: 'action'},
  },
]
 
export default {
  name: 'DepartList',
  mixins: [JeecgListMixin],
  components: {
    DeviceModal,
    OrganTree,
    splitPane,
  },
  // 页面数据
  data() {
    return {
      iExpandedKeys: [],
      loading: false,
      autoExpandParent: true,
      currFlowId: '',
      currFlowName: '',
      disable: true,
      treeData: [],
      visible: false,
      departTree: [],
      rightClickSelectedKey: '',
      rightClickSelectedOrgCode: '',
      hiding: true,
      model: {},
      dropTrigger: '',
      columns: columns,
      disableSubmit: false,
      checkedKeys: [],
      selectedKeys: [],
      autoIncr: 1,
      currSelected: {},
 
      allTreeKeys: [],
      checkStrictly: true,
 
      form: this.$form.createForm(this),
      labelCol: {
        xs: {span: 24},
        sm: {span: 5},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      },
      graphDatasource: {
        nodes: [],
        edges: [],
      },
      validatorRules: {},
      url: {
        list: '/jyz/device/tables',
        delete: '/jyz/device/delete',
        importExcelUrl: 'jyz/device/importExcel'
      },
      orgCategoryDisabled: false,
      /* 分页参数 */
      ipagination: {
        current: 1,
        pageSize: 15,
        pageSizeOptions: ['15', '30', '50'],
        showTotal: function showTotal(total, range) {
          return range[0] + '-' + range[1] + ' 共' + total + '条';
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      queryParam:{
        parentCode:JSON.parse(localStorage.getItem("userDepartInfo")).orgCode
      }
    }
  },
  // 计算属性
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  // 方法
  methods: {
    handleImportExcel(info) {
      var h = this.$createElement;
 
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
        if (info.file.response.success) {
          // this.$message.success(`${info.file.name} 文件上传成功`);
          var _info$file$response = info.file.response,
            name = _info$file$response.result,
            _info$file$response$r = _info$file$response.result,
            errorLines = _info$file$response$r.errorLines,
            errorMessages = _info$file$response$r.errorMessages,
            successLines = _info$file$response$r.successLines;
 
          this.$message.success(name);
          if (errorLines > 0) {
            this.$warning({
              title: '导入失败',
              content: h('div', [errorMessages.map(function (item) {
                return h(
                  'div',
                  {style: 'white-space:nowrap;overflow-x:scroll'},
                  [item]
                );
              })])
            });
          }
          this.loadData();
        } else {
          this.$message.error(info.file.name + ' ' + info.file.response.message + '.');
        }
      } else if (info.file.status === 'error') {
        if (info.file.response.status === 500) {
          var data = info.file.response;
          var token = _vue2.default.ls.get(_mutationTypes.ACCESS_TOKEN);
          if (token && data.message.includes('Token失效')) {
            _antDesignVue.Modal.error({
              title: '登录已过期',
              content: '很抱歉,登录已过期,请重新登录',
              okText: '重新登录',
              mask: false,
              onOk: function onOk() {
                _vue2.default.hackStore.dispatch('Logout').then(function () {
                  _vue2.default.ls.remove(_mutationTypes.ACCESS_TOKEN);
                  window.location.reload();
                });
              }
            });
          }
        } else {
          this.$message.error('\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25');
        }
      }
    },
 
    onTreeNodeSelect(id, node) {
      this.queryParam.parentCode = node.selectedNodes[0].data.props.orgCode
      this.loadData()
    },
    handleEdit: function (record) {
      this.$refs.deviceModal.edit(record)
      this.$refs.deviceModal.title = '编辑'
    },
    handleAdd() {
      this.$refs.deviceModal.add()
      this.$refs.deviceModal.title = '新增'
    },
    modalFormOk() {
      this.loadData();
    },
    treeDataList(data) {
      if (data) {
        this.queryParam.parentCode = data.orgCode
      }
    },
    pullCamera(record) {
      getAction("/jyz/device/syncData", {deviceSn: record.sn}).then((res) => {
        if (res.code == 200) {
          this.$message.success("同步成功")
        }
      })
    },
  },
  created() {
  },
  // 在created后执行
  mounted() {
  },
 
  // 监听
  watch: {}
 
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
 
.organ_tree_ct {
  height: 76vh;
}
.query-form{
  display: flex;
  align-items: center;
  button{
    margin-bottom: 0 !important;
  }
}
</style>