Browse Source

商品分类处理表单is_show字段单选框,处理数据删除操作以及规则

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
1dd45f0c81
  1. 5
      vendor/antgoods/goods/src/controllers/CategoryController.php
  2. 14
      vendor/antgoods/goods/src/models/ars/Category.php
  3. 1
      vendor/antgoods/goods/src/models/searchs/CategorySearch.php
  4. 5
      vendor/antgoods/goods/src/views/category/_form.php

5
vendor/antgoods/goods/src/controllers/CategoryController.php

@ -105,7 +105,10 @@ class CategoryController extends Controller
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
$model = $this->findModel($id);
$model->is_delete = Category::IS_DELETE_YES;
$model->save();
return $this->redirect(['index']);
}

14
vendor/antgoods/goods/src/models/ars/Category.php

@ -22,6 +22,18 @@ use yii\behaviors\TimestampBehavior;
*/
class Category extends \yii\db\ActiveRecord
{
//是否显示is_show
const IS_SHOW_DISPLAY = 0;//显示
const IS_SHOW_HIDE = 1;//隐藏
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
public static $isShow = [
self::IS_SHOW_DISPLAY => '显示',
self::IS_SHOW_HIDE => '隐藏'
];
/**
* {@inheritdoc}
*/
@ -56,7 +68,7 @@ class Category extends \yii\db\ActiveRecord
'sort_order' => '排序',
'icon_type' => '图标类型',
'icon' => '图标',
'is_show' => '是否显示,1为不显示',
'is_show' => '是否显示',
'is_delete' => '是否删除,1为已删除',
'created_at' => '创建时间',
'updated_at' => '更新时间',

1
vendor/antgoods/goods/src/models/searchs/CategorySearch.php

@ -121,6 +121,7 @@ class CategorySearch extends Category
* 条件筛选
*/
private function filter($query, $dataProvider){
$query->andFilterWhere(['is_delete' => 0]);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');

5
vendor/antgoods/goods/src/views/category/_form.php

@ -2,6 +2,7 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use blobt\widgets\Icheck;
/* @var $this yii\web\View */
/* @var $model antgoods\goods\models\ars\Category */
@ -22,9 +23,7 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'icon')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'is_show')->textInput() ?>
<?= $form->field($model, 'is_delete')->textInput() ?>
<?= $form->field($model, 'is_show')->widget(Icheck::className(), ["items" => $model::$isShow, 'type' => "radio"]) ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>

Loading…
Cancel
Save