admin
2024-05-11 9a1433b0ff2754d9c11f98a654af44ec7d5ab992
提交 | 用户 | 时间
e57a89 1 <template>
2   <div class="app-container">
3     <el-card class="box-card">
9a1433 4 <!--      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">-->
A 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 <!--&lt;!&ndash;          <el-button type="warning" icon="el-icon-copy-document" size="mini" @click="advancedQuery">高级查询</el-button>&ndash;&gt;-->
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       <div>
30         <div id="printMe">
31           <div ref="canvasWrapper"></div>
32           <p>1111</p>
33         </div>
34         <button @click="print">打印</button>
35         <button @click="test1">生成二维码</button>
36       </div>
e57a89 37     </el-card>
38
39     <el-card style="margin-top: 10px" class="box-card">
40       <el-row :gutter="10" class="mb8">
41         <el-col :span="1.5">
42           <el-button
43             type="primary"
44             plain
45             icon="el-icon-plus"
46             size="mini"
47             @click="handleAdd"
48             v-hasPermi="['bs:workshop:add']"
49           >新增</el-button>
50         </el-col>
51         <el-col :span="1.5">
52           <el-button
53             type="success"
54             plain
55             icon="el-icon-edit"
56             size="mini"
57             :disabled="single"
58             @click="handleUpdate"
59             v-hasPermi="['bs:workshop:edit']"
60           >修改</el-button>
61         </el-col>
62         <el-col :span="1.5">
63           <el-button
64             type="danger"
65             plain
66             icon="el-icon-delete"
67             size="mini"
68             :disabled="multiple"
69             @click="handleDelete"
70             v-hasPermi="['bs:workshop:remove']"
71           >删除</el-button>
72         </el-col>
73         <el-col :span="1.5">
74           <el-button
75             type="warning"
76             plain
77             icon="el-icon-download"
78             size="mini"
79             @click="handleExport"
80             v-hasPermi="['bs:workshop:export']"
81           >导出</el-button>
82         </el-col>
83         <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
84       </el-row>
85       <el-table v-loading="loading" border :data="workshopList" @selection-change="handleSelectionChange" v-if="workshopList.length > 0">
86         <el-table-column type="selection" width="55" align="center" />
87         <!--      <el-table-column label="id" align="center" prop="id" />-->
88         <el-table-column label="车间编码" width="120" align="center" prop="workshopCode">
89         </el-table-column>
90         <el-table-column :show-overflow-tooltip='true' width="150" label="车间名称" align="center" prop="workshopName">
91         </el-table-column>
92         <el-table-column label="状态" align="center" prop="status" width="80">
93           <template slot-scope="scope">
94             <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
95           </template>
96         </el-table-column>
97         <el-table-column label="备注" width="150" align="center" prop="remarks">
98         </el-table-column>
99         <el-table-column label="创建人" align="center" prop="createUser" width="150">
100         </el-table-column>
101         <el-table-column label="创建时间" align="center" prop="createTime" width="180">
102         </el-table-column>
103         <el-table-column label="更新人" align="center" prop="updateUser" width="150">
104         </el-table-column>
105         <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
106         </el-table-column>
107         <el-table-column fixed="right" label="操作" width="200" align="center" class-name="small-padding fixed-width">
108           <template slot-scope="scope">
109             <el-button
110               size="mini"
111               type="success"
112               plain
113               style="width: 72px"
114               icon="el-icon-edit"
115               @click="handleUpdate(scope.row)"
116               v-hasPermi="['bs:workshop:edit']"
117             >修改</el-button>
118             <el-button
119               size="mini"
120               plain
121               style="width: 72px"
122               type="danger"
123               icon="el-icon-delete"
124               @click="handleDelete(scope.row)"
125               v-hasPermi="['bs:workshop:remove']"
126             >删除</el-button>
127           </template>
128         </el-table-column>
129       </el-table>
130       <el-empty v-else>
131         <span slot="description">暂无数据</span>
132       </el-empty>
133     </el-card>
134
135
136     <pagination
137       v-show="total>0"
138       :total="total"
139       :page.sync="queryParams.pageNum"
140       :limit.sync="queryParams.pageSize"
141       @pagination="getList"
142     />
143
144     <!-- 添加或修改车间信息对话框 -->
145     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="500px" append-to-body>
146       <span slot="title">
147         <i class="el-icon-s-order"></i>
148         {{titleName}}
149       </span>
150       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
151         <el-form-item label="车间编码" prop="workshopCode">
152           <el-input v-model="form.workshopCode" placeholder="请输入车间编码" />
153         </el-form-item>
154         <el-form-item label="车间名称" prop="workshopName">
155           <el-input v-model="form.workshopName" placeholder="请输入车间名称" />
156         </el-form-item>
157         <el-form-item label="状态" prop="status">
158           <el-radio-group v-model="form.status">
159             <el-radio
160               v-for="dict in dict.type.sys_normal_disable"
161               :key="dict.value"
162               :label="dict.value"
163             >{{dict.label}}</el-radio>
164           </el-radio-group>
165         </el-form-item>
166         <el-form-item label="备注" prop="remarks">
167           <el-input v-model="form.remarks" placeholder="请输入备注" />
168         </el-form-item>
169       </el-form>
170       <div slot="footer" class="dialog-footer">
171         <el-button type="primary" @click="submitForm">确 定</el-button>
172         <el-button @click="cancel">取 消</el-button>
173       </div>
174     </el-dialog>
175   </div>
176 </template>
177
178 <script>
9a1433 179 import QRCode from 'qrcode'
e57a89 180 import { listWorkshop, getWorkshop, delWorkshop, addWorkshop, updateWorkshop } from "@/api/main/bs/workshop/workshop";
181
182 export default {
183   name: "Workshop",
184   dicts: ['sys_normal_disable'],
185   data() {
186     return {
9a1433 187       text: '1234',
e57a89 188       select: '',
189       // 遮罩层
190       loading: true,
191       titleName: 'test',
192       // 选中数组
193       ids: [],
194       // 非单个禁用
195       single: true,
196       // 非多个禁用
197       multiple: true,
198       // 显示搜索条件
199       showSearch: true,
200       advancedShowSearch: false,
201
202       // 总条数
203       total: 0,
204       // 车间信息表格数据
205       workshopList: [],
206       // 弹出层标题
207       title: "",
208       // 是否显示弹出层
209       open: false,
210       // 查询参数
211       queryParams: {
212         pageNum: 1,
213         pageSize: 10,
214         workshopCode: null,
215         workshopName: null,
216         remarks: null,
217         createUser: null
218       },
219       // 表单参数
220       form: {},
221       // 表单校验
222       rules: {
223         id: [
224           { required: true, message: "id不能为空", trigger: "blur" }
225         ],
226         workshopCode: [
227           { required: true, message: "车间编码不能为空", trigger: "blur" }
228         ],
229         workshopName: [
230           { required: true, message: "车间名称不能为空", trigger: "blur" }
231         ],
232       }
233     };
234   },
235   created() {
236     this.getList();
9a1433 237     this.test1();
e57a89 238   },
239   methods: {
9a1433 240     print() {
A 241
242       let printMe = document.querySelector('#printMe');
243       let printWindow = window.open('', '_blank');
244       printWindow.document.write(printMe.innerHTML);
245       printWindow.document.close();
246       printWindow.focus();
247       printWindow.print();
248       printWindow.close();
249     },
250     test1(){
251       QRCode.toCanvas(this.text, {
252         width: 40,
253         // height: 40,
254         margin: 1,
255
256       }, (error, canvas) => {
257         if (error) {
258           console.error(error)
259           return
260         }
261         // 在canvas的父元素中插入canvas元素
262         this.$refs.canvasWrapper.appendChild(canvas)
263       })
264     },
e57a89 265     advancedQuery(){
266        this.advancedShowSearch = (this.advancedShowSearch) ? this.advancedShowSearch = false : this.advancedShowSearch = true;
267     },
268     /** 查询车间信息列表 */
269     getList() {
270       this.loading = true;
271       listWorkshop(this.queryParams).then(response => {
272         this.workshopList = response.rows;
273         this.total = response.total;
274         this.loading = false;
275       });
276     },
277     // 取消按钮
278     cancel() {
279       this.open = false;
280       this.reset();
281     },
282     // 表单重置
283     reset() {
284       this.form = {
285         id: null,
286         workshopCode: null,
287         workshopName: null,
288         spareField1: null,
289         spareField2: null,
290         remarks: null,
291         createUser: null,
292         createTime: null,
293         updateUser: null,
294         status: "0",
295         updateTime: null
296       };
297       this.resetForm("form");
298     },
299     /** 搜索按钮操作 */
300     handleQuery() {
301       this.queryParams.pageNum = 1;
302       this.getList();
303     },
304     /** 重置按钮操作 */
305     resetQuery() {
306       this.resetForm("queryForm");
307       this.queryParams.remarks = null;
308       this.queryParams.createUser = null;
309       this.handleQuery();
310     },
311     // 多选框选中数据
312     handleSelectionChange(selection) {
313       this.ids = selection.map(item => item.id)
314       this.single = selection.length!==1
315       this.multiple = !selection.length
316     },
317     /** 新增按钮操作 */
318     handleAdd() {
319       this.reset();
320       this.open = true;
321       this.titleName = "添加车间信息";
322     },
323     /** 修改按钮操作 */
324     handleUpdate(row) {
325       this.reset();
326       const id = row.id || this.ids
327       getWorkshop(id).then(response => {
328         this.form = response.data;
329         this.open = true;
330         this.titleName = "修改车间信息";
331       });
332     },
333     /** 提交按钮 */
334     submitForm() {
335       this.$refs["form"].validate(valid => {
336         if (valid) {
337           if (this.form.id != null) {
338             updateWorkshop(this.form).then(response => {
339               this.$modal.msgSuccess("修改成功");
340               this.open = false;
341               this.getList();
342             });
343           } else {
344             addWorkshop(this.form).then(response => {
345               this.$modal.msgSuccess("新增成功");
346               this.open = false;
347               this.getList();
348             });
349           }
350         }
351       });
352     },
353     /** 删除按钮操作 */
354     handleDelete(row) {
355       const ids = row.id || this.ids;
356       this.$modal.confirm('是否确认删除车间信息编号为"' + ids + '"的数据项?').then(function() {
357         return delWorkshop(ids);
358       }).then(() => {
359         this.getList();
360         this.$modal.msgSuccess("删除成功");
361       }).catch(() => {});
362     },
363     /** 导出按钮操作 */
364     handleExport() {
365       this.download('bs/workshop/export', {
366         ...this.queryParams
367       }, `workshop_${new Date().getTime()}.xlsx`)
368     }
369   }
370 };
371 </script>