edit.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="keywords" content="">
  8. <meta name="description" content="">
  9. <title></title>
  10. <link rel="stylesheet" href="../../component/pear/css/pear.css">
  11. <link rel="stylesheet" href="../../admin/css/other/generate.css"/>
  12. <style>
  13. .layui-form-label {
  14. width: 110px;
  15. }
  16. .layui-input-block {
  17. margin-left: 140px;
  18. }
  19. .layui-form-checked i, .layui-form-checked:hover i {
  20. color: #000;
  21. font-weight: bold;
  22. }
  23. </style>
  24. </head>
  25. <body class="pear-container">
  26. <form class="layui-form" lay-filter="form-generate">
  27. <div class="mainBox">
  28. <div class="main-container">
  29. <div class="layui-row layui-col-space10">
  30. <div class="layui-col-md6">
  31. <div class="layui-card">
  32. <div class="layui-card-header">基础信息</div>
  33. <input type="hidden" name="id" />
  34. <div class="layui-card-body" style="height: 450px;">
  35. <div class="layui-form-item">
  36. <label class="layui-form-label layui-required">表名称:</label>
  37. <div class="layui-input-block">
  38. <input type="text" name="tableName" lay-verify="required"
  39. class="layui-input" placeholder="请输入表名称" maxlength="200"/>
  40. </div>
  41. </div>
  42. <div class="layui-form-item">
  43. <label class="layui-form-label layui-required">表描述:</label>
  44. <div class="layui-input-block">
  45. <input type="text" name="tableComment" lay-verify="required"
  46. class="layui-input" placeholder="请输入表描述" maxlength="500"/>
  47. </div>
  48. </div>
  49. <div class="layui-form-item">
  50. <label class="layui-form-label layui-required">实体类名:</label>
  51. <div class="layui-input-block">
  52. <input type="text" name="className" lay-verify="required"
  53. class="layui-input" placeholder="请输入实体类名称" maxlength="100"/>
  54. </div>
  55. </div>
  56. <div class="layui-form-item">
  57. <label class="layui-form-label layui-required">功能描述:</label>
  58. <div class="layui-input-block">
  59. <input type="text" name="functionName" lay-verify="required"
  60. class="layui-input" placeholder="请输入生成功能名" maxlength="50"/>
  61. </div>
  62. </div>
  63. <div class="layui-form-item">
  64. <label class="layui-form-label layui-required">作者:</label>
  65. <div class="layui-input-block">
  66. <input type="text" name="functionAuthor" lay-verify="required" lay-verType="tips"
  67. class="layui-input" placeholder="请输入作者" maxlength="50"/>
  68. </div>
  69. </div>
  70. <div class="layui-form-item">
  71. <label class="layui-form-label">备注:</label>
  72. <div class="layui-input-block">
  73. <textarea rows="5" name="remark" maxlength="500"
  74. class="layui-textarea" autocomplete="off"></textarea>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="layui-col-md6">
  81. <div class="layui-card">
  82. <div class="layui-card-header">高级配置</div>
  83. <div class="layui-card-body" style="height: 450px;overflow: auto">
  84. <div class="layui-form-item">
  85. <label class="layui-form-label layui-required">生成模板:</label>
  86. <div class="layui-input-block">
  87. <select id="tplCategory" name='tplCategory' lay-filter="tpl">
  88. <option value="crud">单表(增删改查)</option>
  89. <option value="tree">树表(增删改查)</option>
  90. </select>
  91. </div>
  92. </div>
  93. <div class="layui-form-item tree-field layui-hide">
  94. <label class="layui-form-label layui-required">主键字段:</label>
  95. <div class="layui-input-block">
  96. <input type="text" name="treeCode" maxlength="50"
  97. class="layui-input" placeholder="请输入主键字段" />
  98. </div>
  99. </div>
  100. <div class="layui-form-item tree-field layui-hide">
  101. <label class="layui-form-label">父级字段:</label>
  102. <div class="layui-input-block">
  103. <input type="text" name="treeParentCode" maxlength="50"
  104. class="layui-input" placeholder="请输入树表字段"/>
  105. </div>
  106. </div>
  107. <div class="layui-form-item">
  108. <label class="layui-form-label layui-required">基本路径:</label>
  109. <div class="layui-input-block">
  110. <input type="text" name="packageName" maxlength="100" lay-verify="required"
  111. class="layui-input" placeholder="生成在哪个java包下,例如 com.ruoyi.project.system"/>
  112. </div>
  113. </div>
  114. <div class="layui-form-item">
  115. <label class="layui-form-label layui-required">模块名称:</label>
  116. <div class="layui-input-block">
  117. <input type="text" name="moduleName" maxlength="30" lay-verify="required" lay-verType="tips"
  118. class="layui-input" placeholder="可理解为子系统名,例如 system" />
  119. </div>
  120. </div>
  121. <div class="layui-form-item">
  122. <label class="layui-form-label layui-required">业务名称:</label>
  123. <div class="layui-input-block">
  124. <input type="text" name="businessName" lay-verify="required" lay-verType="tips"
  125. class="layui-input" placeholder="可理解为功能英文名,例如 user" maxlength="50"/>
  126. </div>
  127. </div>
  128. <div class="layui-form-item">
  129. <label class="layui-form-label layui-required" title="分配到指定菜单下,例如 系统管理">上级菜单:</label>
  130. <div class="layui-input-block">
  131. <div id="tree"></div>
  132. </div>
  133. </div>
  134. <div class="layui-form-item">
  135. <label class="layui-form-label layui-required" title="默认为zip压缩包下载,也可以自定义生成路径">生成方式:</label>
  136. <div class="layui-input-block">
  137. <input type="radio" name="genType" value="0" checked title="zip压缩包"/>
  138. <input type="radio" name="genType" value="1" title="自定义路径"/>
  139. </div>
  140. </div>
  141. <div class="layui-form-item">
  142. <label class="layui-form-label layui-required" title="填写磁盘绝对路径,若不填写,则生成到当前Web项目下">生成路径:</label>
  143. <div class="layui-input-block">
  144. <input class="layui-input" id="genPath" name="genPath" type="text"
  145. placeholder="请输入项目路径" maxlength="200">
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. <div class="layui-col-md12">
  152. <div class="layui-card">
  153. <div class="layui-card-header">属性配置</div>
  154. <div class="layui-card-body">
  155. <input name="tableId" type="hidden"/>
  156. <table id="table_gen_column"></table>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. <div class="bottom">
  164. <div class="button-container">
  165. <button class="pear-btn pear-btn-sm pear-btn-primary" lay-submit lay-filter="save" id="save">保存
  166. </button>
  167. <button class="pear-btn pear-btn-sm close" type="button">关闭</button>
  168. </div>
  169. </div>
  170. </form>
  171. <script src="../../component/layui/layui.js"></script>
  172. <script src="../../component/pear/pear.js"></script>
  173. <script src="../../component/js/xm-select.js"></script>
  174. <script>
  175. layui.use(['request', 'dtree', 'common', 'table', 'form','popup'], function () {
  176. var $ = layui.jquery,
  177. request = layui.request,
  178. common = layui.common,
  179. form = layui.form,
  180. dtree = layui.dtree,
  181. table = layui.table,
  182. popup = layui.popup;
  183. var MODULE_PATH = "/generator/v1/";
  184. var menuSelectTree = xmSelect.render({
  185. el: '#tree',
  186. name: 'parentMenu', // 表单提交name
  187. model: {label: {type: 'text'}},
  188. //layVerify: 'required', // 必填
  189. clickClose: true, // 点击关闭
  190. tree: {
  191. show: true, // 是否显示树状结构
  192. showLine: false, // 是否显示虚线
  193. strict: false, // 是否严格遵守父子模式
  194. expandedKeys: [1] // 默认展开节点的数组, 为 true 时, 展开所有节点
  195. },
  196. prop: { // key value 名称修改
  197. name: 'title',
  198. value: 'id'
  199. },
  200. on: function (data) {
  201. if (data.isAdd) {
  202. return data.change.slice(0, 1)
  203. }
  204. },
  205. data: []
  206. });
  207. layer.ready(function() {
  208. request.httpGet('/system/menu/v1/selectTree', function(result) {
  209. if (result.success) {
  210. menuSelectTree.update({
  211. data: result.data,
  212. autoRow: true
  213. });
  214. var id = request.getQueryString("id");
  215. if (id) {
  216. request.httpGet(MODULE_PATH + id, function (result) {
  217. form.val('form-generate', result.data);
  218. if (result.data.parentMenu) {
  219. menuSelectTree.setValue([result.data.parentMenu]);
  220. }
  221. table.render({
  222. elem: '#table_gen_column',
  223. skin: 'line',
  224. page: false,
  225. data: result.data.columns,
  226. limit: result.data.columns.length,
  227. done: function () {
  228. form.render('select');
  229. $('.layui-table-cell>input.layui-input[type="text"]').parent().css('padding', '0px 5px');
  230. $('.layui-table-body').css('min-height', '600px');
  231. },
  232. cols: [
  233. [
  234. {title: '序号', width: 60, templet: function (row) {
  235. var index = row.LAY_INDEX - 1;
  236. var columnIdHtml = common.sprintf("<input type='hidden' name='columns[%s].id' value='%s'>", index,
  237. row.id);
  238. var sortHtml = common.sprintf(
  239. "<input type='hidden' name='columns[%s].sort' value='%s' id='columns_sort_%s'>", index, row.sort, row.id
  240. );
  241. return columnIdHtml + sortHtml + (index++);
  242. }},
  243. {field: 'columnName', title: '字段列名', width: 120},
  244. {field: 'columnComment', title: '字段描述', align: 'center', templet: function (row) {
  245. var index = row.LAY_INDEX - 1;
  246. var html = common.sprintf(
  247. "<input class='layui-input' type='text' name='columns[%s].columnComment' value='%s'>", index, row.columnComment
  248. );
  249. return html;
  250. }},
  251. {field: 'columnType', title: '物理类型', width: 120},
  252. {field: 'javaType', title: 'Java类型', align: 'center', width: 100, templet: function (row) {
  253. var index = row.LAY_INDEX - 1;
  254. var javaType = row.javaType;
  255. var html = '<select name="columns[' + index + '].javaType">' +
  256. '<option value="Long" ' + (javaType === "Long" ? ' selected' : '') + '>Long</option>' +
  257. '<option value="String" ' + (javaType === "String" ? ' selected' : '') + '>String</option>' +
  258. '<option value="Integer" ' + (javaType === "Integer" ? ' selected' : '') + '>Integer</option>' +
  259. '<option value="Double" ' + (javaType === "Double" ? ' selected' : '') + '>Double</option>' +
  260. '<option value="BigDecimal" ' + (javaType === "BigDecimal" ? ' selected' : '') + '>BigDecimal</option>' +
  261. '<option value="Date" ' + (javaType === "Date" ? ' selected' : '') + '>Date</option>' +
  262. '<option value="Boolean" ' + (javaType === "Boolean" ? ' selected' : '') + '>Boolean</option>' +
  263. '</select>';
  264. return html;
  265. }},
  266. {field: 'javaField', title: 'Java属性', align: 'center', width: 150, templet: function (row) {
  267. var index = row.LAY_INDEX - 1;
  268. var html = common.sprintf(
  269. "<input class='layui-input' type='text' name='columns[%s].javaField' value='%s' lay-verify='required' lay-verType='tips'>",
  270. index, row.javaField);
  271. return html;
  272. }},
  273. {field: 'isInsert', title: '插入', align: 'center', width: 60, templet: function (row) {
  274. var index = row.LAY_INDEX - 1;
  275. var isCheck = row.isInsert == 1 ? 'checked' : '';
  276. var html = common.sprintf("<input type='checkbox' name='columns[%s].isInsert' value='1' %s>", index,
  277. isCheck);
  278. return html;
  279. }},
  280. {field: 'isEdit', title: '编辑', align: 'center', width: 60, templet: function (row) {
  281. var index = row.LAY_INDEX - 1;
  282. var isCheck = row.isEdit == 1 ? 'checked' : '';
  283. var html = common.sprintf("<input type='checkbox' name='columns[%s].isEdit' value='1' %s>", index,
  284. isCheck);
  285. return html;
  286. }},
  287. {field: 'isQuery', title: '查询', align: 'center', width: 60, templet: function (row) {
  288. var index = row.LAY_INDEX - 1;
  289. var isCheck = row.isQuery == 1 ? 'checked' : '';
  290. var html = common.sprintf("<input type='checkbox' name='columns[%s].isQuery' value='1' %s>", index,
  291. isCheck);
  292. return html;
  293. }},
  294. {field: 'isList', title: '列表', align: 'center', width: 60, templet: function (row) {
  295. var index = row.LAY_INDEX - 1;
  296. var isCheck = row.isList == 1 ? 'checked' : '';
  297. var html = common.sprintf("<input type='checkbox' name='columns[%s].isList' value='1' %s>", index,
  298. isCheck);
  299. return html;
  300. }},
  301. {field: 'isRequired', title: '必填', align: 'center', width: 60, templet: function (row) {
  302. var index = row.LAY_INDEX - 1;
  303. var isCheck = row.isRequired == 1 ? 'checked' : '';
  304. var html = common.sprintf("<input type='checkbox' name='columns[%s].isRequired' value='1' %s>", index,
  305. isCheck);
  306. return html;
  307. }},
  308. {field: 'queryType', title: '查询方式', align: 'center', width: 100, templet: function (row) {
  309. var index = row.LAY_INDEX - 1;
  310. var queryType = row.queryType;
  311. var html = '<select name=\'columns[' + index + '].queryType\'>\n' +
  312. '<option value="EQ" ' + (queryType === "EQ" ? ' selected' : '') + '>=</option>\n' +
  313. '<option value="NE" ' + (queryType === "NE" ? ' selected' : '') + '>!=</option>\n' +
  314. '<option value="GT" ' + (queryType === "GT" ? ' selected' : '') + '>></option>\n' +
  315. '<option value="GTE" ' + (queryType === "GTE" ? ' selected' : '') + '>>=</option>\n' +
  316. '<option value="LT" ' + (queryType === "LT" ? ' selected' : '') + '><</option>\n' +
  317. '<option value="LTE" ' + (queryType === "LTE" ? ' selected' : '') + '><=</option>\n' +
  318. '<option value="LIKE" ' + (queryType === "LIKE" ? ' selected' : '') + '>Like</option>\n' +
  319. '<option value="BETWEEN" ' + (queryType === "BETWEEN" ? ' selected' : '') + '>Between</option>\n' +
  320. '</select>';
  321. return html;
  322. }},
  323. {field: 'htmlType', title: '显示类型', align: 'center', width: 100, templet: function (row) {
  324. var index = row.LAY_INDEX - 1;
  325. var htmlType = row.htmlType;
  326. var html = '<select name=\'columns[' + index + '].htmlType\'>\n' +
  327. '<option value="input" ' + (htmlType === "input" ? ' selected' : '') + '>文本框</option>\n' +
  328. '<option value="textarea" ' + (htmlType === "textarea" ? ' selected' : '') + '>文本域</option>\n' +
  329. '<option value="select" ' + (htmlType === "select" ? ' selected' : '') + '>下拉框</option>\n' +
  330. '<option value="radio" ' + (htmlType === "radio" ? ' selected' : '') + '>单选框</option>\n' +
  331. '<option value="checkbox" ' + (htmlType === "checkbox" ? ' selected' : '') + '>复选框</option>\n' +
  332. '<option value="datetime" ' + (htmlType === "datetime" ? ' selected' : '') + '>日期控件</option>\n' +
  333. '<option value="upload" ' + (htmlType === "upload" ? ' selected' : '') + '>上传控件</option>\n' +
  334. '</select>';
  335. return html;
  336. }},
  337. {field: 'dictType', title: '字典类型', align: 'center', width: 100, templet: function (row) {
  338. var index = row.LAY_INDEX - 1;
  339. var dictType = row.dictType;
  340. var html = '<select name=\'columns[' + index + '].dictType\' >';
  341. // $.ajax({
  342. // type: 'get',
  343. // url: '/system/dict/list',
  344. // async: false,
  345. // dataType: 'json',
  346. // success: function (res) {
  347. // if (res.code === 200) {
  348. // html += '<option value="input" >空</option>';
  349. // $.each(res.data, function (i, item) {
  350. // html += '<option value="' + item.id + '" ' + (dictType === item.id ? ' selected' : '') + '>' + item
  351. // .name + '</option>\n';
  352. // });
  353. // }
  354. // }
  355. // });
  356. html += '<option value="input">空</option>';
  357. html += '</select>';
  358. return html;
  359. }}
  360. ]
  361. ]
  362. });
  363. });
  364. }
  365. }
  366. });
  367. });
  368. form.render();
  369. // 关闭弹框
  370. $('.close').on('click', function () {
  371. parent.layui.tab.delCurrentTabByElem('content', function (id) {
  372. })
  373. });
  374. form.on('submit(save)', function(data) {
  375. request.http({
  376. url: MODULE_PATH +(data.field.id ? 'edit' : ''),
  377. type: 'post',
  378. data: data.field,
  379. success: function (res) {
  380. if (res.success) {
  381. popup.success(res.msg, function () {
  382. })
  383. } else {
  384. popup.failure(res.msg);
  385. }
  386. }
  387. });
  388. return false;
  389. });
  390. })
  391. </script>
  392. </body>
  393. </html>