<?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 $m0Odc) { return $m0Odc->withPageTitle('导入/更新商品信息')->withPageDescription('商品编码唯一，根据商品编码更新或新建商品')->withTemplateName('商品信息')->withTemplateData(array(array('XXXX', '测试名称')))->withHeadTitles(array('编码', '标题'))->handleImport(function ($GpXwG, $FRVtF) { $MZdfD = ArrayPackage::build($GpXwG); $l970E = array(); $l970E['sn'] = $MZdfD->nextTrimString(); $bOnbt = array(); $bOnbt['title'] = $MZdfD->nextTrimString(); ModelUtil::update('xxxx', $l970E, $bOnbt); return Response::generateSuccess(); })->performExcel(); } public function withDialog($WSv7J = true) { if ($WSv7J) { $this->data['frameView'] = 'modstart::admin.dialogFrame'; } else { $this->data['frameView'] = 'modstart::admin.frame'; } return $this; } public function withPageTitle($tGx1j) { $this->data['pageTitle'] = $tGx1j; return $this; } public function withPageDescription($k2GfG, $yqHNy = false) { goto hLzpm; hLzpm: if (!$yqHNy) { $k2GfG = HtmlUtil::text2html($k2GfG); } goto uIOA2; uIOA2: $this->data['pageDescription'] = $k2GfG; goto bE96h; bE96h: return $this; goto sE0cv; sE0cv: } public function withTemplateName($DhiGJ) { $this->data['templateName'] = $DhiGJ; return $this; } public function withTemplateData($EIJx6) { $this->data['templateData'] = $EIJx6; return $this; } public function withHeadTitles($j4ukO) { $this->data['headTitles'] = $j4ukO; return $this; } public function handleImport($TIlpS) { $this->importCallback = $TIlpS; 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($FRVtF = array()) { return $this->perform(null, 'common', $FRVtF); } private function perform($Zl0nq, $N8SrS, $FRVtF = array()) { goto tTkkm; QEGyV: return view('module::Vendor.View.quickRun.import.' . $N8SrS, array_merge($this->data, array('ext' => $Zl0nq, 'formats' => $FRVtF['formats']))); goto vUuNI; UbfSO: $i3uTh = InputPackage::buildFromInput(); goto m31Sh; CvNqH: if (!isset($FRVtF['formats'])) { $FRVtF['formats'] = array('xlsx', 'csv'); } goto UbfSO; m31Sh: if (Request::isPost()) { goto OI1J5; OI1J5: $GpXwG = $i3uTh->getJson('data'); goto l7oD3; l7oD3: AdminPermission::demoCheck(); goto QTT3g; QTT3g: return call_user_func_array($this->importCallback, array($GpXwG, array())); goto tx7Wc; tx7Wc: } goto QEGyV; tTkkm: if (null === $Zl0nq) { $Zl0nq = 'xlsx'; } goto CvNqH; vUuNI: } }