admin
2024-11-22 e973ff52c9cfe64e6f5cb0ab1ab298890fa05802
提交 | 用户 | 时间
c9abcf 1 <template>
H 2   <div class="app-container">
3     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
04f79e 4       <el-form-item label="工位编号" prop="locationCode">
H 5         <el-input
6           v-model="queryParams.locationCode"
7           placeholder="请输入工位编号"
8           clearable
9           @keyup.enter.native="handleQuery"
10         />
11       </el-form-item>
c9abcf 12       <el-form-item label="工位名称" prop="locationName">
H 13         <el-input
14           v-model="queryParams.locationName"
15           placeholder="请输入工位名称"
16           clearable
17           @keyup.enter.native="handleQuery"
18         />
19       </el-form-item>
20       <el-form-item label="地址" prop="node">
21         <el-input
22           v-model="queryParams.node"
23           placeholder="请输入地址"
24           clearable
25           @keyup.enter.native="handleQuery"
26         />
27       </el-form-item>
04f79e 28       <el-form-item label="采集类型" prop="type">
H 29         <el-input
30           v-model="queryParams.node"
31           placeholder="请输入采集类型"
32           clearable
33           @keyup.enter.native="handleQuery"
34         />
35       </el-form-item>
36
37       <el-form-item style="float: right" >
c9abcf 38         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
04f79e 39 <!--        <el-button icon="el-icon-setting" size="mini" @click="toggleAdvancedSearch">高级查询</el-button>-->
c9abcf 40         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
04f79e 41
c9abcf 42       </el-form-item>
H 43     </el-form>
44
45     <el-row :gutter="10" class="mb8">
46       <el-col :span="1.5">
47         <el-button
48           type="primary"
49           plain
50           icon="el-icon-plus"
51           size="mini"
52           @click="handleAdd"
53           v-hasPermi="['sc:opcConf:add']"
54         >新增</el-button>
55       </el-col>
56       <el-col :span="1.5">
57         <el-button
58           type="success"
59           plain
60           icon="el-icon-edit"
61           size="mini"
62           :disabled="single"
63           @click="handleUpdate"
64           v-hasPermi="['sc:opcConf:edit']"
65         >修改</el-button>
66       </el-col>
67       <el-col :span="1.5">
68         <el-button
69           type="danger"
70           plain
71           icon="el-icon-delete"
72           size="mini"
73           :disabled="multiple"
74           @click="handleDelete"
75           v-hasPermi="['sc:opcConf:remove']"
76         >删除</el-button>
77       </el-col>
78       <el-col :span="1.5">
79         <el-button
80           type="warning"
81           plain
82           icon="el-icon-download"
83           size="mini"
84           @click="handleExport"
85           v-hasPermi="['sc:opcConf:export']"
86         >导出</el-button>
87       </el-col>
88       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
89     </el-row>
90
04f79e 91     <el-table v-loading="loading" border :data="opcConfList" @selection-change="handleSelectionChange">
c9abcf 92       <el-table-column type="selection" width="55" align="center" />
H 93       <el-table-column label="工位编码" align="center" prop="locationCode" />
94       <el-table-column label="工位名称" align="center" prop="locationName" />
95       <el-table-column label="地址" align="center" prop="node" />
96       <el-table-column label="采集类型" align="center" prop="type" />
04f79e 97       <el-table-column label="是否订阅" align="center" prop="subscribe" >
H 98         <template slot-scope="scope">
99           <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.subscribe"/>
100         </template>
101       </el-table-column>
c9abcf 102       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
H 103         <template slot-scope="scope">
104           <el-button
105             size="mini"
04f79e 106             style="width: 72px"
H 107             type="success"
108             plain
c9abcf 109             icon="el-icon-edit"
H 110             @click="handleUpdate(scope.row)"
111             v-hasPermi="['sc:opcConf:edit']"
112           >修改</el-button>
113           <el-button
114             size="mini"
04f79e 115             style="width: 72px"
H 116             type="danger"
117             plain
c9abcf 118             icon="el-icon-delete"
H 119             @click="handleDelete(scope.row)"
120             v-hasPermi="['sc:opcConf:remove']"
121           >删除</el-button>
122         </template>
123       </el-table-column>
124     </el-table>
125
126     <pagination
127       v-show="total>0"
128       :total="total"
129       :page.sync="queryParams.pageNum"
130       :limit.sync="queryParams.pageSize"
131       @pagination="getList"
132     />
133
134     <!-- 添加或修改OPC交互配置对话框 -->
04f79e 135     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body >
c9abcf 136       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
H 137         <el-form-item label="工位编码" prop="locationCode">
04f79e 138           <el-input v-model="form.locationCode"  placeholder="请输入内容" />
c9abcf 139         </el-form-item>
H 140         <el-form-item label="工位名称" prop="locationName">
141           <el-input v-model="form.locationName" placeholder="请输入工位名称" />
142         </el-form-item>
143         <el-form-item label="地址" prop="node">
144           <el-input v-model="form.node" placeholder="请输入地址" />
145         </el-form-item>
04f79e 146         <el-form-item label="采集类型" prop="type">
H 147           <el-input v-model="form.type" placeholder="请输入采集类型" />
148         </el-form-item>
149         <el-form-item label="是否订阅" prop="subscribe">
150           <el-radio-group v-model="form.subscribe">
151             <el-radio
152               v-for="dict in dict.type.sys_yes_no"
153               :key="dict.value"
154               :label="dict.value"
155             >{{dict.label}}</el-radio>
156           </el-radio-group>
157         </el-form-item>
c9abcf 158       </el-form>
H 159       <div slot="footer" class="dialog-footer">
160         <el-button type="primary" @click="submitForm">确 定</el-button>
161         <el-button @click="cancel">取 消</el-button>
162       </div>
163     </el-dialog>
164   </div>
165 </template>
166
167 <script>
168 import { listOpcConf, getOpcConf, delOpcConf, addOpcConf, updateOpcConf } from "@/api/main/sc/opcConf";
169
170 export default {
171   name: "OpcConf",
04f79e 172   dicts: ['sys_yes_no'],
c9abcf 173   data() {
H 174     return {
04f79e 175       advancedSearchVisible: false,
c9abcf 176       // 遮罩层
H 177       loading: true,
178       // 选中数组
179       ids: [],
180       // 非单个禁用
181       single: true,
182       // 非多个禁用
183       multiple: true,
184       // 显示搜索条件
185       showSearch: true,
186       // 总条数
187       total: 0,
188       // OPC交互配置表格数据
189       opcConfList: [],
190       // 弹出层标题
191       title: "",
192       // 是否显示弹出层
193       open: false,
194       // 查询参数
195       queryParams: {
196         pageNum: 1,
197         pageSize: 10,
198         locationCode: null,
199         locationName: null,
200         node: null,
201         type: null,
202         subscribe: null,
203       },
204       // 表单参数
205       form: {},
206       // 表单校验
207       rules: {
04f79e 208         locationCode: [
H 209           { required: true, message: "工位编码不能为空", trigger: "blur" },
210           { pattern: /^[a-zA-Z0-9]*$/, message: "总成序列号不能包含中文字符", trigger: "blur" }
211         ],
212         locationName: [
213           { required: true, message: "工位名称不能为空", trigger: "blur" },
214         ],
215         node: [
216           { required: true, message: "地址不能为空", trigger: "blur" },
217           { pattern: /^[a-zA-Z0-9]*$/, message: "地址不能包含中文字符", trigger: "blur" }
218         ],
c9abcf 219       }
H 220     };
221   },
222   created() {
223     this.getList();
224   },
225   methods: {
04f79e 226     toggleAdvancedSearch() {
H 227       this.advancedSearchVisible = !this.advancedSearchVisible;
228     },
c9abcf 229     /** 查询OPC交互配置列表 */
H 230     getList() {
231       this.loading = true;
232       listOpcConf(this.queryParams).then(response => {
233         this.opcConfList = response.rows;
234         this.total = response.total;
235         this.loading = false;
236       });
237     },
238     // 取消按钮
239     cancel() {
240       this.open = false;
241       this.reset();
242     },
243     // 表单重置
244     reset() {
245       this.form = {
246         id: null,
247         locationCode: null,
248         locationName: null,
249         node: null,
250         type: null,
251         subscribe: null,
252         delFlag: null,
253         createBy: null,
254         createTime: null,
255         updateBy: null,
256         updateTime: null
257       };
258       this.resetForm("form");
259     },
260     /** 搜索按钮操作 */
261     handleQuery() {
262       this.queryParams.pageNum = 1;
263       this.getList();
264     },
265     /** 重置按钮操作 */
266     resetQuery() {
267       this.resetForm("queryForm");
268       this.handleQuery();
269     },
270     // 多选框选中数据
271     handleSelectionChange(selection) {
272       this.ids = selection.map(item => item.id)
273       this.single = selection.length!==1
274       this.multiple = !selection.length
275     },
276     /** 新增按钮操作 */
277     handleAdd() {
278       this.reset();
279       this.open = true;
280       this.title = "添加OPC交互配置";
281     },
282     /** 修改按钮操作 */
283     handleUpdate(row) {
284       this.reset();
285       const id = row.id || this.ids
286       getOpcConf(id).then(response => {
287         this.form = response.data;
288         this.open = true;
289         this.title = "修改OPC交互配置";
290       });
291     },
292     /** 提交按钮 */
293     submitForm() {
294       this.$refs["form"].validate(valid => {
295         if (valid) {
296           if (this.form.id != null) {
297             updateOpcConf(this.form).then(response => {
298               this.$modal.msgSuccess("修改成功");
299               this.open = false;
300               this.getList();
301             });
302           } else {
303             addOpcConf(this.form).then(response => {
304               this.$modal.msgSuccess("新增成功");
305               this.open = false;
306               this.getList();
307             });
308           }
309         }
310       });
311     },
312     /** 删除按钮操作 */
313     handleDelete(row) {
314       const ids = row.id || this.ids;
315       this.$modal.confirm('是否确认删除OPC交互配置编号为"' + ids + '"的数据项?').then(function() {
316         return delOpcConf(ids);
317       }).then(() => {
318         this.getList();
319         this.$modal.msgSuccess("删除成功");
320       }).catch(() => {});
321     },
322     /** 导出按钮操作 */
323     handleExport() {
324       this.download('sc/opcConf/export', {
325         ...this.queryParams
326       }, `opcConf_${new Date().getTime()}.xlsx`)
327     }
328   }
329 };
330 </script>