|
@ -104,6 +104,7 @@ class GoodsController extends Controller |
|
|
public function actionUpdate($id) |
|
|
public function actionUpdate($id) |
|
|
{ |
|
|
{ |
|
|
$model = $this->findModel($id); |
|
|
$model = $this->findModel($id); |
|
|
|
|
|
$model->imageId = $model->image; |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) { |
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) { |
|
|
return $this->redirect('index'); |
|
|
return $this->redirect('index'); |
|
@ -183,7 +184,7 @@ class GoodsController extends Controller |
|
|
$model->name = $file_name; |
|
|
$model->name = $file_name; |
|
|
$file_manager = new \backend\logic\file\FileManager(); |
|
|
$file_manager = new \backend\logic\file\FileManager(); |
|
|
$type = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']); |
|
|
$type = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']); |
|
|
if ($type != -1) { |
|
|
|
|
|
|
|
|
if ($type) { |
|
|
$model->type = $type; |
|
|
$model->type = $type; |
|
|
} |
|
|
} |
|
|
$model->alias = $data['alias']; |
|
|
$model->alias = $data['alias']; |
|
@ -200,18 +201,49 @@ class GoodsController extends Controller |
|
|
public function actionImgIdDel() |
|
|
public function actionImgIdDel() |
|
|
{ |
|
|
{ |
|
|
//判断该类是否存在
|
|
|
//判断该类是否存在
|
|
|
if(!class_exists('\common\models\ars\TemFile')){ |
|
|
|
|
|
|
|
|
if(!class_exists('\common\models\ars\TemFile') || !class_exists('\common\models\ars\File')){ |
|
|
return ''; |
|
|
return ''; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$alias = Yii::$app->request->get('data')['alias']; |
|
|
|
|
|
$img_id = Yii::$app->request->get('imgid'); |
|
|
$img_id = Yii::$app->request->get('imgid'); |
|
|
$img_id_arr = explode(',', $img_id); |
|
|
$img_id_arr = explode(',', $img_id); |
|
|
|
|
|
if(isset(Yii::$app->request->get('data')['alias'])) { |
|
|
|
|
|
$alias = Yii::$app->request->get('data')['alias']; |
|
|
$tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]); |
|
|
$tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]); |
|
|
if ($tem_file) { |
|
|
if ($tem_file) { |
|
|
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]); |
|
|
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]); |
|
|
} |
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
foreach (Yii::$app->request->get() as $key => $value) { |
|
|
|
|
|
$tem_file = \common\models\ars\File::findOne(['alias' => $value]); |
|
|
|
|
|
if ($tem_file) { |
|
|
|
|
|
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
$img_id_str = implode(',', $img_id_arr); |
|
|
$img_id_str = implode(',', $img_id_arr); |
|
|
return $img_id_str; |
|
|
return $img_id_str; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function actionImageFile() |
|
|
|
|
|
{ |
|
|
|
|
|
//判断该类是否存在
|
|
|
|
|
|
if(!class_exists('\common\models\ars\File')){ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$file_id_str = Yii::$app->request->get('fileidstr'); |
|
|
|
|
|
$file_id_arr = explode(',', $file_id_str); |
|
|
|
|
|
$data = \common\models\ars\File::find()->where(['id' => $file_id_arr])->all(); |
|
|
|
|
|
if($data) { |
|
|
|
|
|
$res = array(); |
|
|
|
|
|
$i = 0; |
|
|
|
|
|
foreach ($data as $key => $value) { |
|
|
|
|
|
$res[$i]['name'] = $value->alias; |
|
|
|
|
|
$res[$i]['path'] = Yii::$app->request->hostInfo . '/' . $value->path; |
|
|
|
|
|
$res[$i]['size'] = filesize($value->path); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return json_encode($res); |
|
|
|
|
|
} |
|
|
} |
|
|
} |