Commit 0b45424d authored by ZhuChunYang's avatar ZhuChunYang

应用排序修改

parent b8554db4
...@@ -73,4 +73,25 @@ class ApplicationCategoryController extends BaseController ...@@ -73,4 +73,25 @@ class ApplicationCategoryController extends BaseController
return ['code' => 1, 'msg' => 'failed']; return ['code' => 1, 'msg' => 'failed'];
} }
public function actionSetSort()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$sort = $request->get('sort',1);
if($id){
$category = CoinApplicationCategory::getCategoryById($id);
if(!$category){
return ['code' => 1,'msg' =>'分类不存在,不能设置排序'];
}
$category->sort=$sort;
$category->save();
return ['code' => 0,'msg' => '分类排序设置成功'];
}else{
return ['code' => 1 ,'msg' => '分类排序设置失败'];
}
}
}
} }
\ No newline at end of file
...@@ -184,4 +184,26 @@ class ApplicationController extends BaseController ...@@ -184,4 +184,26 @@ class ApplicationController extends BaseController
return ['code' => 1, 'msg' => 'failed']; return ['code' => 1, 'msg' => 'failed'];
} }
public function actionSetSort()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$category_id = $request->get('category_id','');
$sort = $request->get('sort',1);
if($id && $category_id){
$app_cate = CoinAppCate::getAppCate($category_id,$id);
if(!$app_cate){
return ['code' => 1,'msg' =>'应用不存在,不能设置排序'];
}
$app_cate->sort=$sort;
$app_cate->save();
return ['code' => 0,'msg' => '应用排序设置成功'];
}else{
return ['code' => 1 ,'msg' => '应用排序设置失败'];
}
}
}
} }
\ No newline at end of file
...@@ -119,7 +119,6 @@ ...@@ -119,7 +119,6 @@
page: true, page: true,
limit: 10, limit: 10,
skin: 'row', skin: 'row',
even: true,
url: '/admin/application-category/index', url: '/admin/application-category/index',
cols: [[ cols: [[
{ {
...@@ -142,7 +141,8 @@ ...@@ -142,7 +141,8 @@
}, },
{ {
field: 'sort', field: 'sort',
title: '排序' title: '排序',
edit: 'text'
}, },
{ {
field: 'banner', field: 'banner',
...@@ -332,4 +332,17 @@ ...@@ -332,4 +332,17 @@
} }
}); });
//监听单元格编辑
table.on('edit(table1)', function(obj){
var value = obj.value; //得到修改后的值
var data = obj.data; //得到所在行所有键值
$.get('/admin/application-category/set-sort', {id:data.id,sort:value}, function(rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
table.reload('table1',{});
}else{
}
});
});
</script> </script>
\ No newline at end of file
...@@ -90,7 +90,8 @@ ...@@ -90,7 +90,8 @@
}, },
{ {
field: 'sort', field: 'sort',
title: '排序' title: '排序',
edit: 'text'
}, },
{ {
field: 'has_h5', field: 'has_h5',
...@@ -234,4 +235,18 @@ ...@@ -234,4 +235,18 @@
}); });
} }
}); });
//监听单元格编辑
table.on('edit(table1)', function(obj){
var value = obj.value; //得到修改后的值
var data = obj.data; //得到所在行所有键值
$.get('/admin/application/set-sort', {id:data.id,category_id:category_id,sort:value}, function(rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
table.reload('table1',{});
}else{
}
});
});
</script> </script>
\ No newline at end of file
...@@ -76,8 +76,8 @@ class ApplicationBusiness ...@@ -76,8 +76,8 @@ class ApplicationBusiness
{ {
$app_cate_Model = CoinAppCate::find(); $app_cate_Model = CoinAppCate::find();
$data = $app_cate_Model->JoinWith(['application'], false) $data = $app_cate_Model->JoinWith(['application'], false)
->select('cate_id,app_id,name,icon,sort,type,native_url,h5_url,android_url,ios_url,app_store_url,redirect_type,') ->select('cate_id,app_id,name,icon,type,native_url,h5_url,android_url,ios_url,app_store_url,redirect_type,'.CoinAppCate::tableName().'.sort')
->orderBy('sort asc')->asArray()->all(); ->orderBy(CoinAppCate::tableName().'.sort asc')->asArray()->all();
$icon_Items = array_column($data,'icon'); $icon_Items = array_column($data,'icon');
$icon_Items = array_unique($icon_Items); $icon_Items = array_unique($icon_Items);
$icon_Infos = CoinImage::getItemsByIds($icon_Items); $icon_Infos = CoinImage::getItemsByIds($icon_Items);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment