houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-card shadow="never" class="aui-card--fill">
3     <div class="mod-oadp-opcua">
4       <el-form
5         :inline="true"
6         :model="dataForm"
7         @keyup.enter.native="getDataList()"
8       >
9         <el-form-item>
10           <el-input
11             v-model="dataForm.serverName"
12             placeholder="服务名称"
13             clearable
14           ></el-input>
15         </el-form-item>
16         <el-form-item>
17           <el-button @click="getDataList()">{{ $t("query") }}</el-button>
18         </el-form-item>
19         <el-form-item>
20           <el-button
21             v-hasPermi="['configinfo:opcua:add']"
22             type="primary"
23             @click="addOrUpdateHandle()"
24             >新增
25           </el-button>
26         </el-form-item>
27         <el-form-item>
28           <el-button
29             v-hasPermi="['configinfo:opcua:publish']"
30             type="primary"
31             @click="writeConfigHandle()"
32             >发布
33           </el-button>
34         </el-form-item>
35       </el-form>
36       <el-table
37         v-loading="dataListLoading"
38         :data="dataList"
39         border
40         style="width: 100%"
41       >
42         <el-table-column
43           prop="serverName"
44           label="服务名"
45           header-align="center"
46           align="center"
47         ></el-table-column>
48         <el-table-column
49           prop="endpointUrl"
50           label="端点URL"
51           header-align="center"
52           align="center"
53         ></el-table-column>
54         <el-table-column
55           prop="securityPolicy"
56           label="安全策略"
57           header-align="center"
58           align="center"
59         ></el-table-column>
60         <el-table-column
61           prop="securityMode"
62           label="安全模式"
63           header-align="center"
64           align="center"
65         ></el-table-column>
66         <el-table-column
67           prop="connectionType"
68           label="连接方式"
69           header-align="center"
70           align="center"
71         ></el-table-column>
72         <el-table-column
73           prop="userName"
74           label="用户名"
75           header-align="center"
76           align="center"
77         ></el-table-column>
78         <el-table-column
79           prop="password"
80           label="密码"
81           header-align="center"
82           align="center"
83         ></el-table-column>
84         <el-table-column
85           prop="certificatePath"
86           label="安全证书路径"
87           header-align="center"
88           align="center"
89         ></el-table-column>
90         <el-table-column
91           prop="connectInactivityTimeout"
92           label="设备不活动超时时间"
93           header-align="center"
94           align="center"
95         ></el-table-column>
96         <el-table-column
97           prop="reconnectInterval"
98           label="重连超时"
99           header-align="center"
100           align="center"
101         ></el-table-column>
102         <el-table-column
103           :label="$t('handle')"
104           fixed="right"
105           header-align="center"
106           align="center"
107           width="160"
108         >
109           <template slot-scope="scope">
110             <el-button
111               v-hasPermi="['configinfo:opcua:update']"
112               type="text"
113               size="small"
114               @click="addOrUpdateHandle(scope.row.id)"
115               >{{ $t("update") }}
116             </el-button>
117             <el-button
118               v-hasPermi="['configinfo:opcua:delete']"
119               type="text"
120               size="small"
121               @click="deleteHandle(scope.row.id)"
122               >{{ $t("delete") }}
123             </el-button>
124             <el-button
125                 v-hasPermi="['configinfo:opcua:tag']"
126                 type="text"
127                 size="small"
128                 @click="tagItemHandle(scope.row.serverName)"
129             >Tag
130             </el-button>
131           </template>
132         </el-table-column>
133       </el-table>
134       <el-pagination
135         @size-change="sizeChangeHandle"
136         @current-change="currentChangeHandle"
137         :current-page="pageIndex"
138         :page-sizes="[10, 20, 50, 100]"
139         :page-size="pageSize"
140         :total="totalPage"
141         layout="total, sizes, prev, pager, next, jumper"
142       >
143       </el-pagination>
144       <!-- 弹窗, 新增 / 修改 -->
145       <add-or-update
146         v-if="addOrUpdateVisible"
147         ref="addOrUpdate"
148         @refreshDataList="getDataList"
149       ></add-or-update>
150       <!-- 弹窗, tag -->
151       <tag-item
152         v-if="tagItemVisible"
153         ref="tagItem"
154         @refreshDataList="getDataList"
155       ></tag-item>
156     </div>
157   </el-card>
158 </template>
159 <script>
160 import AddOrUpdate from "./opcua-add-or-update";
161 import TagItem from "./opcua-tag";
162
163 export default {
164   data() {
165     return {
166       dataForm: {
167         id: "",
168         serverName: "",
169         endpointUrl: "",
170         securityPolicy: "",
171         securityMode: "",
172         connectionType: "",
173         userName: "",
174         password: "",
175         certificatePath: "",
176         connectInactivityTimeout: "",
177         reconnectInterval: "",
178       },
179       tagItemVisible: false,
180       dataList: [],
181       pageIndex: 1,
182       pageSize: 10,
183       totalPage: 0,
184       dataListLoading: false,
185       dataListSelections: [],
186       addOrUpdateVisible: false,
187     };
188   },
189
190   components: {
191     AddOrUpdate,
192     TagItem,
193   },
194   mounted() {
195     this.getDataList();
196   },
197   methods: {
198     // 获取数据列表
199     getDataList() {
200       this.dataListLoading = true;
201       this.$http({
202         url: "/data/channel/opcua/device/list",
203         method: "get",
204         params: this.$http.adornParams({
205           page: this.pageIndex,
206           limit: this.pageSize,
207           serverName: this.dataForm.serverName,
208         }),
209       }).then(({ code, page }) => {
210         if (page && code === 0) {
211           this.dataList = page.list;
212           this.totalPage = page.totalCount;
213         } else {
214           this.dataList = [];
215           this.totalPage = 0;
216         }
217         this.dataListLoading = false;
218       });
219     },
220     // 每页数
221     sizeChangeHandle(val) {
222       this.pageSize = val;
223       this.pageIndex = 1;
224       this.getDataList();
225     },
226     // 当前页
227     currentChangeHandle(val) {
228       this.pageIndex = val;
229       this.getDataList();
230     },
231     // 新增 / 修改
232     addOrUpdateHandle(id) {
233       this.addOrUpdateVisible = true;
234       this.$nextTick(() => {
235         this.$refs.addOrUpdate.init(id);
236       });
237     },
238
239     // 删除
240     deleteHandle(id) {
241       this.$confirm(`确定对选中项进行删除操作?`, "提示", {
242         confirmButtonText: "确定",
243         cancelButtonText: "取消",
244         type: "warning",
245       })
246         .then(() => {
247           this.$http({
248             headers: {
249               "Content-Type": "application/json",
250             },
251             url: `/data/channel/opcua/device/delete`,
252             method: "post",
253             data: this.$http.adornData({
254               id: id,
255             }),
256           }).then(({ data }) => {
257             if (data && data.code === 0) {
258               this.$message({
259                 message: "操作成功",
260                 type: "success",
261                 duration: 1500,
262                 onClose: () => {
263                   this.getDataList();
264                 },
265               });
266             } else {
267               this.$message.error(data.msg);
268             }
269           });
270         })
271         .catch(() => {});
272     },
273      //  tag方法
274       tagItemHandle(serverName) {
275         this.tagItemVisible = true;
276         this.$nextTick(() => {
277           this.$refs.tagItem.init(serverName);
278         });
279       },
280     //写配置
281     writeConfigHandle() {
282       this.$confirm(`确定将当前配置写入oadp?`, "提示", {
283         confirmButtonText: "确定",
284         cancelButtonText: "取消",
285         type: "warning",
286       })
287         .then(() => {
288           this.$http({
289             url: `/data/queryConfig`,
290             method: "post",
291           }).then(({ data }) => {
292             if (data && data.code === 0) {
293               this.$message({
294                 message: "操作成功",
295                 type: "success",
296                 duration: 1500,
297                 onClose: () => {
298                   this.getDataList();
299                 },
300               });
301             } else {
302               this.$message.error(data.msg);
303             }
304           });
305         })
306         .catch(() => {});
307     },
308   },
309 };
310 </script>