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