<?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 $UoHtd) { return $UoHtd->withPageTitle('导入/更新商品信息')->withPageDescription('商品编码唯一，根据商品编码更新或新建商品')->withTemplateName('商品信息')->withTemplateData(array(array('XXXX', '测试名称')))->withHeadTitles(array('编码', '标题'))->handleImport(function ($MGhSY, $quZRe) { $qWHC7 = ArrayPackage::build($MGhSY); $LUhqT = array(); $LUhqT['sn'] = $qWHC7->nextTrimString(); $vYMn8 = array(); $vYMn8['title'] = $qWHC7->nextTrimString(); ModelUtil::update('xxxx', $LUhqT, $vYMn8); return Response::generateSuccess(); })->performExcel(); } public function withDialog($XdAd6 = true) { if ($XdAd6) { $this->data['frameView'] = 'modstart::admin.dialogFrame'; } else { $this->data['frameView'] = 'modstart::admin.frame'; } return $this; } public function withPageTitle($aXgwy) { $this->data['pageTitle'] = $aXgwy; return $this; } public function withPageDescription($TqKmY, $ZR10v = false) { goto wohhG; SJZmK: $this->data['pageDescription'] = $TqKmY; goto PSgRr; PSgRr: return $this; goto bg6SV; wohhG: if (!$ZR10v) { $TqKmY = HtmlUtil::text2html($TqKmY); } goto SJZmK; bg6SV: } public function withTemplateName($yF4N4) { $this->data['templateName'] = $yF4N4; return $this; } public function withTemplateData($CJiXs) { $this->data['templateData'] = $CJiXs; return $this; } public function withHeadTitles($zhJAo) { $this->data['headTitles'] = $zhJAo; return $this; } public function handleImport($NOPYJ) { $this->importCallback = $NOPYJ; 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($quZRe = array()) { return $this->perform(null, 'common', $quZRe); } private function perform($r3sj4, $z619t, $quZRe = array()) { goto kf0bE; Jzo4W: if (!isset($quZRe['formats'])) { $quZRe['formats'] = array('xlsx', 'csv'); } goto jTG3B; jKcNT: if (Request::isPost()) { goto aJsc1; Mh151: return call_user_func_array($this->importCallback, array($MGhSY, array())); goto xNbaJ; wXtE7: AdminPermission::demoCheck(); goto Mh151; aJsc1: $MGhSY = $Q9nmo->getJson('data'); goto wXtE7; xNbaJ: } goto tIB30; tIB30: return view('module::Vendor.View.quickRun.import.' . $z619t, array_merge($this->data, array('ext' => $r3sj4, 'formats' => $quZRe['formats']))); goto PtFSD; jTG3B: $Q9nmo = InputPackage::buildFromInput(); goto jKcNT; kf0bE: if (null === $r3sj4) { $r3sj4 = 'xlsx'; } goto Jzo4W; PtFSD: } }