hdy
2024-01-06 9c5ce6d05798da90d130ddf42d366fab369735e7
提交 | 用户 | 时间
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>
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>
eb4d1e 23           <el-option
H 24             v-for="dict in dict.type.sys_normal_disable"
25             :key="dict.value"
26             :label="dict.label"
27             :value="dict.value"
28           />
fd7ea7 29         </el-select>
YY 30       </el-form-item>
a04319 31       <el-form-item style="float: right">
fd7ea7 32         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
YY 33         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
34       </el-form-item>
35     </el-form>
a04319 36     </el-card>
H 37     <el-card style="margin-top: 10px" class="box-card">
fd7ea7 38     <el-row :gutter="10" class="mb8">
YY 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
6f148b 84     <el-table v-loading="loading" border :data="materialList" @selection-change="handleSelectionChange" v-if="materialList.length > 0">
fd7ea7 85       <el-table-column type="selection" width="55" align="center" />
f6bd1a 86       <el-table-column label="物料编号"  align="center" prop="materialCode" width="180">
fd7ea7 87       </el-table-column>
f6bd1a 88       <el-table-column label="物料名称" align="center" prop="materialName" width="250">
eb4d1e 89       </el-table-column>
f6bd1a 90       <el-table-column label="视图" align="center" prop="materialView" width="180">
fd7ea7 91       </el-table-column>
YY 92       <el-table-column label="类型" align="center" prop="typeL">
01b045 93         <template slot-scope="scope">
94           <dict-tag :options="dict.type.material_type" :value="scope.row.typeL"/>
95         </template>
fd7ea7 96       </el-table-column>
f6bd1a 97
C 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">
30049a 102         <template slot-scope="scope">
H 103           <dict-tag :options="dict.type.unit" :value="scope.row.unit"/>
104         </template>
fd7ea7 105       </el-table-column>
01b045 106 <!--      <el-table-column label="ERP规格" align="center" prop="erpSpec">-->
107 <!--      </el-table-column>-->
f6bd1a 108
C 109       <el-table-column label="状态" align="center" prop="status" width="80">
a04319 110         <template slot-scope="scope">
H 111           <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
112         </template>
fd7ea7 113       </el-table-column>
f6bd1a 114
C 115 <!--      <el-table-column label="厂商" align="center" prop="supplier">
116       </el-table-column>-->
117       <el-table-column label="备注" align="center" prop="remarks" width="180">
0cddc0 118       </el-table-column>
f6bd1a 119       <el-table-column label="创建人" align="center" prop="createUser" width="150">
8043f5 120       </el-table-column>
f6bd1a 121       <el-table-column label="创建时间" align="center" prop="createTime" width="170">
C 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">
fd7ea7 128       </el-table-column>
6f148b 129       <el-table-column fixed="right" label="操作" width="200" align="center" class-name="small-padding fixed-width">
fd7ea7 130         <template slot-scope="scope">
YY 131           <el-button
132             size="mini"
a04319 133             type="success"
H 134             plain
135             style="width: 72px"
fd7ea7 136             icon="el-icon-edit"
YY 137             @click="handleUpdate(scope.row)"
138             v-hasPermi="['bs:material:edit']"
139           >修改</el-button>
140           <el-button
141             size="mini"
a04319 142             plain
H 143             style="width: 72px"
144             type="danger"
fd7ea7 145             icon="el-icon-delete"
YY 146             @click="handleDelete(scope.row)"
147             v-hasPermi="['bs:material:remove']"
148           >删除</el-button>
149         </template>
150       </el-table-column>
151     </el-table>
a04319 152       <el-empty v-else>
H 153         <span slot="description">暂无数据</span>
154       </el-empty>
155     </el-card>
fd7ea7 156     <pagination
YY 157       v-show="total>0"
158       :total="total"
159       :page.sync="queryParams.pageNum"
160       :limit.sync="queryParams.pageSize"
161       @pagination="getList"
162     />
163
164     <!-- 添加或修改物料信息对话框 -->
45a2ee 165     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="700px" append-to-body>
a04319 166       <span slot="title">
H 167         <i class="el-icon-s-order"></i>
168         {{titleName}}
169       </span>
eb4d1e 170       <el-form ref="form" inline :model="form" :rules="rules" label-width="80px">
fd7ea7 171         <el-form-item label="物料编号" prop="materialCode">
YY 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>
f6bd1a 177         <el-form-item label="物料类型" prop="typeL">
C 178           <!--          <el-input v-model="form.typeL" placeholder="请输入类型" />-->
01b045 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>
f6bd1a 187         </el-form-item>
C 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="请输入视图" />
fd7ea7 193         </el-form-item>
YY 194         <el-form-item label="单位" prop="unit">
30049a 195 <!--          <el-input v-model="form.unit" placeholder="请输入单位" />-->
01b045 196           <el-select v-model="form.unit" style="width: 204px;" placeholder="请选择单位" clearable>
30049a 197             <el-option
H 198               v-for="dict in dict.type.unit"
199               :key="dict.value"
200               :label="dict.label"
201               :value="dict.value"
202             />
203           </el-select>
fd7ea7 204         </el-form-item>
YY 205         <el-form-item label="备注" prop="remarks">
206           <el-input v-model="form.remarks" placeholder="请输入备注" />
207         </el-form-item>
f6bd1a 208 <!--        <el-form-item label="ERP规格" prop="erpSpec">
fd7ea7 209           <el-input v-model="form.erpSpec" placeholder="请输入ERP规格" />
f6bd1a 210         </el-form-item>-->
C 211 <!--        <el-form-item label="厂商" prop="supplier">
eb4d1e 212           <el-input v-model="form.supplier" placeholder="请输入厂商" />
f6bd1a 213         </el-form-item>-->
fd7ea7 214         <el-form-item label="状态" prop="status">
YY 215           <el-radio-group v-model="form.status">
0cddc0 216             <el-radio
YY 217               v-for="dict in dict.type.sys_normal_disable"
fd7ea7 218               :key="dict.value"
YY 219               :label="dict.value"
0cddc0 220             >{{dict.label}}</el-radio>
fd7ea7 221           </el-radio-group>
YY 222         </el-form-item>
eb4d1e 223
fd7ea7 224       </el-form>
YY 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",
01b045 238   dicts: ['sys_normal_disable','unit','material_type'],
fd7ea7 239   data() {
YY 240     return {
241       // 遮罩层
242       loading: true,
a04319 243       titleName: 'test',
fd7ea7 244       // 选中数组
YY 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         ],
a04319 288         materialCode: [
H 289           { required: true, message: "物料编码不能为空", trigger: "blur" }
290         ],
291         materialName: [
292           { required: true, message: "物料名称不能为空", trigger: "blur" }
293         ],
294         typeL: [
295           { required: true, message: "类型不能为空", trigger: "blur" }
8043f5 296         ],
fd7ea7 297       }
YY 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,
a04319 337         status: '0',
fd7ea7 338         supplier: null
YY 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;
a04319 362       this.titleName = "添加物料信息";
fd7ea7 363     },
YY 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;
a04319 371         this.titleName = "修改物料信息";
fd7ea7 372       });
YY 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>