Commit 6c2d4607 authored by ZhuChunYang's avatar ZhuChunYang

update

parent 9d5c6fe8
...@@ -31,8 +31,8 @@ class ApplicationCategoryController extends BaseController ...@@ -31,8 +31,8 @@ class ApplicationCategoryController extends BaseController
$data = CoinApplicationCategory::getList($page, $limit, $where); $data = CoinApplicationCategory::getList($page, $limit, $where);
return $data; return $data;
} }
//$items = CoinApplicationCategory::getItemsByPid(0); $items = CoinApplicationCategory::getItemsByPid(0);
return $this->render('index'); return $this->render('index',['items' => $items]);
} }
/** /**
...@@ -42,7 +42,7 @@ class ApplicationCategoryController extends BaseController ...@@ -42,7 +42,7 @@ class ApplicationCategoryController extends BaseController
{ {
if (Yii::$app->request->isPost) { if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json'; Yii::$app->response->format = 'json';
$fields = ['id','name','sort','icon']; $fields = ['id','name','sort','icon','pid'];
$params = $this->initParams(Yii::$app->request->post(), $fields); $params = $this->initParams(Yii::$app->request->post(), $fields);
$application_category = new CoinApplicationCategoryForm(); $application_category = new CoinApplicationCategoryForm();
if($params['id']){ //edit if($params['id']){ //edit
...@@ -75,16 +75,4 @@ class ApplicationCategoryController extends BaseController ...@@ -75,16 +75,4 @@ class ApplicationCategoryController extends BaseController
return ['code' => 1, 'msg' => 'failed']; return ['code' => 1, 'msg' => 'failed'];
} }
public function actionUpload()
{
Yii::$app->response->format = 'json';
try {
$apk = UploadedFile::getInstanceByName('apk');
$filepath = Yii::$app->uploader->upload($apk);
return ['code' => 0, 'msg' => 'succeed', 'path' => $filepath];
} catch (\Exception $e) {
return ['code' => $e->getCode(), 'msg' => $e->getMessage()];
}
}
} }
\ No newline at end of file
...@@ -25,7 +25,7 @@ class CoinApplicationCategoryForm extends BaseForm ...@@ -25,7 +25,7 @@ class CoinApplicationCategoryForm extends BaseForm
{ {
return [ return [
self::SCENARIO_ADD => ['name','sort','icon','pid'], self::SCENARIO_ADD => ['name','sort','icon','pid'],
self::SCENARIO_EDIT => ['id','name','sort','icon'], self::SCENARIO_EDIT => ['id','name','sort','icon','pid'],
]; ];
} }
...@@ -37,6 +37,7 @@ class CoinApplicationCategoryForm extends BaseForm ...@@ -37,6 +37,7 @@ class CoinApplicationCategoryForm extends BaseForm
'name' => '名称', 'name' => '名称',
'icon' => '图标', 'icon' => '图标',
'sort' => '排序', 'sort' => '排序',
'pid' => '父级分类ID'
]; ];
} }
...@@ -47,6 +48,7 @@ class CoinApplicationCategoryForm extends BaseForm ...@@ -47,6 +48,7 @@ class CoinApplicationCategoryForm extends BaseForm
[['id','name','sort'], 'required', 'on' => self::SCENARIO_EDIT], [['id','name','sort'], 'required', 'on' => self::SCENARIO_EDIT],
['sort', 'default', 'value' => 99], ['sort', 'default', 'value' => 99],
['icon', 'default', 'value' => 0], ['icon', 'default', 'value' => 0],
['pid', 'default', 'value' => 0],
['name', 'checkName'], ['name', 'checkName'],
]; ];
} }
...@@ -92,7 +94,8 @@ class CoinApplicationCategoryForm extends BaseForm ...@@ -92,7 +94,8 @@ class CoinApplicationCategoryForm extends BaseForm
if($coin_applicate_category){ if($coin_applicate_category){
$coin_applicate_category->setAttributes($this->attributes,false); $coin_applicate_category->setAttributes($this->attributes,false);
$coin_applicate_category->save(); $coin_applicate_category->save();
return ['code' => 0,'msg' => '应用分类修改成功!']; $items = CoinApplicationCategory::getItemsByPid(0);
return ['code' => 0,'msg' => '应用分类修改成功!','items' => $items];
}else{ }else{
return ['code' => 1,'msg' => '应用分类不存在']; return ['code' => 1,'msg' => '应用分类不存在'];
} }
......
...@@ -35,6 +35,18 @@ ...@@ -35,6 +35,18 @@
<form class="layui-form form_add" action="javascript:void(0)" id="form1" method="post" lay-filter="form1"> <form class="layui-form form_add" action="javascript:void(0)" id="form1" method="post" lay-filter="form1">
<input type="hidden" name="_csrf" value="<?= Yii::$app->request->getCsrfToken() ?>"> <input type="hidden" name="_csrf" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input type="hidden" name="id" value=""> <input type="hidden" name="id" value="">
<div class="layui-form-item">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">所属分类</label>
<div class="layui-input-block">
<select name="pid" id="select">
<option value="0">顶级分类</option>
<?php foreach ($items as $key => $value): ?>
<option value="<?= $key ?>"><?= $value ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="layui-form-item layui-form-text"> <div class="layui-form-item layui-form-text">
<label class="layui-form-label">名称</label> <label class="layui-form-label">名称</label>
<div class="layui-input-block"> <div class="layui-input-block">
...@@ -113,6 +125,13 @@ ...@@ -113,6 +125,13 @@
width:50 width:50
}, },
{
field: 'pid',
title: '所属父级',
hide:true,
width:50
},
]], ]],
}); });
...@@ -135,6 +154,7 @@ ...@@ -135,6 +154,7 @@
name: data.name, name: data.name,
icon: data.icon, icon: data.icon,
sort: data.sort, sort: data.sort,
pid: data.pid,
}); });
$("#icon1").attr('src', data.icon_url); $("#icon1").attr('src', data.icon_url);
}, },
...@@ -149,6 +169,8 @@ ...@@ -149,6 +169,8 @@
curr: 1 curr: 1
} }
}); });
refreshSelect(rev.items);
} }
}); });
}, },
...@@ -241,8 +263,19 @@ ...@@ -241,8 +263,19 @@
name: '', name: '',
icon: '', icon: '',
sort: '', sort: '',
pid: 0,
}); });
$("#icon1").attr('src', ''); $("#icon1").attr('src', '');
} }
//刷新分类下拉框
function refreshSelect(items){
var html = '<option value="0">顶级分类</option>';
$.each(items, function(i, c) {
html += '<option value="' + i + '">' + c + '</option>';
});
$('#select').html(html);
form.render('select');
}
</script> </script>
\ No newline at end of file
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