春风项目四线(合箱线、总装线)
cl
2024-01-18 d18622be3bf4c48e9cf17bc4d3254245438ed272
提交 | 用户 | 时间
fd2207 1 <template>
2   <div class="app-container">
3     <el-card class="box-card">
4         <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
5           <el-form-item label="产品编码" prop="productCode">
6             <el-input
7               v-model="queryParams.productCode"
8               placeholder="请输入产品编码"
9               clearable
10               @keyup.enter.native="handleQuery"
11             />
12           </el-form-item>
13           <el-form-item label="产品名称" prop="productName">
14             <el-input
15               v-model="queryParams.productName"
16               placeholder="请输入产品名称"
17               clearable
18               @keyup.enter.native="handleQuery"
19             />
20           </el-form-item>
21           <el-form-item style="float: right">
22             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
23             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
24           </el-form-item>
25         </el-form>
26     </el-card>
27
28     <el-card style="margin-top: 10px" class="box-card">
29         <el-row :gutter="10" class="mb8">
30           <el-col :span="1.5">
31             <el-button
32               type="primary"
33               plain
34               icon="el-icon-plus"
35               size="mini"
36               @click="handleAdd"
37               v-hasPermi="['bs:beatSetting:add']"
38             >新增</el-button>
39           </el-col>
40           <el-col :span="1.5">
41             <el-button
42               type="success"
43               plain
44               icon="el-icon-edit"
45               size="mini"
46               :disabled="single"
47               @click="handleUpdate"
48               v-hasPermi="['bs:beatSetting:edit']"
49             >修改</el-button>
50           </el-col>
51           <el-col :span="1.5">
52             <el-button
53               type="danger"
54               plain
55               icon="el-icon-delete"
56               size="mini"
57               :disabled="multiple"
58               @click="handleDelete"
59               v-hasPermi="['bs:beatSetting:remove']"
60             >删除</el-button>
61           </el-col>
62           <el-col :span="1.5">
63             <el-button
64               type="warning"
65               plain
66               icon="el-icon-download"
67               size="mini"
68               @click="handleExport"
69               v-hasPermi="['bs:beatSetting:export']"
70             >导出</el-button>
71           </el-col>
72           <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
73         </el-row>
74
75         <el-table border v-loading="loading" :data="beatSettingList" @selection-change="handleSelectionChange">
76           <el-table-column type="selection" width="55" align="center" />
77           <el-table-column label="产品编码" align="center" prop="productCode">
78           </el-table-column>
79           <el-table-column label="产品名称" align="center" prop="productName">
80           </el-table-column>
81           <el-table-column label="节拍" align="center" prop="beat">
82           </el-table-column>
83           <el-table-column fixed="right" width="200" label="操作" align="center" class-name="small-padding fixed-width">
84             <template slot-scope="scope">
85               <el-button
86                 size="mini"
87                 type="success"
88                 plain
89                 style="width: 72px"
90                 icon="el-icon-edit"
91                 @click="handleUpdate(scope.row)"
92                 v-hasPermi="['bs:beatSetting:edit']"
93               >修改</el-button>
94               <el-button
95                 size="mini"
96                 type="danger"
97                 plain
98                 style="width: 72px"
99                 icon="el-icon-delete"
100                 @click="handleDelete(scope.row)"
101                 v-hasPermi="['bs:beatSetting:remove']"
102               >删除</el-button>
103             </template>
104           </el-table-column>
105         </el-table>
106     </el-card>
107
108     <pagination
109       v-show="total>0"
110       :total="total"
111       :page.sync="queryParams.pageNum"
112       :limit.sync="queryParams.pageSize"
113       @pagination="getList"
114     />
115
116     <!-- 添加或修改节拍设置对话框 -->
117     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="500px" append-to-body>
118       <span slot="title">
119         <i class="el-icon-s-order"></i>
120         {{titleName}}
121       </span>
122       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
123         <el-form-item label="产品编码" prop="productCode">
124           <el-select style="width: 100%" @change="handleSelectChange(form.productCode)" v-model="form.productCode" placeholder="请输入产品编码">
125             <el-option
126               v-for="item in options"
127               :key="item.productCode"
128               :label="item.productCode"
129               :value="item.productCode">
130             </el-option>
131           </el-select>
132         </el-form-item>
133         <el-form-item  label="产品名称" prop="productName">
134           <el-input  disabled v-model="form.productName" placeholder="请输入产品名称" />
135         </el-form-item>
136         <el-form-item label="节拍" prop="beat">
137           <el-input v-model="form.beat" placeholder="请输入节拍" />
138         </el-form-item>
139         <el-form-item label="备注" prop="remark">
140           <el-input v-model="form.remark" placeholder="请输入备注" />
141         </el-form-item>
142       </el-form>
143       <div slot="footer" class="dialog-footer">
144         <el-button type="primary" @click="submitForm">确 定</el-button>
145         <el-button @click="cancel">取 消</el-button>
146       </div>
147     </el-dialog>
148   </div>
149 </template>
150
151 <script>
152 import { listBeatSetting, getBeatSetting, delBeatSetting, addBeatSetting, updateBeatSetting } from "@/api/main/bs/beatSetting/beatSetting";
153 import {listProductBom} from "@/api/main/bs/ProductBom/ProductBom";
154
155 export default {
156   name: "BeatSetting",
157   data() {
158     return {
159       // 遮罩层
160       loading: true,
161       titleName: "",
162       options: [],
163       // 选中数组
164       ids: [],
165       // 非单个禁用
166       single: true,
167       // 非多个禁用
168       multiple: true,
169       // 显示搜索条件
170       showSearch: true,
171       // 总条数
172       total: 0,
173       // 节拍设置表格数据
174       beatSettingList: [],
175       // 弹出层标题
176       title: "",
177       // 是否显示弹出层
178       open: false,
179       // 查询参数
180       queryParams: {
181         pageNum: 1,
182         pageSize: 10,
183         productCode: null,
184         productName: null,
185         beat: null,
186         spareField1: null,
187         spareField2: null,
188         createUser: null,
189         updateUser: null,
190         dataSource: null
191       },
192       productCodeQueryParams: {
193         pageNum: 1,
194         pageSize: 10,
195         productCode: null,
196         productName: null,
197         beat: null,
198         spareField1: null,
199         spareField2: null,
200         createUser: null,
201         updateUser: null,
202         dataSource: null
203       },
204       // 表单参数
205       form: {},
206       // 表单校验
207       rules: {
208         id: [
209           { required: true, message: "主键id不能为空", trigger: "blur" }
210         ],
211         beat: [
212           { required: true, message: "节拍不能为空", trigger: "blur" }
213         ],
214       }
215     };
216   },
217   created() {
218     this.getList();
219     this.initProductBom();
220   },
221   methods: {
222     /** 查询节拍设置列表 */
223     handleSelectChange(selectedOption) {
224       this.productCodeQueryParams.productCode = selectedOption;
225       listProductBom(this.productCodeQueryParams).then(response => {
226         this.form.productName = response.rows[0].productName;
227       });
228     },
229     initProductBom(){
230       listProductBom(this.queryParams).then(response => {
231         this.options = response.rows;
232       });
233     },
234
235     getList() {
236       this.loading = true;
237       listBeatSetting(this.queryParams).then(response => {
238         this.beatSettingList = response.rows;
239         this.total = response.total;
240         this.loading = false;
241       });
242     },
243     // 取消按钮
244     cancel() {
245       this.open = false;
246       this.reset();
247     },
248     // 表单重置
249     reset() {
250       this.form = {
251         id: null,
252         productCode: null,
253         productName: null,
254         beat: null,
255         spareField1: null,
256         spareField2: null,
257         remark: null,
258         createUser: null,
259         createTime: null,
260         updateUser: null,
261         updateTime: null,
262         dataSource: null
263       };
264       this.resetForm("form");
265     },
266     /** 搜索按钮操作 */
267     handleQuery() {
268       this.queryParams.pageNum = 1;
269       this.getList();
270     },
271     /** 重置按钮操作 */
272     resetQuery() {
273       this.resetForm("queryForm");
274       this.handleQuery();
275     },
276     // 多选框选中数据
277     handleSelectionChange(selection) {
278       this.ids = selection.map(item => item.id)
279       this.single = selection.length!==1
280       this.multiple = !selection.length
281     },
282     /** 新增按钮操作 */
283     handleAdd() {
284       this.reset();
285       this.open = true;
286       this.titleName = "添加节拍设置";
287     },
288     /** 修改按钮操作 */
289     handleUpdate(row) {
290       this.reset();
291       const id = row.id || this.ids
292       getBeatSetting(id).then(response => {
293         this.form = response.data;
294         this.open = true;
295         this.titleName = "修改节拍设置";
296       });
297     },
298     /** 提交按钮 */
299     submitForm() {
300       this.$refs["form"].validate(valid => {
301         if (valid) {
302           if (this.form.id != null) {
303             updateBeatSetting(this.form).then(response => {
304               this.$modal.msgSuccess("修改成功");
305               this.open = false;
306               this.getList();
307             });
308           } else {
309             addBeatSetting(this.form).then(response => {
310               this.$modal.msgSuccess("新增成功");
311               this.open = false;
312               this.getList();
313             });
314           }
315         }
316       });
317     },
318     /** 删除按钮操作 */
319     handleDelete(row) {
320       const ids = row.id || this.ids;
321       this.$modal.confirm('是否确认删除节拍设置编号为"' + ids + '"的数据项?').then(function() {
322         return delBeatSetting(ids);
323       }).then(() => {
324         this.getList();
325         this.$modal.msgSuccess("删除成功");
326       }).catch(() => {});
327     },
328     /** 导出按钮操作 */
329     handleExport() {
330       this.download('bs/beatSetting/export', {
331         ...this.queryParams
332       }, `beatSetting_${new Date().getTime()}.xlsx`)
333     }
334   }
335 };
336 </script>