diff --git a/vendor/antgoods/goods/src/controllers/GoodsController.php b/vendor/antgoods/goods/src/controllers/GoodsController.php index 39e69a2..33a5ff7 100644 --- a/vendor/antgoods/goods/src/controllers/GoodsController.php +++ b/vendor/antgoods/goods/src/controllers/GoodsController.php @@ -180,6 +180,24 @@ class GoodsController extends Controller $model->alias = $data['alias']; $model->path = $data['path']; $model->save(); + return $model->id; } } + + /** + * @return string + * 点击删除按钮时同时删除字符串中的id + */ + public function actionImgIdDel() + { + $alias = Yii::$app->request->get('data')['alias']; + $imgid = Yii::$app->request->get('imgid'); + $imgidarr = explode(',', $imgid); + $temfile = TemFile::findOne(['alias' => $alias]); + if ($temfile) { + $imgidarr = array_diff($imgidarr, [$temfile->id]); + } + $imgidstr = implode(',', $imgidarr); + return $imgidstr; + } } diff --git a/vendor/antgoods/goods/src/models/ars/Goods.php b/vendor/antgoods/goods/src/models/ars/Goods.php index 85c68dc..ab00598 100644 --- a/vendor/antgoods/goods/src/models/ars/Goods.php +++ b/vendor/antgoods/goods/src/models/ars/Goods.php @@ -44,6 +44,7 @@ use yii\behaviors\TimestampBehavior; */ class Goods extends \yii\db\ActiveRecord { + public $imagePath; //是否删除is_delete const IS_DELETE_NO = 0;//未删除 const IS_DELETE_YES = 1;//已删除 diff --git a/vendor/antgoods/goods/src/views/goods/_form.php b/vendor/antgoods/goods/src/views/goods/_form.php index 07366ef..0d262c0 100644 --- a/vendor/antgoods/goods/src/views/goods/_form.php +++ b/vendor/antgoods/goods/src/views/goods/_form.php @@ -68,11 +68,33 @@ use antgoods\goods\models\ars\Supplier; = $form->field($model, 'express_template')->textInput() ?> - = $form->field($model, 'image')->widget(\iron\widgets\Upload::className(), [ + = $form->field($model, 'image')->textInput() ?> + = $form->field($model, 'imagePath')->widget(\iron\widgets\Upload::className(), [ 'url' => 'upload', 'deleteUrl' => 'imageDel', 'dragdropWidth'=> 800, - 'afterSave' => 'savefile' + 'afterSave' => 'savefile', + 'successScript' => " + success: function(data) + { + var imageval = $('#goods-image').val(); + if(imageval == ''){ + $('#goods-image').val(data); + }else{ + $('#goods-image').val($('#goods-image').val()+','+data); + } + } + ", + 'deleteScript' => " + $.ajax({ + url: 'img-id-del', + data: {data: data, imgid: $('#goods-image').val()}, + success: function(data) + { + $('#goods-image').val(data); + }, + }); + ", ]) ?>