From c628aa5be83394f14b0c5f3e26eed49127c4d62b Mon Sep 17 00:00:00 2001
From: 马小法 <ma_0425@163.com>
Date: 星期一, 30 八月 2021 16:49:30 +0800
Subject: [PATCH] 修改代码生成字典回显样式

---
 ruoyi-generator/src/main/resources/vm/vue/index.vue.vm |   81 ++++++++--------------------------------
 1 files changed, 16 insertions(+), 65 deletions(-)

diff --git a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
index 501f2f6..0086559 100644
--- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
+++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
@@ -108,7 +108,7 @@
           plain
           icon="el-icon-download"
           size="mini"
-		  :loading="exportLoading"
+          :loading="exportLoading"
           @click="handleExport"
           v-hasPermi="['${moduleName}:${businessName}:export']"
         >导出</el-button>
@@ -135,7 +135,11 @@
         </template>
       </el-table-column>
 #elseif($column.list && "" != $column.dictType)
-      <el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
+      <el-table-column label="${comment}" align="center" prop="${javaField}">
+        <template slot-scope="scope">
+          <dict-tag :options="${javaField}Options" :value="scope.row.${javaField}"/>
+        </template>
+      </el-table-column>
 #elseif($column.list && "" != $javaField)
       <el-table-column label="${comment}" align="center" prop="${javaField}" />
 #end
@@ -310,47 +314,9 @@
 
 <script>
 import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
-#foreach($column in $columns)
-#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
-import ImageUpload from '@/components/ImageUpload';
-#break
-#end
-#end
-#foreach($column in $columns)
-#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
-import FileUpload from '@/components/FileUpload';
-#break
-#end
-#end
-#foreach($column in $columns)
-#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
-import Editor from '@/components/Editor';
-#break
-#end
-#end
 
 export default {
   name: "${BusinessName}",
-  components: {
-#foreach($column in $columns)
-#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
-    ImageUpload,
-#break
-#end
-#end
-#foreach($column in $columns)
-#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
-    FileUpload,
-#break
-#end
-#end
-#foreach($column in $columns)
-#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
-    Editor,
-#break
-#end
-#end
-  },
   data() {
     return {
       // 遮罩层
@@ -464,20 +430,6 @@
         this.loading = false;
       });
     },
-#foreach ($column in $columns)
-#if(${column.dictType} != '')
-#set($parentheseIndex=$column.columnComment.indexOf("("))
-#if($parentheseIndex != -1)
-#set($comment=$column.columnComment.substring(0, $parentheseIndex))
-#else
-#set($comment=$column.columnComment)
-#end
-    // $comment字典翻译
-    ${column.javaField}Format(row, column) {
-      return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
-    },
-#end
-#end
     // 取消按钮
     cancel() {
       this.open = false;
@@ -590,7 +542,7 @@
         }).then(() => {
           this.getList();
           this.msgSuccess("删除成功");
-        })
+        }).catch(() => {});
     },
 #if($table.sub)
 	/** ${subTable.functionName}序号 */
@@ -611,19 +563,18 @@
     /** ${subTable.functionName}删除按钮操作 */
     handleDelete${subClassName}() {
       if (this.checked${subClassName}.length == 0) {
-        this.$alert("请先选择要删除的${subTable.functionName}数据", "提示", { confirmButtonText: "确定", });
+        this.msgError("请先选择要删除的${subTable.functionName}数据");
       } else {
-        this.${subclassName}List.splice(this.checked${subClassName}[0].index - 1, 1);
+        const ${subclassName}List = this.${subclassName}List;
+        const checked${subClassName} = this.checked${subClassName};
+        this.${subclassName}List = ${subclassName}List.filter(function(item) {
+          return checked${subClassName}.indexOf(item.index) == -1
+        });
       }
     },
-    /** 单选框选中数据 */
+    /** 复选框选中数据 */
     handle${subClassName}SelectionChange(selection) {
-      if (selection.length > 1) {
-        this.$refs.${subclassName}.clearSelection();
-        this.$refs.${subclassName}.toggleRowSelection(selection.pop());
-      } else {
-        this.checked${subClassName} = selection;
-      }
+      this.checked${subClassName} = selection.map(item => item.index)
     },
 #end
     /** 导出按钮操作 */
@@ -639,7 +590,7 @@
         }).then(response => {
           this.download(response.msg);
           this.exportLoading = false;
-        })
+        }).catch(() => {});
     }
   }
 };

--
Gitblit v1.9.2