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