v1.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * The dashboard widget class file of zin module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author sunhao<sunhao@easycorp.ltd>
  8. * @package zin
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. /**
  13. * 仪表盘(dashboard)部件类。
  14. * The dashboard widget class.
  15. *
  16. * @author Hao Sun
  17. */
  18. class dashboard extends wg
  19. {
  20. /**
  21. * Define widget properties.
  22. *
  23. * @var array
  24. * @access protected
  25. */
  26. protected static $defineProps = array(
  27. 'id?: string', // ID。
  28. 'cache?: bool|string', // 是否启用缓存。
  29. 'responsive?: bool', // 是否启用响应式。
  30. 'blocks: array', // 区块列表。
  31. 'grid?: int', // 栅格数。
  32. 'gap?: int', // 间距。
  33. 'leftStop?: int', // 区块水平停靠间隔。
  34. 'cellHeight?: int', // 网格高度。
  35. 'blockFetch?: string|function|array', // 区块数据获取 url 或选项。
  36. 'blockDefaultSize?: array', // 区块默认大小。
  37. 'blockSizeMap?: array', // 区块大小映射。
  38. 'blockMenu?: array', // 区块菜单。
  39. 'onLayoutChange?: function', // 布局变更事件。
  40. 'onlyLoadVisible?: bool', // 仅加载可见区块。
  41. 'emptyBlockContent?: array|string', // 空区块内容。
  42. 'onClickMenu?: function', // 布局变更事件。
  43. 'onLoad?: function' // 区块加载完成事件。
  44. );
  45. static $dashboardID = 0;
  46. protected function created()
  47. {
  48. $this->setDefaultProps(array('id' => static::$dashboardID ? static::$dashboardID : 'dashboard', 'cache' => data('app.user.account')));
  49. static::$dashboardID++;
  50. }
  51. /**
  52. * Build widget.
  53. */
  54. protected function build()
  55. {
  56. return zui::dashboard
  57. (
  58. set($this->props->skip(array('id'))),
  59. set('_id', $this->prop('id')),
  60. set('_props', $this->getRestProps())
  61. );
  62. }
  63. }