<?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 $OAfo5) { return $OAfo5->withPageTitle('导入/更新商品信息')->withPageDescription('商品编码唯一，根据商品编码更新或新建商品')->withTemplateName('商品信息')->withTemplateData(array(array('XXXX', '测试名称')))->withHeadTitles(array('编码', '标题'))->handleImport(function ($xJzrK, $f_HcG) { $HDfwB = ArrayPackage::build($xJzrK); $b5RtF = array(); $b5RtF['sn'] = $HDfwB->nextTrimString(); $umZPe = array(); $umZPe['title'] = $HDfwB->nextTrimString(); ModelUtil::update('xxxx', $b5RtF, $umZPe); return Response::generateSuccess(); })->performExcel(); } public function withDialog($VK9lT = true) { if ($VK9lT) { $this->data['frameView'] = 'modstart::admin.dialogFrame'; } else { $this->data['frameView'] = 'modstart::admin.frame'; } return $this; } public function withPageTitle($zaBao) { $this->data['pageTitle'] = $zaBao; return $this; } public function withPageDescription($V2Wdc, $itNW8 = false) { goto KCcCx; JG2xh: $this->data['pageDescription'] = $V2Wdc; goto qVJvD; qVJvD: return $this; goto OS0Vg; KCcCx: if (!$itNW8) { $V2Wdc = HtmlUtil::text2html($V2Wdc); } goto JG2xh; OS0Vg: } public function withTemplateName($AUckg) { $this->data['templateName'] = $AUckg; return $this; } public function withTemplateData($AIfUa) { $this->data['templateData'] = $AIfUa; return $this; } public function withHeadTitles($QSavc) { $this->data['headTitles'] = $QSavc; return $this; } public function handleImport($caXDF) { $this->importCallback = $caXDF; 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($f_HcG = array()) { return $this->perform(null, 'common', $f_HcG); } private function perform($HCF4y, $RiwEA, $f_HcG = array()) { goto wy8i8; cOgUU: if (Request::isPost()) { goto mF7Ww; oDbmf: AdminPermission::demoCheck(); goto nJl1S; mF7Ww: $xJzrK = $OPo_x->getJson('data'); goto oDbmf; nJl1S: return call_user_func_array($this->importCallback, array($xJzrK, array())); goto jyLw5; jyLw5: } goto c5gC7; c5gC7: return view('module::Vendor.View.quickRun.import.' . $RiwEA, array_merge($this->data, array('ext' => $HCF4y, 'formats' => $f_HcG['formats']))); goto q8x8n; L7X_f: $OPo_x = InputPackage::buildFromInput(); goto cOgUU; wy8i8: if (null === $HCF4y) { $HCF4y = 'xlsx'; } goto cnm3w; cnm3w: if (!isset($f_HcG['formats'])) { $f_HcG['formats'] = array('xlsx', 'csv'); } goto L7X_f; q8x8n: } }