menu.php 7.5 KB

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