Browse Source

处理函数变量命名规范

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
b7b244c4a1
  1. 26
      vendor/antgoods/goods/src/controllers/GoodsController.php
  2. 2
      vendor/antgoods/goods/src/views/goods/_form.php

26
vendor/antgoods/goods/src/controllers/GoodsController.php

@ -81,7 +81,9 @@ class GoodsController extends Controller
{ {
$model = new Goods(); $model = new Goods();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
if ($model->load(Yii::$app->request->post())) {
$img_id_arr = explode(',', $model->image);
$model->save();
return $this->redirect('index'); return $this->redirect('index');
} }
@ -164,15 +166,15 @@ class GoodsController extends Controller
/** /**
* 处理文件上传成功后回调保存到临时文件表中 * 处理文件上传成功后回调保存到临时文件表中
*/ */
public function actionSavefile()
public function actionSaveFile()
{ {
$data = Yii::$app->request->get('data'); $data = Yii::$app->request->get('data');
$fileName = Yii::$app->request->get('fileName')[0];
$file_name = Yii::$app->request->get('fileName')[0];
if ($data['status'] == true) { if ($data['status'] == true) {
$model = new TemFile(); $model = new TemFile();
$model->user_id = Yii::$app->user->identity->id; $model->user_id = Yii::$app->user->identity->id;
$model->name = $fileName;
$model->name = $file_name;
$type = Yii::$app->file->searchType(FileManager::$extension, pathinfo($data['path'])['extension']); $type = Yii::$app->file->searchType(FileManager::$extension, pathinfo($data['path'])['extension']);
if ($type != -1) { if ($type != -1) {
$model->type = $type; $model->type = $type;
@ -191,13 +193,13 @@ class GoodsController extends Controller
public function actionImgIdDel() public function actionImgIdDel()
{ {
$alias = Yii::$app->request->get('data')['alias']; $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;
$img_id = Yii::$app->request->get('imgid');
$img_id_arr = explode(',', $img_id);
$tem_file = TemFile::findOne(['alias' => $alias]);
if ($tem_file) {
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]);
}
$img_id_str = implode(',', $img_id_arr);
return $img_id_str;
} }
} }

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

@ -73,7 +73,7 @@ use antgoods\goods\models\ars\Supplier;
'url' => 'upload', 'url' => 'upload',
'deleteUrl' => 'imageDel', 'deleteUrl' => 'imageDel',
'dragdropWidth'=> 800, 'dragdropWidth'=> 800,
'afterSave' => 'savefile',
'afterSave' => 'save-file',
'maxCount' => 1, 'maxCount' => 1,
'successScript' => " 'successScript' => "
success: function(data) success: function(data)

Loading…
Cancel
Save