Commit b3ba15d0 authored by 张晓林's avatar 张晓林

图片上传修改,添加Excel上传

parent 83cfcd8c
...@@ -164,8 +164,10 @@ return [ ...@@ -164,8 +164,10 @@ return [
'extraPatterns'=>[ 'extraPatterns'=>[
'GET,OPTIONS licence-list'=>'licence-list', 'GET,OPTIONS licence-list'=>'licence-list',
'GET,OPTIONS licence-detail'=>'licence-detail', 'GET,OPTIONS licence-detail'=>'licence-detail',
'GET,OPTIONS licence-excel-download'=>'licence-excel-download',
'POST,OPTIONS licence-insert'=>'licence-insert', 'POST,OPTIONS licence-insert'=>'licence-insert',
'POST,OPTIONS licence-img-upload'=>'licence-img-upload', 'POST,OPTIONS licence-img-upload'=>'licence-img-upload',
'POST,OPTIONS licence-excel-upload'=>'licence-excel-upload',
], ],
], ],
//省市区 //省市区
......
...@@ -9,7 +9,7 @@ use backend\helpers\Func; ...@@ -9,7 +9,7 @@ use backend\helpers\Func;
use backend\helpers\UploadFiles; use backend\helpers\UploadFiles;
use yii\web\UploadedFile; use yii\web\UploadedFile;
use yii\web\HttpException; use yii\web\HttpException;
use yidas\phpSpreadsheet\Helper;
class BranchLicenceController extends BaseController{ class BranchLicenceController extends BaseController{
public $modelClass = 'backend\models\v1\branch\BranchLicence'; public $modelClass = 'backend\models\v1\branch\BranchLicence';
...@@ -97,12 +97,60 @@ class BranchLicenceController extends BaseController{ ...@@ -97,12 +97,60 @@ class BranchLicenceController extends BaseController{
if ($fileInfo['CODE']==200) { if ($fileInfo['CODE']==200) {
// 文件上传成功 // 文件上传成功
throw new HttpException(200); return [
'CODE'=>200,
'imgUrl'=>$fileInfo['INFO']
];
}else{ }else{
throw new HttpException(422); throw new HttpException(422);
} }
} }
} }
/**
* @OA\Post(
* path="/backend/web/v1/branch/branch-licences/licence-excel-upload",
* tags={"门店&DC"},
* summary="批量更新或导入门店证照(张晓林)",
* operationId="uploadFiles",
* @OA\Response(
* response=200,
* description="导入成功",
* ),
* security={{"Authorization":{}}},
* @OA\RequestBody(
* description="上传Excel",
* @OA\MediaType(
* mediaType="multipart/form-data",
* @OA\Schema(
* type="object",
* @OA\Property(
* property="uploadFile",
* type="string",
* format="binary"
* ),
* )
* )
* )
* )
*/
public function actionLicenceExcelUpload(){
//多文件时依赖注入参数参考UploadFiles类
$model = new UploadFiles(['jpg','xls']);
if (Yii::$app->request->isPost) {
//多文件用getInstances
$model->uploadFiles = UploadedFile::getInstance($model,'uploadFile');
$fileInfo = $model->upload();
$file = $fileInfo['INFO'];
Helper::getRow();
return $file;
if ($fileInfo['CODE']==200) {
// 文件上传成功
throw new HttpException(200);
}else{
throw new HttpException(422);
}
}
}
/** /**
* @OA\GET( * @OA\GET(
* path="/backend/web/v1/branch/branch-licences/licence-list", * path="/backend/web/v1/branch/branch-licences/licence-list",
......
...@@ -5,6 +5,7 @@ use yii\db\ActiveRecord; ...@@ -5,6 +5,7 @@ use yii\db\ActiveRecord;
class BranchLicence extends ActiveRecord{ class BranchLicence extends ActiveRecord{
public $LICENCEEXCEL;
public static function tableName() public static function tableName()
{ {
return 'shop_branch_licence'; return 'shop_branch_licence';
...@@ -21,6 +22,7 @@ class BranchLicence extends ActiveRecord{ ...@@ -21,6 +22,7 @@ class BranchLicence extends ActiveRecord{
[['LICENCE_CODE','LICENCE_NAME'],'string','max'=>20,'on'=>'licenceInsert'], [['LICENCE_CODE','LICENCE_NAME'],'string','max'=>20,'on'=>'licenceInsert'],
[['IS_FROM','IS_SHOW'],'default','value'=>1], [['IS_FROM','IS_SHOW'],'default','value'=>1],
[['LICENCE_EXPIRY_DATE'],'datetime','format'=>'Y-m-d','on'=>'licenceInsert'], [['LICENCE_EXPIRY_DATE'],'datetime','format'=>'Y-m-d','on'=>'licenceInsert'],
[['!LICENCEEXCEL'],'required','on'=>'excelDown','message'=>'缺少Excel名称'],
]; ];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment