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