<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\QuickRun\Export; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; class ExportHandle { private $data = array('pageTitle' => '导出数据', 'defaultExportName' => 'Export', 'headTitles' => array(), 'customHeadTitle' => false); private $fetchCallback; public function withPageTitle($l2OFZ) { $this->data['pageTitle'] = $l2OFZ; return $this; } public function withDefaultExportName($MBsl5) { $this->data['defaultExportName'] = $MBsl5; return $this; } public function withHeadTitles($U1vxU) { $this->data['headTitles'] = $U1vxU; return $this; } public function withCustomHeadTitle($JN1_R) { $this->data['customHeadTitle'] = $JN1_R; return $this; } public function handleFetch($jlZvo) { $this->fetchCallback = $jlZvo; return $this; } public function performExcel() { return $this->perform('xlsx', 'excel'); } public function performCsv() { return $this->perform('xlsx', 'csv'); } public function performCommon($uxJUJ = array()) { return $this->perform(null, 'common', $uxJUJ); } private function perform($hdPuJ, $faKDa, $uxJUJ = array()) { goto kW5t9; qJKBW: $l2OFZ = $this->data['pageTitle']; goto ypf9Z; fctqH: $Aqj3Z = $tBuXm->getPageSize(null, null, null, 100); goto L7H_A; ypf9Z: $MBsl5 = $this->data['defaultExportName']; goto pym5A; OFR22: $MLj8u = $tBuXm->getTrimString('format', $hdPuJ); goto pOesG; hSvHk: $Nv2EE = call_user_func_array($this->fetchCallback, array(1, 1, $mNCUj, array())); goto xT42N; WOLS8: if (Request::isPost()) { goto JMm2L; SEaFh: $cwaKT['code'] = 0; goto HS8hY; q9zLD: BizException::throwsIfEmpty('请选择导出列', $ieECS); goto oIUvu; XDalV: $cwaKT['exportName'] = $w2r1C . '.' . $MLj8u; goto lAGzm; XgIqZ: $cwaKT['finished'] = count($Nv2EE['list']) != $Aqj3Z; goto XDalV; oIUvu: $Nv2EE = call_user_func_array($this->fetchCallback, array($WLCMC, $Aqj3Z, $mNCUj, array())); goto EdMAd; IQhLZ: $cwaKT['total'] = $Nv2EE['total']; goto XgIqZ; lRaOu: return Response::generateSuccessData($cwaKT); goto H2Mnp; EdMAd: if ($jPaw3) { goto TGvUV; MroGN: $r3OUg = array(); goto a33GU; cU_QA: foreach ($Nv2EE['list'] as $qGgGl) { goto GwCyA; wvTfi: foreach ($qGgGl as $h7nVH => $p7Owm) { if (in_array($h7nVH, $ieECS)) { $zB1g3[] = $p7Owm; } } goto wX3n2; GwCyA: $zB1g3 = array(); goto wvTfi; wX3n2: $hmq1P[] = $zB1g3; goto eU4k9; eU4k9: } goto MroGN; a33GU: foreach ($this->data['headTitles'] as $Iy3ah => $qGgGl) { if (in_array($Iy3ah, $ieECS)) { $r3OUg[] = $qGgGl; } } goto eT2XH; TGvUV: $hmq1P = array(); goto cU_QA; eT2XH: } else { $hmq1P = $Nv2EE['list']; $r3OUg = $this->data['headTitles']; } goto WFNex; WFNex: $cwaKT = array(); goto SEaFh; lAGzm: $cwaKT['exportHeadTitles'] = $r3OUg; goto lRaOu; HS8hY: $cwaKT['list'] = $hmq1P; goto IQhLZ; JMm2L: BizException::throwsIfEmpty('导出文件名为空', $w2r1C); goto q9zLD; H2Mnp: } goto hSvHk; MXbiP: $w2r1C = $tBuXm->getTrimString('exportName', $MBsl5); goto OFR22; Jm8J0: $WLCMC = $tBuXm->getPage(); goto fctqH; xT42N: return view('module::Vendor.View.quickRun.export.' . $faKDa, array('pageTitle' => $l2OFZ, 'exportName' => $w2r1C, 'total' => $Nv2EE['total'], 'formats' => $uxJUJ['formats'], 'customHeadTitle' => $jPaw3, 'headTitles' => $U1vxU)); goto gUmZ2; kW5t9: if (null === $hdPuJ) { $hdPuJ = 'xlsx'; } goto chH2G; pOesG: $ieECS = $tBuXm->getJson('checkedHeadTitles'); goto WOLS8; pym5A: $U1vxU = $this->data['headTitles']; goto uUjle; L7H_A: $mNCUj = $tBuXm->getJsonAsInput('_param')->getArray('search'); goto MXbiP; uUjle: $jPaw3 = $this->data['customHeadTitle']; goto FBWdD; FBWdD: $tBuXm = InputPackage::buildFromInput(); goto Jm8J0; chH2G: if (!isset($uxJUJ['formats'])) { $uxJUJ['formats'] = array('xlsx', 'csv'); } goto qJKBW; gUmZ2: } }