春风项目四线(合箱线、总装线)
wujian
2024-01-31 c74dcb8dca7b9e3eded0d20299f19a26a6b70974
提交 | 用户 | 时间
fd2207 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="workshopCode">
6           <el-input
7             v-model="queryParams.workshopCode"
8             placeholder="请输入车间编码"
9             clearable
10             @keyup.enter.native="handleQuery"
11           />
12         </el-form-item>
13         <el-form-item label="车间名称" prop="workshopName">
14           <el-input
15             v-model="queryParams.workshopName"
16             placeholder="请输入车间名称"
17             clearable
18             @keyup.enter.native="handleQuery"
19           />
20         </el-form-item>
21         <el-form-item style="float: right">
22           <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
23 <!--          <el-button type="warning" icon="el-icon-copy-document" size="mini" @click="advancedQuery">高级查询</el-button>-->
24           <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
25         </el-form-item>
26       </el-form>
27       <el-form :model="queryParams" ref="queryParams" size="small" :inline="true" v-show="advancedShowSearch" label-width="68px">
28       </el-form>
29     </el-card>
30
31     <el-card style="margin-top: 10px" class="box-card">
32       <el-row :gutter="10" class="mb8">
33         <el-col :span="1.5">
34           <el-button
35             type="primary"
36             plain
37             icon="el-icon-plus"
38             size="mini"
39             @click="handleAdd"
40             v-hasPermi="['bs:workshop:add']"
41           >新增</el-button>
42         </el-col>
43         <el-col :span="1.5">
44           <el-button
45             type="success"
46             plain
47             icon="el-icon-edit"
48             size="mini"
49             :disabled="single"
50             @click="handleUpdate"
51             v-hasPermi="['bs:workshop:edit']"
52           >修改</el-button>
53         </el-col>
54         <el-col :span="1.5">
55           <el-button
56             type="danger"
57             plain
58             icon="el-icon-delete"
59             size="mini"
60             :disabled="multiple"
61             @click="handleDelete"
62             v-hasPermi="['bs:workshop:remove']"
63           >删除</el-button>
64         </el-col>
65         <el-col :span="1.5">
66           <el-button
b6c635 67             type="info"
68             plain
69             icon="el-icon-upload2"
70             size="mini"
71             @click="handleImport"
72           >导入</el-button>
73         </el-col>
74         <el-col :span="1.5">
75           <el-button
fd2207 76             type="warning"
77             plain
78             icon="el-icon-download"
79             size="mini"
80             @click="handleExport"
81             v-hasPermi="['bs:workshop:export']"
82           >导出</el-button>
83         </el-col>
84         <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
85       </el-row>
86       <el-table v-loading="loading" border :data="workshopList" @selection-change="handleSelectionChange" v-if="workshopList.length > 0">
87         <el-table-column type="selection" width="55" align="center" />
88         <!--      <el-table-column label="id" align="center" prop="id" />-->
89         <el-table-column label="车间编码" width="120" align="center" prop="workshopCode">
90         </el-table-column>
91         <el-table-column :show-overflow-tooltip='true' width="150" label="车间名称" align="center" prop="workshopName">
92         </el-table-column>
93         <el-table-column label="状态" align="center" prop="status" width="80">
94           <template slot-scope="scope">
95             <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
96           </template>
97         </el-table-column>
98         <el-table-column label="备注" width="150" align="center" prop="remarks">
99         </el-table-column>
100         <el-table-column label="创建人" align="center" prop="createUser" width="150">
101         </el-table-column>
102         <el-table-column label="创建时间" align="center" prop="createTime" width="180">
103         </el-table-column>
104         <el-table-column label="更新人" align="center" prop="updateUser" width="150">
105         </el-table-column>
106         <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
107         </el-table-column>
108         <el-table-column fixed="right" label="操作" width="200" align="center" class-name="small-padding fixed-width">
109           <template slot-scope="scope">
110             <el-button
111               size="mini"
112               type="success"
113               plain
114               style="width: 72px"
115               icon="el-icon-edit"
116               @click="handleUpdate(scope.row)"
117               v-hasPermi="['bs:workshop:edit']"
118             >修改</el-button>
119             <el-button
120               size="mini"
121               plain
122               style="width: 72px"
123               type="danger"
124               icon="el-icon-delete"
125               @click="handleDelete(scope.row)"
126               v-hasPermi="['bs:workshop:remove']"
127             >删除</el-button>
128           </template>
129         </el-table-column>
130       </el-table>
131       <el-empty v-else>
132         <span slot="description">暂无数据</span>
133       </el-empty>
134     </el-card>
135
136
137     <pagination
138       v-show="total>0"
139       :total="total"
140       :page.sync="queryParams.pageNum"
141       :limit.sync="queryParams.pageSize"
142       @pagination="getList"
143     />
144
145     <!-- 添加或修改车间信息对话框 -->
146     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="500px" append-to-body>
147       <span slot="title">
148         <i class="el-icon-s-order"></i>
149         {{titleName}}
150       </span>
151       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
152         <el-form-item label="车间编码" prop="workshopCode">
153           <el-input v-model="form.workshopCode" placeholder="请输入车间编码" />
154         </el-form-item>
155         <el-form-item label="车间名称" prop="workshopName">
156           <el-input v-model="form.workshopName" placeholder="请输入车间名称" />
157         </el-form-item>
158         <el-form-item label="状态" prop="status">
159           <el-radio-group v-model="form.status">
160             <el-radio
161               v-for="dict in dict.type.sys_normal_disable"
162               :key="dict.value"
163               :label="dict.value"
164             >{{dict.label}}</el-radio>
165           </el-radio-group>
166         </el-form-item>
167         <el-form-item label="备注" prop="remarks">
168           <el-input v-model="form.remarks" placeholder="请输入备注" />
169         </el-form-item>
170       </el-form>
171       <div slot="footer" class="dialog-footer">
172         <el-button type="primary" @click="submitForm">确 定</el-button>
173         <el-button @click="cancel">取 消</el-button>
174       </div>
175     </el-dialog>
b6c635 176
177     <!-- 用户导入对话框 -->
178     <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
179       <el-upload
180         ref="upload"
181         :limit="1"
182         accept=".xlsx, .xls"
183         :headers="upload.headers"
184         :action="upload.url + '?updateSupport=' + upload.updateSupport"
185         :disabled="upload.isUploading"
186         :on-progress="handleFileUploadProgress"
187         :on-success="handleFileSuccess"
188         :auto-upload="false"
189         drag
190       >
191         <i class="el-icon-upload"></i>
192         <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
193         <div class="el-upload__tip text-center" slot="tip">
194           <div class="el-upload__tip" slot="tip">
195             <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的车间数据
196           </div>
197           <span>仅允许导入xls、xlsx格式文件。</span>
198           <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
199         </div>
200       </el-upload>
201       <div slot="footer" class="dialog-footer">
202         <el-button type="primary" @click="submitFileForm">确 定</el-button>
203         <el-button @click="upload.open = false">取 消</el-button>
204       </div>
205     </el-dialog>
fd2207 206   </div>
207 </template>
208
209 <script>
210 import { listWorkshop, getWorkshop, delWorkshop, addWorkshop, updateWorkshop } from "@/api/main/bs/workshop/workshop";
b6c635 211 import {getToken} from "@/utils/auth";
fd2207 212
213 export default {
214   name: "Workshop",
215   dicts: ['sys_normal_disable'],
216   data() {
217     return {
218       select: '',
219       // 遮罩层
220       loading: true,
221       titleName: 'test',
222       // 选中数组
223       ids: [],
224       // 非单个禁用
225       single: true,
226       // 非多个禁用
227       multiple: true,
228       // 显示搜索条件
229       showSearch: true,
230       advancedShowSearch: false,
231
232       // 总条数
233       total: 0,
234       // 车间信息表格数据
235       workshopList: [],
236       // 弹出层标题
237       title: "",
238       // 是否显示弹出层
239       open: false,
240       // 查询参数
241       queryParams: {
242         pageNum: 1,
243         pageSize: 10,
244         workshopCode: null,
245         workshopName: null,
246         remarks: null,
247         createUser: null
248       },
249       // 表单参数
250       form: {},
251       // 表单校验
252       rules: {
253         id: [
254           { required: true, message: "id不能为空", trigger: "blur" }
255         ],
256         workshopCode: [
257           { required: true, message: "车间编码不能为空", trigger: "blur" }
258         ],
259         workshopName: [
260           { required: true, message: "车间名称不能为空", trigger: "blur" }
261         ],
b6c635 262       },
263       // 用户导入参数
264       upload: {
265         // 是否显示弹出层(用户导入)
266         open: false,
267         // 弹出层标题(用户导入)
268         title: "",
269         // 是否禁用上传
270         isUploading: false,
271         // 是否更新已经存在的用户数据
272         updateSupport: 0,
273         // 设置上传的请求头部
274         headers: { Authorization: "Bearer " + getToken() },
275         // 上传的地址
276         url: process.env.VUE_APP_BASE_API + "/bs/workshop/importData"
277       },
fd2207 278     };
279   },
280   created() {
281     this.getList();
282   },
283   methods: {
b6c635 284     // 提交上传文件
285     submitFileForm() {
286       this.$refs.upload.submit();
287     },
288     /** 下载模板操作 */
289     importTemplate() {
290       this.download('bs/workshop/importTemplate', {
291       }, `车间信息_${new Date().getTime()}.xlsx`)
292     },
293     // 文件上传成功处理
294     handleFileSuccess(response, file, fileList) {
295       this.upload.open = false;
296       this.upload.isUploading = false;
297       this.$refs.upload.clearFiles();
298       this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
299       this.getList();
300     },
301     // 文件上传中处理
302     handleFileUploadProgress(event, file, fileList) {
303       this.upload.isUploading = true;
304     },
305     /** 导入按钮操作 */
306     handleImport() {
307       this.upload.title = "车间导入";
308       this.upload.open = true;
309     },
fd2207 310     advancedQuery(){
311        this.advancedShowSearch = (this.advancedShowSearch) ? this.advancedShowSearch = false : this.advancedShowSearch = true;
312     },
313     /** 查询车间信息列表 */
314     getList() {
315       this.loading = true;
316       listWorkshop(this.queryParams).then(response => {
317         this.workshopList = response.rows;
318         this.total = response.total;
319         this.loading = false;
320       });
321     },
322     // 取消按钮
323     cancel() {
324       this.open = false;
325       this.reset();
326     },
327     // 表单重置
328     reset() {
329       this.form = {
330         id: null,
331         workshopCode: null,
332         workshopName: null,
333         spareField1: null,
334         spareField2: null,
335         remarks: null,
336         createUser: null,
337         createTime: null,
338         updateUser: null,
339         status: "0",
340         updateTime: null
341       };
342       this.resetForm("form");
343     },
344     /** 搜索按钮操作 */
345     handleQuery() {
346       this.queryParams.pageNum = 1;
347       this.getList();
348     },
349     /** 重置按钮操作 */
350     resetQuery() {
351       this.resetForm("queryForm");
352       this.queryParams.remarks = null;
353       this.queryParams.createUser = null;
354       this.handleQuery();
355     },
356     // 多选框选中数据
357     handleSelectionChange(selection) {
358       this.ids = selection.map(item => item.id)
359       this.single = selection.length!==1
360       this.multiple = !selection.length
361     },
362     /** 新增按钮操作 */
363     handleAdd() {
364       this.reset();
365       this.open = true;
366       this.titleName = "添加车间信息";
367     },
368     /** 修改按钮操作 */
369     handleUpdate(row) {
370       this.reset();
371       const id = row.id || this.ids
372       getWorkshop(id).then(response => {
373         this.form = response.data;
374         this.open = true;
375         this.titleName = "修改车间信息";
376       });
377     },
378     /** 提交按钮 */
379     submitForm() {
380       this.$refs["form"].validate(valid => {
381         if (valid) {
382           if (this.form.id != null) {
383             updateWorkshop(this.form).then(response => {
384               this.$modal.msgSuccess("修改成功");
385               this.open = false;
386               this.getList();
387             });
388           } else {
389             addWorkshop(this.form).then(response => {
390               this.$modal.msgSuccess("新增成功");
391               this.open = false;
392               this.getList();
393             });
394           }
395         }
396       });
397     },
398     /** 删除按钮操作 */
399     handleDelete(row) {
400       const ids = row.id || this.ids;
401       this.$modal.confirm('是否确认删除车间信息编号为"' + ids + '"的数据项?').then(function() {
402         return delWorkshop(ids);
403       }).then(() => {
404         this.getList();
405         this.$modal.msgSuccess("删除成功");
406       }).catch(() => {});
407     },
408     /** 导出按钮操作 */
409     handleExport() {
410       this.download('bs/workshop/export', {
411         ...this.queryParams
412       }, `workshop_${new Date().getTime()}.xlsx`)
413     }
414   }
415 };
416 </script>