<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\QuickRun\Export; use ModStart\Admin\Auth\AdminPermission; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\ArrayPackage; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Core\Util\HtmlUtil; class ImportHandle { private $data = array('frameView' => 'modstart::admin.dialogFrame', 'pageTitle' => '导入数据', 'pageDescription' => '', 'templateName' => 'Template', 'templateData' => array(), 'headTitles' => array()); private $importCallback; public function example(ImportHandle $J40WC) { return $J40WC->withPageTitle('导入/更新商品信息')->withPageDescription('商品编码唯一，根据商品编码更新或新建商品')->withTemplateName('商品信息')->withTemplateData(array(array('XXXX', '测试名称')))->withHeadTitles(array('编码', '标题'))->handleImport(function ($U8wjN, $qOrzw) { $owryS = ArrayPackage::build($U8wjN); $xAO9M = array(); $xAO9M['sn'] = $owryS->nextTrimString(); $chyCL = array(); $chyCL['title'] = $owryS->nextTrimString(); ModelUtil::update('xxxx', $xAO9M, $chyCL); return Response::generateSuccess(); })->performExcel(); } public function withDialog($K10pP = true) { if ($K10pP) { $this->data['frameView'] = 'modstart::admin.dialogFrame'; } else { $this->data['frameView'] = 'modstart::admin.frame'; } return $this; } public function withPageTitle($dhknk) { $this->data['pageTitle'] = $dhknk; return $this; } public function withPageDescription($IXdxS, $brBgK = false) { goto TSUJp; FePeX: return $this; goto B1ZQF; TSUJp: if (!$brBgK) { $IXdxS = HtmlUtil::text2html($IXdxS); } goto x50xS; x50xS: $this->data['pageDescription'] = $IXdxS; goto FePeX; B1ZQF: } public function withTemplateName($xODr1) { $this->data['templateName'] = $xODr1; return $this; } public function withTemplateData($QmY2j) { $this->data['templateData'] = $QmY2j; return $this; } public function withHeadTitles($vQNyr) { $this->data['headTitles'] = $vQNyr; return $this; } public function handleImport($GdSl0) { $this->importCallback = $GdSl0; return $this; } public function performExcel() { return $this->perform('xlsx', 'common', array('formats' => array('xlsx'))); } public function performCsv() { return $this->perform('csv', 'common', array('formats' => array('csv'))); } public function performCommon($qOrzw = array()) { return $this->perform(null, 'common', $qOrzw); } private function perform($ofwGA, $qVdRh, $qOrzw = array()) { goto BP3Rj; xrt3O: if (!isset($qOrzw['formats'])) { $qOrzw['formats'] = array('xlsx', 'csv'); } goto ihhhP; KEclu: return view('module::Vendor.View.quickRun.import.' . $qVdRh, array_merge($this->data, array('ext' => $ofwGA, 'formats' => $qOrzw['formats']))); goto ullrj; ihhhP: $WZ8dY = InputPackage::buildFromInput(); goto KR0OE; BP3Rj: if (null === $ofwGA) { $ofwGA = 'xlsx'; } goto xrt3O; KR0OE: if (Request::isPost()) { goto Y6rQk; FzY5S: AdminPermission::demoCheck(); goto OCQ0S; Y6rQk: $U8wjN = $WZ8dY->getJson('data'); goto FzY5S; OCQ0S: return call_user_func_array($this->importCallback, array($U8wjN, array())); goto DEcbq; DEcbq: } goto KEclu; ullrj: } }