self::TYPE_OTHER, 'data' => [] ]; /** * @var array */ protected static $propsRule = [ 'type' => 'string', 'disabled' => 'boolean', 'clearable' => 'boolean', 'changeOnSelect' => 'boolean', 'filterable' => 'boolean', 'transfer' => 'boolean', 'placeholder' => 'string', 'trigger' => 'string', 'size' => 'string', 'notFoundText' => 'string', ]; protected function init() { $this->placeholder($this->getPlaceHolder()); } /** * @param array $value * @return $this */ public function value($value) { if (!is_array($value)) $value = []; $this->value = $value; return $this; } /** * 可选项的数据源 * 例如:{ * "value":"北京市", "label":"北京市", "children":[{ * "value":"东城区", "label":"东城区" * }] * } * * @param array $data * @return $this */ public function data(array $data) { if (!is_array($this->props['data'])) $this->props['data'] = []; $this->props['data'] = array_merge($this->props['data'], $data); return $this; } /** * @param $var * @return $this */ public function jsData($var) { $this->props['data'] = 'js.' . $var; return $this; } /** * 获取组件类型 * * @return mixed */ public function getType() { return $this->props['type']; } /** * @return Validate */ public function getValidateHandler() { return Validate::arr(); } /** * @return array */ public function build() { return [ 'type' => $this->name, 'field' => $this->field, 'title' => $this->title, 'value' => $this->value, 'props' => (object)$this->props, 'validate' => $this->validate, 'col' => $this->col ]; } }