v1.php 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * The datePicker 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. require_once dirname(__DIR__) . DS . 'input' . DS . 'v1.php';
  13. /**
  14. * 日期选择器(datePicker)部件类
  15. * The datePicker widget class
  16. */
  17. class datePicker extends wg
  18. {
  19. /**
  20. * Define widget properties.
  21. *
  22. * @var array
  23. * @access protected
  24. */
  25. protected static $defineProps = array
  26. (
  27. 'id?: string="$GID"', // 组件根元素的 ID。
  28. 'formID?: string', // 组件隐藏的表单元素 ID。
  29. 'className?: string|array', // 类名。
  30. 'style?: array', // 样式。
  31. 'tagName?: string', // 组件根元素的标签名。
  32. 'attrs?: array', // 附加到组件根元素上的属性。
  33. 'clickType?: "toggle"|"open"', // 点击类型,`toggle` 表示点击按钮时切换显示隐藏,`open` 表示点击按钮时只打。
  34. 'afterRender?: function', // 渲染完成后的回调函数。
  35. 'beforeDestroy?: function', // 销毁前的回调函数。
  36. 'name?: string', // 作为表单项的名称。
  37. 'value?: string|string[]', // 默认值。
  38. 'onChange?: function', // 值变更回调函数。
  39. 'disabled?: boolean', // 是否禁用。
  40. 'readonly?: boolean', // 是否只读。
  41. 'multiple?: boolean|number=false', // 是否允许选择多个值,如果指定为数字,则限制多选的数目,默认 `false`。
  42. 'required?: boolean', // 是否必选(不允许空值,不可以被清除)。
  43. 'placeholder?: string', // 选择框上的占位文本。
  44. 'format?: string', // 日期格式,默认 yyyy-MM-dd。
  45. 'display?: string|function', // 日期显示格式,指定回调函数设置显示的格式。
  46. 'icon?: string|array="calendar"', // 在输入框右侧显示的图标。
  47. 'weekNames?: string[]', // 星期名称,索引为 0 表示周日。
  48. 'monthNames?: string[]', // 月份名称,索引为 0 表示一月份。
  49. 'yearText?: string', // 用于显示年份的格式化文本。
  50. 'todayText?: string', // 用于显示“今天”的文本。
  51. 'clearText?: string', // 用于显示“清除”的文本。
  52. 'weekStart?: int', // 一周从星期几开始,默认 1。
  53. 'minDate?: string|int|function', // 最小可选的日期。
  54. 'maxDate?: string|int|function', // 最大可选的日期。
  55. 'menu?: array', // 左侧显示的菜单设置。
  56. 'actions?: array', // 底部工具栏设置。
  57. 'onInvalid?: function' // 日期值无效时的回调函数。
  58. );
  59. /**
  60. * Build the widget.
  61. *
  62. * @access protected
  63. * @return mixed
  64. */
  65. protected function build()
  66. {
  67. list($props, $restProps) = $this->props->split(array_keys(static::definedPropsList()));
  68. if(isset($props['id']))
  69. {
  70. $props['_id'] = $props['id'];
  71. unset($props['id']);
  72. }
  73. return zui::datePicker
  74. (
  75. set::_class('form-group-wrapper'),
  76. set::_map(array('value' => 'defaultValue', 'formID' => 'id')),
  77. set($props),
  78. set::_props($restProps),
  79. $this->children()
  80. );
  81. }
  82. }