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