BOM
hdy
2024-11-26 f47bd7409609995c7eebb81a0b92b6e4aff0bdbf
提交 | 用户 | 时间
f47bd7 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">
4       <el-form-item label="工位编码" prop="locationCode">
5         <el-input
6           v-model="queryParams.locationCode"
7           placeholder="请输入工位编码"
8           clearable
9           @keyup.enter.native="handleQuery"
10         />
11       </el-form-item>
12       <el-form-item label="工位名称" prop="locationName">
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="materialCode">
21         <el-input
22           v-model="queryParams.materialCode"
23           placeholder="请输入物料编码"
24           clearable
25           @keyup.enter.native="handleQuery"
26         />
27       </el-form-item>
28       <el-form-item label="物料名称" prop="materialName">
29         <el-input
30           v-model="queryParams.materialName"
31           placeholder="请输入物料名称"
32           clearable
33           @keyup.enter.native="handleQuery"
34         />
35       </el-form-item>
36       <el-form-item label="单位" prop="unit">
37         <el-input
38           v-model="queryParams.unit"
39           placeholder="请输入单位"
40           clearable
41           @keyup.enter.native="handleQuery"
42         />
43       </el-form-item>
44       <el-form-item style="float: right">
45         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
46         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
47       </el-form-item>
48     </el-form>
49     <el-card style="margin-top: 10px" class="box-card">
50     <el-row :gutter="10" class="mb8">
51       <el-col :span="1.5">
52         <el-button
53           type="primary"
54           plain
55           icon="el-icon-plus"
56           size="mini"
57           @click="handleAdd"
58           v-hasPermi="['bs:bomChildInfo:add']"
59         >新增</el-button>
60       </el-col>
61       <el-col :span="1.5">
62         <el-button
63           type="success"
64           plain
65           icon="el-icon-edit"
66           size="mini"
67           :disabled="single"
68           @click="handleUpdate"
69           v-hasPermi="['bs:bomChildInfo:edit']"
70         >修改</el-button>
71       </el-col>
72       <el-col :span="1.5">
73         <el-button
74           type="danger"
75           plain
76           icon="el-icon-delete"
77           size="mini"
78           :disabled="multiple"
79           @click="handleDelete"
80           v-hasPermi="['bs:bomChildInfo:remove']"
81         >删除</el-button>
82       </el-col>
83       <el-col :span="1.5">
84         <el-button
85           type="warning"
86           plain
87           icon="el-icon-download"
88           size="mini"
89           @click="handleExport"
90           v-hasPermi="['bs:bomChildInfo:export']"
91         >导出</el-button>
92       </el-col>
93       <el-col :span="1.5">
94         <el-button
95           type="warning"
96           plain
97           icon="el-icon-close"
98           size="mini"
99           @click="handleClose"
100         >关闭</el-button>
101       </el-col>
102     </el-row>
103
104     <el-descriptions class="margin-top" :size="'medium'" border>
105       <el-descriptions-item >
106         <template slot="label">
107           <i class="el-icon-user"></i>
108           BOM编码
109         </template>
110           {{headerInformationData.bomCode}}
111       </el-descriptions-item>
112       <el-descriptions-item >
113         <template slot="label">
114           <i class="el-icon-location-outline"></i>
115           产品编码
116         </template>
117         {{headerInformationData.productCode}}
118       </el-descriptions-item>
119       <el-descriptions-item >
120         <template slot="label">
121           <i class="el-icon-tickets"></i>
122           产品名称
123         </template>
124         {{headerInformationData.productName}}
125       </el-descriptions-item>
126     </el-descriptions>
127
128     <el-table border v-loading="loading" :data="bomChildInfoList" @selection-change="handleSelectionChange" v-if="bomChildInfoList.length > 0">
129       <el-table-column type="selection" width="55" align="center" />
130       <el-table-column show-overflow-tooltip="true" label="工位编码" align="center" prop="locationCode" />
131       <el-table-column show-overflow-tooltip="true" label="工位名称" align="center" prop="locationName" />
132       <el-table-column show-overflow-tooltip="true" label="物料编码" align="center" prop="materialCode" />
133       <el-table-column show-overflow-tooltip="true" label="物料名称" align="center" prop="materialName" />
134       <el-table-column show-overflow-tooltip="true" label="单耗" align="center" prop="costQty" />
135       <el-table-column show-overflow-tooltip="true" label="单位" align="center" prop="unit" />
136       <el-table-column show-overflow-tooltip="true" label="备注" align="center" prop="remark" />
137     </el-table>
138     <el-empty v-else>
139       <span slot="description">暂无数据</span>
140     </el-empty>
141     </el-card>
142
143     <pagination
144       v-show="total>0"
145       :total="total"
146       :page.sync="queryParams.pageNum"
147       :limit.sync="queryParams.pageSize"
148       @pagination="getList"
149     />
150
151     <!-- 添加或修改基础BOM子信息对话框 -->
152     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="500px" append-to-body>
153         <span slot="title">
154         <i class="el-icon-s-order"></i>
155         {{titleName}}
156       </span>
157       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
158         <el-form-item label="BOM编码" prop="bomCode">
159           <el-input v-model="querybomCode" :disabled="true" />
160         </el-form-item>
161         <el-form-item label="工位编码" prop="locationCode">
162           <el-input v-model="form.locationCode" placeholder="请输入工位编码" />
163         </el-form-item>
164         <el-form-item label="工位名称" prop="locationName">
165           <el-input v-model="form.locationName" placeholder="请输入工位名称" />
166         </el-form-item>
167         <el-form-item label="物料编码" prop="materialCode">
168           <el-input v-model="form.materialCode" placeholder="请输入物料编码" />
169         </el-form-item>
170         <el-form-item label="物料名称" prop="materialName">
171           <el-input v-model="form.materialName" placeholder="请输入物料名称" />
172         </el-form-item>
173         <el-form-item label="单耗" prop="costQty">
174           <el-input v-model="form.costQty" placeholder="请输入单耗" />
175         </el-form-item>
176         <el-form-item label="单位" prop="unit">
177           <el-input v-model="form.unit" placeholder="请输入单位" />
178         </el-form-item>
179         <el-form-item label="备注" prop="remark">
180           <el-input v-model="form.remark" placeholder="请输入备注" />
181         </el-form-item>
182       </el-form>
183       <div slot="footer" class="dialog-footer">
184         <el-button type="primary" @click="submitForm">确 定</el-button>
185         <el-button @click="cancel">取 消</el-button>
186       </div>
187     </el-dialog>
188   </div>
189 </template>
190
191 <script>
192 import { listBomChildInfo, getBomChildInfo, delBomChildInfo, addBomChildInfo, updateBomChildInfo } from "@/api/main/bs/bomChildInfo";
193 import { listBomInfo } from "@/api/main/bs/bomInfo";
194
195 export default {
196   name: "BomChildInfo",
197   data() {
198     return {
199       // 遮罩层
200       loading: true,
201       titleName: '',
202       // 选中数组
203       ids: [],
204       // 非单个禁用
205       single: true,
206       // 非多个禁用
207       multiple: true,
208       // 显示搜索条件
209       showSearch: true,
210       // 总条数
211       total: 0,
212       // 基础BOM子信息表格数据
213       bomChildInfoList: [],
214       // 弹出层标题
215       title: "",
216       querybomCode: "",
217       queryproductCode: "",
218       queryproductName: "",
219       // 是否显示弹出层
220       open: false,
221       // 查询参数
222       queryParams: {
223         pageNum: 1,
224         pageSize: 10,
225         productCode: null,
226         productName: null,
227         locationCode: null,
228         locationName: null,
229         materialCode: null,
230         materialName: null,
231         costQty: null,
232         unit: null,
233         bomCode: null,
234       },
235       headerInformationData:{
236         bomCode: "",
237         productCode: "",
238         productName: ""
239       },
240
241       // 表单参数
242       form: {},
243       // 表单校验
244       rules: {
245         id: [
246           { required: true, message: "主键id不能为空", trigger: "blur" }
247         ],
248       }
249     };
250   },
251   created() {
252     let bomCode = this.$route.query.bomCode;
253     this.queryParams.bomCode = bomCode
254     this.querybomCode = bomCode
255     this.getList();
256     this.headerInformation();
257     this.getProcesses();
258   },
259   methods: {
260     /** 返回按钮操作 */
261     handleClose() {
262       const obj = { path: "/main/bs/bomInfo" };
263       this.$tab.closeOpenPage(obj);
264     },
265     /** BOM表头信息 */
266     headerInformation() {
267       listBomInfo(this.queryParams).then(response => {
268         this.headerInformationData = response.rows[0];
269       });
270     },
271
272     getProcesses() {
273       listBomChildInfo(null).then(response => {
274         this.options = response.rows;
275       });
276     },
277
278     /** 查询基础BOM子信息列表 */
279     getList() {
280       this.loading = true;
281       listBomChildInfo(this.queryParams).then(response => {
282         this.bomChildInfoList = response.rows;
283         this.total = response.total;
284         this.loading = false;
285       });
286     },
287     // 取消按钮
288     cancel() {
289       this.open = false;
290       this.reset();
291     },
292     // 表单重置
293     reset() {
294       this.form = {
295         id: null,
296         productCode: null,
297         productName: null,
298         locationCode: null,
299         locationName: null,
300         materialCode: null,
301         materialName: null,
302         costQty: null,
303         unit: null,
304         remark: null,
305         bomCode: null,
306         delFlag: null
307       };
308       this.resetForm("form");
309     },
310     /** 搜索按钮操作 */
311     handleQuery() {
312       this.queryParams.pageNum = 1;
313       this.getList();
314     },
315     /** 重置按钮操作 */
316     resetQuery() {
317       this.resetForm("queryForm");
318       this.handleQuery();
319     },
320     // 多选框选中数据
321     handleSelectionChange(selection) {
322       this.ids = selection.map(item => item.id)
323       this.single = selection.length!==1
324       this.multiple = !selection.length
325     },
326     /** 新增按钮操作 */
327     handleAdd() {
328       this.reset();
329       this.open = true;
330       this.title = "添加基础BOM子信息";
331     },
332     /** 修改按钮操作 */
333     handleUpdate(row) {
334       this.reset();
335       const id = row.id || this.ids
336       getBomChildInfo(id).then(response => {
337         this.form = response.data;
338         this.open = true;
339         this.title = "修改基础BOM子信息";
340       });
341     },
342     /** 提交按钮 */
343     submitForm() {
344       this.form.bomCode = this.querybomCode;
345       this.$refs["form"].validate(valid => {
346         if (valid) {
347           if (this.form.id != null) {
348             updateBomChildInfo(this.form).then(response => {
349               this.$modal.msgSuccess("修改成功");
350               this.open = false;
351               this.getList();
352             });
353           } else {
354             addBomChildInfo(this.form).then(response => {
355               this.$modal.msgSuccess("新增成功");
356               this.open = false;
357               this.getList();
358             });
359           }
360         }
361       });
362     },
363     /** 删除按钮操作 */
364     handleDelete(row) {
365       const ids = row.id || this.ids;
366       this.$modal.confirm('是否确认删除').then(function() {
367         return delBomChildInfo(ids);
368       }).then(() => {
369         this.getList();
370         this.$modal.msgSuccess("删除成功");
371       }).catch(() => {});
372     },
373     /** 导出按钮操作 */
374     handleExport() {
375       this.download('bs/bomChildInfo/export', {
376         ...this.queryParams
377       }, `bomChildInfo_${new Date().getTime()}.xlsx`)
378     }
379   }
380 };
381 </script>