admin
2024-11-22 9d822f15a8be5c3f4273b6a36ee928597521b2b7
提交 | 用户 | 时间
9d822f 1 <template>
A 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-width="100" label="总成序列号" prop="sfcCode">
5         <el-input
6           v-model="queryParams.sfcCode"
7           placeholder="请输入总成序列号"
8           clearable
9           @keyup.enter.native="handleQuery"
10         />
11       </el-form-item>
12       <el-form-item label="工位编码" prop="locationCode">
13         <el-input
14           v-model="queryParams.locationCode"
15           placeholder="请输入工位编码"
16           clearable
17           @keyup.enter.native="handleQuery"
18         />
19       </el-form-item>
20 <!--      <el-form-item label="参数编码" prop="paramCode">-->
21 <!--        <el-input-->
22 <!--          v-model="queryParams.paramCode"-->
23 <!--          placeholder="请输入参数编码"-->
24 <!--          clearable-->
25 <!--          @keyup.enter.native="handleQuery"-->
26 <!--        />-->
27 <!--      </el-form-item>-->
28 <!--      <el-form-item label="参数名称" prop="paramName">-->
29 <!--        <el-input-->
30 <!--          v-model="queryParams.paramName"-->
31 <!--          placeholder="请输入参数名称"-->
32 <!--          clearable-->
33 <!--          @keyup.enter.native="handleQuery"-->
34 <!--        />-->
35 <!--      </el-form-item>-->
36       <el-form-item style="float: right">
37         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
38         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
39       </el-form-item>
40     </el-form>
41
42     <el-row :gutter="10" class="mb8">
43       <el-col :span="1.5">
44         <el-button
45           type="primary"
46           plain
47           icon="el-icon-plus"
48           size="mini"
49           @click="handleAdd"
50           v-hasPermi="['da:materialCollection:add']"
51         >新增</el-button>
52       </el-col>
53       <el-col :span="1.5">
54         <el-button
55           type="success"
56           plain
57           icon="el-icon-edit"
58           size="mini"
59           :disabled="single"
60           @click="handleUpdate"
61           v-hasPermi="['da:materialCollection:edit']"
62         >修改</el-button>
63       </el-col>
64       <el-col :span="1.5">
65         <el-button
66           type="danger"
67           plain
68           icon="el-icon-delete"
69           size="mini"
70           :disabled="multiple"
71           @click="handleDelete"
72           v-hasPermi="['da:materialCollection:remove']"
73         >删除</el-button>
74       </el-col>
75       <el-col :span="1.5">
76         <el-button
77           type="warning"
78           plain
79           icon="el-icon-download"
80           size="mini"
81           @click="handleExport"
82           v-hasPermi="['da:materialCollection:export']"
83         >导出</el-button>
84       </el-col>
85     </el-row>
86
87     <el-table border v-loading="loading" :data="materialCollectionList" @selection-change="handleSelectionChange">
88       <el-table-column show-overflow-tooltip="true" type="selection" width="55" align="center" />
89       <el-table-column label="主键id" align="center" prop="id" />
90       <el-table-column label="总成序列号" align="center" prop="sfcCode" />
91       <el-table-column label="工位编码" align="center" prop="locationCode" />
92       <el-table-column label="参数编码" align="center" prop="paramCode" />
93       <el-table-column label="参数名称" align="center" prop="paramName" />
94       <el-table-column label="参数值" align="center" prop="paramValue" />
95       <el-table-column label="采集时间" align="center" prop="collectTime" width="180">
96       </el-table-column>
97     </el-table>
98
99     <pagination
100       v-show="total>0"
101       :total="total"
102       :page.sync="queryParams.pageNum"
103       :limit.sync="queryParams.pageSize"
104       @pagination="getList"
105     />
106
107     <!-- 添加或修改物料采集对话框 -->
108     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
109       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
110         <el-form-item label="总成序列号" prop="sfcCode">
111           <el-input v-model="form.sfcCode" placeholder="请输入总成序列号" />
112         </el-form-item>
113         <el-form-item label="工位编码" prop="locationCode">
114           <el-input v-model="form.locationCode" placeholder="请输入工位编码" />
115         </el-form-item>
116         <el-form-item label="参数编码" prop="paramCode">
117           <el-input v-model="form.paramCode" placeholder="请输入参数编码" />
118         </el-form-item>
119         <el-form-item label="参数名称" prop="paramName">
120           <el-input v-model="form.paramName" placeholder="请输入参数名称" />
121         </el-form-item>
122         <el-form-item label="参数值" prop="paramValue">
123           <el-input v-model="form.paramValue" placeholder="请输入参数值" />
124         </el-form-item>
125       </el-form>
126       <div slot="footer" class="dialog-footer">
127         <el-button type="primary" @click="submitForm">确 定</el-button>
128         <el-button @click="cancel">取 消</el-button>
129       </div>
130     </el-dialog>
131   </div>
132 </template>
133
134 <script>
135 import { listMaterialCollection, getMaterialCollection, delMaterialCollection, addMaterialCollection, updateMaterialCollection } from "@/api/main/da/materialCollection";
136
137 export default {
138   name: "MaterialCollection",
139   data() {
140     return {
141       // 遮罩层
142       loading: true,
143       // 选中数组
144       ids: [],
145       // 非单个禁用
146       single: true,
147       // 非多个禁用
148       multiple: true,
149       // 显示搜索条件
150       showSearch: true,
151       // 总条数
152       total: 0,
153       // 物料采集表格数据
154       materialCollectionList: [],
155       // 弹出层标题
156       title: "",
157       // 是否显示弹出层
158       open: false,
159       // 查询参数
160       queryParams: {
161         pageNum: 1,
162         pageSize: 10,
163         sfcCode: null,
164         locationCode: null,
165         paramCode: null,
166         paramName: null,
167       },
168       // 表单参数
169       form: {},
170       // 表单校验
171       rules: {
172       }
173     };
174   },
175   created() {
176     this.getList();
177   },
178   methods: {
179     /** 查询物料采集列表 */
180     getList() {
181       this.loading = true;
182       listMaterialCollection(this.queryParams).then(response => {
183         this.materialCollectionList = response.rows;
184         this.total = response.total;
185         this.loading = false;
186       });
187     },
188     // 取消按钮
189     cancel() {
190       this.open = false;
191       this.reset();
192     },
193     // 表单重置
194     reset() {
195       this.form = {
196         id: null,
197         sfcCode: null,
198         locationCode: null,
199         paramCode: null,
200         paramName: null,
201         paramValue: null,
202         collectTime: null
203       };
204       this.resetForm("form");
205     },
206     /** 搜索按钮操作 */
207     handleQuery() {
208       this.queryParams.pageNum = 1;
209       this.getList();
210     },
211     /** 重置按钮操作 */
212     resetQuery() {
213       this.resetForm("queryForm");
214       this.handleQuery();
215     },
216     // 多选框选中数据
217     handleSelectionChange(selection) {
218       this.ids = selection.map(item => item.id)
219       this.single = selection.length!==1
220       this.multiple = !selection.length
221     },
222     /** 新增按钮操作 */
223     handleAdd() {
224       this.reset();
225       this.open = true;
226       this.title = "添加物料采集";
227     },
228     /** 修改按钮操作 */
229     handleUpdate(row) {
230       this.reset();
231       const id = row.id || this.ids
232       getMaterialCollection(id).then(response => {
233         this.form = response.data;
234         this.open = true;
235         this.title = "修改物料采集";
236       });
237     },
238     /** 提交按钮 */
239     submitForm() {
240       this.$refs["form"].validate(valid => {
241         if (valid) {
242           if (this.form.id != null) {
243             updateMaterialCollection(this.form).then(response => {
244               this.$modal.msgSuccess("修改成功");
245               this.open = false;
246               this.getList();
247             });
248           } else {
249             addMaterialCollection(this.form).then(response => {
250               this.$modal.msgSuccess("新增成功");
251               this.open = false;
252               this.getList();
253             });
254           }
255         }
256       });
257     },
258     /** 删除按钮操作 */
259     handleDelete(row) {
260       const ids = row.id || this.ids;
261       this.$modal.confirm('是否确认删除物料采集编号为"' + ids + '"的数据项?').then(function() {
262         return delMaterialCollection(ids);
263       }).then(() => {
264         this.getList();
265         this.$modal.msgSuccess("删除成功");
266       }).catch(() => {});
267     },
268     /** 导出按钮操作 */
269     handleExport() {
270       this.download('da/materialCollection/export', {
271         ...this.queryParams
272       }, `materialCollection_${new Date().getTime()}.xlsx`)
273     }
274   }
275 };
276 </script>