<?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 $XqHFV) { return $XqHFV->withPageTitle('导入/更新商品信息')->withPageDescription('商品编码唯一，根据商品编码更新或新建商品')->withTemplateName('商品信息')->withTemplateData(array(array('XXXX', '测试名称')))->withHeadTitles(array('编码', '标题'))->handleImport(function ($smBDO, $KJ3xr) { $xAW3P = ArrayPackage::build($smBDO); $J3gqh = array(); $J3gqh['sn'] = $xAW3P->nextTrimString(); $xo6i2 = array(); $xo6i2['title'] = $xAW3P->nextTrimString(); ModelUtil::update('xxxx', $J3gqh, $xo6i2); return Response::generateSuccess(); })->performExcel(); } public function withDialog($LYsql = true) { if ($LYsql) { $this->data['frameView'] = 'modstart::admin.dialogFrame'; } else { $this->data['frameView'] = 'modstart::admin.frame'; } return $this; } public function withPageTitle($vB4op) { $this->data['pageTitle'] = $vB4op; return $this; } public function withPageDescription($oj07D, $V9g2u = false) { goto PlvrD; PlvrD: if (!$V9g2u) { $oj07D = HtmlUtil::text2html($oj07D); } goto leMfg; leMfg: $this->data['pageDescription'] = $oj07D; goto LZ188; LZ188: return $this; goto PVRgy; PVRgy: } public function withTemplateName($uFS5C) { $this->data['templateName'] = $uFS5C; return $this; } public function withTemplateData($JKXDQ) { $this->data['templateData'] = $JKXDQ; return $this; } public function withHeadTitles($D8A4I) { $this->data['headTitles'] = $D8A4I; return $this; } public function handleImport($k8RFa) { $this->importCallback = $k8RFa; 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($KJ3xr = array()) { return $this->perform(null, 'common', $KJ3xr); } private function perform($yTRYd, $wFt7y, $KJ3xr = array()) { goto keIxW; oGd0v: return view('module::Vendor.View.quickRun.import.' . $wFt7y, array_merge($this->data, array('ext' => $yTRYd, 'formats' => $KJ3xr['formats']))); goto CYoE7; keIxW: if (null === $yTRYd) { $yTRYd = 'xlsx'; } goto FjOdg; zHu2O: $Ylazq = InputPackage::buildFromInput(); goto tkCkQ; FjOdg: if (!isset($KJ3xr['formats'])) { $KJ3xr['formats'] = array('xlsx', 'csv'); } goto zHu2O; tkCkQ: if (Request::isPost()) { goto XL5XS; X9f53: AdminPermission::demoCheck(); goto pIzMB; XL5XS: $smBDO = $Ylazq->getJson('data'); goto X9f53; pIzMB: return call_user_func_array($this->importCallback, array($smBDO, array())); goto uTPRw; uTPRw: } goto oGd0v; CYoE7: } }