Test.php 12 KB

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