<?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($vB4op) { $this->data['pageTitle'] = $vB4op; return $this; } public function withDefaultExportName($wGX8b) { $this->data['defaultExportName'] = $wGX8b; return $this; } public function withHeadTitles($D8A4I) { $this->data['headTitles'] = $D8A4I; return $this; } public function withCustomHeadTitle($LYsql) { $this->data['customHeadTitle'] = $LYsql; return $this; } public function handleFetch($k8RFa) { $this->fetchCallback = $k8RFa; return $this; } public function performExcel() { return $this->perform('xlsx', 'excel'); } public function performCsv() { return $this->perform('xlsx', 'csv'); } public function performCommon($KJ3xr = array()) { return $this->perform(null, 'common', $KJ3xr); } private function perform($yTRYd, $wFt7y, $KJ3xr = array()) { goto XGras; XGras: if (null === $yTRYd) { $yTRYd = 'xlsx'; } goto ojTFE; ZE0bo: $cbtIR = $Ylazq->getJsonAsInput('_param')->getArray('search'); goto Goz18; mo2D0: $egN8y = call_user_func_array($this->fetchCallback, array(1, 1, $cbtIR, array())); goto tJHlG; aO14e: $wGX8b = $this->data['defaultExportName']; goto FvV1C; tJHlG: return view('module::Vendor.View.quickRun.export.' . $wFt7y, array('pageTitle' => $vB4op, 'exportName' => $LsMTR, 'total' => $egN8y['total'], 'formats' => $KJ3xr['formats'], 'customHeadTitle' => $Bi3ar, 'headTitles' => $D8A4I)); goto S4yqv; FvV1C: $D8A4I = $this->data['headTitles']; goto SGOwY; oLxtw: $evgNV = $Ylazq->getPage(); goto PYcLK; ojTFE: if (!isset($KJ3xr['formats'])) { $KJ3xr['formats'] = array('xlsx', 'csv'); } goto e1tq3; Teo4j: if (Request::isPost()) { goto ODpqv; FdJ4x: BizException::throwsIfEmpty('请选择导出列', $sz0uv); goto Jqxsf; UQWvF: $smBDO['exportName'] = $LsMTR . '.' . $dWTel; goto MNrld; tQEBD: $smBDO['list'] = $cBMfa; goto OBYj4; Jqxsf: $egN8y = call_user_func_array($this->fetchCallback, array($evgNV, $wo2xO, $cbtIR, array())); goto nM4BQ; nM4BQ: if ($Bi3ar) { goto G6nQB; cIt0a: foreach ($egN8y['list'] as $PSYn9) { goto D3R6g; emLjE: $cBMfa[] = $SJfZL; goto c6UKs; oG6XF: foreach ($PSYn9 as $N_gGC => $M9Vo3) { if (in_array($N_gGC, $sz0uv)) { $SJfZL[] = $M9Vo3; } } goto emLjE; D3R6g: $SJfZL = array(); goto oG6XF; c6UKs: } goto W13hX; Gve7N: foreach ($this->data['headTitles'] as $qzlby => $PSYn9) { if (in_array($qzlby, $sz0uv)) { $HHvfP[] = $PSYn9; } } goto W56Iz; W13hX: $HHvfP = array(); goto Gve7N; G6nQB: $cBMfa = array(); goto cIt0a; W56Iz: } else { $cBMfa = $egN8y['list']; $HHvfP = $this->data['headTitles']; } goto f886r; MNrld: $smBDO['exportHeadTitles'] = $HHvfP; goto l3qTx; l3qTx: return Response::generateSuccessData($smBDO); goto fGvVa; DSWN7: $smBDO['finished'] = count($egN8y['list']) != $wo2xO; goto UQWvF; OBYj4: $smBDO['total'] = $egN8y['total']; goto DSWN7; KQPFN: $smBDO['code'] = 0; goto tQEBD; f886r: $smBDO = array(); goto KQPFN; ODpqv: BizException::throwsIfEmpty('导出文件名为空', $LsMTR); goto FdJ4x; fGvVa: } goto mo2D0; PYcLK: $wo2xO = $Ylazq->getPageSize(null, null, null, 100); goto ZE0bo; Goz18: $LsMTR = $Ylazq->getTrimString('exportName', $wGX8b); goto eZpY1; e1tq3: $vB4op = $this->data['pageTitle']; goto aO14e; I9hAT: $sz0uv = $Ylazq->getJson('checkedHeadTitles'); goto Teo4j; SGOwY: $Bi3ar = $this->data['customHeadTitle']; goto OcIvj; eZpY1: $dWTel = $Ylazq->getTrimString('format', $yTRYd); goto I9hAT; OcIvj: $Ylazq = InputPackage::buildFromInput(); goto oLxtw; S4yqv: } }