Commit 5c6adb25fc3c114085e64f0c34bab3623c3e647a

Authored by RuoYi
1 parent be778ba3

代码生成支持复选框

ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
... ... @@ -157,6 +157,23 @@
157 157 <el-option label="请选择字典生成" value="" />
158 158 </el-select>
159 159 </el-form-item>
  160 +#elseif($column.htmlType == "checkbox" && "" != $dictType)
  161 + <el-form-item label="${comment}">
  162 + <el-checkbox-group v-model="form.${field}">
  163 + <el-checkbox
  164 + v-for="dict in ${field}Options"
  165 + :key="dict.dictValue"
  166 + :label="dict.dictValue">
  167 + {{dict.dictLabel}}
  168 + </el-checkbox>
  169 + </el-checkbox-group>
  170 + </el-form-item>
  171 +#elseif($column.htmlType == "checkbox" && $dictType)
  172 + <el-form-item label="${comment}">
  173 + <el-checkbox-group v-model="form.${field}">
  174 + <el-checkbox>请选择字典生成</el-checkbox>
  175 + </el-checkbox-group>
  176 + </el-form-item>
160 177 #elseif($column.htmlType == "radio" && "" != $dictType)
161 178 <el-form-item label="${comment}">
162 179 <el-radio-group v-model="form.${field}">
... ... @@ -312,7 +329,7 @@ export default {
312 329 #end
313 330 // $comment字典翻译
314 331 ${column.javaField}Format(row, column) {
315   - return this.selectDictLabel(this.${column.javaField}Options, row.${column.javaField});
  332 + return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
316 333 },
317 334 #end
318 335 #end
... ... @@ -328,6 +345,9 @@ export default {
328 345 #if($column.htmlType == "radio")
329 346 $column.javaField: "0"#if($velocityCount != $columns.size()),#end
330 347  
  348 +#elseif($column.htmlType == "checkbox")
  349 + $column.javaField: []#if($velocityCount != $columns.size()),#end
  350 +
331 351 #else
332 352 $column.javaField: undefined#if($velocityCount != $columns.size()),#end
333 353  
... ... @@ -361,6 +381,11 @@ export default {
361 381 }
362 382 get${BusinessName}(row.${pkColumn.javaField}).then(response => {
363 383 this.form = response.data;
  384 +#foreach ($column in $columns)
  385 +#if($column.htmlType == "checkbox")
  386 + this.form.$column.javaField = this.form.${column.javaField}.split(",");
  387 +#end
  388 +#end
364 389 this.open = true;
365 390 this.title = "修改${functionName}";
366 391 });
... ... @@ -369,6 +394,11 @@ export default {
369 394 submitForm: function() {
370 395 this.#[[$]]#refs["form"].validate(valid => {
371 396 if (valid) {
  397 +#foreach ($column in $columns)
  398 +#if($column.htmlType == "checkbox")
  399 + this.form.$column.javaField = this.form.${column.javaField}.join(",");
  400 +#end
  401 +#end
372 402 if (this.form.${pkColumn.javaField} != undefined) {
373 403 update${BusinessName}(this.form).then(response => {
374 404 if (response.code === 200) {
... ...
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
... ... @@ -185,6 +185,23 @@
185 185 <el-option label="请选择字典生成" value="" />
186 186 </el-select>
187 187 </el-form-item>
  188 +#elseif($column.htmlType == "checkbox" && "" != $dictType)
  189 + <el-form-item label="${comment}">
  190 + <el-checkbox-group v-model="form.${field}">
  191 + <el-checkbox
  192 + v-for="dict in ${field}Options"
  193 + :key="dict.dictValue"
  194 + :label="dict.dictValue">
  195 + {{dict.dictLabel}}
  196 + </el-checkbox>
  197 + </el-checkbox-group>
  198 + </el-form-item>
  199 +#elseif($column.htmlType == "checkbox" && $dictType)
  200 + <el-form-item label="${comment}">
  201 + <el-checkbox-group v-model="form.${field}">
  202 + <el-checkbox>请选择字典生成</el-checkbox>
  203 + </el-checkbox-group>
  204 + </el-form-item>
188 205 #elseif($column.htmlType == "radio" && "" != $dictType)
189 206 <el-form-item label="${comment}">
190 207 <el-radio-group v-model="form.${field}">
... ... @@ -326,7 +343,7 @@ export default {
326 343 #end
327 344 // $comment字典翻译
328 345 ${column.javaField}Format(row, column) {
329   - return this.selectDictLabel(this.${column.javaField}Options, row.${column.javaField});
  346 + return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
330 347 },
331 348 #end
332 349 #end
... ... @@ -342,6 +359,9 @@ export default {
342 359 #if($column.htmlType == "radio")
343 360 $column.javaField: "0"#if($velocityCount != $columns.size()),#end
344 361  
  362 +#elseif($column.htmlType == "checkbox")
  363 + $column.javaField: []#if($velocityCount != $columns.size()),#end
  364 +
345 365 #else
346 366 $column.javaField: undefined#if($velocityCount != $columns.size()),#end
347 367  
... ... @@ -378,6 +398,11 @@ export default {
378 398 const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
379 399 get${BusinessName}(${pkColumn.javaField}).then(response => {
380 400 this.form = response.data;
  401 +#foreach ($column in $columns)
  402 +#if($column.htmlType == "checkbox")
  403 + this.form.$column.javaField = this.form.${column.javaField}.split(",");
  404 +#end
  405 +#end
381 406 this.open = true;
382 407 this.title = "修改${functionName}";
383 408 });
... ... @@ -386,6 +411,11 @@ export default {
386 411 submitForm: function() {
387 412 this.#[[$]]#refs["form"].validate(valid => {
388 413 if (valid) {
  414 +#foreach ($column in $columns)
  415 +#if($column.htmlType == "checkbox")
  416 + this.form.$column.javaField = this.form.${column.javaField}.join(",");
  417 +#end
  418 +#end
389 419 if (this.form.${pkColumn.javaField} != undefined) {
390 420 update${BusinessName}(this.form).then(response => {
391 421 if (response.code === 200) {
... ...
ruoyi-ui/src/main.js
... ... @@ -18,7 +18,7 @@ import &#39;./assets/icons&#39; // icon
18 18 import './permission' // permission control
19 19 import { getDicts } from "@/api/system/dict/data";
20 20 import { getConfigKey } from "@/api/system/config";
21   -import { parseTime, resetForm, addDateRange, selectDictLabel, download, handleTree } from "@/utils/ruoyi";
  21 +import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";
22 22 import Pagination from "@/components/Pagination";
23 23  
24 24 // 全局方法挂载
... ... @@ -28,6 +28,7 @@ Vue.prototype.parseTime = parseTime
28 28 Vue.prototype.resetForm = resetForm
29 29 Vue.prototype.addDateRange = addDateRange
30 30 Vue.prototype.selectDictLabel = selectDictLabel
  31 +Vue.prototype.selectDictLabels = selectDictLabels
31 32 Vue.prototype.download = download
32 33 Vue.prototype.handleTree = handleTree
33 34  
... ...
ruoyi-ui/src/utils/ruoyi.js
... ... @@ -77,6 +77,21 @@ export function selectDictLabel(datas, value) {
77 77 return actions.join('');
78 78 }
79 79  
  80 +// 回显数据字典(字符串数组)
  81 +export function selectDictLabels(datas, value, separator) {
  82 + var actions = [];
  83 + var currentSeparator = undefined === separator ? "," : separator;
  84 + var temp = value.split(currentSeparator);
  85 + Object.keys(value.split(currentSeparator)).some((val) => {
  86 + Object.keys(datas).some((key) => {
  87 + if (datas[key].dictValue == ('' + temp[val])) {
  88 + actions.push(datas[key].dictLabel + currentSeparator);
  89 + }
  90 + })
  91 + })
  92 + return actions.join('').substring(0, actions.join('').length - 1);
  93 +}
  94 +
80 95 // 通用下载方法
81 96 export function download(fileName) {
82 97 window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
... ... @@ -98,10 +113,10 @@ export function sprintf(str) {
98 113  
99 114 // 转换字符串,undefined,null等转化为""
100 115 export function praseStrEmpty(str) {
101   - if (!str || str == "undefined" || str == "null") {
102   - return "";
103   - }
104   - return str;
  116 + if (!str || str == "undefined" || str == "null") {
  117 + return "";
  118 + }
  119 + return str;
105 120 }
106 121  
107 122 /**
... ... @@ -120,15 +135,15 @@ export function handleTree(data, id, parentId, children, rootId) {
120 135 //对源数据深度克隆
121 136 const cloneData = JSON.parse(JSON.stringify(data))
122 137 //循环所有项
123   - const treeData = cloneData.filter(father => {
124   - let branchArr = cloneData.filter(child => {
125   - //返回每一项的子级数组
126   - return father[id] === child[parentId]
127   - });
128   - branchArr.length > 0 ? father.children = branchArr : '';
129   - //返回第一层
130   - return father[parentId] === rootId;
  138 + const treeData = cloneData.filter(father => {
  139 + let branchArr = cloneData.filter(child => {
  140 + //返回每一项的子级数组
  141 + return father[id] === child[parentId]
  142 + });
  143 + branchArr.length > 0 ? father.children = branchArr : '';
  144 + //返回第一层
  145 + return father[parentId] === rootId;
131 146 });
132 147 return treeData != '' ? treeData : data;
133   - }
134   -
  148 +}
  149 +
... ...
sql/ry_20200629.sql renamed to sql/ry_20200723.sql
... ... @@ -120,7 +120,7 @@ create table sys_role (
120 120 -- ----------------------------
121 121 -- 初始化-角色信息表数据
122 122 -- ----------------------------
123   -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', '系统管理员');
  123 +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', '超级管理员');
124 124 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', '普通角色');
125 125  
126 126  
... ...