123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?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 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 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);
- if(empty($status)) {
- if($status === 0) $this->setIsLongText();
- $this->setMsg($msg);
- }
- }
- }
|