menu.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. $group = function()
  34. {
  35. $array = array();
  36. $menu = Dever::db('manage/menu_group')->state();
  37. if($menu)
  38. {
  39. $array += $menu;
  40. }
  41. return $array;
  42. };
  43. if (layadmin()) {
  44. $link = 'https://www.layui.com/doc/element/icon.html';
  45. } else {
  46. $link = 'http://dwz.cn/1j8SP0';
  47. }
  48. return array
  49. (
  50. # 表名
  51. 'name' => 'menu',
  52. # 显示给用户看的名称
  53. 'lang' => '管理菜单设置',
  54. 'order' => 2,
  55. //'check' => 'key',
  56. # 数据结构
  57. 'struct' => array
  58. (
  59. 'id' => array
  60. (
  61. 'type' => 'int-11',
  62. 'name' => '菜单ID',
  63. 'default' => '',
  64. 'desc' => '',
  65. 'match' => 'is_numeric',
  66. 'order' => 'desc',
  67. ),
  68. 'name' => array
  69. (
  70. 'type' => 'varchar-50',
  71. 'name' => '菜单名称',
  72. 'default' => '',
  73. 'desc' => '请输入菜单名称',
  74. 'match' => 'is_string',
  75. 'update' => 'text',
  76. 'search' => 'order,fulltext',
  77. 'list' => true,
  78. ),
  79. 'group_id' => array
  80. (
  81. 'type' => 'int-11',
  82. 'name' => '选择分组',
  83. 'default' => 1,
  84. 'desc' => '请选择选择分组',
  85. 'match' => 'is_numeric',
  86. 'update' => 'select',
  87. 'search' => 'select',
  88. 'list' => true,
  89. 'option' => $group,
  90. 'edit' => true,
  91. ),
  92. 'menu_id' => array
  93. (
  94. 'type' => 'int-11',
  95. 'name' => '上级菜单',
  96. 'default' => -1,
  97. 'desc' => '请选择上级菜单',
  98. 'match' => 'is_numeric',
  99. //'update' => 'select',
  100. //'search' => 'order,select',
  101. 'value' => Dever::input('option_menu_id', -1),
  102. 'list' => '{menu_id} > 0 ? Dever::load("manage/menu-one#name", {menu_id}) : "父级菜单"',
  103. 'option' => $menu,
  104. //'edit' => true,
  105. ),
  106. 'menu' => array
  107. (
  108. 'type' => 'varchar-800',
  109. 'name' => '上级菜单',
  110. 'default' => Dever::input('option_menu', -1),
  111. 'desc' => '请选择上级菜单',
  112. 'match' => 'is_string',
  113. 'update' => 'linkage',
  114. 'linkage' => 'id=' . Dever::input('where_id'),
  115. 'option' => Dever::url('menu.getCate', 'manage'),
  116. ),
  117. 'key' => array
  118. (
  119. 'type' => 'varchar-100',
  120. 'name' => '菜单标识-选填,可以为空,用来标识菜单的唯一性',
  121. 'default' => '',
  122. 'desc' => '请输入菜单标识',
  123. 'match' => 'option',
  124. 'update' => 'text',
  125. 'search' => 'fulltext',
  126. //'list' => true,
  127. //'modal' => 'test',
  128. ),
  129. 'link' => array
  130. (
  131. 'type' => 'varchar-150',
  132. 'name' => '链接(或路径)-选填,可以为空',
  133. 'default' => '',
  134. 'desc' => '请输入链接',
  135. 'match' => 'option',
  136. 'update' => 'text',
  137. //'search' => 'fulltext',
  138. //'list' => true,
  139. ),
  140. 'reorder' => array
  141. (
  142. 'type' => 'int-11',
  143. 'name' => '排序',
  144. 'default' => '1',
  145. 'desc' => '请输入排序',
  146. 'match' => 'option',
  147. 'update' => 'text',
  148. 'search' => 'order',
  149. 'list' => true,
  150. 'order' => 'desc',
  151. 'edit' => true,
  152. ),
  153. 'type' => array
  154. (
  155. 'type' => 'tinyint-1',
  156. 'name' => '开启子菜单',
  157. 'default' => '2',
  158. 'desc' => '请选择开启子菜单',
  159. 'match' => 'is_numeric',
  160. 'option' => $type,
  161. //'update' => 'radio',
  162. //'list' => true,
  163. ),
  164. 'icon' => array
  165. (
  166. 'type' => 'varchar-100',
  167. 'name' => '图标代码-请<a href="'.$link.'" target="_blank">点此</a>查看图标代码',
  168. 'default' => 'glyphicon glyphicon-folder-close',
  169. 'desc' => '请输入图标代码',
  170. 'match' => 'is_string',
  171. //'option' => $icon,
  172. 'update' => 'text',
  173. ),
  174. 'fast' => array
  175. (
  176. 'type' => 'tinyint-1',
  177. 'name' => '是否快捷菜单',
  178. 'default' => '2',
  179. 'desc' => '请选择快捷菜单',
  180. 'match' => 'is_numeric',
  181. 'option' => $fast,
  182. 'update' => 'radio',
  183. 'list' => true,
  184. 'edit' => true,
  185. ),
  186. 'state' => array
  187. (
  188. 'type' => 'tinyint-1',
  189. 'name' => '状态',
  190. 'default' => '1',
  191. 'desc' => '请选择状态',
  192. 'match' => 'is_numeric',
  193. ),
  194. 'cdate' => array
  195. (
  196. 'type' => 'int-11',
  197. 'name' => '录入时间',
  198. 'match' => array('is_numeric', time()),
  199. 'desc' => '',
  200. # 只有insert时才生效
  201. 'insert' => true,
  202. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  203. ),
  204. ),
  205. 'manage' => array
  206. (
  207. # 列表页的类型
  208. 'list_type' => 'tree',
  209. 'list_button' => array
  210. (
  211. 'update' => '编辑',
  212. 'add' => array('新增子菜单', '"{menu}" == -1 ? "menu&option_menu={id}" : "menu&option_menu={menu},{id}"'),
  213. 'delete' => '删除',
  214. ),
  215. 'button' => array
  216. (
  217. '更新菜单' => 'manage/menu.update',
  218. '菜单分组' => array('location', 'manage/project/database/list&project=manage&table=menu_group'),
  219. //'全部清空' => 'manage/menu.delete',
  220. ),
  221. # 每页显示条数,第一个为默认值
  222. 'num' => array(30,50,100),
  223. ),
  224. # request 请求接口定义
  225. 'request' => array
  226. (
  227. 'getAll' => array
  228. (
  229. # 匹配的正则或函数 选填项
  230. 'option' => array
  231. (
  232. 'menu_id' => 'yes',
  233. 'id' => array('yes', '!='),
  234. 'state' => 1,
  235. ),
  236. 'type' => 'all',
  237. 'order' => array('reorder' => 'desc', 'id' => 'asc'),
  238. 'col' => 'id as value, name',
  239. ),
  240. # info 取一条正常的数据
  241. 'info' => array
  242. (
  243. 'where' => array
  244. (
  245. 'id' => 'is_numeric',
  246. 'state' => 1,
  247. ),
  248. 'type' => 'one',
  249. ),
  250. 'key' => array
  251. (
  252. 'where' => array
  253. (
  254. 'key' => 'yes',
  255. ),
  256. 'type' => 'one',
  257. ),
  258. 'keyId' => array
  259. (
  260. 'where' => array
  261. (
  262. 'key' => 'yes',
  263. 'id' => array('yes', '!='),
  264. ),
  265. 'type' => 'one',
  266. ),
  267. # 取所有菜单
  268. 'all' => array
  269. (
  270. 'type' => 'all',
  271. 'order' => array('reorder` desc,`id', 'desc'),
  272. 'col' => '*|id',
  273. ),
  274. # main 取所有子菜单
  275. 'child' => array
  276. (
  277. 'where' => array
  278. (
  279. 'state' => 1,
  280. 'menu_id' => array(1, '>='),
  281. ),
  282. 'type' => 'all',
  283. 'order' => array('reorder` desc,`id', 'desc'),
  284. 'col' => '*|menu_id|key|',
  285. ),
  286. # main 取所有一级菜单
  287. 'main' => array
  288. (
  289. 'where' => array
  290. (
  291. 'state' => 1,
  292. 'menu_id' => -1,
  293. ),
  294. 'option' => array
  295. (
  296. 'key' => array('yes', 'in'),
  297. ),
  298. 'type' => 'all',
  299. 'order' => array('reorder` desc,`id', 'desc'),
  300. 'col' => '*|key',
  301. ),
  302. # main 取所有一级菜单
  303. 'get' => array
  304. (
  305. 'where' => array
  306. (
  307. 'state' => 1,
  308. 'menu_id' => -1,
  309. ),
  310. 'type' => 'all',
  311. 'order' => array('reorder` desc,`id', 'desc'),
  312. 'col' => '*|id',
  313. ),
  314. # in测试in
  315. 'in' => array
  316. (
  317. 'where' => array
  318. (
  319. 'id' => array('yes', 'in'),
  320. ),
  321. 'type' => 'all',
  322. //'order' => array('id' => 'desc'),
  323. ),
  324. ),
  325. );