<?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 $Bp1gR) { return $Bp1gR->withPageTitle('导入/更新商品信息')->withPageDescription('商品编码唯一，根据商品编码更新或新建商品')->withTemplateName('商品信息')->withTemplateData(array(array('XXXX', '测试名称')))->withHeadTitles(array('编码', '标题'))->handleImport(function ($Pg57y, $EPwwc) { $Pzx09 = ArrayPackage::build($Pg57y); $HBsr7 = array(); $HBsr7['sn'] = $Pzx09->nextTrimString(); $EUGER = array(); $EUGER['title'] = $Pzx09->nextTrimString(); ModelUtil::update('xxxx', $HBsr7, $EUGER); return Response::generateSuccess(); })->performExcel(); } public function withDialog($Plsu_ = true) { if ($Plsu_) { $this->data['frameView'] = 'modstart::admin.dialogFrame'; } else { $this->data['frameView'] = 'modstart::admin.frame'; } return $this; } public function withPageTitle($LDUKQ) { $this->data['pageTitle'] = $LDUKQ; return $this; } public function withPageDescription($VfHbQ, $mpueg = false) { goto PqyA2; PqyA2: if (!$mpueg) { $VfHbQ = HtmlUtil::text2html($VfHbQ); } goto UlKyw; X3ER4: return $this; goto cggyT; UlKyw: $this->data['pageDescription'] = $VfHbQ; goto X3ER4; cggyT: } public function withTemplateName($go2gi) { $this->data['templateName'] = $go2gi; return $this; } public function withTemplateData($YxsLg) { $this->data['templateData'] = $YxsLg; return $this; } public function withHeadTitles($Svpj_) { $this->data['headTitles'] = $Svpj_; return $this; } public function handleImport($hy4YA) { $this->importCallback = $hy4YA; 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($EPwwc = array()) { return $this->perform(null, 'common', $EPwwc); } private function perform($zZGik, $RzPgc, $EPwwc = array()) { goto AUesw; dQnw6: return view('module::Vendor.View.quickRun.import.' . $RzPgc, array_merge($this->data, array('ext' => $zZGik, 'formats' => $EPwwc['formats']))); goto vB7VD; AUesw: if (null === $zZGik) { $zZGik = 'xlsx'; } goto R1jUZ; R1jUZ: if (!isset($EPwwc['formats'])) { $EPwwc['formats'] = array('xlsx', 'csv'); } goto h22QT; vySVE: if (Request::isPost()) { goto V5p0l; V5p0l: $Pg57y = $Nw6ws->getJson('data'); goto zq4Sh; LnU1l: return call_user_func_array($this->importCallback, array($Pg57y, array())); goto nBfg_; zq4Sh: AdminPermission::demoCheck(); goto LnU1l; nBfg_: } goto dQnw6; h22QT: $Nw6ws = InputPackage::buildFromInput(); goto vySVE; vB7VD: } }