-
admin
2024-05-17 1ccd6932893e47722574e6d1147e63b2ec4972c1
提交 | 用户 | 时间
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">
5eda9e 31           <div ref="canvasWrapper" id="canvasWrapper"></div>
9a1433 32           <p>1111</p>
A 33         </div>
5eda9e 34         <el-button @click="print">打印</el-button>
H 35         <el-button @click="test1">生成二维码</el-button>
9a1433 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>
6068fa 105         <el-table-column label="更新时间" align="center" prop="updateTime">
e57a89 106         </el-table-column>
6068fa 107         <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width">
e57a89 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>
5eda9e 179 import QRCode from 'qrcodejs2'
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();
5eda9e 237     // this.test1();
e57a89 238   },
239   methods: {
9a1433 240     print() {
5eda9e 241       // 本页面直接打印(有bug单岁先不要删)
H 242       // let oldStr = window.document.body.innerHTML;
243       // let newStr = document.getElementById('printMe').innerHTML;
244       // document.body.innerHTML = newStr;
245       // window.print();
246       // document.body.innerHTML = oldStr;
247       // return false;
9a1433 248
5eda9e 249       // 新开页面打印
H 250       let newStr = document.getElementById('printMe').innerHTML;
251       let newWin = window.open('', '_blank');
252       newWin.document.body.innerHTML = newStr;
253       newWin.print();
254       return false;
9a1433 255     },
A 256     test1(){
5eda9e 257       document.getElementById('canvasWrapper').innerHTML = '';
H 258       this.$nextTick(() => {
259         let qrCode = new QRCode('canvasWrapper',{
260           width: 50,
261           height: 50,
262           text: this.text,
263           colorDark: '#000',
264           colorLight: '#fff'
265         })
9a1433 266       })
A 267     },
e57a89 268     advancedQuery(){
269        this.advancedShowSearch = (this.advancedShowSearch) ? this.advancedShowSearch = false : this.advancedShowSearch = true;
270     },
271     /** 查询车间信息列表 */
272     getList() {
273       this.loading = true;
274       listWorkshop(this.queryParams).then(response => {
275         this.workshopList = response.rows;
276         this.total = response.total;
277         this.loading = false;
278       });
279     },
280     // 取消按钮
281     cancel() {
282       this.open = false;
283       this.reset();
284     },
285     // 表单重置
286     reset() {
287       this.form = {
288         id: null,
289         workshopCode: null,
290         workshopName: null,
291         spareField1: null,
292         spareField2: null,
293         remarks: null,
294         createUser: null,
295         createTime: null,
296         updateUser: null,
297         status: "0",
298         updateTime: null
299       };
300       this.resetForm("form");
301     },
302     /** 搜索按钮操作 */
303     handleQuery() {
304       this.queryParams.pageNum = 1;
305       this.getList();
306     },
307     /** 重置按钮操作 */
308     resetQuery() {
309       this.resetForm("queryForm");
310       this.queryParams.remarks = null;
311       this.queryParams.createUser = null;
312       this.handleQuery();
313     },
314     // 多选框选中数据
315     handleSelectionChange(selection) {
316       this.ids = selection.map(item => item.id)
317       this.single = selection.length!==1
318       this.multiple = !selection.length
319     },
320     /** 新增按钮操作 */
321     handleAdd() {
322       this.reset();
323       this.open = true;
324       this.titleName = "添加车间信息";
325     },
326     /** 修改按钮操作 */
327     handleUpdate(row) {
328       this.reset();
329       const id = row.id || this.ids
330       getWorkshop(id).then(response => {
331         this.form = response.data;
332         this.open = true;
333         this.titleName = "修改车间信息";
334       });
335     },
336     /** 提交按钮 */
337     submitForm() {
338       this.$refs["form"].validate(valid => {
339         if (valid) {
340           if (this.form.id != null) {
341             updateWorkshop(this.form).then(response => {
342               this.$modal.msgSuccess("修改成功");
343               this.open = false;
344               this.getList();
345             });
346           } else {
347             addWorkshop(this.form).then(response => {
348               this.$modal.msgSuccess("新增成功");
349               this.open = false;
350               this.getList();
351             });
352           }
353         }
354       });
355     },
356     /** 删除按钮操作 */
357     handleDelete(row) {
358       const ids = row.id || this.ids;
359       this.$modal.confirm('是否确认删除车间信息编号为"' + ids + '"的数据项?').then(function() {
360         return delWorkshop(ids);
361       }).then(() => {
362         this.getList();
363         this.$modal.msgSuccess("删除成功");
364       }).catch(() => {});
365     },
366     /** 导出按钮操作 */
367     handleExport() {
368       this.download('bs/workshop/export', {
369         ...this.queryParams
370       }, `workshop_${new Date().getTime()}.xlsx`)
371     }
372   }
373 };
374 </script>