懒羊羊
2024-01-25 d3409e53d656dff668c12a335bcb6f367ca63fdb
提交 | 用户 | 时间
1b9512 1 <template>
YY 2   <div class="app-container">
21530e 3     <el-card class="box-card">
d3409e 4         <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
5           <el-form-item label="节点" prop="node">
6             <el-input
7               v-model="queryParams.node"
8               placeholder="请输入节点"
9               clearable
10               @keyup.enter.native="handleQuery"
11             />
12           </el-form-item>
13           <el-form-item label="订阅类型" prop="rFunction">
14             <el-select v-model="queryParams.rFunction" placeholder="请选择订阅类型" clearable>
15               <el-option
16                 v-for="dict in dict.type.subscription_type"
17                 :key="dict.value"
18                 :label="dict.label"
19                 :value="dict.value"
20               />
21             </el-select>
22           </el-form-item>
23           <el-form-item label="工序编码" prop="process">
24             <el-input
25               v-model="queryParams.process"
26               placeholder="请输入工序编码"
27               clearable
28               @keyup.enter.native="handleQuery"
29             />
30           </el-form-item>
31           <el-form-item label="状态" prop="state">
32             <el-select v-model="queryParams.state" placeholder="请选择状态" clearable>
33               <el-option
34                 v-for="dict in dict.type.sys_normal_disable"
35                 :key="dict.value"
36                 :label="dict.label"
37                 :value="dict.value"
38               />
39             </el-select>
40           </el-form-item>
41           <el-form-item style="float: right">
42             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
43             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
44           </el-form-item>
45         </el-form>
21530e 46     </el-card>
1b9512 47
21530e 48     <el-card style="margin-top: 10px" class="box-card">
d3409e 49         <el-row :gutter="10" class="mb8">
50           <el-col :span="1.5">
51             <el-button
52               type="primary"
53               plain
54               icon="el-icon-plus"
55               size="mini"
56               @click="handleAdd"
57               v-hasPermi="['da:opcuaconfig:add']"
58             >新增</el-button>
59           </el-col>
60           <el-col :span="1.5">
61             <el-button
62               type="success"
63               plain
64               icon="el-icon-edit"
65               size="mini"
66               :disabled="single"
67               @click="handleUpdate"
68               v-hasPermi="['da:opcuaconfig:edit']"
69             >修改</el-button>
70           </el-col>
71           <el-col :span="1.5">
72             <el-button
73               type="danger"
74               plain
75               icon="el-icon-delete"
76               size="mini"
77               :disabled="multiple"
78               @click="handleDelete"
79               v-hasPermi="['da:opcuaconfig:remove']"
80             >删除</el-button>
81           </el-col>
82           <el-col :span="1.5">
83             <el-button
84               type="warning"
85               plain
86               icon="el-icon-download"
87               size="mini"
88               @click="handleExport"
89               v-hasPermi="['main:opcuaconfig:export']"
90             >导出</el-button>
91           </el-col>
92           <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
93         </el-row>
1b9512 94
d3409e 95         <el-table border v-loading="loading" :data="opcuaconfigList" @selection-change="handleSelectionChange">
96           <el-table-column type="selection" width="55" align="center" />
97 <!--          <el-table-column label="ID" align="center" prop="id" />-->
98           <el-table-column label="工序名称" align="center" prop="processName">
99             <!--            <template slot-scope="scope">-->
100             <!--              <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.processName"/>-->
101             <!--            </template>-->
102           </el-table-column>
103           <el-table-column label="工序编码" align="center" prop="process">
104             <!--            <template slot-scope="scope">-->
105             <!--              <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.process"/>-->
106             <!--            </template>-->
107           </el-table-column>
108           <el-table-column label="交互节点" align="center" prop="node">
109 <!--            <template slot-scope="scope">-->
110 <!--              <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.node"/>-->
111 <!--            </template>-->
112           </el-table-column>
113           <el-table-column label="数据类型" align="center" prop="sysTypes">
114             <template slot-scope="scope">
115               <dict-tag :options="dict.type.data_type" :value="scope.row.sysTypes"/>
116             </template>
117           </el-table-column>
118           <el-table-column label="是否订阅" align="center" prop="subscribe">
119             <template slot-scope="scope">
120               <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.subscribe"/>
121             </template>
122           </el-table-column>
123           <el-table-column label="订阅类型" align="center" prop="rFunction">
124             <template slot-scope="scope">
125               <dict-tag :options="dict.type.subscription_type" :value="scope.row.rFunction"/>
126             </template>
127           </el-table-column>
128           <el-table-column label="状态" align="center" prop="state">
129             <template slot-scope="scope">
130               <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.state"/>
131             </template>
132           </el-table-column>
133           <el-table-column label="备注" align="center" prop="remarks">
134             <!--            <template slot-scope="scope">-->
135             <!--              <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.remarks"/>-->
136             <!--            </template>-->
137           </el-table-column>
138           <el-table-column fixed="right" width="200" label="操作" align="center" class-name="small-padding fixed-width">
139             <template slot-scope="scope">
140               <el-button
141                 size="mini"
142                 type="success"
143                 plain
144                 style="width: 72px"
145                 icon="el-icon-edit"
146                 @click="handleUpdate(scope.row)"
147                 v-hasPermi="['main:opcuaconfig:edit']"
148               >修改</el-button>
149               <el-button
150                 size="mini"
151                 type="danger"
152                 plain
153                 style="width: 72px"
154                 icon="el-icon-delete"
155                 @click="handleDelete(scope.row)"
156                 v-hasPermi="['main:opcuaconfig:remove']"
157               >删除</el-button>
158             </template>
159           </el-table-column>
160         </el-table>
21530e 161     </el-card>
1b9512 162
YY 163     <pagination
164       v-show="total>0"
165       :total="total"
166       :page.sync="queryParams.pageNum"
167       :limit.sync="queryParams.pageSize"
168       @pagination="getList"
169     />
170
d3409e 171     <!-- 添加或修改交互信号配置对话框 -->
45a2ee 172     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="500px" append-to-body>
d3409e 173       <span slot="title">
174         <i class="el-icon-s-order"></i>
175         {{titleName}}
176       </span>
1b9512 177       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
d3409e 178         <el-form-item label="交互节点" prop="node">
1b9512 179           <el-input v-model="form.node" placeholder="请输入节点" />
YY 180         </el-form-item>
d3409e 181         <el-form-item label="数据类型" prop="sysTypes">
182           <el-select v-model="form.sysTypes" placeholder="请选择数据类型">
183             <el-option
184               v-for="dict in dict.type.data_type"
185               :key="dict.value"
186               :label="dict.label"
187               :value="dict.value"
188             ></el-option>
1b9512 189           </el-select>
YY 190         </el-form-item>
191         <el-form-item label="是否订阅" prop="subscribe">
192           <el-select v-model="form.subscribe" placeholder="请选择是否订阅">
d3409e 193             <el-option
194               v-for="dict in dict.type.sys_yes_no"
195               :key="dict.value"
196               :label="dict.label"
197               :value="dict.value"
198             ></el-option>
1b9512 199           </el-select>
YY 200         </el-form-item>
d3409e 201         <el-form-item label="订阅类型" prop="rFunction">
202           <el-select v-model="form.rFunction" placeholder="请选择订阅类型">
203             <el-option
204               v-for="dict in dict.type.subscription_type"
205               :key="dict.value"
206               :label="dict.label"
207               :value="dict.value"
208             ></el-option>
209           </el-select>
1b9512 210         </el-form-item>
d3409e 211 <!--        <el-form-item label="工序名称" prop="processName">-->
212 <!--          <el-input v-model="form.processName" placeholder="请输入工序名称" />-->
213 <!--        </el-form-item>-->
214 <!--        <el-form-item label="工序编码" prop="process">-->
215 <!--          <el-input v-model="form.process" placeholder="请输入工序编码" />-->
216 <!--        </el-form-item>-->
217         <el-form-item label="工序编码" prop="process">
218           <el-select style="width: 100%" @change="handleSelectChange(form.process)" v-model="form.process" placeholder="请选择">
219             <el-option
220               v-for="item in options"
221               :key="item.processesCode"
222               :label="item.processesCode"
223               :value="item.processesCode">
224             </el-option>
225           </el-select>
226         </el-form-item>
227         <el-form-item label="工序名称" prop="processName">
228           <el-input disabled v-model="form.processName" placeholder="请输入工序名称" />
229         </el-form-item>
230         <el-form-item label="状态" prop="state">
231           <el-select v-model="form.state" placeholder="请选择状态">
232             <el-option
233               v-for="dict in dict.type.sys_normal_disable"
234               :key="dict.value"
235               :label="dict.label"
236               :value="parseInt(dict.value)"
237             ></el-option>
238           </el-select>
1b9512 239         </el-form-item>
YY 240         <el-form-item label="备注" prop="remarks">
241           <el-input v-model="form.remarks" placeholder="请输入备注" />
242         </el-form-item>
243       </el-form>
244       <div slot="footer" class="dialog-footer">
245         <el-button type="primary" @click="submitForm">确 定</el-button>
246         <el-button @click="cancel">取 消</el-button>
247       </div>
248     </el-dialog>
249   </div>
250 </template>
251
252 <script>
253 import { listOpcuaconfig, getOpcuaconfig, delOpcuaconfig, addOpcuaconfig, updateOpcuaconfig } from "@/api/main/da/opcuaconfig/opcuaconfig";
d3409e 254 import {listProcesses} from "@/api/main/bs/processes/processes";
1b9512 255
YY 256 export default {
257   name: "Opcuaconfig",
d3409e 258   dicts: ['subscription_type', 'sys_yes_no', 'data_type','sys_normal_disable'],
1b9512 259   data() {
YY 260     return {
d3409e 261       options: [],
1b9512 262       // 遮罩层
YY 263       loading: true,
d3409e 264       titleName: "",
1b9512 265       // 选中数组
YY 266       ids: [],
267       // 非单个禁用
268       single: true,
269       // 非多个禁用
270       multiple: true,
271       // 显示搜索条件
272       showSearch: true,
273       // 总条数
274       total: 0,
d3409e 275       // 交互信号配置表格数据
1b9512 276       opcuaconfigList: [],
YY 277       // 弹出层标题
278       title: "",
279       // 是否显示弹出层
280       open: false,
281       // 查询参数
282       queryParams: {
283         pageNum: 1,
284         pageSize: 10,
285         node: null,
286         rFunction: null,
d3409e 287         process: null,
288         state: null
289       },
290       ProcessesqueryParams: {
291         pageNum: 1,
292         pageSize: 10,
293         process: null,
294         processName: null,
295         keyProcessesFlag: null,
296         routeCode: undefined,
1b9512 297       },
YY 298       // 表单参数
299       form: {},
300       // 表单校验
301       rules: {
302         id: [
303           { required: true, message: "ID不能为空", trigger: "blur" }
304         ],
305       }
306     };
307   },
308   created() {
309     this.getList();
d3409e 310     this.getProcessesList();
311
1b9512 312   },
YY 313   methods: {
d3409e 314     /** 查询工序信息列表 */
315     getProcessesList() {
316       this.loading = true;
317       listProcesses(this.queryParams).then(response => {
318         this.options = response.rows;
319       });
21530e 320     },
d3409e 321     handleSelectChange(selectedOption) {
322       this.ProcessesqueryParams.process = selectedOption;
323       listProcesses(this.ProcessesqueryParams).then(response => {
324         this.form.processName = response.rows[0].processesName;
325       });
326     },
327     /** 查询交互信号配置列表 */
1b9512 328     getList() {
YY 329       this.loading = true;
330       listOpcuaconfig(this.queryParams).then(response => {
331         this.opcuaconfigList = response.rows;
332         this.total = response.total;
333         this.loading = false;
334       });
335     },
336     // 取消按钮
337     cancel() {
338       this.open = false;
339       this.reset();
340     },
341     // 表单重置
342     reset() {
343       this.form = {
344         id: null,
345         node: null,
346         sysTypes: null,
347         subscribe: null,
348         rFunction: null,
d3409e 349         remarks: null,
350         processName: null,
351         process: null,
352         state: null
1b9512 353       };
YY 354       this.resetForm("form");
355     },
356     /** 搜索按钮操作 */
357     handleQuery() {
358       this.queryParams.pageNum = 1;
359       this.getList();
360     },
361     /** 重置按钮操作 */
362     resetQuery() {
363       this.resetForm("queryForm");
364       this.handleQuery();
365     },
366     // 多选框选中数据
367     handleSelectionChange(selection) {
368       this.ids = selection.map(item => item.id)
369       this.single = selection.length!==1
370       this.multiple = !selection.length
371     },
372     /** 新增按钮操作 */
373     handleAdd() {
374       this.reset();
375       this.open = true;
d3409e 376       this.titleName = "添加交互信号配置";
1b9512 377     },
YY 378     /** 修改按钮操作 */
379     handleUpdate(row) {
380       this.reset();
381       const id = row.id || this.ids
382       getOpcuaconfig(id).then(response => {
383         this.form = response.data;
384         this.open = true;
d3409e 385         this.titleName = "修改交互信号配置";
1b9512 386       });
YY 387     },
388     /** 提交按钮 */
389     submitForm() {
390       this.$refs["form"].validate(valid => {
391         if (valid) {
392           if (this.form.id != null) {
393             updateOpcuaconfig(this.form).then(response => {
394               this.$modal.msgSuccess("修改成功");
395               this.open = false;
396               this.getList();
397             });
398           } else {
399             addOpcuaconfig(this.form).then(response => {
400               this.$modal.msgSuccess("新增成功");
401               this.open = false;
402               this.getList();
403             });
404           }
405         }
406       });
407     },
408     /** 删除按钮操作 */
409     handleDelete(row) {
410       const ids = row.id || this.ids;
d3409e 411       this.$modal.confirm('是否确认删除交互信号配置编号为"' + ids + '"的数据项?').then(function() {
1b9512 412         return delOpcuaconfig(ids);
YY 413       }).then(() => {
414         this.getList();
415         this.$modal.msgSuccess("删除成功");
416       }).catch(() => {});
417     },
418     /** 导出按钮操作 */
419     handleExport() {
420       this.download('da/opcuaconfig/export', {
421         ...this.queryParams
422       }, `opcuaconfig_${new Date().getTime()}.xlsx`)
423     }
424   }
425 };
426 </script>