提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-drawer |
|
3 |
direction="rtl" |
|
4 |
:visible.sync="visible" |
|
5 |
@close="handleClose" |
|
6 |
size="50%" |
|
7 |
> |
|
8 |
<div style="padding: 10px;"> |
|
9 |
<el-form |
|
10 |
:inline="true" |
|
11 |
:model="dataForm" |
|
12 |
ref="dataForm" |
|
13 |
@keyup.enter.native="getDataList()" |
|
14 |
> |
|
15 |
<el-form-item prop="tagName"> |
|
16 |
<el-input |
|
17 |
v-model="dataForm.tagName" |
|
18 |
placeholder="点名称" |
|
19 |
clearable |
|
20 |
> |
|
21 |
</el-input> |
|
22 |
</el-form-item> |
|
23 |
<el-form-item> |
|
24 |
<el-button @click="getDataList()" |
|
25 |
>{{ $t("query") }} |
|
26 |
</el-button> |
|
27 |
</el-form-item> |
|
28 |
<el-form-item> |
|
29 |
<el-button type="primary" @click="addOrUpdateHandle()" |
|
30 |
>新增 |
|
31 |
</el-button> |
|
32 |
</el-form-item> |
|
33 |
<el-form-item> |
|
34 |
<el-upload |
|
35 |
class="upload-demo" |
|
36 |
:action="importUrl" |
|
37 |
:on-success="onSuccess" |
|
38 |
multiple |
|
39 |
:limit="20" |
|
40 |
:show-file-list="false" |
|
41 |
:file-list="fileList"> |
|
42 |
<el-button type="success">导入</el-button> |
|
43 |
</el-upload> |
|
44 |
</el-form-item> |
|
45 |
</el-form> |
|
46 |
<el-table |
|
47 |
v-loading="dataListLoading" |
|
48 |
:data="dataList" |
|
49 |
border |
|
50 |
style="width: 100%" |
|
51 |
> |
|
52 |
<el-table-column |
|
53 |
prop="tagName" |
|
54 |
label="Tag名称" |
|
55 |
header-align="center" |
|
56 |
align="left" |
|
57 |
min-width="150" |
|
58 |
></el-table-column> |
|
59 |
<el-table-column |
|
60 |
prop="dataType" |
|
61 |
label="数据类型" |
|
62 |
header-align="center" |
|
63 |
align="center" |
|
64 |
></el-table-column> |
|
65 |
<el-table-column |
|
66 |
prop="address" |
|
67 |
label="opcua地址" |
|
68 |
header-align="center" |
|
69 |
align="center" |
|
70 |
min-width="200" |
|
71 |
> |
|
72 |
</el-table-column> |
|
73 |
<el-table-column |
|
74 |
prop="samplingRate" |
|
75 |
label="采集频率" |
|
76 |
header-align="center" |
|
77 |
align="center" |
|
78 |
> |
|
79 |
</el-table-column> |
|
80 |
<el-table-column |
|
81 |
prop="enabled" |
|
82 |
label="是否启用" |
|
83 |
header-align="center" |
|
84 |
align="center" |
|
85 |
> |
|
86 |
<template slot-scope="scope"> |
|
87 |
<el-tag v-if="scope.row.enabled === true" size="small">是</el-tag> |
|
88 |
<el-tag v-else size="small" type="danger">否</el-tag> |
|
89 |
</template> |
|
90 |
</el-table-column> |
|
91 |
<el-table-column |
|
92 |
:label="$t('handle')" |
|
93 |
fixed="right" |
|
94 |
header-align="center" |
|
95 |
align="center" |
|
96 |
width="180" |
|
97 |
> |
|
98 |
<template slot-scope="scope"> |
|
99 |
<el-button |
|
100 |
type="text" |
|
101 |
size="small" |
|
102 |
@click="addOrUpdateHandle(scope.row.id)" |
|
103 |
>{{ $t("update") }} |
|
104 |
</el-button> |
|
105 |
<el-button |
|
106 |
type="text" |
|
107 |
size="small" |
|
108 |
@click="deleteHandle(scope.row.id)" |
|
109 |
>{{ $t("delete") }} |
|
110 |
</el-button> |
|
111 |
<el-button type="text" size="small" @click="chartHandle(scope.row)" |
|
112 |
>历史值</el-button> |
|
113 |
<el-button type="text" size="small" @click="currentHandle(scope.row)" |
|
114 |
>当前值</el-button> |
|
115 |
</template> |
|
116 |
</el-table-column> |
|
117 |
</el-table> |
|
118 |
<el-pagination |
|
119 |
@size-change="sizeChangeHandle" |
|
120 |
@current-change="currentChangeHandle" |
|
121 |
:current-page="pageIndex" |
|
122 |
:page-sizes="[10, 20, 50, 100]" |
|
123 |
:page-size="pageSize" |
|
124 |
:total="totalPage" |
|
125 |
layout="total, sizes, prev, pager, next, jumper" |
|
126 |
> |
|
127 |
</el-pagination> |
|
128 |
</div> |
|
129 |
|
|
130 |
<!-- 弹窗, 新增 / 修改 --> |
|
131 |
<add-or-update |
|
132 |
v-if="addOrUpdateVisible" |
|
133 |
ref="addOrUpdate" |
|
134 |
@refreshDataList="getDataList" |
|
135 |
></add-or-update> |
|
136 |
<!-- 弹窗, 历史数据 --> |
|
137 |
<chart-view v-if="chartViewVisible" ref="chartView"></chart-view> |
|
138 |
<!-- 弹窗, 当前数据 --> |
|
139 |
<current-view v-if="currentViewVisible" ref="currentView"></current-view> |
|
140 |
</el-drawer> |
|
141 |
</template> |
|
142 |
|
|
143 |
<script> |
|
144 |
import AddOrUpdate from "./opcua-tag-add-or-update"; |
|
145 |
import ChartView from "./components/data-tag-chart"; |
|
146 |
import CurrentView from "./components/data-tag-current.vue"; |
|
147 |
|
|
148 |
export default { |
|
149 |
props: { |
|
150 |
address: String, |
|
151 |
}, |
|
152 |
data() { |
|
153 |
return { |
|
154 |
visible: false, |
|
155 |
dataForm: { |
|
156 |
id: "", |
|
157 |
tagName: "", |
|
158 |
dataType: "", |
|
159 |
enabled: "", |
|
160 |
device: "", |
|
161 |
address: "", |
|
162 |
samplingRate: "", |
|
163 |
}, |
|
164 |
dataList: [], |
|
165 |
pageIndex: 1, |
|
166 |
pageSize: 10, |
|
167 |
totalPage: 0, |
|
168 |
dataListLoading: false, |
|
169 |
dataListSelections: [], |
|
170 |
addOrUpdateVisible: false, |
|
171 |
chartViewVisible: false, |
|
172 |
currentViewVisible: false, |
|
173 |
importUrl: '', |
|
174 |
}; |
|
175 |
}, |
|
176 |
|
|
177 |
components: { |
|
178 |
AddOrUpdate, |
|
179 |
ChartView, |
|
180 |
CurrentView |
|
181 |
}, |
|
182 |
mounted() { |
|
183 |
this.getDataList(); |
|
184 |
}, |
|
185 |
|
|
186 |
methods: { |
|
187 |
init(serverName) { |
|
188 |
this.dataForm.device = serverName; |
|
189 |
this.visible = true; |
|
190 |
this.importUrl = '/proxyApi/data/opcuaTag/import/' + serverName |
|
191 |
this.$nextTick(() => { |
|
192 |
this.getDataList(); |
|
193 |
}); |
|
194 |
}, |
|
195 |
handleClose() { |
|
196 |
this.$refs["dataForm"].resetFields(); |
|
197 |
this.dataList = []; |
|
198 |
}, |
|
199 |
// 获取数据列表 |
|
200 |
getDataList() { |
|
201 |
this.dataListLoading = true; |
|
202 |
this.$http({ |
|
203 |
url: "/data/channel/opcua/tag/list", |
|
204 |
method: "get", |
|
205 |
|
|
206 |
params: this.$http.adornParams({ |
|
207 |
page: this.pageIndex, |
|
208 |
limit: this.pageSize, |
|
209 |
device: this.dataForm.device, |
|
210 |
tagName: this.dataForm.tagName, |
|
211 |
address: this.dataForm.address, |
|
212 |
}), |
|
213 |
}).then(({ data }) => { |
|
214 |
if (data && data.code === 0) { |
|
215 |
this.dataList = data.page.list; |
|
216 |
this.totalPage = data.page.totalCount; |
|
217 |
} else { |
|
218 |
this.dataList = []; |
|
219 |
this.totalPage = 0; |
|
220 |
} |
|
221 |
this.dataListLoading = false; |
|
222 |
}); |
|
223 |
}, |
|
224 |
// 每页数 |
|
225 |
sizeChangeHandle(val) { |
|
226 |
this.pageSize = val; |
|
227 |
this.pageIndex = 1; |
|
228 |
this.getDataList(); |
|
229 |
}, |
|
230 |
// 当前页 |
|
231 |
currentChangeHandle(val) { |
|
232 |
this.pageIndex = val; |
|
233 |
this.getDataList(); |
|
234 |
}, |
|
235 |
// 多选 |
|
236 |
selectionChangeHandle(val) { |
|
237 |
this.dataListSelections = val; |
|
238 |
}, |
|
239 |
// 新增 / 修改 |
|
240 |
addOrUpdateHandle(id) { |
|
241 |
this.addOrUpdateVisible = true; |
|
242 |
this.$nextTick(() => { |
|
243 |
this.$refs.addOrUpdate.init(id, this.dataForm.device); |
|
244 |
}); |
|
245 |
}, |
|
246 |
// 删除 |
|
247 |
deleteHandle(id) { |
|
248 |
this.$confirm(`确定对选中项进行删除操作?`, "提示", { |
|
249 |
confirmButtonText: "确定", |
|
250 |
cancelButtonText: "取消", |
|
251 |
type: "warning", |
|
252 |
}) |
|
253 |
.then(() => { |
|
254 |
this.$http({ |
|
255 |
headers: { |
|
256 |
"Content-Type": "application/json", |
|
257 |
}, |
|
258 |
url: `/data/channel/opcua/tag/delete`, |
|
259 |
method: "post", |
|
260 |
data: this.$http.adornData({ |
|
261 |
id: id, |
|
262 |
}), |
|
263 |
}).then(({ data }) => { |
|
264 |
if (data && data.code === 0) { |
|
265 |
this.$message({ |
|
266 |
message: "操作成功", |
|
267 |
type: "success", |
|
268 |
duration: 1500, |
|
269 |
onClose: () => { |
|
270 |
this.getDataList(); |
|
271 |
}, |
|
272 |
}); |
|
273 |
} else { |
|
274 |
this.$message.error(data.msg); |
|
275 |
} |
|
276 |
}); |
|
277 |
}) |
|
278 |
.catch(() => {}); |
|
279 |
}, |
|
280 |
//历史数据 |
|
281 |
chartHandle(row) { |
|
282 |
this.chartViewVisible = true; |
|
283 |
this.$nextTick(() => { |
|
284 |
this.$refs.chartView.init(row); |
|
285 |
}); |
|
286 |
}, |
|
287 |
//当前数据 |
|
288 |
currentHandle(row) { |
|
289 |
this.currentViewVisible = true; |
|
290 |
this.$nextTick(() => { |
|
291 |
this.$refs.currentView.init(row); |
|
292 |
}); |
|
293 |
}, |
|
294 |
onSuccess (response, file, fileList) { |
|
295 |
this.getDataList() |
|
296 |
this.$message({ |
|
297 |
message: '上传成功', |
|
298 |
type: 'success', |
|
299 |
duration: 1500 |
|
300 |
}) |
|
301 |
}, |
|
302 |
}, |
|
303 |
}; |
|
304 |
</script> |