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