doum
2026-03-10 92cd2a4474d33cee339f5da9d2ea51fd32b3f74a
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
<template>
    <TableLayout :permissions="['business:device:query']">
        <!-- 搜索表单 -->
        <el-form ref="searchForm"  slot="search-form" :model="searchForm" label-width="100px" inline>
            <el-form-item title="名称" prop="name">
                <el-input v-model="searchForm.name" placeholder="请输入名称" @keypress.enter.native="search"></el-input>
            </el-form-item>
            <el-form-item title="标识符" prop="no">
                <el-input v-model="searchForm.no" placeholder="请输入设备标识符" @keypress.enter.native="search"></el-input>
            </el-form-item>
            <el-form-item title="设备号" prop="doorNo">
                <el-input v-model="searchForm.doorNo" placeholder="请输入设备号" @keypress.enter.native="search"></el-input>
            </el-form-item>
            <section>
                <el-button type="primary" @click="search">搜索</el-button>
                <el-button @click="reset">重置</el-button>
            </section>
        </el-form>
        <!-- 表格和分页 -->
        <template v-slot:table-wrap>
          <ul class="toolbar" v-permissions="['business:device:create', 'business:device:delete']">
            <li><el-button type="primary" @click="$refs.operaDeviceWindow.open('新建电表')" icon="el-icon-plus" v-permissions="['business:device:create']">新建</el-button></li>
            <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:device:delete']">删除</el-button></li>
          </ul>
            <el-table
                v-loading="isWorking.search"
                :data="tableData.list"
                stripe >
              <el-table-column type="selection" width="55"></el-table-column>
              <el-table-column prop="name" label="名称" fixed min-width="150" align="center"></el-table-column>
              <el-table-column prop="no" label="电表地址域" min-width="100" align="center" ></el-table-column>
              <el-table-column prop="doorNo" label="设备号"  min-width="120" align="center" show-overflow-tooltip></el-table-column>
<!--
              <el-table-column prop="channelNo" label="开关序号" align="center" min-width="100"></el-table-column>
-->
              <el-table-column prop="manufature" label="厂商" align="center" min-width="100" show-overflow-tooltip></el-table-column>
              <el-table-column prop="regionPathName" align="center"  min-width="100" label="所在位置"></el-table-column>
              <el-table-column prop="ip" label="IP"  min-width="150" align="center" show-overflow-tooltip ></el-table-column>
              <el-table-column prop="port" label="端口" align="center"  ></el-table-column>
              <el-table-column prop="isUsed" label="是否使用">
                <template slot-scope="{row}">
                  <el-switch @change="changeUsed($event, row)" v-model="row.isUsed" active-color="#13ce66"
                             inactive-color="#ff4949" :active-value="0" :inactive-value="1">
                  </el-switch>
                </template>
              </el-table-column>
              <el-table-column prop="doorNameObj.pwdLevel" label="密码等级" align="center" min-width="150"></el-table-column>
              <el-table-column prop="doorNameObj.pwd" label="密码" align="center">
                <template slot-scope="{row}">
                  <span :class=" 'blue'">{{row.showPwd?row.doorNameObj.pwd:'******'}}</span>
                  <el-button  style="margin-left: 10px" v-if="row.doorNameObj.pwd!=null"
                              @click.native.p.prevent="showPassward(row)" type="text">
                    <i class="el-icon-view" :class="row.showPwd?'red':'blue'" :title="row.showPwd?'隐藏':'显示'"></i>
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column prop="doorNameObj.userCode" label="操作者代码" align="center" min-width="150"></el-table-column>
              <el-table-column prop="editDate" label="最近更新时间" align="center" min-width="150"></el-table-column>
              <el-table-column
                  label="操作"
                  align="center"
                  min-width="280"
                  fixed="right"
              >
                  <template slot-scope="{row}">
                    <el-button type="text" @click="$refs.operaDeviceWindow.open('编辑电表', row)" icon="el-icon-edit" v-permissions="['business:device:update']">编辑</el-button>
                    <el-button type="text" @click="$refs.operaDeviceDataWindow.open('查看电表数据', row)" icon="el-icon-view" v-permissions="['business:device:update']">数据</el-button>
                    <el-button type="text" @click="send(row,1)" icon="el-icon-circle-check"  v-permissions="['business:device:update']">开闸</el-button>
                    <el-button type="text" class="red" @click="send(row,0)" icon="el-icon-circle-close"  v-permissions="['business:device:update']">关闸</el-button>
                    <el-button type="text" class="red" @click="readData(row)" icon="el-icon-circle-close"  v-permissions="['business:device:update']">读取数据</el-button>
                    <el-button type="text" class="red" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:device:delete']">删除</el-button>
                  </template>
                </el-table-column>
            </el-table>
            <pagination
                @size-change="handleSizeChange"
                @current-change="handlePageChange"
                :pagination="tableData.pagination"  >
            </pagination>
        </template>
      <el-dialog
          :visible.sync="visibleSend"
          style="z-index: 100000"
          append-to-body
          width="50%"
          height="50%"
          :title="'控制电表-【'+ form.name+'】'"
      >
        <el-form :model="form" ref="form"  :rules="rules">
          <el-form-item label="执行操作:"  >
            <b class="green" v-if="form.status ===1">开闸</b>
            <b class="red" v-else>关闸</b>
          </el-form-item>
          <el-form-item label="有效时间" prop="cmdDate">
            <el-date-picker type="datetime" v-model="form.cmdDate" value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="请选择有效时间"   />
          </el-form-item>
<!--
          <p class="tip-warn" style="width: 100%;"><i class="el-icon-warning"></i></p>
-->
        </el-form>
        <template  v-slot:footer  >
          <el-button @click="sendAction(0)" type="primary" v-if="form.status === 1" :loading="isWorkSending">确认开闸</el-button>
          <el-button @click="sendAction(1)" type="danger" v-if="form.status !== 1" :loading="isWorkSending">确认关闸</el-button>
          <el-button @click="sendClose()">返回</el-button>
        </template>
      </el-dialog>
        <!-- 新建/修改 -->
    <OperaDeviceDianbiaoWindow ref="operaDeviceWindow" @success="handlePageChange"/>
    <OperaDeviceDataListWindow ref="operaDeviceDataWindow" @success="handlePageChange"/>
    </TableLayout>
</template>
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaDeviceDataListWindow from '@/components/business/OperaDianbiaoDataListWindow'
import OperaDeviceDianbiaoWindow from '@/components/business/OperaDeviceDianbiaoWindow'
export default {
  name: 'DeviceDuanluqi',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaDeviceDianbiaoWindow, OperaDeviceDataListWindow },
  data () {
    return {
      // 搜索
      searchForm: {
        doorNo: '',
        no: '',
        name: '',
        type: 6
      },
      isWorkSending: false,
      form: {
        id: '',
        status: null,
        name:null,
        cmdDate: null
      },
      visibleSend: false,
      options: [],
      rules: {
        cmdDate: [{ required: true, message: '请选择操作有效时间' }]
      }
    }
  },
  created () {
    this.config({
      module: '设备信息表',
      api: '/business/device',
      'field.id': 'id',
      'field.main': 'id'
    })
    this.search()
  },
  methods: {
    changeUsed (e, row) {
      this.api.updateUsedById({
        id: row.id,
        isUsed: e
      })
    },
    showPassward (row) {
      if (!row.showPwd) {
        this.$set(row, 'showPwd', true)
      } else {
        this.$set(row, 'showPwd', false)
      }
    },
    sendAction (status) {
      this.form.status = status
      this.$dialog.actionConfirm('确认进行电表【' + (this.form.status === 1 ? '开闸' : '关闸') + '】操作吗?', '操作确认提醒')
        .then(() => {
          console.log(this.form)
          this.isWorkSending = true
          this.api.dianbaoCmd(this.form)
            .then(res => {
              this.$tip.apiSuccess(res || '请求成功')
              this.handlePageChange()
            })
            .catch(e => {
            })
            .finally(() => {
              this.isWorkSending = false
            })
        })
        .catch(() => {})
    },
    readData (row) {
      this.api.dianbiaoData({ id: row.id })
        .then(res => {
          this.$tip.apiSuccess(res || '请求成功')
          this.handlePageChange()
        })
        .catch(e => {
        })
        .finally(() => {
          this.isWorkSending = false
        })
    },
    send (row, type) {
      this.visibleSend = true
      this.form = { id: row.id, name: row.name, cmdDate: null, status: type}
    },
    sendClose () {
      this.visibleSend = false
      this.isWorkSending = false
      this.form = { id: '', name: '', status: '', cmdDate: '' }
    }
  }
}
</script>