label = $label; $this->name = $name; JsFacade::registerLayUIModule('upload'); } /** * 获取html * @return mixed|string */ public function getHtml() { return <<{$this->getLabel()}
{$this->getForm()}
HTML; } /** * 获取label * @return string */ private function getLabel() { return Basics::indentAndLineFeed(4, Basics::BEFORE) . ""; } /** * 获取表单html文本 * @return string */ private function getForm() { JsFacade::layUICode($this->upLoadJs()); JsFacade::resetCode($this->resetCode()); $html = <<
{:lang('preview')}:
IMG; return $html . Basics::indentAndLineFeed(4, Basics::BEFORE); } /** * 多图上传的 js文件 * @return string */ private function upLoadJs() { return <<name} = custom.moreUpload($, '{$this->name}', upload).init(); JST; } private function resetCode() { $init = $this->default ? "'{\$data.{$this->name}}'.split(',')" : ''; return <<name}.init($init); JST; } /** * 设置默认值 * @param $value * @return mixed */ public function setDefault($value) { $value and $this->default = $value; return $this; } }