<?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 $Df7Bd) { return $Df7Bd->withPageTitle('导入/更新商品信息')->withPageDescription('商品编码唯一，根据商品编码更新或新建商品')->withTemplateName('商品信息')->withTemplateData(array(array('XXXX', '测试名称')))->withHeadTitles(array('编码', '标题'))->handleImport(function ($avcnU, $w6bW5) { $pd0Ai = ArrayPackage::build($avcnU); $dNpGx = array(); $dNpGx['sn'] = $pd0Ai->nextTrimString(); $Gszjy = array(); $Gszjy['title'] = $pd0Ai->nextTrimString(); ModelUtil::update('xxxx', $dNpGx, $Gszjy); return Response::generateSuccess(); })->performExcel(); } public function withDialog($Mpi3o = true) { if ($Mpi3o) { $this->data['frameView'] = 'modstart::admin.dialogFrame'; } else { $this->data['frameView'] = 'modstart::admin.frame'; } return $this; } public function withPageTitle($lqr_d) { $this->data['pageTitle'] = $lqr_d; return $this; } public function withPageDescription($vVP5W, $lXxWA = false) { goto BVaSV; emg2G: return $this; goto VfybZ; mkYdA: $this->data['pageDescription'] = $vVP5W; goto emg2G; BVaSV: if (!$lXxWA) { $vVP5W = HtmlUtil::text2html($vVP5W); } goto mkYdA; VfybZ: } public function withTemplateName($VSb6Q) { $this->data['templateName'] = $VSb6Q; return $this; } public function withTemplateData($nwAwA) { $this->data['templateData'] = $nwAwA; return $this; } public function withHeadTitles($Eq0Re) { $this->data['headTitles'] = $Eq0Re; return $this; } public function handleImport($eIeJB) { $this->importCallback = $eIeJB; 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($w6bW5 = array()) { return $this->perform(null, 'common', $w6bW5); } private function perform($cd69r, $kF488, $w6bW5 = array()) { goto lLhEs; lLhEs: if (null === $cd69r) { $cd69r = 'xlsx'; } goto frNE3; frNE3: if (!isset($w6bW5['formats'])) { $w6bW5['formats'] = array('xlsx', 'csv'); } goto diLAa; diLAa: $Km8YS = InputPackage::buildFromInput(); goto z5XfF; DZBv0: return view('module::Vendor.View.quickRun.import.' . $kF488, array_merge($this->data, array('ext' => $cd69r, 'formats' => $w6bW5['formats']))); goto FeM7K; z5XfF: if (Request::isPost()) { goto SSBJc; SSBJc: $avcnU = $Km8YS->getJson('data'); goto PtiCK; aHgHi: return call_user_func_array($this->importCallback, array($avcnU, array())); goto swtZh; PtiCK: AdminPermission::demoCheck(); goto aHgHi; swtZh: } goto DZBv0; FeM7K: } }