table.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. {extend name="common/base"/}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <form class="layui-form p-4">
  5. <h3 class="pb-3">数据表信息</h3>
  6. <table class="layui-table layui-table-form">
  7. <tr>
  8. <td class="layui-td-gray-2">数据表名称</td>
  9. <td>{$detail.title}</td>
  10. <td class="layui-td-gray-2">数据表备注</td>
  11. <td>{$detail.Comment}</td>
  12. <td class="layui-td-gray-2">当前记录数</td>
  13. <td>{$detail.Rows}</td>
  14. <td class="layui-td-gray-2">创建时间</td>
  15. <td>{$detail.Create_time}</td>
  16. </tr>
  17. </table>
  18. {neq name="$detail.c" value="0"}
  19. <h3 class="py-3">文件信息</h3>
  20. <table class="layui-table layui-table-form">
  21. <tr>
  22. <td colspan="8" class="red" style="text-align:left; line-height:1.8">
  23. 温馨提示:<br/>
  24. 1、【<strong>一键CRUD生成代码</strong>】已帮你完成 <strong>60%</strong> 以上的开发工作,以下是生成的文件所在目录。
  25. <br/>
  26. 2、可以刷新系统页面,点击左边的刚刚新增的<strong>菜单</strong>访问相关功能,如需更改菜单左侧图标,请在[系统管理]->[菜单节点]找到对应的菜单编辑修改即可。
  27. <br/>
  28. 3、代码生成以后,不建议删除(除非不需要了),建议在当前的基础上修改或新增开发,开发方式与传统的开发方式无区别。
  29. <br/>
  30. 4、CRUD生成的代码是最基础的代码,开发者通过二次开发修改,可能使得功能更完善,代码更健壮,特别是逻辑上的处理,以下是二次开发建议。
  31. <br/>
  32. 5、后端功能开发参考文档 <a href="https://www.kancloud.cn/manual/thinkphp6_0/1037479" target="_blank" class="layui-btn layui-btn-normal layui-btn-xs">ThinkPHP6开发文档</a>,前端页面开发参考文档 <a href="http://admin.gougucms.com" target="_blank" class="layui-btn layui-btn-xs">UI开发文档</a>
  33. </td>
  34. </tr>
  35. <tr>
  36. <td class="layui-td-gray-2">控制器</td>
  37. <td>{$detail.c}</td>
  38. <td class="layui-td-gray">开发建议</td>
  39. <td class="red">功能逻辑完善、控制器的其他方法的补充完善等</td>
  40. </tr>
  41. <tr>
  42. <td class="layui-td-gray-2">数据模型</td>
  43. <td>{$detail.m=='0'?'-':$detail.m}</td>
  44. <td class="layui-td-gray">开发建议</td>
  45. <td class="red">数据搜索条件完善、查询字段增减调整、关联表查询等</td>
  46. </tr>
  47. <tr>
  48. <td class="layui-td-gray-2">数据校验器</td>
  49. <td>{$detail.v=='0'?'-':$detail.v}</td>
  50. <td class="layui-td-gray">开发建议</td>
  51. <td class="red">增强数据校验规则、修改调整校验提示等</td>
  52. </tr>
  53. <tr>
  54. <td class="layui-td-gray-2">列表页面</td>
  55. <td>{$detail.l=='0'?'-':$detail.l}</td>
  56. <td class="layui-td-gray">开发建议</td>
  57. <td class="red">列表显示字段增减调整、列表字段表格宽度调整、其他按钮、链接的补充完善等</td>
  58. </tr>
  59. <tr>
  60. <td class="layui-td-gray-2">添加页面</td>
  61. <td>{$detail.a=='0'?'-':$detail.a}</td>
  62. <td class="layui-td-gray">开发建议</td>
  63. <td class="red">需要输入的字段增减调整、单选、多选、下拉选的内容调整等</td>
  64. </tr>
  65. <tr>
  66. <td class="layui-td-gray-2">编辑页面</td>
  67. <td>{$detail.e=='0'?'-':$detail.e}</td>
  68. <td class="layui-td-gray">开发建议</td>
  69. <td class="red">需要编辑的字段增减调整、单选、多选、下拉选的内容调整等</td>
  70. </tr>
  71. <tr>
  72. <td class="layui-td-gray-2">查看页面</td>
  73. <td>{$detail.r=='0'?'-':$detail.r}</td>
  74. <td class="layui-td-gray">开发建议</td>
  75. <td class="red">显示字段增减调整、其他按钮、连接的补充完善等</td>
  76. </tr>
  77. </table>
  78. <h3 class="py-3">数据表字段</h3>
  79. <table class="layui-table layui-form">
  80. <thead>
  81. <th style="text-align:center;">字段列名</th>
  82. <th style="text-align:center;">数据类型</th>
  83. <th style="text-align:center;">字段注释</th>
  84. </thead>
  85. <tbody>
  86. {volist name="columns" id="vo"}
  87. <tr>
  88. <td>{$vo.Field}</td>
  89. <td>{$vo.Type}</td>
  90. <td>{$vo.Comment}</td>
  91. </tr>
  92. {/volist}
  93. </tbody>
  94. </table>
  95. {else/}
  96. <h3 class="py-3">数据表字段</h3>
  97. <table class="layui-table layui-form">
  98. <thead>
  99. <th style="text-align:center;">字段列名</th>
  100. <th style="text-align:center;">字段注释</th>
  101. <th style="text-align:center;">数据类型</th>
  102. <th class="blue" style="text-align:center;">表单字段名称</th>
  103. <th class="blue" style="text-align:center;">是否必填</th>
  104. <th class="blue" style="text-align:center;">表单元素类型</th>
  105. <th class="green" style="text-align:center;">新增页展示</th>
  106. <th class="green" style="text-align:center;">编辑页展示</th>
  107. <th class="green" style="text-align:center;">列表页展示</th>
  108. <th class="green" style="text-align:center;">查询页展示</th>
  109. </thead>
  110. <tbody>
  111. {volist name="columns" id="vo"}
  112. <tr>
  113. <td>{$vo.Field}</td>
  114. <td>{$vo.Comment}</td>
  115. <td>{$vo.Type}</td>
  116. {eq name="$vo.Field" value="id"}
  117. <td style="text-align:center;">-</td>
  118. <td style="text-align:center;">-</td>
  119. <td style="text-align:center;">-</td>
  120. <td style="text-align:center;">-</td>
  121. <td style="text-align:center;">-</td>
  122. <td style="text-align:center;">-</td>
  123. <td style="text-align:center;">-</td>
  124. {else/}
  125. <td style="text-align:center;">
  126. <input type="hidden" name="{$vo.Field}" value="{$vo.Field}" class="crud-flie">
  127. <input type="text" name="{$vo.Field}_title" value="{$vo.name|default=''}" class="layui-input"></td>
  128. <td style="text-align:center;"><input type="checkbox" name="{$vo.Field}_required" value="1" lay-skin="primary"></td>
  129. <td>
  130. <select name="{$vo.Field}_type">
  131. <option value="input" selected="">文本框</option>
  132. <option value="textarea">多行文本</option>
  133. <option value="select">下拉框</option>
  134. <option value="radio">单选框</option>
  135. <option value="checkbox">复选框</option>
  136. <option value="summernote">富文本</option>
  137. <option value="datetime">日期控件</option>
  138. <option value="upload">上传控件</option>
  139. </select>
  140. </td>
  141. <td style="text-align:center;"><input type="checkbox" name="{$vo.Field}_add" value="{$vo.Field}" lay-skin="primary"></td>
  142. <td style="text-align:center;"><input type="checkbox" name="{$vo.Field}_edit" value="{$vo.Field}" lay-skin="primary"></td>
  143. <td style="text-align:center;"><input type="checkbox" name="{$vo.Field}_list" value="{$vo.Field}" lay-skin="primary"></td>
  144. <td style="text-align:center;"><input type="checkbox" name="{$vo.Field}_read" value="{$vo.Field}" lay-skin="primary"></td>
  145. {/eq}
  146. </tr>
  147. {/volist}
  148. </tbody>
  149. </table>
  150. <div class="py-3">
  151. <input type="hidden" name="field" value="{$detail.title}">
  152. <input type="hidden" name="name" value="{$detail.Comment}">
  153. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">一键CRUD生成代码</button>
  154. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  155. </div>
  156. {/neq}
  157. </form>
  158. {/block}
  159. <!-- /主体 -->
  160. {block name="script"}
  161. <script>
  162. const moduleInit = ['tool'];
  163. function gouguInit() {
  164. var form = layui.form,tool=layui.tool;
  165. //监听提交
  166. form.on('submit(webform)', function (data) {
  167. var arr_crud = [],crud_a=[],crud_e=[],crud_r=[],crud_l=[],crud_v=[];
  168. $('.crud-flie').each(function() {
  169. arr_crud.push($(this).val());
  170. });
  171. let isPost = true;
  172. for(var i=0;i<arr_crud.length;i++){
  173. let crud = arr_crud[i];
  174. let title = $('[name="'+crud+'_title"]').val();
  175. let type = $('[name="'+crud+'_type"]').val();
  176. let required = $('input[name="'+crud+'_required"]:checked').val();
  177. let add = $('input[name="'+crud+'_add"]:checked').val();
  178. let edit = $('input[name="'+crud+'_edit"]:checked').val();
  179. let read = $('input[name="'+crud+'_read"]:checked').val();
  180. let list = $('input[name="'+crud+'_list"]:checked').val();
  181. required=required?1:0;
  182. if(required){
  183. if(title == ''){
  184. layer.msg('字段【'+crud+'】名称不能为空');
  185. isPost = false;
  186. break;
  187. }
  188. crud_v.push({'field':crud,'type':type,'title':title});
  189. }
  190. else{
  191. required = 0;
  192. }
  193. if(add){
  194. if(title == ''){
  195. layer.msg('字段【'+crud+'】名称不能为空');
  196. isPost = false;
  197. break;
  198. }
  199. crud_a.push({'field':crud,'type':type,'required':required,'title':title});
  200. }
  201. if(edit){
  202. if(title == ''){
  203. layer.msg('字段【'+crud+'】名称不能为空');
  204. isPost = false;
  205. break;
  206. }
  207. crud_e.push({'field':crud,'type':type,'required':required,'title':title});
  208. }
  209. if(read){
  210. if(title == ''){
  211. layer.msg('字段【'+crud+'】名称不能为空');
  212. isPost = false;
  213. break;
  214. }
  215. crud_r.push({'field':crud,'type':type,'required':required,'title':title});
  216. }
  217. if(list){
  218. if(title == ''){
  219. layer.msg('字段【'+crud+'】名称不能为空');
  220. isPost = false;
  221. break;
  222. }
  223. crud_l.push({'field':crud,'type':type,'required':required,'title':title});
  224. }
  225. }
  226. //数组
  227. console.log(crud_v);
  228. console.log(crud_a);
  229. console.log(crud_e);
  230. console.log(crud_r);
  231. console.log(crud_l);
  232. if(crud_v.length==0 && isPost == true){
  233. layer.msg('必填选项不能为空');
  234. return false;
  235. }
  236. if(crud_a.length==0 && isPost == true){
  237. layer.msg('新增页展示不能为空');
  238. return false;
  239. }
  240. if(crud_e.length==0 && isPost == true){
  241. layer.msg('编辑页展示不能为空');
  242. return false;
  243. }
  244. if(crud_r.length==0 && isPost == true){
  245. layer.msg('查看页展示不能为空');
  246. return false;
  247. }
  248. if(crud_l.length==0 && isPost == true){
  249. layer.msg('列表页展示不能为空');
  250. return false;
  251. }
  252. let callback = function (e) {
  253. console.log(e);
  254. if (e == '') {
  255. layer.msg('crud生成成功,正在生成菜单...');
  256. tool.post("/admin/crud/menu", {field:data.field.field,name:data.field.name}, function(res){
  257. layer.msg(res.msg);
  258. if (res.code == 0) {
  259. setTimeout(function(){
  260. parent.location.reload();
  261. },2000);
  262. }
  263. });
  264. }
  265. else{
  266. layer.msg('代码已生成,如需重新生成,请删除后再重试');
  267. }
  268. }
  269. if(isPost == true){
  270. tool.post("/admin/crud/crud", {field:data.field.field,name:data.field.name,crud_v:crud_v,crud_a:crud_a,crud_e:crud_e,crud_r:crud_r,crud_l:crud_l}, callback);
  271. }
  272. return false;
  273. });
  274. }
  275. </script>
  276. {/block}