wyg
2024-06-17 44f5fadd6a669405cd8a7608aa510bd62688a750
提交 | 用户 | 时间
bdd09a 1 <template>
W 2   <div class="app-container">
3     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
44f5fa 4         <el-form-item label="工厂" prop="werks">
W 5         <el-input
6           v-model.trim="queryParams.werks"
7           placeholder="请输入工厂"
8           clearable
9           @keyup.enter.native="handleQuery"
10         /> 
11       </el-form-item>
bdd09a 12       <el-form-item label="名称" prop="warehouseName">
W 13         <el-input
44f5fa 14           v-model.trim="queryParams.warehouseName"
bdd09a 15           placeholder="请输入名称"
W 16           clearable
17           @keyup.enter.native="handleQuery"
18         />
19       </el-form-item>
44f5fa 20
W 21       <el-form-item label="编号" prop="lgort">
bdd09a 22         <el-input
44f5fa 23           v-model.trim="queryParams.lgort"
W 24           placeholder="请输入编号"
bdd09a 25           clearable
W 26           @keyup.enter.native="handleQuery"
27         />
28       </el-form-item>
44f5fa 29     
bdd09a 30       <el-form-item label="状态" prop="state">
W 31         <el-input
44f5fa 32           v-model.trim="queryParams.state"
bdd09a 33           placeholder="请输入状态"
W 34           clearable
35           @keyup.enter.native="handleQuery"
36         />
37       </el-form-item>
38       <el-form-item>
39         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
40         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
41       </el-form-item>
42     </el-form>
43
44     <el-row :gutter="10" class="mb8">
45       <el-col :span="1.5">
46         <el-button
47           type="primary"
48           plain
49           icon="el-icon-plus"
50           size="mini"
51           @click="handleAdd"
52           v-hasPermi="['system:warehouse:add']"
53         >新增</el-button>
54       </el-col>
55       <el-col :span="1.5">
56         <el-button
57           type="success"
58           plain
59           icon="el-icon-edit"
60           size="mini"
61           :disabled="single"
62           @click="handleUpdate"
63           v-hasPermi="['system:warehouse:edit']"
64         >修改</el-button>
65       </el-col>
66       <el-col :span="1.5">
67         <el-button
68           type="danger"
69           plain
70           icon="el-icon-delete"
71           size="mini"
72           :disabled="multiple"
73           @click="handleDelete"
74           v-hasPermi="['system:warehouse:remove']"
75         >删除</el-button>
76       </el-col>
77       <el-col :span="1.5">
78         <el-button
79           type="warning"
80           plain
81           icon="el-icon-download"
82           size="mini"
83           @click="handleExport"
84           v-hasPermi="['system:warehouse:export']"
85         >导出</el-button>
86       </el-col>
87       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
88     </el-row>
89
44f5fa 90     <el-table v-loading="loading" border :data="warehouseList" @selection-change="handleSelectionChange">
bdd09a 91       <el-table-column type="selection" width="55" align="center" />
44f5fa 92       <el-table-column
W 93        label="序号"
94       type="index"
95       fixed
96       width="50" />
97       <!-- <el-table-column label="仓库ID" align="center" prop="warehouseId" v-if="true"/> -->
bdd09a 98       <el-table-column label="仓库编号" align="center" prop="lgort" />
W 99       <el-table-column label="名称" align="center" prop="warehouseName" />
100       <el-table-column label="工厂" align="center" prop="werks" />
101       <el-table-column label="类别" align="center" prop="type" />
44f5fa 102       <el-table-column label="是否启用" align="center" prop="isUseLocation" >
W 103         <template slot-scope="scope">
104            <dict-tag :options="dict.type.isenable" :value="scope.row.isUseLocation"/>
105         </template>
106       </el-table-column>
107       <!-- <el-table-column label="管理员ID" align="center" prop="userId" /> -->
108         <el-table-column label="管理员名称" align="center" prop="userName" />
bdd09a 109       <el-table-column label="管理员电话" align="center" prop="userPhone" />
W 110       <el-table-column label="坐标X" align="center" prop="coordinateX" />
111       <el-table-column label="坐标Y" align="center" prop="coordinateY" />
112       <el-table-column label="描述" align="center" prop="description" />
44f5fa 113       <!-- <el-table-column label="状态" align="center" prop="state" /> -->
bdd09a 114       <el-table-column label="最后更新人id" align="center" prop="lastUpdatedUserId" />
W 115       <el-table-column label="最后更新人姓名" align="center" prop="lastUpdatedUserName" />
116       <el-table-column label="最后更新时间" align="center" prop="lastUpdatedDateTime" width="180">
117         <template slot-scope="scope">
118           <span>{{ parseTime(scope.row.lastUpdatedDateTime, '{y}-{m}-{d}') }}</span>
119         </template>
120       </el-table-column>
121       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
122         <template slot-scope="scope">
123           <el-button
124             size="mini"
125             type="text"
126             icon="el-icon-edit"
127             @click="handleUpdate(scope.row)"
128             v-hasPermi="['system:warehouse:edit']"
129           >修改</el-button>
130           <el-button
131             size="mini"
132             type="text"
133             icon="el-icon-delete"
134             @click="handleDelete(scope.row)"
135             v-hasPermi="['system:warehouse:remove']"
136           >删除</el-button>
137         </template>
138       </el-table-column>
139     </el-table>
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     <!-- 添加或修改仓库对话框 -->
44f5fa 150     <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
bdd09a 151       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
W 152         <el-form-item label="仓库编号" prop="lgort">
44f5fa 153           <el-input v-model.trim="form.lgort" placeholder="请输入仓库编号" />
bdd09a 154         </el-form-item>
W 155         <el-form-item label="名称" prop="warehouseName">
44f5fa 156           <el-input v-model.trim="form.warehouseName" placeholder="请输入名称" />
bdd09a 157         </el-form-item>
W 158         <el-form-item label="工厂" prop="werks">
44f5fa 159           <el-input v-model.trim="form.werks" placeholder="请输入工厂" />
bdd09a 160         </el-form-item>
44f5fa 161           <el-form-item label="类别" prop="type">
W 162           <el-input v-model.trim="form.type" placeholder="请输入类别" />
bdd09a 163         </el-form-item>
44f5fa 164         <el-form-item label="是否启用" prop="isUseLocation">
W 165           <!-- <el-input v-model.trim="form.isUseLocation" placeholder="请输入0,不启用
166             1,启用" /> -->
167                   <el-select v-model="form.isUseLocation" placeholder="是否启用" clearable>
168             <el-option
169               v-for="dict in dict.type.isenable"
170               :key="dict.value"
171               :label="dict.label"
172               :value="dict.value"
173             />
174           </el-select>
175         </el-form-item>
176         <el-form-item label="管理员名称" prop="userId">
177           <el-input v-model.trim="form.userName" placeholder="请输入管理员名称" />
bdd09a 178         </el-form-item>
W 179         <el-form-item label="管理员电话" prop="userPhone">
44f5fa 180           <el-input v-model.trim="form.userPhone" placeholder="请输入管理员电话" />
bdd09a 181         </el-form-item>
W 182         <el-form-item label="坐标X" prop="coordinateX">
44f5fa 183           <el-input v-model.trim="form.coordinateX" placeholder="请输入坐标X" />
bdd09a 184         </el-form-item>
W 185         <el-form-item label="坐标Y" prop="coordinateY">
44f5fa 186           <el-input v-model.trim="form.coordinateY" placeholder="请输入坐标Y" />
bdd09a 187         </el-form-item>
W 188         <el-form-item label="描述" prop="description">
44f5fa 189           <el-input v-model.trim="form.description" placeholder="请输入描述" />
bdd09a 190         </el-form-item>
44f5fa 191         <!-- <el-form-item label="状态" prop="state">
W 192           <el-input v-model.trim="form.state" placeholder="请输入状态" />
193         </el-form-item> -->
194         <!-- <el-form-item label="最后更新人id" prop="lastUpdatedUserId">
195           <el-input v-model.trim="form.lastUpdatedUserId" placeholder="请输入最后更新人id" />
bdd09a 196         </el-form-item>
W 197         <el-form-item label="最后更新人姓名" prop="lastUpdatedUserName">
44f5fa 198           <el-input v-model.trim="form.lastUpdatedUserName" placeholder="请输入最后更新人姓名" />
bdd09a 199         </el-form-item>
W 200         <el-form-item label="最后更新时间" prop="lastUpdatedDateTime">
201           <el-date-picker clearable
202             v-model="form.lastUpdatedDateTime"
203             type="datetime"
204             value-format="yyyy-MM-dd HH:mm:ss"
205             placeholder="请选择最后更新时间">
206           </el-date-picker>
44f5fa 207         </el-form-item> -->
bdd09a 208       </el-form>
W 209       <div slot="footer" class="dialog-footer">
210         <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
211         <el-button @click="cancel">取 消</el-button>
212       </div>
213     </el-dialog>
214   </div>
215 </template>
216
217 <script>
218 import { listWarehouse, getWarehouse, delWarehouse, addWarehouse, updateWarehouse } from "@/api/basicData/warehouse";
219
220 export default {
221   name: "Warehouse",
44f5fa 222     dicts: ['isenable'],
bdd09a 223   data() {
W 224     return {
225       // 按钮loading
226       buttonLoading: false,
227       // 遮罩层
228       loading: true,
229       // 选中数组
230       ids: [],
231       // 非单个禁用
232       single: true,
233       // 非多个禁用
234       multiple: true,
235       // 显示搜索条件
236       showSearch: true,
237       // 总条数
238       total: 0,
239       // 仓库表格数据
240       warehouseList: [],
241       // 弹出层标题
242       title: "",
243       // 是否显示弹出层
244       open: false,
245       // 查询参数
246       queryParams: {
247         pageNum: 1,
248         pageSize: 10,
249         warehouseName: undefined,
250         werks: undefined,
251         type: undefined,
252         state: undefined,
253       },
254       // 表单参数
255       form: {},
256       // 表单校验
257       rules: {
258         warehouseId: [
259           { required: true, message: "仓库ID不能为空", trigger: "blur" }
260         ],
261         lgort: [
262           { required: true, message: "仓库编号不能为空", trigger: "blur" }
263         ],
264         warehouseName: [
265           { required: true, message: "名称不能为空", trigger: "blur" }
266         ],
267         werks: [
268           { required: true, message: "工厂不能为空", trigger: "blur" }
269         ],
270         type: [
271           { required: true, message: "类别不能为空", trigger: "change" }
272         ],
273         // isUseLocation: [
274         //   { required: true, message: "0,不启用
275         //     1,启用不能为空", trigger: "blur" }
276         // ],
277         userId: [
278           { required: true, message: "管理员ID不能为空", trigger: "blur" }
279         ],
280         userPhone: [
281           { required: true, message: "管理员电话不能为空", trigger: "blur" }
282         ],
283         coordinateX: [
284           { required: true, message: "坐标X不能为空", trigger: "blur" }
285         ],
286         coordinateY: [
287           { required: true, message: "坐标Y不能为空", trigger: "blur" }
288         ],
289         description: [
290           { required: true, message: "描述不能为空", trigger: "blur" }
291         ],
292         state: [
293           { required: true, message: "状态不能为空", trigger: "blur" }
294         ],
44f5fa 295       
bdd09a 296       }
W 297     };
298   },
299   created() {
300     this.getList();
301   },
302   methods: {
303     /** 查询仓库列表 */
304     getList() {
305       this.loading = true;
306       listWarehouse(this.queryParams).then(response => {
307         this.warehouseList = response.rows;
308         this.total = response.total;
309         this.loading = false;
310       });
311     },
312     // 取消按钮
313     cancel() {
314       this.open = false;
315       this.reset();
316     },
317     // 表单重置
318     reset() {
319       this.form = {
320         warehouseId: undefined,
321         lgort: undefined,
322         warehouseName: undefined,
323         werks: undefined,
324         type: undefined,
325         isUseLocation: undefined,
326         userId: undefined,
327         userPhone: undefined,
328         coordinateX: undefined,
329         coordinateY: undefined,
330         description: undefined,
331         state: undefined,
332         displayOrder: undefined,
333         createdUserId: undefined,
334         createdUserName: undefined,
335         createdDateTime: undefined,
336         lastUpdatedUserId: undefined,
337         lastUpdatedUserName: undefined,
338         lastUpdatedDateTime: undefined,
339         isDeleted: undefined
340       };
341       this.resetForm("form");
342     },
343     /** 搜索按钮操作 */
344     handleQuery() {
345       this.queryParams.pageNum = 1;
346       this.getList();
347     },
348     /** 重置按钮操作 */
349     resetQuery() {
350       this.resetForm("queryForm");
351       this.handleQuery();
352     },
353     // 多选框选中数据
354     handleSelectionChange(selection) {
355       this.ids = selection.map(item => item.warehouseId)
356       this.single = selection.length!==1
357       this.multiple = !selection.length
358     },
359     /** 新增按钮操作 */
360     handleAdd() {
361       this.reset();
362       this.open = true;
363       this.title = "添加仓库";
364     },
365     /** 修改按钮操作 */
366     handleUpdate(row) {
367       this.loading = true;
368       this.reset();
369       const warehouseId = row.warehouseId || this.ids
370       getWarehouse(warehouseId).then(response => {
371         this.loading = false;
372         this.form = response.data;
373         this.open = true;
374         this.title = "修改仓库";
375       });
376     },
377     /** 提交按钮 */
378     submitForm() {
379       this.$refs["form"].validate(valid => {
380         if (valid) {
381           this.buttonLoading = true;
382           if (this.form.warehouseId != null) {
383             updateWarehouse(this.form).then(response => {
384               this.$modal.msgSuccess("修改成功");
385               this.open = false;
386               this.getList();
387             }).finally(() => {
388               this.buttonLoading = false;
389             });
390           } else {
391             addWarehouse(this.form).then(response => {
392               this.$modal.msgSuccess("新增成功");
393               this.open = false;
394               this.getList();
395             }).finally(() => {
396               this.buttonLoading = false;
397             });
398           }
399         }
400       });
401     },
402     /** 删除按钮操作 */
403     handleDelete(row) {
404       const warehouseIds = row.warehouseId || this.ids;
405       this.$modal.confirm('是否确认删除仓库编号为"' + warehouseIds + '"的数据项?').then(() => {
406         this.loading = true;
407         return delWarehouse(warehouseIds);
408       }).then(() => {
409         this.loading = false;
410         this.getList();
411         this.$modal.msgSuccess("删除成功");
412       }).catch(() => {
413       }).finally(() => {
414         this.loading = false;
415       });
416     },
417     /** 导出按钮操作 */
418     handleExport() {
419       this.download('system/warehouse/export', {
420         ...this.queryParams
421       }, `warehouse_${new Date().getTime()}.xlsx`)
422     }
423   }
424 };
425 </script>