hdy
2 天以前 1c50cb5546715fa21496fbdf2bdacb7ae8836b8a
提交 | 用户 | 时间
fb3b3e 1 <template>
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="lineCode">
5         <el-input
6           v-model="queryParams.lineCode"
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="operationType">
21         <el-select v-model="queryParams.operationType" placeholder="请选择操作类型" clearable>
22           <el-option
23             v-for="dict in dict.type.operation_type"
24             :key="dict.value"
25             :label="dict.label"
26             :value="dict.value"
27           />
28         </el-select>
29       </el-form-item>
30       <el-form-item label="参数编码" prop="paramCode">
31         <el-input
32           v-model="queryParams.paramCode"
33           placeholder="请输入参数编码"
34           clearable
35           @keyup.enter.native="handleQuery"
36         />
37       </el-form-item>
38       <el-form-item style="float: right">
39         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
40         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
41       </el-form-item>
42     </el-form>
43
44     <div style="width: 600px">
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="['main:info: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="['main:info: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="['main:info: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="['main:info:export']"
86           >导出</el-button>
87         </el-col>
88       </el-row>
89     </div>
90
91     <el-descriptions class="margin-top" :column="3" :size="size" border>
92       <el-descriptions-item>
93         <template slot="label">
94           <i class="el-icon-user"></i>
95           配方编码
96         </template>
97         {{queryParams.formulaCode}}
98       </el-descriptions-item>
99       <el-descriptions-item>
100         <template slot="label">
101           <i class="el-icon-mobile-phone"></i>
102           配方名称
103         </template>
104         {{showData.formulaName}}
105       </el-descriptions-item>
106       <el-descriptions-item>
107         <template slot="label">
108           <i class="el-icon-location-outline"></i>
109           产品编号
110         </template>
111         {{showData.productCode}}
112       </el-descriptions-item>
113       <el-descriptions-item>
114         <template slot="label">
115           <i class="el-icon-tickets"></i>
116           产品名称
117         </template>
118         {{showData.productName}}
119       </el-descriptions-item>
120     </el-descriptions>
121     <el-table border v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
122       <el-table-column type="selection" width="55" align="center" />
123       <el-table-column show-overflow-tooltip label="配方编码" align="center" prop="formulaCode" />
124       <el-table-column show-overflow-tooltip label="产线编号" align="center" prop="lineCode" />
125       <el-table-column show-overflow-tooltip label="工位编号" align="center" prop="locationCode" />
126       <el-table-column show-overflow-tooltip label="产品编号" align="center" prop="productCode" />
127       <el-table-column show-overflow-tooltip label="操作内容" align="center" prop="operationContent" />
128       <el-table-column label="操作类型" align="center" prop="operationType">
129         <template slot-scope="scope">
130           <dict-tag :options="dict.type.operation_type" :value="scope.row.operationType"/>
131         </template>
132       </el-table-column>
133       <el-table-column show-overflow-tooltip label="排序" align="center" prop="stepSort" />
134       <el-table-column show-overflow-tooltip label="参数编码" align="center" prop="paramCode" />
135       <el-table-column label="图片" align="center" prop="picture" width="100">
136         <template slot-scope="scope">
137           <image-preview :src="scope.row.picture" :width="50" :height="50"/>
138         </template>
139       </el-table-column>
140       <el-table-column show-overflow-tooltip label="备注" align="center" prop="remarks" />
141
142     </el-table>
143
144     <pagination
145       v-show="total>0"
146       :total="total"
147       :page.sync="queryParams.pageNum"
148       :limit.sync="queryParams.pageSize"
149       @pagination="getList"
150     />
151
152     <!-- 添加或修改配方配置子信息对话框 -->
153     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
154       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
155         <el-form-item label="配方编码" prop="formulaCode">
156           <el-input v-model="form.formulaCode" placeholder="请输入配方编码" disabled />
157         </el-form-item>
158         <el-form-item label="产品编号" prop="productCode">
159           <el-input v-model="form.productCode" placeholder="请输入产品编号" disabled/>
160         </el-form-item>
161         <el-form-item label="产线编号" prop="lineCode">
162           <el-input v-model="form.lineCode" placeholder="请输入产线编号" />
163         </el-form-item>
164         <el-form-item label="工位编号" prop="locationCode">
165           <el-input v-model="form.locationCode" placeholder="请输入工位编号" />
166         </el-form-item>
167
168         <el-form-item label="操作内容">
169           <editor v-model="form.operationContent" :min-height="192"/>
170         </el-form-item>
171         <el-form-item label="操作类型" prop="operationType">
172           <el-select v-model="form.operationType" placeholder="请选择操作类型">
173             <el-option
174               v-for="dict in dict.type.operation_type"
175               :key="dict.value"
176               :label="dict.label"
177               :value="dict.value"
178             ></el-option>
179           </el-select>
180         </el-form-item>
181         <el-form-item label="排序" prop="stepSort">
182           <el-input v-model="form.stepSort" placeholder="请输入排序" />
183         </el-form-item>
184         <el-form-item label="参数编码" prop="paramCode">
185           <el-input v-model="form.paramCode" placeholder="请输入参数编码" />
186         </el-form-item>
187         <el-form-item label="图片" prop="picture">
188           <image-upload v-model="form.picture"/>
189         </el-form-item>
190         <el-form-item label="备注" prop="remarks">
191           <el-input v-model="form.remarks" type="textarea" placeholder="请输入内容"
192                     maxlength="30"
193                     show-word-limit />
194         </el-form-item>
195
196       </el-form>
197       <div slot="footer" class="dialog-footer">
198         <el-button type="primary" @click="submitForm">确 定</el-button>
199         <el-button @click="cancel">取 消</el-button>
200       </div>
201     </el-dialog>
202   </div>
203 </template>
204
205 <script>
206 import {addInfo, delInfo, getInfo, listInfo, updateInfo} from "@/api/main/bs/formulaChildinfo";
207 import { getOne } from '@/api/main/bs/formulaInfo'
208
209 export default {
210   name: "formulaInfoChild",
211   dicts: ['operation_type'],
212   data() {
213     return {
214       // 遮罩层
215       loading: true,
216       // 选中数组
217       ids: [],
218       // 非单个禁用
219       single: true,
220       // 非多个禁用
221       multiple: true,
222       // 显示搜索条件
223       showSearch: true,
224       // 总条数
225       total: 0,
226       // 配方配置子信息表格数据
227       infoList: [],
228       // 弹出层标题
229       title: "",
230       // 是否显示弹出层
231       open: false,
232       // 查询参数
233       queryParams: {
234         pageNum: 1,
235         pageSize: 10,
236         lineCode: null,
237         locationCode: null,
238         productCode: null,
239         operationType: null,
240         stepSort: null,
241         paramCode: null,
242         formulaCode: null,
243       },
244       showData: {
245         formulaCode: null,
246         productCode: null,
247         productName: null,
248         formulaName: null,
249       },
250       // 表单参数
251       form: {},
252       // 表单校验
253       rules: {
254         lineCode: [
255           { required: true, message: "产线编号不能为空", trigger: "blur" }
256         ],
257         locationCode: [
258           { required: true, message: "工位编号不能为空", trigger: "blur" }
259         ],
260         productCode: [
261           { required: true, message: "产品编号不能为空", trigger: "blur" }
262         ],
263         operationContent: [
264           { required: true, message: "操作内容不能为空", trigger: "blur" }
265         ],
266         operationType: [
267           { required: true, message: "操作类型不能为空", trigger: "change" }
268         ],
269         stepSort: [
270           { required: true, message: "排序不能为空", trigger: "blur" }
271         ],
272         paramCode: [
273           { required: true, message: "参数编码不能为空", trigger: "blur" }
274         ],
275       }
276     };
277   },
278   created() {
279     this.queryParams.formulaCode = this.$route.query.formulaCode
280     this.getOne()
281     console.log('this.queryParams.formulaCode',this.queryParams.formulaCode)
282     this.getList();
283   },
284   methods: {
285     getOne(){
286       getOne({formulaCode: this.queryParams.formulaCode}).then(res => {
287         if (res.code === 200){
288           this.showData.productCode = res.data.productCode
289           this.showData.productName = res.data.productName
290           this.showData.formulaName = res.data.formulaName
291         }
292       })
293     },
294     /** 查询配方配置子信息列表 */
295     getList() {
296       this.loading = true;
297       listInfo(this.queryParams).then(response => {
298         this.infoList = response.rows;
299         this.total = response.total;
300         this.loading = false;
301       });
302     },
303     // 取消按钮
304     cancel() {
305       this.open = false;
306       this.reset();
307     },
308     // 表单重置
309     reset() {
310       this.form = {
311         id: null,
312         lineCode: null,
313         locationCode: null,
314         productCode: null,
315         operationContent: null,
316         operationType: null,
317         stepSort: null,
318         paramCode: null,
319         picture: null,
320         remarks: null,
321         createBy: null,
322         createTime: null,
323         updateBy: null,
324         updateTime: null,
325         collectData: null,
326         results: null,
327         formulaCode: null,
328         delFlag: null
329       };
330       this.resetForm("form");
331     },
332     /** 搜索按钮操作 */
333     handleQuery() {
334       this.queryParams.pageNum = 1;
335       this.getList();
336     },
337     /** 重置按钮操作 */
338     resetQuery() {
339       this.resetForm("queryForm");
340       this.handleQuery();
341     },
342     // 多选框选中数据
343     handleSelectionChange(selection) {
344       this.ids = selection.map(item => item.id)
345       this.single = selection.length!==1
346       this.multiple = !selection.length
347     },
348     /** 新增按钮操作 */
349     handleAdd() {
350       this.reset();
351       this.form.productCode = this.showData.productCode
352       this.form.formulaCode = this.queryParams.formulaCode
353       this.open = true;
354       this.title = "添加配方配置子信息";
355     },
356     /** 修改按钮操作 */
357     handleUpdate(row) {
358       this.reset();
359       const id = row.id || this.ids
360       getInfo(id).then(response => {
361         this.form = response.data;
362         this.open = true;
363         this.title = "修改配方配置子信息";
364       });
365     },
366     /** 提交按钮 */
367     submitForm() {
368       this.$refs["form"].validate(valid => {
369         if (valid) {
370           if (this.form.id != null) {
371             updateInfo(this.form).then(response => {
372               this.$modal.msgSuccess("修改成功");
373               this.open = false;
374               this.getList();
375             });
376           } else {
377             addInfo(this.form).then(response => {
378               this.$modal.msgSuccess("新增成功");
379               this.open = false;
380               this.getList();
381             });
382           }
383         }
384       });
385     },
386     /** 删除按钮操作 */
387     handleDelete(row) {
388       const ids = row.id || this.ids;
389       this.$modal.confirm('是否确认删除').then(function() {
390         return delInfo(ids);
391       }).then(() => {
392         this.getList();
393         this.$modal.msgSuccess("删除成功");
394       }).catch(() => {});
395     },
396     /** 导出按钮操作 */
397     handleExport() {
398       this.download('formulaChildInfo/export', {
399         ...this.queryParams
400       }, `info_${new Date().getTime()}.xlsx`)
401     }
402   }
403 };
404 </script>