menu.php 7.0 KB

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