menu.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '可用',
  6. 2 => '不可用',
  7. );
  8. $fast = array
  9. (
  10. 1 => '是',
  11. 2 => '否',
  12. );
  13. $type = array
  14. (
  15. 1 => '开启',
  16. 2 => '不开启',
  17. );
  18. # 图标
  19. $icon = array
  20. (
  21. 1 => '默认',
  22. );
  23. $menu = function()
  24. {
  25. $array = array(-1 => array('name' => '父级菜单'));
  26. $menu = Dever::load('manage/menu-get');
  27. if($menu)
  28. {
  29. $array += $menu;
  30. }
  31. return $array;
  32. };
  33. if (layadmin()) {
  34. $link = 'https://www.layui.com/doc/element/icon.html';
  35. } else {
  36. $link = 'http://dwz.cn/1j8SP0';
  37. }
  38. return array
  39. (
  40. # 表名
  41. 'name' => 'menu',
  42. # 显示给用户看的名称
  43. 'lang' => '管理菜单设置',
  44. 'order' => 2,
  45. # 不允许key重复
  46. 'start' => array
  47. (
  48. //'update' => 'manage/menu.checkKey',
  49. //'insert' => 'manage/menu.checkKey',
  50. ),
  51. //'check' => 'key',
  52. # 数据结构
  53. 'struct' => array
  54. (
  55. 'id' => array
  56. (
  57. 'type' => 'int-11',
  58. 'name' => '菜单ID',
  59. 'default' => '',
  60. 'desc' => '',
  61. 'match' => 'is_numeric',
  62. 'order' => 'desc',
  63. ),
  64. 'name' => array
  65. (
  66. 'type' => 'varchar-50',
  67. 'name' => '菜单名称',
  68. 'default' => '',
  69. 'desc' => '请输入菜单名称',
  70. 'match' => 'is_string',
  71. 'update' => 'text',
  72. 'search' => 'order,fulltext',
  73. 'list' => true,
  74. ),
  75. 'menu_id' => array
  76. (
  77. 'type' => 'int-11',
  78. 'name' => '上级菜单',
  79. 'default' => -1,
  80. 'desc' => '请选择上级菜单',
  81. 'match' => 'is_numeric',
  82. 'update' => 'select',
  83. 'search' => 'order,select',
  84. 'list' => '{menu_id} > 0 ? Dever::load("manage/menu-one#name", {menu_id}) : "父级菜单"',
  85. 'option' => $menu,
  86. ),
  87. 'key' => array
  88. (
  89. 'type' => 'varchar-100',
  90. 'name' => '菜单唯一key',
  91. 'default' => '',
  92. 'desc' => '请输入菜单唯一key',
  93. 'match' => 'option',
  94. 'update' => 'text',
  95. 'search' => 'fulltext',
  96. 'list' => true,
  97. //'modal' => 'test',
  98. ),
  99. 'link' => array
  100. (
  101. 'type' => 'varchar-150',
  102. 'name' => '链接(或路径)',
  103. 'default' => '',
  104. 'desc' => '请输入链接',
  105. 'match' => 'is_string',
  106. 'update' => 'text',
  107. //'search' => 'fulltext',
  108. //'list' => true,
  109. ),
  110. 'reorder' => array
  111. (
  112. 'type' => 'int-11',
  113. 'name' => '排序',
  114. 'default' => '1',
  115. 'desc' => '请输入排序',
  116. 'match' => 'option',
  117. 'update' => 'text',
  118. 'search' => 'order',
  119. 'list' => true,
  120. 'order' => 'desc',
  121. 'edit' => true,
  122. ),
  123. 'type' => array
  124. (
  125. 'type' => 'tinyint-1',
  126. 'name' => '开启子菜单',
  127. 'default' => '2',
  128. 'desc' => '请选择开启子菜单',
  129. 'match' => 'is_numeric',
  130. 'option' => $type,
  131. 'update' => 'radio',
  132. 'list' => true,
  133. ),
  134. 'icon' => array
  135. (
  136. 'type' => 'varchar-100',
  137. 'name' => '图标代码-请<a href="'.$link.'" target="_blank">点此</a>查看图标代码',
  138. 'default' => 'glyphicon glyphicon-folder-close',
  139. 'desc' => '请输入图标代码',
  140. 'match' => 'is_string',
  141. //'option' => $icon,
  142. 'update' => 'text',
  143. ),
  144. 'fast' => array
  145. (
  146. 'type' => 'tinyint-1',
  147. 'name' => '是否快捷菜单',
  148. 'default' => '2',
  149. 'desc' => '请选择快捷菜单',
  150. 'match' => 'is_numeric',
  151. 'option' => $fast,
  152. 'update' => 'radio',
  153. 'list' => true,
  154. 'edit' => true,
  155. ),
  156. 'state' => array
  157. (
  158. 'type' => 'tinyint-1',
  159. 'name' => '状态',
  160. 'default' => '1',
  161. 'desc' => '请选择状态',
  162. 'match' => 'is_numeric',
  163. ),
  164. 'cdate' => array
  165. (
  166. 'type' => 'int-11',
  167. 'name' => '录入时间',
  168. 'match' => array('is_numeric', time()),
  169. 'desc' => '',
  170. # 只有insert时才生效
  171. 'insert' => true,
  172. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  173. ),
  174. ),
  175. 'manage' => array
  176. (
  177. 'list_button' => array('delete' => '删除'),
  178. 'button' => array
  179. (
  180. '更新菜单' => 'manage/menu.update',
  181. //'全部清空' => 'manage/menu.delete',
  182. ),
  183. # 每页显示条数,第一个为默认值
  184. 'num' => array(30,50,100),
  185. ),
  186. # request 请求接口定义
  187. 'request' => array
  188. (
  189. # info 取一条正常的数据
  190. 'info' => array
  191. (
  192. 'where' => array
  193. (
  194. 'id' => 'is_numeric',
  195. 'state' => 1,
  196. ),
  197. 'type' => 'one',
  198. ),
  199. 'key' => array
  200. (
  201. 'where' => array
  202. (
  203. 'key' => 'yes',
  204. ),
  205. 'type' => 'one',
  206. ),
  207. 'keyId' => array
  208. (
  209. 'where' => array
  210. (
  211. 'key' => 'yes',
  212. 'id' => array('yes', '!='),
  213. ),
  214. 'type' => 'one',
  215. ),
  216. # 取所有菜单
  217. 'all' => array
  218. (
  219. 'type' => 'all',
  220. 'order' => array('reorder` desc,`id', 'desc'),
  221. 'col' => '*|id',
  222. ),
  223. # main 取所有子菜单
  224. 'child' => array
  225. (
  226. 'where' => array
  227. (
  228. 'state' => 1,
  229. 'menu_id' => array(1, '>='),
  230. ),
  231. 'type' => 'all',
  232. 'order' => array('reorder` desc,`id', 'desc'),
  233. 'col' => '*|menu_id|key|',
  234. ),
  235. # main 取所有一级菜单
  236. 'main' => array
  237. (
  238. 'where' => array
  239. (
  240. 'state' => 1,
  241. 'menu_id' => -1,
  242. ),
  243. 'option' => array
  244. (
  245. 'key' => array('yes', 'in'),
  246. ),
  247. 'type' => 'all',
  248. 'order' => array('reorder` desc,`id', 'desc'),
  249. 'col' => '*|key',
  250. ),
  251. # main 取所有一级菜单
  252. 'get' => array
  253. (
  254. 'where' => array
  255. (
  256. 'state' => 1,
  257. 'menu_id' => -1,
  258. ),
  259. 'type' => 'all',
  260. 'order' => array('reorder` desc,`id', 'desc'),
  261. 'col' => '*|id',
  262. ),
  263. # in测试in
  264. 'in' => array
  265. (
  266. 'where' => array
  267. (
  268. 'id' => array('yes', 'in'),
  269. ),
  270. 'type' => 'all',
  271. //'order' => array('id' => 'desc'),
  272. ),
  273. ),
  274. );