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