0, 'type' => 'select', 'uploadType' => self::TYPE_FILE, 'headers' => [], 'data' => [], 'format' => [], 'show-upload-list' => false ]; /** * @var array */ protected static $propsRule = [ 'uploadType' => 'string', 'action' => 'string', 'multiple' => 'boolean', 'name' => 'string', 'accept' => 'string', 'maxSize' => 'int', 'withCredentials' => 'boolean', 'maxLength' => 'int' ]; /** * */ protected function init() { $this->name($this->field); } /** * 设置上传的请求头部 * * @param array $headers * @return $this */ public function headers(array $headers) { $this->props['headers'] = array_merge($this->props['headers'], $headers); return $this; } /** * 支持的文件类型,与 accept 不同的是, * format 是识别文件的后缀名,accept 为 input 标签原生的 accept 属性, * 会在选择文件时过滤,可以两者结合使用 * * @param array $headers * @return $this */ public function format(array $format) { $this->props['format'] = array_merge($this->props['format'], $format); return $this; } /** * 上传时附带的额外参数 * * @param array $headers * @return $this */ public function data(array $data) { $this->props['data'] = array_merge($this->props['data'], $data); return $this; } public function getPlaceHolder($pre = '请上传') { return parent::getPlaceHolder($pre); } /** * @param string|array $value * @return $this */ public function value($value) { $this->value = $value; return $this; } protected function getValidateHandler() { return Validate::arr(); } /** * @return array */ public function build() { $this->props['headers'] = (object)$this->props['headers']; $this->props['data'] = (object)$this->props['data']; return [ 'type' => $this->name, 'field' => $this->field, 'title' => $this->title, 'value' => $this->value, 'props' => (object)$this->props, 'validate' => $this->validate, 'col' => $this->col ]; } }