Browse Source

完成商品模块创建商品保存图片操作

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
3f405f607e
  1. 2
      backend/logic/file/FileManager.php
  2. 5
      vendor/antgoods/goods/src/controllers/GoodsController.php
  3. 2
      vendor/antgoods/goods/src/logic/goods/GoodsManager.php
  4. 2
      vendor/antgoods/goods/src/views/goods/_form.php

2
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' => '存在查找不到的文件'];

5
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');
}

2
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;
}

2
vendor/antgoods/goods/src/views/goods/_form.php

@ -68,7 +68,7 @@ use antgoods\goods\models\ars\Supplier;
<?= $form->field($model, 'express_template')->textInput() ?>
<?= $form->field($model, 'imageId')->textInput()->label('') ?>
<?= $form->field($model, 'imageId')->hiddenInput()->label('') ?>
<?= $form->field($model, 'imagePath')->widget(\iron\widgets\Upload::className(), [
'url' => 'upload',
'deleteUrl' => 'imageDel',

Loading…
Cancel
Save