123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="keywords" content="">
- <meta name="description" content="">
- <title></title>
- <link rel="stylesheet" href="../../component/pear/css/pear.css">
- <link rel="stylesheet" href="../../admin/css/other/generate.css"/>
- <style>
- .layui-form-label {
- width: 110px;
- }
- .layui-input-block {
- margin-left: 140px;
- }
- .layui-form-checked i, .layui-form-checked:hover i {
- color: #000;
- font-weight: bold;
- }
- </style>
- </head>
- <body class="pear-container">
- <form class="layui-form" lay-filter="form-generate">
- <div class="mainBox">
- <div class="main-container">
- <div class="layui-row layui-col-space10">
- <div class="layui-col-md6">
- <div class="layui-card">
- <div class="layui-card-header">基础信息</div>
- <input type="hidden" name="id" />
- <div class="layui-card-body" style="height: 450px;">
- <div class="layui-form-item">
- <label class="layui-form-label layui-required">表名称:</label>
- <div class="layui-input-block">
- <input type="text" name="tableName" lay-verify="required"
- class="layui-input" placeholder="请输入表名称" maxlength="200"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required">表描述:</label>
- <div class="layui-input-block">
- <input type="text" name="tableComment" lay-verify="required"
- class="layui-input" placeholder="请输入表描述" maxlength="500"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required">实体类名:</label>
- <div class="layui-input-block">
- <input type="text" name="className" lay-verify="required"
- class="layui-input" placeholder="请输入实体类名称" maxlength="100"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required">功能描述:</label>
- <div class="layui-input-block">
- <input type="text" name="functionName" lay-verify="required"
- class="layui-input" placeholder="请输入生成功能名" maxlength="50"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required">作者:</label>
- <div class="layui-input-block">
- <input type="text" name="functionAuthor" lay-verify="required" lay-verType="tips"
- class="layui-input" placeholder="请输入作者" maxlength="50"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">备注:</label>
- <div class="layui-input-block">
- <textarea rows="5" name="remark" maxlength="500"
- class="layui-textarea" autocomplete="off"></textarea>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="layui-col-md6">
- <div class="layui-card">
- <div class="layui-card-header">高级配置</div>
- <div class="layui-card-body" style="height: 450px;overflow: auto">
- <div class="layui-form-item">
- <label class="layui-form-label layui-required">生成模板:</label>
- <div class="layui-input-block">
- <select id="tplCategory" name='tplCategory' lay-filter="tpl">
- <option value="crud">单表(增删改查)</option>
- <option value="tree">树表(增删改查)</option>
- </select>
- </div>
- </div>
- <div class="layui-form-item tree-field layui-hide">
- <label class="layui-form-label layui-required">主键字段:</label>
- <div class="layui-input-block">
- <input type="text" name="treeCode" maxlength="50"
- class="layui-input" placeholder="请输入主键字段" />
- </div>
- </div>
- <div class="layui-form-item tree-field layui-hide">
- <label class="layui-form-label">父级字段:</label>
- <div class="layui-input-block">
- <input type="text" name="treeParentCode" maxlength="50"
- class="layui-input" placeholder="请输入树表字段"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required">基本路径:</label>
- <div class="layui-input-block">
- <input type="text" name="packageName" maxlength="100" lay-verify="required"
- class="layui-input" placeholder="生成在哪个java包下,例如 com.ruoyi.project.system"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required">模块名称:</label>
- <div class="layui-input-block">
- <input type="text" name="moduleName" maxlength="30" lay-verify="required" lay-verType="tips"
- class="layui-input" placeholder="可理解为子系统名,例如 system" />
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required">业务名称:</label>
- <div class="layui-input-block">
- <input type="text" name="businessName" lay-verify="required" lay-verType="tips"
- class="layui-input" placeholder="可理解为功能英文名,例如 user" maxlength="50"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required" title="分配到指定菜单下,例如 系统管理">上级菜单:</label>
- <div class="layui-input-block">
- <div id="tree"></div>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required" title="默认为zip压缩包下载,也可以自定义生成路径">生成方式:</label>
- <div class="layui-input-block">
- <input type="radio" name="genType" value="0" checked title="zip压缩包"/>
- <input type="radio" name="genType" value="1" title="自定义路径"/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label layui-required" title="填写磁盘绝对路径,若不填写,则生成到当前Web项目下">生成路径:</label>
- <div class="layui-input-block">
- <input class="layui-input" id="genPath" name="genPath" type="text"
- placeholder="请输入项目路径" maxlength="200">
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="layui-col-md12">
- <div class="layui-card">
- <div class="layui-card-header">属性配置</div>
- <div class="layui-card-body">
- <input name="tableId" type="hidden"/>
- <table id="table_gen_column"></table>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="bottom">
- <div class="button-container">
- <button class="pear-btn pear-btn-sm pear-btn-primary" lay-submit lay-filter="save" id="save">保存
- </button>
- <button class="pear-btn pear-btn-sm close" type="button">关闭</button>
- </div>
- </div>
- </form>
- <script src="../../component/layui/layui.js"></script>
- <script src="../../component/pear/pear.js"></script>
- <script src="../../component/js/xm-select.js"></script>
- <script>
- layui.use(['request', 'dtree', 'common', 'table', 'form','popup'], function () {
- var $ = layui.jquery,
- request = layui.request,
- common = layui.common,
- form = layui.form,
- dtree = layui.dtree,
- table = layui.table,
- popup = layui.popup;
- var MODULE_PATH = "/generator/v1/";
- var menuSelectTree = xmSelect.render({
- el: '#tree',
- name: 'parentMenu', // 表单提交name
- model: {label: {type: 'text'}},
- //layVerify: 'required', // 必填
- clickClose: true, // 点击关闭
- tree: {
- show: true, // 是否显示树状结构
- showLine: false, // 是否显示虚线
- strict: false, // 是否严格遵守父子模式
- expandedKeys: [1] // 默认展开节点的数组, 为 true 时, 展开所有节点
- },
- prop: { // key value 名称修改
- name: 'title',
- value: 'id'
- },
- on: function (data) {
- if (data.isAdd) {
- return data.change.slice(0, 1)
- }
- },
- data: []
- });
- layer.ready(function() {
- request.httpGet('/system/menu/v1/selectTree', function(result) {
- if (result.success) {
- menuSelectTree.update({
- data: result.data,
- autoRow: true
- });
- var id = request.getQueryString("id");
- if (id) {
- request.httpGet(MODULE_PATH + id, function (result) {
- form.val('form-generate', result.data);
- if (result.data.parentMenu) {
- menuSelectTree.setValue([result.data.parentMenu]);
- }
- table.render({
- elem: '#table_gen_column',
- skin: 'line',
- page: false,
- data: result.data.columns,
- limit: result.data.columns.length,
- done: function () {
- form.render('select');
- $('.layui-table-cell>input.layui-input[type="text"]').parent().css('padding', '0px 5px');
- $('.layui-table-body').css('min-height', '600px');
- },
- cols: [
- [
- {title: '序号', width: 60, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var columnIdHtml = common.sprintf("<input type='hidden' name='columns[%s].id' value='%s'>", index,
- row.id);
- var sortHtml = common.sprintf(
- "<input type='hidden' name='columns[%s].sort' value='%s' id='columns_sort_%s'>", index, row.sort, row.id
- );
- return columnIdHtml + sortHtml + (index++);
- }},
- {field: 'columnName', title: '字段列名', width: 120},
- {field: 'columnComment', title: '字段描述', align: 'center', templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var html = common.sprintf(
- "<input class='layui-input' type='text' name='columns[%s].columnComment' value='%s'>", index, row.columnComment
- );
- return html;
- }},
- {field: 'columnType', title: '物理类型', width: 120},
- {field: 'javaType', title: 'Java类型', align: 'center', width: 100, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var javaType = row.javaType;
- var html = '<select name="columns[' + index + '].javaType">' +
- '<option value="Long" ' + (javaType === "Long" ? ' selected' : '') + '>Long</option>' +
- '<option value="String" ' + (javaType === "String" ? ' selected' : '') + '>String</option>' +
- '<option value="Integer" ' + (javaType === "Integer" ? ' selected' : '') + '>Integer</option>' +
- '<option value="Double" ' + (javaType === "Double" ? ' selected' : '') + '>Double</option>' +
- '<option value="BigDecimal" ' + (javaType === "BigDecimal" ? ' selected' : '') + '>BigDecimal</option>' +
- '<option value="Date" ' + (javaType === "Date" ? ' selected' : '') + '>Date</option>' +
- '<option value="Boolean" ' + (javaType === "Boolean" ? ' selected' : '') + '>Boolean</option>' +
- '</select>';
- return html;
- }},
- {field: 'javaField', title: 'Java属性', align: 'center', width: 150, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var html = common.sprintf(
- "<input class='layui-input' type='text' name='columns[%s].javaField' value='%s' lay-verify='required' lay-verType='tips'>",
- index, row.javaField);
- return html;
- }},
- {field: 'isInsert', title: '插入', align: 'center', width: 60, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var isCheck = row.isInsert == 1 ? 'checked' : '';
- var html = common.sprintf("<input type='checkbox' name='columns[%s].isInsert' value='1' %s>", index,
- isCheck);
- return html;
- }},
- {field: 'isEdit', title: '编辑', align: 'center', width: 60, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var isCheck = row.isEdit == 1 ? 'checked' : '';
- var html = common.sprintf("<input type='checkbox' name='columns[%s].isEdit' value='1' %s>", index,
- isCheck);
- return html;
- }},
- {field: 'isQuery', title: '查询', align: 'center', width: 60, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var isCheck = row.isQuery == 1 ? 'checked' : '';
- var html = common.sprintf("<input type='checkbox' name='columns[%s].isQuery' value='1' %s>", index,
- isCheck);
- return html;
- }},
- {field: 'isList', title: '列表', align: 'center', width: 60, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var isCheck = row.isList == 1 ? 'checked' : '';
- var html = common.sprintf("<input type='checkbox' name='columns[%s].isList' value='1' %s>", index,
- isCheck);
- return html;
- }},
- {field: 'isRequired', title: '必填', align: 'center', width: 60, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var isCheck = row.isRequired == 1 ? 'checked' : '';
- var html = common.sprintf("<input type='checkbox' name='columns[%s].isRequired' value='1' %s>", index,
- isCheck);
- return html;
- }},
- {field: 'queryType', title: '查询方式', align: 'center', width: 100, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var queryType = row.queryType;
- var html = '<select name=\'columns[' + index + '].queryType\'>\n' +
- '<option value="EQ" ' + (queryType === "EQ" ? ' selected' : '') + '>=</option>\n' +
- '<option value="NE" ' + (queryType === "NE" ? ' selected' : '') + '>!=</option>\n' +
- '<option value="GT" ' + (queryType === "GT" ? ' selected' : '') + '>></option>\n' +
- '<option value="GTE" ' + (queryType === "GTE" ? ' selected' : '') + '>>=</option>\n' +
- '<option value="LT" ' + (queryType === "LT" ? ' selected' : '') + '><</option>\n' +
- '<option value="LTE" ' + (queryType === "LTE" ? ' selected' : '') + '><=</option>\n' +
- '<option value="LIKE" ' + (queryType === "LIKE" ? ' selected' : '') + '>Like</option>\n' +
- '<option value="BETWEEN" ' + (queryType === "BETWEEN" ? ' selected' : '') + '>Between</option>\n' +
- '</select>';
- return html;
- }},
- {field: 'htmlType', title: '显示类型', align: 'center', width: 100, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var htmlType = row.htmlType;
- var html = '<select name=\'columns[' + index + '].htmlType\'>\n' +
- '<option value="input" ' + (htmlType === "input" ? ' selected' : '') + '>文本框</option>\n' +
- '<option value="textarea" ' + (htmlType === "textarea" ? ' selected' : '') + '>文本域</option>\n' +
- '<option value="select" ' + (htmlType === "select" ? ' selected' : '') + '>下拉框</option>\n' +
- '<option value="radio" ' + (htmlType === "radio" ? ' selected' : '') + '>单选框</option>\n' +
- '<option value="checkbox" ' + (htmlType === "checkbox" ? ' selected' : '') + '>复选框</option>\n' +
- '<option value="datetime" ' + (htmlType === "datetime" ? ' selected' : '') + '>日期控件</option>\n' +
- '<option value="upload" ' + (htmlType === "upload" ? ' selected' : '') + '>上传控件</option>\n' +
- '</select>';
- return html;
- }},
- {field: 'dictType', title: '字典类型', align: 'center', width: 100, templet: function (row) {
- var index = row.LAY_INDEX - 1;
- var dictType = row.dictType;
- var html = '<select name=\'columns[' + index + '].dictType\' >';
- // $.ajax({
- // type: 'get',
- // url: '/system/dict/list',
- // async: false,
- // dataType: 'json',
- // success: function (res) {
- // if (res.code === 200) {
- // html += '<option value="input" >空</option>';
- // $.each(res.data, function (i, item) {
- // html += '<option value="' + item.id + '" ' + (dictType === item.id ? ' selected' : '') + '>' + item
- // .name + '</option>\n';
- // });
- // }
- // }
- // });
- html += '<option value="input">空</option>';
- html += '</select>';
- return html;
- }}
- ]
- ]
- });
- });
- }
- }
- });
- });
- form.render();
- // 关闭弹框
- $('.close').on('click', function () {
- parent.layui.tab.delCurrentTabByElem('content', function (id) {
- })
- });
- form.on('submit(save)', function(data) {
- request.http({
- url: MODULE_PATH +(data.field.id ? 'edit' : ''),
- type: 'post',
- data: data.field,
- success: function (res) {
- if (res.success) {
- popup.success(res.msg, function () {
- })
- } else {
- popup.failure(res.msg);
- }
- }
- });
- return false;
- });
- })
- </script>
- </body>
- </html>
|