<?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 $tqu7M) { return $tqu7M->withPageTitle('导入/更新商品信息')->withPageDescription('商品编码唯一，根据商品编码更新或新建商品')->withTemplateName('商品信息')->withTemplateData(array(array('XXXX', '测试名称')))->withHeadTitles(array('编码', '标题'))->handleImport(function ($cwaKT, $uxJUJ) { $scQcd = ArrayPackage::build($cwaKT); $k3Pg0 = array(); $k3Pg0['sn'] = $scQcd->nextTrimString(); $jNwg7 = array(); $jNwg7['title'] = $scQcd->nextTrimString(); ModelUtil::update('xxxx', $k3Pg0, $jNwg7); return Response::generateSuccess(); })->performExcel(); } public function withDialog($JN1_R = true) { if ($JN1_R) { $this->data['frameView'] = 'modstart::admin.dialogFrame'; } else { $this->data['frameView'] = 'modstart::admin.frame'; } return $this; } public function withPageTitle($l2OFZ) { $this->data['pageTitle'] = $l2OFZ; return $this; } public function withPageDescription($mSPCd, $UmDw5 = false) { goto RO1dq; PW5KB: $this->data['pageDescription'] = $mSPCd; goto h8RC8; RO1dq: if (!$UmDw5) { $mSPCd = HtmlUtil::text2html($mSPCd); } goto PW5KB; h8RC8: return $this; goto lZ17Y; lZ17Y: } public function withTemplateName($ub3th) { $this->data['templateName'] = $ub3th; return $this; } public function withTemplateData($DlEFb) { $this->data['templateData'] = $DlEFb; return $this; } public function withHeadTitles($U1vxU) { $this->data['headTitles'] = $U1vxU; return $this; } public function handleImport($jlZvo) { $this->importCallback = $jlZvo; 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($uxJUJ = array()) { return $this->perform(null, 'common', $uxJUJ); } private function perform($hdPuJ, $faKDa, $uxJUJ = array()) { goto U4uCD; ALcJf: $tBuXm = InputPackage::buildFromInput(); goto v6vfs; U4uCD: if (null === $hdPuJ) { $hdPuJ = 'xlsx'; } goto m0ZB0; m0ZB0: if (!isset($uxJUJ['formats'])) { $uxJUJ['formats'] = array('xlsx', 'csv'); } goto ALcJf; h_Izw: return view('module::Vendor.View.quickRun.import.' . $faKDa, array_merge($this->data, array('ext' => $hdPuJ, 'formats' => $uxJUJ['formats']))); goto NXShP; v6vfs: if (Request::isPost()) { goto UDgmD; KmTxs: AdminPermission::demoCheck(); goto dYu7d; UDgmD: $cwaKT = $tBuXm->getJson('data'); goto KmTxs; dYu7d: return call_user_func_array($this->importCallback, array($cwaKT, array())); goto GY1xq; GY1xq: } goto h_Izw; NXShP: } }