menu.php 6.8 KB

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