1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Import;
- use App\Service\ImportService;
- use Maatwebsite\Excel\Concerns\ToArray;
- use Maatwebsite\Excel\Concerns\WithCalculatedFormulas;
- class ImportAll implements ToArray,WithCalculatedFormulas {
- private $msg = '';
- public $crt_id = 0;
- public $type = "";
- public $user = [];
- public $is_long_text = false;
- public $other_param = [];
- public function array (array $array){
- $this->handleData($array);
- }
- public function setCrt($crt_id){
- $this->crt_id = $crt_id;
- }
- public function setType($type){
- $this->type = $type;
- }
- public function setUser($user){
- $this->user = $user;
- }
- public function setOtherParam($param){
- $this->other_param = $param;
- }
- public function getMsg(){
- return $this->msg;
- }
- public function setMsg($msg){
- $this->msg = $msg;
- }
- public function setIsLongText($bool = true){
- $this->is_long_text = $bool;
- }
- public function getIsLongText(){
- return $this->is_long_text;
- }
- public function handleData (array $array) {
- $func = $this->type . "Import";
- if(! $func) {
- $this->setMsg("意外错误");
- return;
- }
- list($status,$msg) = (new ImportService())->$func($array,$this->user,$this->other_param);
- if(empty($status)) {
- if($status === 0) $this->setIsLongText();
- $this->setMsg($msg);
- }
- }
- }
|