v1.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * The severityPicker 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. * 严重程度选择器(severityPicker)部件类
  14. * The severityPicker widget class
  15. */
  16. class severityPicker extends wg
  17. {
  18. /**
  19. * Define widget properties.
  20. *
  21. * @var array
  22. * @access protected
  23. */
  24. protected static $defineProps = array
  25. (
  26. 'id?: string="$GID"', // 组件根元素的 ID。
  27. 'formID?: string', // 组件隐藏的表单元素 ID。
  28. 'className?: string|array', // 类名。
  29. 'style?: array', // 样式。
  30. 'tagName?: string', // 组件根元素的标签名。
  31. 'attrs?: array', // 附加到组件根元素上的属性。
  32. 'clickType?: "toggle"|"open"', // 点击类型,`toggle` 表示点击按钮时切换显示隐藏,`open` 表示点击按钮时只打。
  33. 'afterRender?: function', // 渲染完成后的回调函数。
  34. 'beforeDestroy?: function', // 销毁前的回调函数。
  35. 'name?: string', // 作为表单项的名称。
  36. 'value?: string|string[]', // 默认值。
  37. 'onChange?: function', // 值变更回调函数。
  38. 'disabled?: boolean', // 是否禁用。
  39. 'multiple?: boolean|number=false', // 是否允许选择多个值,如果指定为数字,则限制多选的数目,默认 `false`。
  40. 'required?: boolean', // 是否必选(不允许空值,不可以被清除)。
  41. 'placeholder?: string', // 选择框上的占位文本。
  42. 'items?: string[]|array' // 选项列表,默认为 $lang->$moduleName->severityList。
  43. );
  44. /**
  45. * Build widget.
  46. *
  47. * @access protected
  48. */
  49. protected function build()
  50. {
  51. list($props, $restProps) = $this->props->split(array_keys(static::definedPropsList()));
  52. if(isset($props['id']))
  53. {
  54. $props['_id'] = $props['id'];
  55. unset($props['id']);
  56. }
  57. if(!isset($props['required']) || is_null($props['required'])) $props['required'] = true;
  58. if(!isset($props['items']))
  59. {
  60. global $app, $lang;
  61. $moduleName = $app->getModuleName();
  62. if(isset($lang->$moduleName->severityList)) $props['items'] = $lang->$moduleName->severityList;
  63. }
  64. return zui::severityPicker
  65. (
  66. set::_class('form-group-wrapper'),
  67. set::_map(array('value' => 'defaultValue', 'formID' => 'id')),
  68. set::_props($restProps),
  69. set::popWidth('100%'),
  70. set($props),
  71. $this->children()
  72. );
  73. }
  74. }