Commit 6c2d4607 authored by ZhuChunYang's avatar ZhuChunYang

update

parent 9d5c6fe8
......@@ -31,8 +31,8 @@ class ApplicationCategoryController extends BaseController
$data = CoinApplicationCategory::getList($page, $limit, $where);
return $data;
}
//$items = CoinApplicationCategory::getItemsByPid(0);
return $this->render('index');
$items = CoinApplicationCategory::getItemsByPid(0);
return $this->render('index',['items' => $items]);
}
/**
......@@ -42,7 +42,7 @@ class ApplicationCategoryController extends BaseController
{
if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json';
$fields = ['id','name','sort','icon'];
$fields = ['id','name','sort','icon','pid'];
$params = $this->initParams(Yii::$app->request->post(), $fields);
$application_category = new CoinApplicationCategoryForm();
if($params['id']){ //edit
......@@ -75,16 +75,4 @@ class ApplicationCategoryController extends BaseController
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
{
return [
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
'name' => '名称',
'icon' => '图标',
'sort' => '排序',
'pid' => '父级分类ID'
];
}
......@@ -47,6 +48,7 @@ class CoinApplicationCategoryForm extends BaseForm
[['id','name','sort'], 'required', 'on' => self::SCENARIO_EDIT],
['sort', 'default', 'value' => 99],
['icon', 'default', 'value' => 0],
['pid', 'default', 'value' => 0],
['name', 'checkName'],
];
}
......@@ -92,7 +94,8 @@ class CoinApplicationCategoryForm extends BaseForm
if($coin_applicate_category){
$coin_applicate_category->setAttributes($this->attributes,false);
$coin_applicate_category->save();
return ['code' => 0,'msg' => '应用分类修改成功!'];
$items = CoinApplicationCategory::getItemsByPid(0);
return ['code' => 0,'msg' => '应用分类修改成功!','items' => $items];
}else{
return ['code' => 1,'msg' => '应用分类不存在'];
}
......
......@@ -35,6 +35,18 @@
<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="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">
<label class="layui-form-label">名称</label>
<div class="layui-input-block">
......@@ -113,6 +125,13 @@
width:50
},
{
field: 'pid',
title: '所属父级',
hide:true,
width:50
},
]],
});
......@@ -135,6 +154,7 @@
name: data.name,
icon: data.icon,
sort: data.sort,
pid: data.pid,
});
$("#icon1").attr('src', data.icon_url);
},
......@@ -149,6 +169,8 @@
curr: 1
}
});
refreshSelect(rev.items);
}
});
},
......@@ -241,8 +263,19 @@
name: '',
icon: '',
sort: '',
pid: 0,
});
$("#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>
\ 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