| | |
| | | /** 树名称字段 */
|
| | | public static final String TREE_NAME = "treeName";
|
| | |
|
| | | /** 上级菜单ID字段 */
|
| | | public static final String PARENT_MENU_ID = "parentMenuId";
|
| | |
|
| | | /** 上级菜单名称字段 */
|
| | | public static final String PARENT_MENU_NAME = "parentMenuName";
|
| | |
|
| | | /** 数据库字符串类型 */
|
| | | public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text",
|
| | | "mediumtext", "longtext" };
|
| | |
| | | /** 树名称字段 */
|
| | | private String treeName;
|
| | |
|
| | | /** 上级菜单ID字段 */
|
| | | private String parentMenuId;
|
| | |
|
| | | /** 上级菜单名称字段 */
|
| | | private String parentMenuName;
|
| | |
|
| | | public Long getTableId()
|
| | | {
|
| | | return tableId;
|
| | |
| | | this.treeName = treeName;
|
| | | }
|
| | |
|
| | | public String getParentMenuId()
|
| | | {
|
| | | return parentMenuId;
|
| | | }
|
| | |
|
| | | public void setParentMenuId(String parentMenuId)
|
| | | {
|
| | | this.parentMenuId = parentMenuId;
|
| | | }
|
| | |
|
| | | public String getParentMenuName()
|
| | | {
|
| | | return parentMenuName;
|
| | | }
|
| | |
|
| | | public void setParentMenuName(String parentMenuName)
|
| | | {
|
| | | this.parentMenuName = parentMenuName;
|
| | | }
|
| | |
|
| | | public boolean isTree()
|
| | | {
|
| | | return isTree(this.tplCategory);
|
| | |
| | | }
|
| | | return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
|
| | | }
|
| | | }
|
| | | } |
| | |
| | | String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
|
| | | String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
|
| | | String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
| | | String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
| | | String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME);
|
| | | |
| | | genTable.setTreeCode(treeCode);
|
| | | genTable.setTreeParentCode(treeParentCode);
|
| | | genTable.setTreeName(treeName);
|
| | | genTable.setParentMenuId(parentMenuId);
|
| | | genTable.setParentMenuName(parentMenuName);
|
| | | }
|
| | | }
|
| | | }
|
| | | } |
| | |
| | | import com.ruoyi.generator.domain.GenTable;
|
| | | import com.ruoyi.generator.domain.GenTableColumn;
|
| | |
|
| | | /**
|
| | | * 代码生成模板处理
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class VelocityUtils
|
| | | {
|
| | | /** 项目空间路径 */
|
| | | private static final String PROJECT_PATH = "main/java";
|
| | |
|
| | | /** mybatis空间路径 */
|
| | | private static final String MYBATIS_PATH = "main/resources/mapper";
|
| | | private static final String MYBATIS_PATH = "main/resources/mybatis";
|
| | |
|
| | | /** 默认上级菜单,系统工具 */
|
| | | private static final String DEFAULT_PARENT_MENU_ID = "3";
|
| | |
|
| | | /**
|
| | | * 设置模板变量信息
|
| | |
| | | velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
| | | velocityContext.put("columns", genTable.getColumns());
|
| | | velocityContext.put("table", genTable);
|
| | | setMenuVelocityContext(velocityContext, genTable);
|
| | | if (GenConstants.TPL_TREE.equals(tplCategory))
|
| | | {
|
| | | setTreeVelocityContext(velocityContext, genTable);
|
| | | }
|
| | | return velocityContext;
|
| | | }
|
| | |
|
| | | public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
|
| | | {
|
| | | String options = genTable.getOptions();
|
| | | JSONObject paramsObj = JSONObject.parseObject(options);
|
| | | String parentMenuId = getParentMenuId(paramsObj);
|
| | | context.put("parentMenuId", parentMenuId);
|
| | | }
|
| | |
|
| | | public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 获取上级菜单ID字段
|
| | | * |
| | | * @param options 生成其他选项
|
| | | * @return 上级菜单ID字段
|
| | | */
|
| | | public static String getParentMenuId(JSONObject paramsObj)
|
| | | {
|
| | | if (paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
|
| | | {
|
| | | return paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
| | | }
|
| | | return DEFAULT_PARENT_MENU_ID;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取树编码
|
| | | *
|
| | | * @param options 生成其他选项
|
| | |
| | | {
|
| | | return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
|
| | | }
|
| | | return "";
|
| | | return StringUtils.EMPTY;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | {
|
| | | return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
| | | }
|
| | | return "";
|
| | | return StringUtils.EMPTY;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | {
|
| | | return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
|
| | | }
|
| | | return "";
|
| | | return StringUtils.EMPTY;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | | return num;
|
| | | }
|
| | | }
|
| | | } |
| | |
| | | -- 菜单 SQL
|
| | | insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
| | | values('${functionName}', '3', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
|
| | | values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
|
| | |
|
| | | -- 按钮父菜单ID
|
| | | SELECT @parentId := LAST_INSERT_ID();
|
| | |
| | | </el-table>
|
| | | </el-tab-pane>
|
| | | <el-tab-pane label="生成信息" name="genInfo">
|
| | | <gen-info-form ref="genInfo" :info="info" />
|
| | | <gen-info-form ref="genInfo" :info="info" :menus="menus"/>
|
| | | </el-tab-pane>
|
| | | </el-tabs>
|
| | | <el-form label-width="100px">
|
| | |
| | | <script>
|
| | | import { getGenTable, updateGenTable } from "@/api/tool/gen";
|
| | | import { optionselect as getDictOptionselect } from "@/api/system/dict/type";
|
| | | import { listMenu as getMenuTreeselect } from "@/api/system/menu";
|
| | | import basicInfoForm from "./basicInfoForm";
|
| | | import genInfoForm from "./genInfoForm";
|
| | | import Sortable from 'sortablejs'
|
| | |
|
| | | export default {
|
| | | name: "GenEdit",
|
| | | components: {
|
| | |
| | | cloumns: [],
|
| | | // 字典信息
|
| | | dictOptions: [],
|
| | | // 菜单信息
|
| | | menus: [],
|
| | | // 表详细信息
|
| | | info: {}
|
| | | };
|
| | |
| | | getDictOptionselect().then(response => {
|
| | | this.dictOptions = response.data;
|
| | | });
|
| | | /** 查询菜单下拉列表 */
|
| | | getMenuTreeselect().then(response => {
|
| | | this.menus = this.handleTree(response.data, "menuId");
|
| | | });
|
| | | }
|
| | | },
|
| | | methods: {
|
| | |
| | | genTable.params = {
|
| | | treeCode: genTable.treeCode,
|
| | | treeName: genTable.treeName,
|
| | | treeParentCode: genTable.treeParentCode
|
| | | treeParentCode: genTable.treeParentCode,
|
| | | parentMenuId: genTable.parentMenuId
|
| | | };
|
| | | updateGenTable(genTable).then(res => {
|
| | | this.msgSuccess(res.msg);
|
| | |
| | | <el-input v-model="info.functionName" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | |
|
| | | <el-col :span="12">
|
| | | <el-form-item prop="functionName">
|
| | | <span slot="label">
|
| | | 上级菜单
|
| | | <el-tooltip content="分配到指定菜单下,例如 系统管理" placement="top">
|
| | | <i class="el-icon-question"></i>
|
| | | </el-tooltip>
|
| | | </span>
|
| | | <treeselect :append-to-body="true" v-model="info.parentMenuId" :options="menus" :normalizer="normalizer" :show-count="true" placeholder="请选择系统菜单"/>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | </el-row>
|
| | |
|
| | | <el-row v-show="info.tplCategory == 'tree'">
|
| | |
| | | </el-form>
|
| | | </template>
|
| | | <script>
|
| | | import Treeselect from "@riophae/vue-treeselect";
|
| | | import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
| | |
|
| | | export default {
|
| | | name: "BasicInfoForm",
|
| | | components: { Treeselect },
|
| | | props: {
|
| | | info: {
|
| | | type: Object,
|
| | | default: null
|
| | | }
|
| | | },
|
| | | menus: {
|
| | | type: Array,
|
| | | default: []
|
| | | },
|
| | | },
|
| | | data() {
|
| | | return {
|
| | |
| | | }
|
| | | };
|
| | | },
|
| | | created() {}
|
| | | created() {},
|
| | | methods: {
|
| | | /** 转换菜单数据结构 */
|
| | | normalizer(node) {
|
| | | if (node.children && !node.children.length) {
|
| | | delete node.children;
|
| | | }
|
| | | return {
|
| | | id: node.menuId,
|
| | | label: node.menuName,
|
| | | children: node.children
|
| | | };
|
| | | }
|
| | | }
|
| | | };
|
| | | </script>
|
| | |
| | | <el-row>
|
| | | <el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
|
| | | <el-table-column type="selection" width="55"></el-table-column>
|
| | | <el-table-column prop="tableName" label="表名称"></el-table-column>
|
| | | <el-table-column prop="tableComment" label="表描述"></el-table-column>
|
| | | <el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true"></el-table-column>
|
| | | <el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true"></el-table-column>
|
| | | <el-table-column prop="createTime" label="创建时间"></el-table-column>
|
| | | <el-table-column prop="updateTime" label="更新时间"></el-table-column>
|
| | | </el-table>
|