menu.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. return array
  34. (
  35. # 表名
  36. 'name' => 'menu',
  37. # 显示给用户看的名称
  38. 'lang' => '管理菜单设置',
  39. 'order' => 2,
  40. # 不允许key重复
  41. 'start' => array
  42. (
  43. //'update' => 'manage/menu.checkKey',
  44. //'insert' => 'manage/menu.checkKey',
  45. ),
  46. //'check' => 'key',
  47. # 数据结构
  48. 'struct' => array
  49. (
  50. 'id' => array
  51. (
  52. 'type' => 'int-11',
  53. 'name' => '菜单ID',
  54. 'default' => '',
  55. 'desc' => '',
  56. 'match' => 'is_numeric',
  57. 'order' => 'desc',
  58. ),
  59. 'name' => array
  60. (
  61. 'type' => 'varchar-50',
  62. 'name' => '菜单名称',
  63. 'default' => '',
  64. 'desc' => '请输入菜单名称',
  65. 'match' => 'is_string',
  66. 'update' => 'text',
  67. 'search' => 'order,fulltext',
  68. 'list' => true,
  69. ),
  70. 'menu_id' => array
  71. (
  72. 'type' => 'int-11',
  73. 'name' => '上级菜单',
  74. 'default' => -1,
  75. 'desc' => '请选择上级菜单',
  76. 'match' => 'is_numeric',
  77. 'update' => 'select',
  78. 'search' => 'order,select',
  79. 'list' => '{menu_id} > 0 ? Dever::load("manage/menu-one#name", {menu_id}) : "父级菜单"',
  80. 'option' => $menu,
  81. ),
  82. 'key' => array
  83. (
  84. 'type' => 'varchar-100',
  85. 'name' => '菜单唯一key',
  86. 'default' => '',
  87. 'desc' => '请输入菜单唯一key',
  88. 'match' => 'option',
  89. 'update' => 'text',
  90. 'search' => 'fulltext',
  91. 'list' => true,
  92. //'modal' => 'test',
  93. ),
  94. 'link' => array
  95. (
  96. 'type' => 'varchar-150',
  97. 'name' => '链接(或路径)',
  98. 'default' => '',
  99. 'desc' => '请输入链接',
  100. 'match' => 'is_string',
  101. 'update' => 'text',
  102. //'search' => 'fulltext',
  103. //'list' => true,
  104. ),
  105. 'reorder' => array
  106. (
  107. 'type' => 'int-11',
  108. 'name' => '排序',
  109. 'default' => '1',
  110. 'desc' => '请输入排序',
  111. 'match' => 'option',
  112. 'update' => 'text',
  113. 'search' => 'order',
  114. 'list' => true,
  115. 'order' => 'desc',
  116. 'edit' => true,
  117. ),
  118. 'type' => array
  119. (
  120. 'type' => 'tinyint-1',
  121. 'name' => '开启子菜单',
  122. 'default' => '2',
  123. 'desc' => '请选择开启子菜单',
  124. 'match' => 'is_numeric',
  125. 'option' => $type,
  126. 'update' => 'radio',
  127. 'list' => true,
  128. ),
  129. 'icon' => array
  130. (
  131. 'type' => 'varchar-100',
  132. 'name' => '图标代码-请<a href="http://dwz.cn/1j8SP0" target="_blank">点此</a>查看图标代码',
  133. 'default' => 'glyphicon glyphicon-folder-close',
  134. 'desc' => '请输入图标代码',
  135. 'match' => 'is_string',
  136. //'option' => $icon,
  137. 'update' => 'text',
  138. ),
  139. 'fast' => array
  140. (
  141. 'type' => 'tinyint-1',
  142. 'name' => '是否快捷菜单',
  143. 'default' => '2',
  144. 'desc' => '请选择快捷菜单',
  145. 'match' => 'is_numeric',
  146. 'option' => $fast,
  147. 'update' => 'radio',
  148. 'list' => true,
  149. 'edit' => true,
  150. ),
  151. 'state' => array
  152. (
  153. 'type' => 'tinyint-1',
  154. 'name' => '状态',
  155. 'default' => '1',
  156. 'desc' => '请选择状态',
  157. 'match' => 'is_numeric',
  158. ),
  159. 'cdate' => array
  160. (
  161. 'type' => 'int-11',
  162. 'name' => '录入时间',
  163. 'match' => array('is_numeric', time()),
  164. 'desc' => '',
  165. # 只有insert时才生效
  166. 'insert' => true,
  167. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  168. ),
  169. ),
  170. 'manage' => array
  171. (
  172. 'list_button' => array('delete' => '删除'),
  173. 'button' => array
  174. (
  175. '更新菜单' => 'manage/menu.update',
  176. //'全部清空' => 'manage/menu.delete',
  177. ),
  178. # 每页显示条数,第一个为默认值
  179. 'num' => array(30,50,100),
  180. ),
  181. # request 请求接口定义
  182. 'request' => array
  183. (
  184. # info 取一条正常的数据
  185. 'info' => array
  186. (
  187. 'where' => array
  188. (
  189. 'id' => 'is_numeric',
  190. 'state' => 1,
  191. ),
  192. 'type' => 'one',
  193. ),
  194. 'key' => array
  195. (
  196. 'where' => array
  197. (
  198. 'key' => 'yes',
  199. ),
  200. 'type' => 'one',
  201. ),
  202. 'keyId' => array
  203. (
  204. 'where' => array
  205. (
  206. 'key' => 'yes',
  207. 'id' => array('yes', '!='),
  208. ),
  209. 'type' => 'one',
  210. ),
  211. # 取所有菜单
  212. 'all' => array
  213. (
  214. 'type' => 'all',
  215. 'order' => array('reorder` desc,`id', 'desc'),
  216. 'col' => '*|id',
  217. ),
  218. # main 取所有子菜单
  219. 'child' => array
  220. (
  221. 'where' => array
  222. (
  223. 'state' => 1,
  224. 'menu_id' => array(1, '>='),
  225. ),
  226. 'type' => 'all',
  227. 'order' => array('reorder` desc,`id', 'desc'),
  228. 'col' => '*|menu_id|key|',
  229. ),
  230. # main 取所有一级菜单
  231. 'main' => array
  232. (
  233. 'where' => array
  234. (
  235. 'state' => 1,
  236. 'menu_id' => -1,
  237. ),
  238. 'option' => array
  239. (
  240. 'key' => array('yes', 'in'),
  241. ),
  242. 'type' => 'all',
  243. 'order' => array('reorder` desc,`id', 'desc'),
  244. 'col' => '*|key',
  245. ),
  246. # main 取所有一级菜单
  247. 'get' => array
  248. (
  249. 'where' => array
  250. (
  251. 'state' => 1,
  252. 'menu_id' => -1,
  253. ),
  254. 'type' => 'all',
  255. 'order' => array('reorder` desc,`id', 'desc'),
  256. 'col' => '*|id',
  257. ),
  258. # in测试in
  259. 'in' => array
  260. (
  261. 'where' => array
  262. (
  263. 'id' => array('yes', 'in'),
  264. ),
  265. 'type' => 'all',
  266. //'order' => array('id' => 'desc'),
  267. ),
  268. ),
  269. );