<?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 $QTCDn) { return $QTCDn->withPageTitle('导入/更新商品信息')->withPageDescription('商品编码唯一，根据商品编码更新或新建商品')->withTemplateName('商品信息')->withTemplateData(array(array('XXXX', '测试名称')))->withHeadTitles(array('编码', '标题'))->handleImport(function ($q62oK, $mzzZ3) { $jveNw = ArrayPackage::build($q62oK); $bQDKx = array(); $bQDKx['sn'] = $jveNw->nextTrimString(); $o9W_y = array(); $o9W_y['title'] = $jveNw->nextTrimString(); ModelUtil::update('xxxx', $bQDKx, $o9W_y); return Response::generateSuccess(); })->performExcel(); } public function withDialog($qH0w_ = true) { if ($qH0w_) { $this->data['frameView'] = 'modstart::admin.dialogFrame'; } else { $this->data['frameView'] = 'modstart::admin.frame'; } return $this; } public function withPageTitle($GZP1b) { $this->data['pageTitle'] = $GZP1b; return $this; } public function withPageDescription($jdqqh, $XtxzK = false) { goto D3gxx; D3gxx: if (!$XtxzK) { $jdqqh = HtmlUtil::text2html($jdqqh); } goto wO_nM; zrDau: return $this; goto Mv5I_; wO_nM: $this->data['pageDescription'] = $jdqqh; goto zrDau; Mv5I_: } public function withTemplateName($jWV1z) { $this->data['templateName'] = $jWV1z; return $this; } public function withTemplateData($DQ0aq) { $this->data['templateData'] = $DQ0aq; return $this; } public function withHeadTitles($FT1IG) { $this->data['headTitles'] = $FT1IG; return $this; } public function handleImport($Ikxtb) { $this->importCallback = $Ikxtb; 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($mzzZ3 = array()) { return $this->perform(null, 'common', $mzzZ3); } private function perform($zBvIU, $vYMai, $mzzZ3 = array()) { goto oWbsN; BSWb1: $fAvwi = InputPackage::buildFromInput(); goto ZsYl7; HH785: return view('module::Vendor.View.quickRun.import.' . $vYMai, array_merge($this->data, array('ext' => $zBvIU, 'formats' => $mzzZ3['formats']))); goto iSIYv; oWbsN: if (null === $zBvIU) { $zBvIU = 'xlsx'; } goto ftYdy; ZsYl7: if (Request::isPost()) { goto HrHGJ; i2qcI: return call_user_func_array($this->importCallback, array($q62oK, array())); goto oqCC1; HrHGJ: $q62oK = $fAvwi->getJson('data'); goto eP0z1; eP0z1: AdminPermission::demoCheck(); goto i2qcI; oqCC1: } goto HH785; ftYdy: if (!isset($mzzZ3['formats'])) { $mzzZ3['formats'] = array('xlsx', 'csv'); } goto BSWb1; iSIYv: } }