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