春风项目四线(合箱线、总装线)
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="info"
82           plain
83           icon="Sort"
84           @click="toggleExpandAll"
85         >展开/折叠</el-button>
86       </el-col>
87       <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
88     </el-row>
89
90     <el-table
91       v-if="refreshTable"
92       v-loading="loading"
93       :data="${businessName}List"
94       row-key="${treeCode}"
95       :default-expand-all="isExpandAll"
96       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
97     >
98 #foreach($column in $columns)
99 #set($javaField=$column.javaField)
100 #set($parentheseIndex=$column.columnComment.indexOf("("))
101 #if($parentheseIndex != -1)
102 #set($comment=$column.columnComment.substring(0, $parentheseIndex))
103 #else
104 #set($comment=$column.columnComment)
105 #end
106 #if($column.pk)
107 #elseif($column.list && $column.htmlType == "datetime")
108       <el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
109         <template #default="scope">
110           <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
111         </template>
112       </el-table-column>
113 #elseif($column.list && $column.htmlType == "imageUpload")
114       <el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
115         <template #default="scope">
116           <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
117         </template>
118       </el-table-column>
119 #elseif($column.list && "" != $column.dictType)
120       <el-table-column label="${comment}" align="center" prop="${javaField}">
121         <template #default="scope">
122 #if($column.htmlType == "checkbox")
123           <dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
124 #else
125           <dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
126 #end
127         </template>
128       </el-table-column>
129 #elseif($column.list && "" != $javaField)
130 #if(${foreach.index} == 1)
131       <el-table-column label="${comment}" prop="${javaField}" />
132 #else
133       <el-table-column label="${comment}" align="center" prop="${javaField}" />
134 #end
135 #end
136 #end
137       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
138         <template #default="scope">
139           <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
140           <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
141           <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
142         </template>
143       </el-table-column>
144     </el-table>
145
146     <!-- 添加或修改${functionName}对话框 -->
147     <el-dialog :title="title" v-model="open" width="500px" append-to-body>
148       <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
149 #foreach($column in $columns)
150 #set($field=$column.javaField)
151 #if($column.insert && !$column.pk)
152 #if(($column.usableColumn) || (!$column.superColumn))
153 #set($parentheseIndex=$column.columnComment.indexOf("("))
154 #if($parentheseIndex != -1)
155 #set($comment=$column.columnComment.substring(0, $parentheseIndex))
156 #else
157 #set($comment=$column.columnComment)
158 #end
159 #set($dictType=$column.dictType)
160 #if("" != $treeParentCode && $column.javaField == $treeParentCode)
161         <el-form-item label="${comment}" prop="${treeParentCode}">
162           <el-tree-select
163             v-model="form.${treeParentCode}"
164             :data="${businessName}Options"
165             :props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }"
166             value-key="${treeCode}"
167             placeholder="请选择${comment}"
168             check-strictly
169           />
170         </el-form-item>
171 #elseif($column.htmlType == "input")
172         <el-form-item label="${comment}" prop="${field}">
173           <el-input v-model="form.${field}" placeholder="请输入${comment}" />
174         </el-form-item>
175 #elseif($column.htmlType == "imageUpload")
176         <el-form-item label="${comment}" prop="${field}">
177           <image-upload v-model="form.${field}"/>
178         </el-form-item>
179 #elseif($column.htmlType == "fileUpload")
180         <el-form-item label="${comment}" prop="${field}">
181           <file-upload v-model="form.${field}"/>
182         </el-form-item>
183 #elseif($column.htmlType == "editor")
184         <el-form-item label="${comment}">
185           <editor v-model="form.${field}" :min-height="192"/>
186         </el-form-item>
187 #elseif($column.htmlType == "select" && "" != $dictType)
188         <el-form-item label="${comment}" prop="${field}">
189           <el-select v-model="form.${field}" placeholder="请选择${comment}">
190             <el-option
191               v-for="dict in ${dictType}"
192               :key="dict.value"
193               :label="dict.label"
194 #if($column.javaType == "Integer" || $column.javaType == "Long")
195               :value="parseInt(dict.value)"
196 #else
197               :value="dict.value"
198 #end
199             ></el-option>
200           </el-select>
201         </el-form-item>
202 #elseif($column.htmlType == "select" && $dictType)
203         <el-form-item label="${comment}" prop="${field}">
204           <el-select v-model="form.${field}" placeholder="请选择${comment}">
205             <el-option label="请选择字典生成" value="" />
206           </el-select>
207         </el-form-item>
208 #elseif($column.htmlType == "checkbox" && "" != $dictType)
209         <el-form-item label="${comment}" prop="${field}">
210           <el-checkbox-group v-model="form.${field}">
211             <el-checkbox
212               v-for="dict in ${dictType}"
213               :key="dict.value"
214               :label="dict.value">
215               {{dict.label}}
216             </el-checkbox>
217           </el-checkbox-group>
218         </el-form-item>
219 #elseif($column.htmlType == "checkbox" && $dictType)
220         <el-form-item label="${comment}" prop="${field}">
221           <el-checkbox-group v-model="form.${field}">
222             <el-checkbox>请选择字典生成</el-checkbox>
223           </el-checkbox-group>
224         </el-form-item>
225 #elseif($column.htmlType == "radio" && "" != $dictType)
226         <el-form-item label="${comment}" prop="${field}">
227           <el-radio-group v-model="form.${field}">
228             <el-radio
229               v-for="dict in ${dictType}"
230               :key="dict.value"
231 #if($column.javaType == "Integer" || $column.javaType == "Long")
232               :label="parseInt(dict.value)"
233 #else
234               :label="dict.value"
235 #end
236             >{{dict.label}}</el-radio>
237           </el-radio-group>
238         </el-form-item>
239 #elseif($column.htmlType == "radio" && $dictType)
240         <el-form-item label="${comment}" prop="${field}">
241           <el-radio-group v-model="form.${field}">
242             <el-radio label="1">请选择字典生成</el-radio>
243           </el-radio-group>
244         </el-form-item>
245 #elseif($column.htmlType == "datetime")
246         <el-form-item label="${comment}" prop="${field}">
247           <el-date-picker clearable
248             v-model="form.${field}"
249             type="date"
250             value-format="YYYY-MM-DD"
251             placeholder="选择${comment}">
252           </el-date-picker>
253         </el-form-item>
254 #elseif($column.htmlType == "textarea")
255         <el-form-item label="${comment}" prop="${field}">
256           <el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
257         </el-form-item>
258 #end
259 #end
260 #end
261 #end
262       </el-form>
263       <template #footer>
264         <div class="dialog-footer">
265           <el-button type="primary" @click="submitForm">确 定</el-button>
266           <el-button @click="cancel">取 消</el-button>
267         </div>
268       </template>
269     </el-dialog>
270   </div>
271 </template>
272
273 <script setup name="${BusinessName}">
274 import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
275
276 const { proxy } = getCurrentInstance();
277 #if(${dicts} != '')
278 #set($dictsNoSymbol=$dicts.replace("'", ""))
279 const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
280 #end
281
282 const ${businessName}List = ref([]);
283 const ${businessName}Options = ref([]);
284 const open = ref(false);
285 const loading = ref(true);
286 const showSearch = ref(true);
287 const title = ref("");
288 const isExpandAll = ref(true);
289 const refreshTable = ref(true);
290 #foreach ($column in $columns)
291 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
292 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
293 const daterange${AttrName} = ref([]);
294 #end
295 #end
296
297 const data = reactive({
298   form: {},
299   queryParams: {
300     #foreach ($column in $columns)
301 #if($column.query)
302     $column.javaField: null#if($foreach.count != $columns.size()),#end
303 #end
304 #end
305   },
306   rules: {
307     #foreach ($column in $columns)
308 #if($column.required)
309 #set($parentheseIndex=$column.columnComment.indexOf("("))
310 #if($parentheseIndex != -1)
311 #set($comment=$column.columnComment.substring(0, $parentheseIndex))
312 #else
313 #set($comment=$column.columnComment)
314 #end
315     $column.javaField: [
316       { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
317     ]#if($foreach.count != $columns.size()),#end
318 #end
319 #end
320   }
321 });
322
323 const { queryParams, form, rules } = toRefs(data);
324
325 /** 查询${functionName}列表 */
326 function getList() {
327   loading.value = true;
328 #foreach ($column in $columns)
329 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
330   queryParams.value.params = {};
331 #break
332 #end
333 #end
334 #foreach ($column in $columns)
335 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
336 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
337   if (null != daterange${AttrName} && '' != daterange${AttrName}) {
338     queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0];
339     queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1];
340   }
341 #end
342 #end
343   list${BusinessName}(queryParams.value).then(response => {
344     ${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
345     loading.value = false;
346   });
347 }
348
349 /** 查询${functionName}下拉树结构 */
350 function getTreeselect() {
351   list${BusinessName}().then(response => {
352     ${businessName}Options.value = [];
353     const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
354     data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
355     ${businessName}Options.value.push(data);
356   });
357 }
358     
359 // 取消按钮
360 function cancel() {
361   open.value = false;
362   reset();
363 }
364
365 // 表单重置
366 function reset() {
367   form.value = {
368 #foreach ($column in $columns)
369 #if($column.htmlType == "checkbox")
370     $column.javaField: []#if($foreach.count != $columns.size()),#end
371 #else
372     $column.javaField: null#if($foreach.count != $columns.size()),#end
373 #end
374 #end
375   };
376   proxy.resetForm("${businessName}Ref");
377 }
378
379 /** 搜索按钮操作 */
380 function handleQuery() {
381   getList();
382 }
383
384 /** 重置按钮操作 */
385 function resetQuery() {
386 #foreach ($column in $columns)
387 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
388 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
389   daterange${AttrName}.value = [];
390 #end
391 #end
392   proxy.resetForm("queryRef");
393   handleQuery();
394 }
395
396 /** 新增按钮操作 */
397 function handleAdd(row) {
398   reset();
399   getTreeselect();
400   if (row != null && row.${treeCode}) {
401     form.value.${treeParentCode} = row.${treeCode};
402   } else {
403     form.value.${treeParentCode} = 0;
404   }
405   open.value = true;
406   title.value = "添加${functionName}";
407 }
408
409 /** 展开/折叠操作 */
410 function toggleExpandAll() {
411   refreshTable.value = false;
412   isExpandAll.value = !isExpandAll.value;
413   nextTick(() => {
414     refreshTable.value = true;
415   });
416 }
417
418 /** 修改按钮操作 */
419 async function handleUpdate(row) {
420   reset();
421   await getTreeselect();
422   if (row != null) {
423     form.value.${treeParentCode} = row.${treeParentCode};
424   }
425   get${BusinessName}(row.${pkColumn.javaField}).then(response => {
426     form.value = response.data;
427 #foreach ($column in $columns)
428 #if($column.htmlType == "checkbox")
429     form.value.$column.javaField = form.value.${column.javaField}.split(",");
430 #end
431 #end
432     open.value = true;
433     title.value = "修改${functionName}";
434   });
435 }
436
437 /** 提交按钮 */
438 function submitForm() {
439   proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => {
440     if (valid) {
441 #foreach ($column in $columns)
442 #if($column.htmlType == "checkbox")
443       form.value.$column.javaField = form.value.${column.javaField}.join(",");
444 #end
445 #end
446       if (form.value.${pkColumn.javaField} != null) {
447         update${BusinessName}(form.value).then(response => {
448           proxy.#[[$modal]]#.msgSuccess("修改成功");
449           open.value = false;
450           getList();
451         });
452       } else {
453         add${BusinessName}(form.value).then(response => {
454           proxy.#[[$modal]]#.msgSuccess("新增成功");
455           open.value = false;
456           getList();
457         });
458       }
459     }
460   });
461 }
462
463 /** 删除按钮操作 */
464 function handleDelete(row) {
465   proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() {
466     return del${BusinessName}(row.${pkColumn.javaField});
467   }).then(() => {
468     getList();
469     proxy.#[[$modal]]#.msgSuccess("删除成功");
470   }).catch(() => {});
471 }
472
473 getList();
474 </script>