menu.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. 'value' => Dever::input('option_menu_id', -1),
  85. 'list' => '{menu_id} > 0 ? Dever::load("manage/menu-one#name", {menu_id}) : "父级菜单"',
  86. 'option' => $menu,
  87. ),
  88. 'menu' => array
  89. (
  90. 'type' => 'varchar-800',
  91. 'name' => '上级菜单',
  92. 'default' => Dever::input('option_menu', -1),
  93. 'desc' => '请选择上级菜单',
  94. 'match' => 'is_string',
  95. 'update' => 'linkage',
  96. 'linkage' => 'id=' . Dever::input('where_id'),
  97. 'option' => Dever::url('menu.getCate', 'manage'),
  98. ),
  99. 'key' => array
  100. (
  101. 'type' => 'varchar-100',
  102. 'name' => '菜单唯一key',
  103. 'default' => '',
  104. 'desc' => '请输入菜单唯一key',
  105. 'match' => 'option',
  106. 'update' => 'text',
  107. 'search' => 'fulltext',
  108. //'list' => true,
  109. //'modal' => 'test',
  110. ),
  111. 'link' => array
  112. (
  113. 'type' => 'varchar-150',
  114. 'name' => '链接(或路径)',
  115. 'default' => '',
  116. 'desc' => '请输入链接',
  117. 'match' => 'is_string',
  118. 'update' => 'text',
  119. //'search' => 'fulltext',
  120. //'list' => true,
  121. ),
  122. 'reorder' => array
  123. (
  124. 'type' => 'int-11',
  125. 'name' => '排序',
  126. 'default' => '1',
  127. 'desc' => '请输入排序',
  128. 'match' => 'option',
  129. 'update' => 'text',
  130. 'search' => 'order',
  131. 'list' => true,
  132. 'order' => 'desc',
  133. 'edit' => true,
  134. ),
  135. 'type' => array
  136. (
  137. 'type' => 'tinyint-1',
  138. 'name' => '开启子菜单',
  139. 'default' => '2',
  140. 'desc' => '请选择开启子菜单',
  141. 'match' => 'is_numeric',
  142. 'option' => $type,
  143. //'update' => 'radio',
  144. //'list' => true,
  145. ),
  146. 'icon' => array
  147. (
  148. 'type' => 'varchar-100',
  149. 'name' => '图标代码-请<a href="'.$link.'" target="_blank">点此</a>查看图标代码',
  150. 'default' => 'glyphicon glyphicon-folder-close',
  151. 'desc' => '请输入图标代码',
  152. 'match' => 'is_string',
  153. //'option' => $icon,
  154. 'update' => 'text',
  155. ),
  156. 'fast' => array
  157. (
  158. 'type' => 'tinyint-1',
  159. 'name' => '是否快捷菜单',
  160. 'default' => '2',
  161. 'desc' => '请选择快捷菜单',
  162. 'match' => 'is_numeric',
  163. 'option' => $fast,
  164. 'update' => 'radio',
  165. 'list' => true,
  166. 'edit' => true,
  167. ),
  168. 'state' => array
  169. (
  170. 'type' => 'tinyint-1',
  171. 'name' => '状态',
  172. 'default' => '1',
  173. 'desc' => '请选择状态',
  174. 'match' => 'is_numeric',
  175. ),
  176. 'cdate' => array
  177. (
  178. 'type' => 'int-11',
  179. 'name' => '录入时间',
  180. 'match' => array('is_numeric', time()),
  181. 'desc' => '',
  182. # 只有insert时才生效
  183. 'insert' => true,
  184. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  185. ),
  186. ),
  187. 'manage' => array
  188. (
  189. # 列表页的类型
  190. 'list_type' => 'tree',
  191. 'list_button' => array
  192. (
  193. 'update' => '编辑',
  194. 'add' => array('新增子菜单', '"{menu}" == -1 ? "menu&option_menu={id}" : "menu&option_menu={menu},{id}"'),
  195. 'delete' => '删除',
  196. ),
  197. 'button' => array
  198. (
  199. '更新菜单' => 'manage/menu.update',
  200. //'全部清空' => 'manage/menu.delete',
  201. ),
  202. # 每页显示条数,第一个为默认值
  203. 'num' => array(30,50,100),
  204. ),
  205. # request 请求接口定义
  206. 'request' => array
  207. (
  208. 'getAll' => array
  209. (
  210. # 匹配的正则或函数 选填项
  211. 'option' => array
  212. (
  213. 'menu_id' => 'yes',
  214. 'id' => array('yes', '!='),
  215. 'state' => 1,
  216. ),
  217. 'type' => 'all',
  218. 'order' => array('reorder' => 'desc', 'id' => 'asc'),
  219. 'col' => 'id as value, name',
  220. ),
  221. # info 取一条正常的数据
  222. 'info' => array
  223. (
  224. 'where' => array
  225. (
  226. 'id' => 'is_numeric',
  227. 'state' => 1,
  228. ),
  229. 'type' => 'one',
  230. ),
  231. 'key' => array
  232. (
  233. 'where' => array
  234. (
  235. 'key' => 'yes',
  236. ),
  237. 'type' => 'one',
  238. ),
  239. 'keyId' => array
  240. (
  241. 'where' => array
  242. (
  243. 'key' => 'yes',
  244. 'id' => array('yes', '!='),
  245. ),
  246. 'type' => 'one',
  247. ),
  248. # 取所有菜单
  249. 'all' => array
  250. (
  251. 'type' => 'all',
  252. 'order' => array('reorder` desc,`id', 'desc'),
  253. 'col' => '*|id',
  254. ),
  255. # main 取所有子菜单
  256. 'child' => array
  257. (
  258. 'where' => array
  259. (
  260. 'state' => 1,
  261. 'menu_id' => array(1, '>='),
  262. ),
  263. 'type' => 'all',
  264. 'order' => array('reorder` desc,`id', 'desc'),
  265. 'col' => '*|menu_id|key|',
  266. ),
  267. # main 取所有一级菜单
  268. 'main' => array
  269. (
  270. 'where' => array
  271. (
  272. 'state' => 1,
  273. 'menu_id' => -1,
  274. ),
  275. 'option' => array
  276. (
  277. 'key' => array('yes', 'in'),
  278. ),
  279. 'type' => 'all',
  280. 'order' => array('reorder` desc,`id', 'desc'),
  281. 'col' => '*|key',
  282. ),
  283. # main 取所有一级菜单
  284. 'get' => array
  285. (
  286. 'where' => array
  287. (
  288. 'state' => 1,
  289. 'menu_id' => -1,
  290. ),
  291. 'type' => 'all',
  292. 'order' => array('reorder` desc,`id', 'desc'),
  293. 'col' => '*|id',
  294. ),
  295. # in测试in
  296. 'in' => array
  297. (
  298. 'where' => array
  299. (
  300. 'id' => array('yes', 'in'),
  301. ),
  302. 'type' => 'all',
  303. //'order' => array('id' => 'desc'),
  304. ),
  305. ),
  306. );