Test.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <?php namespace Manage\Lib;
  2. use Dever;
  3. use Dever\Helper\Str;
  4. use Dever\Helper\Env;
  5. use Dever\Helper\Secure;
  6. use Dever\Helper\Date;
  7. class Test
  8. {
  9. # 仅为测试用
  10. public function out($data)
  11. {
  12. $result = [];
  13. $result['head'] = ['id', '姓名', '时间'];
  14. $result['body'] = [];
  15. foreach ($data['body'] as $k => $v) {
  16. $result['body'][$k] = [$v['id'], $v['name'], $v['cdate']];
  17. }
  18. return $result;
  19. }
  20. # 仅为测试用,展示表格更多内容
  21. public function show($data)
  22. {
  23. # 返回类型:string字符串,table表格,card卡片,desc描述,list列表
  24. $result['type'] = 'string';
  25. $result['content'] = 'ddddd';
  26. $result['type'] = 'table';
  27. $result['head'] = ['id' => 'id', 'name' => '姓名'];
  28. $result['body'] = array
  29. (
  30. ['id' => '1', 'name' => 'test'],
  31. ['id' => '2', 'name' => 'test2'],
  32. );
  33. $result['type'] = 'card';
  34. $result['content'] = array();
  35. $result['content'][] = array
  36. (
  37. 'title' => '订单信息',
  38. 'shadow' => 'never',//always | never | hover
  39. 'content' => [
  40. '1111',
  41. '2222',
  42. ],
  43. );
  44. $result['type'] = 'list';
  45. $result['content'] = array
  46. (
  47. ['日志类型', 'test'],
  48. ['姓名', 'test1'],
  49. );
  50. return $result;
  51. }
  52. # 仅为测试用,展示表格更多内容
  53. public function show2($data)
  54. {
  55. return ['name' => '查看详情', 'content' => $this->show($data)];
  56. }
  57. # 仅为测试用,展示详情
  58. public function view($page)
  59. {
  60. # 这里获取基本信息
  61. //print_r($page->info);die;
  62. $info[] = array
  63. (
  64. # 类型,info信息 desc描述 table表格,表格有head和body即可
  65. /*
  66. 'type' => 'info',
  67. 'name' => '资源订单',
  68. 'info' => '订单',
  69. # 右侧按钮
  70. 'button' => $button,
  71. # 具体内容
  72. 'content' => [
  73. ['name' => '订单状态', 'value' => '未完成'],
  74. ['name' => '实际支付', 'value' => '¥ 15.00'],
  75. ['name' => '支付方式', 'value' => '余额'],
  76. ['name' => '支付时间', 'value' => '2025-06-03 06:46:15'],
  77. ],*/
  78. 'type' => 'desc',
  79. 'name' => '基本信息',
  80. # 每行展示数量
  81. 'column' => 4,
  82. # 是否有边框
  83. 'border' => true,
  84. # 排列方向:horizontal横向 vertical纵向
  85. 'direction' => 'horizontal',
  86. # 右侧按钮
  87. 'button' => array
  88. (
  89. array
  90. (
  91. 'name' => '编辑',
  92. # fastedit、fastadd、oper、api、link、route,参数与list里的data_button一致,多了一个load,可以单独设置路由
  93. 'type' => 'fastedit',
  94. 'path' => 'platform/role',
  95. # 增加权限,第三个参数是排序,建议大一些
  96. //'func' => $page->getFunc('view_fastedit', '详情页-编辑角色', 1000),
  97. # 这里是按钮用到的参数数据
  98. 'row' => [
  99. 'id' => 1,
  100. ],
  101. ),
  102. ),
  103. # 具体内容
  104. 'content' => array
  105. (
  106. [
  107. 'name' => '标题',
  108. # 类型,text普通文本,tag标签,link链接,image图片 progress进度条 stat统计 timeline时间线 table表格
  109. 'type' => 'text',
  110. 'content' => '内容',
  111. # 样式primary success warning danger info exception
  112. 'style' => 'primary',
  113. ],
  114. [
  115. 'name' => '标题',
  116. 'type' => 'tag',
  117. 'content' => '内容',
  118. 'style' => 'warning',
  119. ],
  120. [
  121. 'name' => '标题',
  122. 'type' => 'link',
  123. 'content' => '内容',
  124. ],
  125. [
  126. 'name' => '图片',
  127. 'type' => 'image',
  128. 'content' => 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
  129. # 'fill', 'contain', 'cover', 'none', 'scale-down'
  130. 'fit' => 'fill',
  131. ],
  132. [
  133. 'name' => '进度条',
  134. 'type' => 'progress',
  135. 'content' => '10',
  136. 'style' => 'exception',
  137. 'width' => '20',
  138. 'inside' => true,
  139. # line dashboard 仪表盘 circle 圆形
  140. 'show' => 'line',
  141. # 开启条纹
  142. 'striped' => true,
  143. # 开启动画
  144. 'indeterminate' => true,
  145. ],
  146. array
  147. (
  148. 'name' => '统计',
  149. 'type' => 'stat',
  150. 'content' => array
  151. (
  152. [
  153. # 一共24
  154. 'span' => '6',
  155. 'name' => '测试',
  156. 'value' => '1000',
  157. ],
  158. [
  159. 'span' => '6',
  160. 'name' => '测试1',
  161. 'value' => '1000',
  162. ],
  163. [
  164. 'span' => '6',
  165. 'name' => '测试2',
  166. 'value' => '1000',
  167. ],
  168. [
  169. 'span' => '6',
  170. 'name' => '测试2',
  171. 'value' => '1000',
  172. ],
  173. ),
  174. ),
  175. array
  176. (
  177. 'name' => '时间线',
  178. 'type' => 'timeline',
  179. 'content' => array
  180. (
  181. [
  182. 'time' => '2020-10-11',
  183. 'name' => '测试',
  184. 'color' => '#0bbd87',
  185. 'size' => 'large',
  186. 'type' => 'primary',
  187. 'hollow' => true,
  188. ],
  189. [
  190. 'time' => '2020-10-11',
  191. 'name' => '测试',
  192. ],
  193. [
  194. 'time' => '2020-10-11',
  195. 'name' => '测试',
  196. ],
  197. [
  198. 'time' => '2020-10-11',
  199. 'name' => '测试',
  200. ],
  201. ),
  202. ),
  203. array
  204. (
  205. 'name' => '表格',
  206. 'type' => 'table',
  207. 'border' => true,
  208. 'height' => '200',
  209. 'head' => array
  210. (
  211. [
  212. 'key' => 'name',
  213. 'name' => '姓名',
  214. 'fixed' => 'fixed',
  215. ],
  216. [
  217. 'key' => 'desc',
  218. 'name' => '描述',
  219. 'fixed' => 'fixed',
  220. ],
  221. ),
  222. 'button' => array
  223. (
  224. [
  225. 'name' => '编辑',
  226. 'type' => 'fastedit',
  227. 'load' => 'platform/role',
  228. ],
  229. ),
  230. 'body' => array
  231. (
  232. [
  233. 'id' => 1,
  234. 'name' => 'test',
  235. 'desc' => 'dfdf',
  236. ],
  237. ),
  238. ),
  239. ),
  240. );
  241. $info[] = array
  242. (
  243. 'type' => 'table',
  244. 'name' => '表格信息',
  245. 'border' => true,
  246. 'height' => '200',
  247. 'head' => array
  248. (
  249. [
  250. 'key' => 'name',
  251. 'name' => '姓名',
  252. 'fixed' => 'fixed',
  253. ],
  254. [
  255. 'key' => 'desc',
  256. 'name' => '描述',
  257. 'fixed' => 'fixed',
  258. ],
  259. ),
  260. 'button' => array
  261. (
  262. array
  263. (
  264. 'name' => '编辑',
  265. 'type' => 'fastedit',
  266. 'load' => 'platform/role',
  267. # 增加权限,第三个参数是排序,建议大一些
  268. 'func' => $page->getFunc('view_fastedit', '详情页-编辑角色', 1000),
  269. ),
  270. ),
  271. 'body' => array
  272. (
  273. [
  274. 'id' => 1,
  275. 'name' => 'test',
  276. 'desc' => 'dfdf',
  277. ],
  278. ),
  279. );
  280. $tab = array
  281. (
  282. 'active' => 'table1',
  283. 'content' => array
  284. (
  285. 'table1' => [
  286. # 这里跟desc一样
  287. 'name' => '标题',
  288. 'type' => 'text',
  289. 'content' => '内容',
  290. 'style' => 'primary',
  291. ],
  292. 'tab2' => array
  293. (
  294. 'name' => '表格',
  295. 'type' => 'table',
  296. 'border' => true,
  297. 'height' => '200',
  298. 'head' => array
  299. (
  300. [
  301. 'key' => 'name',
  302. 'name' => '姓名',
  303. 'fixed' => 'fixed',
  304. ],
  305. [
  306. 'key' => 'desc',
  307. 'name' => '描述',
  308. 'fixed' => 'fixed',
  309. ],
  310. ),
  311. 'button' => array
  312. (
  313. [
  314. 'name' => '编辑',
  315. 'type' => 'fastedit',
  316. 'load' => 'platform/role',
  317. ],
  318. ),
  319. 'body' => array
  320. (
  321. [
  322. 'id' => 1,
  323. 'name' => 'test',
  324. 'desc' => 'dfdf',
  325. ],
  326. ),
  327. ),
  328. )
  329. );
  330. return ['title' => '详情', 'info' => $info, 'tab' => $tab];
  331. }
  332. public function stat($where)
  333. {
  334. return array
  335. (
  336. [
  337. # 一共24
  338. 'span' => '8',
  339. 'name' => '测试',
  340. 'value' => '1000',
  341. ],
  342. [
  343. 'span' => '8',
  344. 'name' => '测试1',
  345. 'value' => '1000',
  346. ],
  347. [
  348. 'span' => '8',
  349. 'name' => '测试2',
  350. 'value' => '1000',
  351. ],
  352. );
  353. }
  354. # 自定义页面
  355. public function diy($data = [])
  356. {
  357. # 里面的类型参考diy.php
  358. return $result;
  359. }
  360. }