diff --git a/backend/logic/file/FileManager.php b/backend/logic/file/FileManager.php index 7b02a75..7b7ff2e 100644 --- a/backend/logic/file/FileManager.php +++ b/backend/logic/file/FileManager.php @@ -67,7 +67,7 @@ class FileManager $i = 1; $first_file_id = 0; foreach ($img_id_arr as $key => $value) { - $tem_file = TemFile::findOne($key); + $tem_file = TemFile::findOne($value); if(!$tem_file) { return ['status' => false, 'info' => '存在查找不到的文件']; diff --git a/vendor/antgoods/goods/src/controllers/GoodsController.php b/vendor/antgoods/goods/src/controllers/GoodsController.php index 50c4740..728c569 100644 --- a/vendor/antgoods/goods/src/controllers/GoodsController.php +++ b/vendor/antgoods/goods/src/controllers/GoodsController.php @@ -3,12 +3,14 @@ namespace antgoods\goods\controllers; use common\models\ars\TemFile; +use MongoDB\Driver\Manager; use Yii; use antgoods\goods\models\ars\Goods; use antgoods\goods\models\searchs\GoodsSearch; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; +use antgoods\goods\logic\goods\GoodsManager; /** * GoodsController implements the CRUD actions for Goods model. @@ -80,7 +82,10 @@ class GoodsController extends Controller $model = new Goods(); if ($model->load(Yii::$app->request->post())) { + $file_id_str = $model->imageId; $model->save(); + $goods_manager = new GoodsManager(); + $goods_manager->saveFile($file_id_str, $model); return $this->redirect('index'); } diff --git a/vendor/antgoods/goods/src/logic/goods/GoodsManager.php b/vendor/antgoods/goods/src/logic/goods/GoodsManager.php index 425b8fe..d5514f6 100644 --- a/vendor/antgoods/goods/src/logic/goods/GoodsManager.php +++ b/vendor/antgoods/goods/src/logic/goods/GoodsManager.php @@ -15,7 +15,7 @@ class GoodsManager */ public function saveFile($fileIdStr, $goodsModel, $filetype = 1) { - if(class_exists('\backend\logic\file\FileManager') || class_exists('\common\models\ars\File')) { + if(!class_exists('\backend\logic\file\FileManager') || !class_exists('\common\models\ars\File')) { return false; } diff --git a/vendor/antgoods/goods/src/views/goods/_form.php b/vendor/antgoods/goods/src/views/goods/_form.php index 2f133be..18bfe40 100644 --- a/vendor/antgoods/goods/src/views/goods/_form.php +++ b/vendor/antgoods/goods/src/views/goods/_form.php @@ -68,7 +68,7 @@ use antgoods\goods\models\ars\Supplier; field($model, 'express_template')->textInput() ?> - field($model, 'imageId')->textInput()->label('') ?> + field($model, 'imageId')->hiddenInput()->label('') ?> field($model, 'imagePath')->widget(\iron\widgets\Upload::className(), [ 'url' => 'upload', 'deleteUrl' => 'imageDel',