From 5c6adb25fc3c114085e64f0c34bab3623c3e647a Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期四, 23 七月 2020 17:02:55 +0800
Subject: [PATCH] 代码生成支持复选框
---
ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm | 32 +++++++++++++++
ruoyi-ui/src/main.js | 3 +
ruoyi-ui/src/utils/ruoyi.js | 43 ++++++++++++++-------
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm | 32 +++++++++++++++
sql/ry_20200723.sql | 2
5 files changed, 94 insertions(+), 18 deletions(-)
diff --git a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
index fb10ed6..7435ae7 100644
--- a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
+++ b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
@@ -157,6 +157,23 @@
<el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" />
</el-select>
</el-form-item>
+#elseif($column.htmlType == "checkbox" && "" != $dictType)
+ <el-form-item label="${comment}">
+ <el-checkbox-group v-model="form.${field}">
+ <el-checkbox
+ v-for="dict in ${field}Options"
+ :key="dict.dictValue"
+ :label="dict.dictValue">
+ {{dict.dictLabel}}
+ </el-checkbox>
+ </el-checkbox-group>
+ </el-form-item>
+#elseif($column.htmlType == "checkbox" && $dictType)
+ <el-form-item label="${comment}">
+ <el-checkbox-group v-model="form.${field}">
+ <el-checkbox>璇烽�夋嫨瀛楀吀鐢熸垚</el-checkbox>
+ </el-checkbox-group>
+ </el-form-item>
#elseif($column.htmlType == "radio" && "" != $dictType)
<el-form-item label="${comment}">
<el-radio-group v-model="form.${field}">
@@ -312,7 +329,7 @@
#end
// $comment瀛楀吀缈昏瘧
${column.javaField}Format(row, column) {
- return this.selectDictLabel(this.${column.javaField}Options, row.${column.javaField});
+ return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
},
#end
#end
@@ -327,6 +344,9 @@
#foreach ($column in $columns)
#if($column.htmlType == "radio")
$column.javaField: "0"#if($velocityCount != $columns.size()),#end
+
+#elseif($column.htmlType == "checkbox")
+ $column.javaField: []#if($velocityCount != $columns.size()),#end
#else
$column.javaField: undefined#if($velocityCount != $columns.size()),#end
@@ -361,6 +381,11 @@
}
get${BusinessName}(row.${pkColumn.javaField}).then(response => {
this.form = response.data;
+#foreach ($column in $columns)
+#if($column.htmlType == "checkbox")
+ this.form.$column.javaField = this.form.${column.javaField}.split(",");
+#end
+#end
this.open = true;
this.title = "淇敼${functionName}";
});
@@ -369,6 +394,11 @@
submitForm: function() {
this.#[[$]]#refs["form"].validate(valid => {
if (valid) {
+#foreach ($column in $columns)
+#if($column.htmlType == "checkbox")
+ this.form.$column.javaField = this.form.${column.javaField}.join(",");
+#end
+#end
if (this.form.${pkColumn.javaField} != undefined) {
update${BusinessName}(this.form).then(response => {
if (response.code === 200) {
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 0b64a0c..df2890e 100644
--- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
+++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
@@ -185,6 +185,23 @@
<el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" />
</el-select>
</el-form-item>
+#elseif($column.htmlType == "checkbox" && "" != $dictType)
+ <el-form-item label="${comment}">
+ <el-checkbox-group v-model="form.${field}">
+ <el-checkbox
+ v-for="dict in ${field}Options"
+ :key="dict.dictValue"
+ :label="dict.dictValue">
+ {{dict.dictLabel}}
+ </el-checkbox>
+ </el-checkbox-group>
+ </el-form-item>
+#elseif($column.htmlType == "checkbox" && $dictType)
+ <el-form-item label="${comment}">
+ <el-checkbox-group v-model="form.${field}">
+ <el-checkbox>璇烽�夋嫨瀛楀吀鐢熸垚</el-checkbox>
+ </el-checkbox-group>
+ </el-form-item>
#elseif($column.htmlType == "radio" && "" != $dictType)
<el-form-item label="${comment}">
<el-radio-group v-model="form.${field}">
@@ -326,7 +343,7 @@
#end
// $comment瀛楀吀缈昏瘧
${column.javaField}Format(row, column) {
- return this.selectDictLabel(this.${column.javaField}Options, row.${column.javaField});
+ return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
},
#end
#end
@@ -341,6 +358,9 @@
#foreach ($column in $columns)
#if($column.htmlType == "radio")
$column.javaField: "0"#if($velocityCount != $columns.size()),#end
+
+#elseif($column.htmlType == "checkbox")
+ $column.javaField: []#if($velocityCount != $columns.size()),#end
#else
$column.javaField: undefined#if($velocityCount != $columns.size()),#end
@@ -378,6 +398,11 @@
const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
get${BusinessName}(${pkColumn.javaField}).then(response => {
this.form = response.data;
+#foreach ($column in $columns)
+#if($column.htmlType == "checkbox")
+ this.form.$column.javaField = this.form.${column.javaField}.split(",");
+#end
+#end
this.open = true;
this.title = "淇敼${functionName}";
});
@@ -386,6 +411,11 @@
submitForm: function() {
this.#[[$]]#refs["form"].validate(valid => {
if (valid) {
+#foreach ($column in $columns)
+#if($column.htmlType == "checkbox")
+ this.form.$column.javaField = this.form.${column.javaField}.join(",");
+#end
+#end
if (this.form.${pkColumn.javaField} != undefined) {
update${BusinessName}(this.form).then(response => {
if (response.code === 200) {
diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js
index c2834bf..7a28b51 100644
--- a/ruoyi-ui/src/main.js
+++ b/ruoyi-ui/src/main.js
@@ -18,7 +18,7 @@
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
-import { parseTime, resetForm, addDateRange, selectDictLabel, download, handleTree } from "@/utils/ruoyi";
+import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";
import Pagination from "@/components/Pagination";
// 鍏ㄥ眬鏂规硶鎸傝浇
@@ -28,6 +28,7 @@
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
+Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js
index decad41..23879aa 100644
--- a/ruoyi-ui/src/utils/ruoyi.js
+++ b/ruoyi-ui/src/utils/ruoyi.js
@@ -77,6 +77,21 @@
return actions.join('');
}
+// 鍥炴樉鏁版嵁瀛楀吀锛堝瓧绗︿覆鏁扮粍锛�
+export function selectDictLabels(datas, value, separator) {
+ var actions = [];
+ var currentSeparator = undefined === separator ? "," : separator;
+ var temp = value.split(currentSeparator);
+ Object.keys(value.split(currentSeparator)).some((val) => {
+ Object.keys(datas).some((key) => {
+ if (datas[key].dictValue == ('' + temp[val])) {
+ actions.push(datas[key].dictLabel + currentSeparator);
+ }
+ })
+ })
+ return actions.join('').substring(0, actions.join('').length - 1);
+}
+
// 閫氱敤涓嬭浇鏂规硶
export function download(fileName) {
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
@@ -98,10 +113,10 @@
// 杞崲瀛楃涓诧紝undefined,null绛夎浆鍖栦负""
export function praseStrEmpty(str) {
- if (!str || str == "undefined" || str == "null") {
- return "";
- }
- return str;
+ if (!str || str == "undefined" || str == "null") {
+ return "";
+ }
+ return str;
}
/**
@@ -120,15 +135,15 @@
//瀵规簮鏁版嵁娣卞害鍏嬮殕
const cloneData = JSON.parse(JSON.stringify(data))
//寰幆鎵�鏈夐」
- const treeData = cloneData.filter(father => {
- let branchArr = cloneData.filter(child => {
- //杩斿洖姣忎竴椤圭殑瀛愮骇鏁扮粍
- return father[id] === child[parentId]
- });
- branchArr.length > 0 ? father.children = branchArr : '';
- //杩斿洖绗竴灞�
- return father[parentId] === rootId;
+ const treeData = cloneData.filter(father => {
+ let branchArr = cloneData.filter(child => {
+ //杩斿洖姣忎竴椤圭殑瀛愮骇鏁扮粍
+ return father[id] === child[parentId]
+ });
+ branchArr.length > 0 ? father.children = branchArr : '';
+ //杩斿洖绗竴灞�
+ return father[parentId] === rootId;
});
return treeData != '' ? treeData : data;
- }
-
+}
+
diff --git a/sql/ry_20200629.sql b/sql/ry_20200723.sql
similarity index 99%
rename from sql/ry_20200629.sql
rename to sql/ry_20200723.sql
index 7c8e8c8..727ac6c 100644
--- a/sql/ry_20200629.sql
+++ b/sql/ry_20200723.sql
@@ -120,7 +120,7 @@
-- ----------------------------
-- 鍒濆鍖�-瑙掕壊淇℃伅琛ㄦ暟鎹�
-- ----------------------------
-insert into sys_role values('1', '绯荤粺绠$悊鍛�', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '绯荤粺绠$悊鍛�');
+insert into sys_role values('1', '瓒呯骇绠$悊鍛�', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '瓒呯骇绠$悊鍛�');
insert into sys_role values('2', '鏅�氳鑹�', 'common', 2, 2, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '鏅�氳鑹�');
--
Gitblit v1.9.3