春风项目四线(合箱线、总装线)
yyt
2024-02-17 386e107222d673a1ea2781a03a7b1b1d28212f58
提交 | 用户 | 时间
fd2207 1 <template>
2   <div class="app-container">
3     <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
4 #foreach($column in $columns)
5 #if($column.query)
6 #set($dictType=$column.dictType)
7 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
8 #set($parentheseIndex=$column.columnComment.indexOf("("))
9 #if($parentheseIndex != -1)
10 #set($comment=$column.columnComment.substring(0, $parentheseIndex))
11 #else
12 #set($comment=$column.columnComment)
13 #end
14 #if($column.htmlType == "input")
15       <el-form-item label="${comment}" prop="${column.javaField}">
16         <el-input
17           v-model="queryParams.${column.javaField}"
18           placeholder="请输入${comment}"
19           clearable
20           @keyup.enter="handleQuery"
21         />
22       </el-form-item>
23 #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
24       <el-form-item label="${comment}" prop="${column.javaField}">
25         <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
26           <el-option
27             v-for="dict in ${dictType}"
28             :key="dict.value"
29             :label="dict.label"
30             :value="dict.value"
31           />
32         </el-select>
33       </el-form-item>
34 #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
35       <el-form-item label="${comment}" prop="${column.javaField}">
36         <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
37           <el-option label="请选择字典生成" value="" />
38         </el-select>
39       </el-form-item>
40 #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
41       <el-form-item label="${comment}" prop="${column.javaField}">
42         <el-date-picker clearable
43           v-model="queryParams.${column.javaField}"
44           type="date"
45           value-format="YYYY-MM-DD"
46           placeholder="请选择${comment}">
47         </el-date-picker>
48       </el-form-item>
49 #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
50       <el-form-item label="${comment}" style="width: 308px">
51         <el-date-picker
52           v-model="daterange${AttrName}"
53           value-format="YYYY-MM-DD"
54           type="daterange"
55           range-separator="-"
56           start-placeholder="开始日期"
57           end-placeholder="结束日期"
58         ></el-date-picker>
59       </el-form-item>
60 #end
61 #end
62 #end
63       <el-form-item>
64         <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
65         <el-button icon="Refresh" @click="resetQuery">重置</el-button>
66       </el-form-item>
67     </el-form>
68
69     <el-row :gutter="10" class="mb8">
70       <el-col :span="1.5">
71         <el-button
72           type="primary"
73           plain
74           icon="Plus"
75           @click="handleAdd"
76           v-hasPermi="['${moduleName}:${businessName}:add']"
77         >新增</el-button>
78       </el-col>
79       <el-col :span="1.5">
80         <el-button
81           type="success"
82           plain
83           icon="Edit"
84           :disabled="single"
85           @click="handleUpdate"
86           v-hasPermi="['${moduleName}:${businessName}:edit']"
87         >修改</el-button>
88       </el-col>
89       <el-col :span="1.5">
90         <el-button
91           type="danger"
92           plain
93           icon="Delete"
94           :disabled="multiple"
95           @click="handleDelete"
96           v-hasPermi="['${moduleName}:${businessName}:remove']"
97         >删除</el-button>
98       </el-col>
99       <el-col :span="1.5">
100         <el-button
101           type="warning"
102           plain
103           icon="Download"
104           @click="handleExport"
105           v-hasPermi="['${moduleName}:${businessName}:export']"
106         >导出</el-button>
107       </el-col>
108       <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
109     </el-row>
110
111     <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
112       <el-table-column type="selection" width="55" align="center" />
113 #foreach($column in $columns)
114 #set($javaField=$column.javaField)
115 #set($parentheseIndex=$column.columnComment.indexOf("("))
116 #if($parentheseIndex != -1)
117 #set($comment=$column.columnComment.substring(0, $parentheseIndex))
118 #else
119 #set($comment=$column.columnComment)
120 #end
121 #if($column.pk)
122       <el-table-column label="${comment}" align="center" prop="${javaField}" />
123 #elseif($column.list && $column.htmlType == "datetime")
124       <el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
125         <template #default="scope">
126           <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
127         </template>
128       </el-table-column>
129 #elseif($column.list && $column.htmlType == "imageUpload")
130       <el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
131         <template #default="scope">
132           <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
133         </template>
134       </el-table-column>
135 #elseif($column.list && "" != $column.dictType)
136       <el-table-column label="${comment}" align="center" prop="${javaField}">
137         <template #default="scope">
138 #if($column.htmlType == "checkbox")
139           <dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
140 #else
141           <dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
142 #end
143         </template>
144       </el-table-column>
145 #elseif($column.list && "" != $javaField)
146       <el-table-column label="${comment}" align="center" prop="${javaField}" />
147 #end
148 #end
149       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
150         <template #default="scope">
151           <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
152           <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
153         </template>
154       </el-table-column>
155     </el-table>
156     
157     <pagination
158       v-show="total>0"
159       :total="total"
160       v-model:page="queryParams.pageNum"
161       v-model:limit="queryParams.pageSize"
162       @pagination="getList"
163     />
164
165     <!-- 添加或修改${functionName}对话框 -->
166     <el-dialog :title="title" v-model="open" width="500px" append-to-body>
167       <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
168 #foreach($column in $columns)
169 #set($field=$column.javaField)
170 #if($column.insert && !$column.pk)
171 #if(($column.usableColumn) || (!$column.superColumn))
172 #set($parentheseIndex=$column.columnComment.indexOf("("))
173 #if($parentheseIndex != -1)
174 #set($comment=$column.columnComment.substring(0, $parentheseIndex))
175 #else
176 #set($comment=$column.columnComment)
177 #end
178 #set($dictType=$column.dictType)
179 #if($column.htmlType == "input")
180         <el-form-item label="${comment}" prop="${field}">
181           <el-input v-model="form.${field}" placeholder="请输入${comment}" />
182         </el-form-item>
183 #elseif($column.htmlType == "imageUpload")
184         <el-form-item label="${comment}" prop="${field}">
185           <image-upload v-model="form.${field}"/>
186         </el-form-item>
187 #elseif($column.htmlType == "fileUpload")
188         <el-form-item label="${comment}" prop="${field}">
189           <file-upload v-model="form.${field}"/>
190         </el-form-item>
191 #elseif($column.htmlType == "editor")
192         <el-form-item label="${comment}">
193           <editor v-model="form.${field}" :min-height="192"/>
194         </el-form-item>
195 #elseif($column.htmlType == "select" && "" != $dictType)
196         <el-form-item label="${comment}" prop="${field}">
197           <el-select v-model="form.${field}" placeholder="请选择${comment}">
198             <el-option
199               v-for="dict in ${dictType}"
200               :key="dict.value"
201               :label="dict.label"
202 #if($column.javaType == "Integer" || $column.javaType == "Long")
203               :value="parseInt(dict.value)"
204 #else
205               :value="dict.value"
206 #end
207             ></el-option>
208           </el-select>
209         </el-form-item>
210 #elseif($column.htmlType == "select" && $dictType)
211         <el-form-item label="${comment}" prop="${field}">
212           <el-select v-model="form.${field}" placeholder="请选择${comment}">
213             <el-option label="请选择字典生成" value="" />
214           </el-select>
215         </el-form-item>
216 #elseif($column.htmlType == "checkbox" && "" != $dictType)
217         <el-form-item label="${comment}" prop="${field}">
218           <el-checkbox-group v-model="form.${field}">
219             <el-checkbox
220               v-for="dict in ${dictType}"
221               :key="dict.value"
222               :label="dict.value">
223               {{dict.label}}
224             </el-checkbox>
225           </el-checkbox-group>
226         </el-form-item>
227 #elseif($column.htmlType == "checkbox" && $dictType)
228         <el-form-item label="${comment}" prop="${field}">
229           <el-checkbox-group v-model="form.${field}">
230             <el-checkbox>请选择字典生成</el-checkbox>
231           </el-checkbox-group>
232         </el-form-item>
233 #elseif($column.htmlType == "radio" && "" != $dictType)
234         <el-form-item label="${comment}" prop="${field}">
235           <el-radio-group v-model="form.${field}">
236             <el-radio
237               v-for="dict in ${dictType}"
238               :key="dict.value"
239 #if($column.javaType == "Integer" || $column.javaType == "Long")
240               :label="parseInt(dict.value)"
241 #else
242               :label="dict.value"
243 #end
244             >{{dict.label}}</el-radio>
245           </el-radio-group>
246         </el-form-item>
247 #elseif($column.htmlType == "radio" && $dictType)
248         <el-form-item label="${comment}" prop="${field}">
249           <el-radio-group v-model="form.${field}">
250             <el-radio label="1">请选择字典生成</el-radio>
251           </el-radio-group>
252         </el-form-item>
253 #elseif($column.htmlType == "datetime")
254         <el-form-item label="${comment}" prop="${field}">
255           <el-date-picker clearable
256             v-model="form.${field}"
257             type="date"
258             value-format="YYYY-MM-DD"
259             placeholder="请选择${comment}">
260           </el-date-picker>
261         </el-form-item>
262 #elseif($column.htmlType == "textarea")
263         <el-form-item label="${comment}" prop="${field}">
264           <el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
265         </el-form-item>
266 #end
267 #end
268 #end
269 #end
270 #if($table.sub)
271         <el-divider content-position="center">${subTable.functionName}信息</el-divider>
272         <el-row :gutter="10" class="mb8">
273           <el-col :span="1.5">
274             <el-button type="primary" icon="Plus" @click="handleAdd${subClassName}">添加</el-button>
275           </el-col>
276           <el-col :span="1.5">
277             <el-button type="danger" icon="Delete" @click="handleDelete${subClassName}">删除</el-button>
278           </el-col>
279         </el-row>
280         <el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
281           <el-table-column type="selection" width="50" align="center" />
282           <el-table-column label="序号" align="center" prop="index" width="50"/>
283 #foreach($column in $subTable.columns)
284 #set($javaField=$column.javaField)
285 #set($parentheseIndex=$column.columnComment.indexOf("("))
286 #if($parentheseIndex != -1)
287 #set($comment=$column.columnComment.substring(0, $parentheseIndex))
288 #else
289 #set($comment=$column.columnComment)
290 #end
291 #if($column.pk || $javaField == ${subTableFkclassName})
292 #elseif($column.list && $column.htmlType == "input")
293           <el-table-column label="$comment" prop="${javaField}" width="150">
294             <template #default="scope">
295               <el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
296             </template>
297           </el-table-column>
298 #elseif($column.list && $column.htmlType == "datetime")
299           <el-table-column label="$comment" prop="${javaField}" width="240">
300             <template #default="scope">
301               <el-date-picker clearable
302                 v-model="scope.row.$javaField"
303                 type="date"
304                 value-format="YYYY-MM-DD"
305                 placeholder="请选择$comment">
306               </el-date-picker>
307             </template>
308           </el-table-column>
309 #elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
310           <el-table-column label="$comment" prop="${javaField}" width="150">
311             <template #default="scope">
312               <el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
313                 <el-option
314                   v-for="dict in $column.dictType"
315                   :key="dict.value"
316                   :label="dict.label"
317                   :value="dict.value"
318                 ></el-option>
319               </el-select>
320             </template>
321           </el-table-column>
322 #elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
323           <el-table-column label="$comment" prop="${javaField}" width="150">
324             <template #default="scope">
325               <el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
326                 <el-option label="请选择字典生成" value="" />
327               </el-select>
328             </template>
329           </el-table-column>
330 #end
331 #end
332         </el-table>
333 #end
334       </el-form>
335       <template #footer>
336         <div class="dialog-footer">
337           <el-button type="primary" @click="submitForm">确 定</el-button>
338           <el-button @click="cancel">取 消</el-button>
339         </div>
340       </template>
341     </el-dialog>
342   </div>
343 </template>
344
345 <script setup name="${BusinessName}">
346 import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
347
348 const { proxy } = getCurrentInstance();
349 #if(${dicts} != '')
350 #set($dictsNoSymbol=$dicts.replace("'", ""))
351 const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
352 #end
353
354 const ${businessName}List = ref([]);
355 #if($table.sub)
356 const ${subclassName}List = ref([]);
357 #end
358 const open = ref(false);
359 const loading = ref(true);
360 const showSearch = ref(true);
361 const ids = ref([]);
362 #if($table.sub)
363 const checked${subClassName} = ref([]);
364 #end
365 const single = ref(true);
366 const multiple = ref(true);
367 const total = ref(0);
368 const title = ref("");
369 #foreach ($column in $columns)
370 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
371 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
372 const daterange${AttrName} = ref([]);
373 #end
374 #end
375
376 const data = reactive({
377   form: {},
378   queryParams: {
379     pageNum: 1,
380     pageSize: 10,
381     #foreach ($column in $columns)
382 #if($column.query)
383     $column.javaField: null#if($foreach.count != $columns.size()),#end
384 #end
385 #end
386   },
387   rules: {
388     #foreach ($column in $columns)
389 #if($column.required)
390 #set($parentheseIndex=$column.columnComment.indexOf("("))
391 #if($parentheseIndex != -1)
392 #set($comment=$column.columnComment.substring(0, $parentheseIndex))
393 #else
394 #set($comment=$column.columnComment)
395 #end
396     $column.javaField: [
397       { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
398     ]#if($foreach.count != $columns.size()),#end
399 #end
400 #end
401   }
402 });
403
404 const { queryParams, form, rules } = toRefs(data);
405
406 /** 查询${functionName}列表 */
407 function getList() {
408   loading.value = true;
409 #foreach ($column in $columns)
410 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
411   queryParams.value.params = {};
412 #break
413 #end
414 #end
415 #foreach ($column in $columns)
416 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
417 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
418   if (null != daterange${AttrName} && '' != daterange${AttrName}) {
419     queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0];
420     queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1];
421   }
422 #end
423 #end
424   list${BusinessName}(queryParams.value).then(response => {
425     ${businessName}List.value = response.rows;
426     total.value = response.total;
427     loading.value = false;
428   });
429 }
430
431 // 取消按钮
432 function cancel() {
433   open.value = false;
434   reset();
435 }
436
437 // 表单重置
438 function reset() {
439   form.value = {
440 #foreach ($column in $columns)
441 #if($column.htmlType == "checkbox")
442     $column.javaField: []#if($foreach.count != $columns.size()),#end
443 #else
444     $column.javaField: null#if($foreach.count != $columns.size()),#end
445 #end
446 #end
447   };
448 #if($table.sub)
449   ${subclassName}List.value = [];
450 #end
451   proxy.resetForm("${businessName}Ref");
452 }
453
454 /** 搜索按钮操作 */
455 function handleQuery() {
456   queryParams.value.pageNum = 1;
457   getList();
458 }
459
460 /** 重置按钮操作 */
461 function resetQuery() {
462 #foreach ($column in $columns)
463 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
464 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
465   daterange${AttrName}.value = [];
466 #end
467 #end
468   proxy.resetForm("queryRef");
469   handleQuery();
470 }
471
472 // 多选框选中数据
473 function handleSelectionChange(selection) {
474   ids.value = selection.map(item => item.${pkColumn.javaField});
475   single.value = selection.length != 1;
476   multiple.value = !selection.length;
477 }
478
479 /** 新增按钮操作 */
480 function handleAdd() {
481   reset();
482   open.value = true;
483   title.value = "添加${functionName}";
484 }
485
486 /** 修改按钮操作 */
487 function handleUpdate(row) {
488   reset();
489   const _${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value
490   get${BusinessName}(_${pkColumn.javaField}).then(response => {
491     form.value = response.data;
492 #foreach ($column in $columns)
493 #if($column.htmlType == "checkbox")
494     form.value.$column.javaField = form.value.${column.javaField}.split(",");
495 #end
496 #end
497 #if($table.sub)
498     ${subclassName}List.value = response.data.${subclassName}List;
499 #end
500     open.value = true;
501     title.value = "修改${functionName}";
502   });
503 }
504
505 /** 提交按钮 */
506 function submitForm() {
507   proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => {
508     if (valid) {
509 #foreach ($column in $columns)
510 #if($column.htmlType == "checkbox")
511       form.value.$column.javaField = form.value.${column.javaField}.join(",");
512 #end
513 #end
514 #if($table.sub)
515       form.value.${subclassName}List = ${subclassName}List.value;
516 #end
517       if (form.value.${pkColumn.javaField} != null) {
518         update${BusinessName}(form.value).then(response => {
519           proxy.#[[$modal]]#.msgSuccess("修改成功");
520           open.value = false;
521           getList();
522         });
523       } else {
524         add${BusinessName}(form.value).then(response => {
525           proxy.#[[$modal]]#.msgSuccess("新增成功");
526           open.value = false;
527           getList();
528         });
529       }
530     }
531   });
532 }
533
534 /** 删除按钮操作 */
535 function handleDelete(row) {
536   const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value;
537   proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').then(function() {
538     return del${BusinessName}(_${pkColumn.javaField}s);
539   }).then(() => {
540     getList();
541     proxy.#[[$modal]]#.msgSuccess("删除成功");
542   }).catch(() => {});
543 }
544
545 #if($table.sub)
546 /** ${subTable.functionName}序号 */
547 function row${subClassName}Index({ row, rowIndex }) {
548   row.index = rowIndex + 1;
549 }
550
551 /** ${subTable.functionName}添加按钮操作 */
552 function handleAdd${subClassName}() {
553   let obj = {};
554 #foreach($column in $subTable.columns)
555 #if($column.pk || $column.javaField == ${subTableFkclassName})
556 #elseif($column.list && "" != $javaField)
557   obj.$column.javaField = "";
558 #end
559 #end
560   ${subclassName}List.value.push(obj);
561 }
562
563 /** ${subTable.functionName}删除按钮操作 */
564 function handleDelete${subClassName}() {
565   if (checked${subClassName}.value.length == 0) {
566     proxy.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据");
567   } else {
568     const ${subclassName}s = ${subclassName}List.value;
569     const checked${subClassName}s = checked${subClassName}.value;
570     ${subclassName}List.value = ${subclassName}s.filter(function(item) {
571       return checked${subClassName}s.indexOf(item.index) == -1
572     });
573   }
574 }
575
576 /** 复选框选中数据 */
577 function handle${subClassName}SelectionChange(selection) {
578   checked${subClassName}.value = selection.map(item => item.index)
579 }
580
581 #end
582 /** 导出按钮操作 */
583 function handleExport() {
584   proxy.download('${moduleName}/${businessName}/export', {
585     ...queryParams.value
586   }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
587 }
588
589 getList();
590 </script>