diff --git a/application/admin/controller/wdsxh/member/Level.php b/application/admin/controller/wdsxh/member/Level.php index c392ab5..bf8ec1d 100644 --- a/application/admin/controller/wdsxh/member/Level.php +++ b/application/admin/controller/wdsxh/member/Level.php @@ -1,6 +1,6 @@ model = new \app\admin\model\wdsxh\member\Level; + $this->member_benefit_model = new \app\admin\model\wdsxh\member\MemberBenefits; $this->view->assign("statusList", $this->model->getStatusList()); $pay_method = (new FeesConfig())->where('id',1)->value('pay_method'); $this->pay_method = $pay_method; @@ -112,6 +114,8 @@ class Level extends Backend public function add() { if (false === $this->request->isPost()) { + $benefits = $this->member_benefit_model->getSimpleByStatus(0); + $this->view->assign('benefits', $benefits); return $this->view->fetch(); } $params = $this->request->post('row/a'); @@ -166,6 +170,11 @@ class Level extends Backend $this->error(__('You have no permission')); } if (false === $this->request->isPost()) { + $benefits = $this->member_benefit_model->getSimpleByStatus(0); + $this->view->assign('benefits', $benefits); + if (is_null($row['benefits_id'])) { + $row['benefits_id'] = []; + } $this->view->assign('row', $row); return $this->view->fetch(); } diff --git a/application/admin/model/wdsxh/member/Level.php b/application/admin/model/wdsxh/member/Level.php index c58b8e2..fbd0d60 100644 --- a/application/admin/model/wdsxh/member/Level.php +++ b/application/admin/model/wdsxh/member/Level.php @@ -1,6 +1,6 @@ 'json', + ]; + // 追加属性 protected $append = [ 'status_text' ]; - + protected static function init() { @@ -46,7 +50,7 @@ class Level extends Model }); } - + public function getStatusList() { return ['normal' => __('Status normal'), 'hidden' => __('Status hidden')]; diff --git a/application/admin/model/wdsxh/member/MemberBenefits.php b/application/admin/model/wdsxh/member/MemberBenefits.php index a810cf4..4d07ace 100644 --- a/application/admin/model/wdsxh/member/MemberBenefits.php +++ b/application/admin/model/wdsxh/member/MemberBenefits.php @@ -53,4 +53,13 @@ class MemberBenefits extends Model $list = $this->getDisabledList(); return isset($list[$value]) ? $list[$value] : ''; } + + public function getSimpleByStatus($disabled = 0) + { + return Self::field(['id', 'title'])->where(function($query) use ($disabled) { + if (null !== $disabled) { + $query->where('disabled', '=', $disabled); + } + })->order('sort', 'asc')->select(); + } } diff --git a/application/admin/view/wdsxh/member/level/add.html b/application/admin/view/wdsxh/member/level/add.html index 9bb03dd..dd82625 100644 --- a/application/admin/view/wdsxh/member/level/add.html +++ b/application/admin/view/wdsxh/member/level/add.html @@ -16,13 +16,10 @@
- - + {foreach $benefits as $benefit} + + {/foreach}
@@ -41,9 +38,9 @@ - - - + + +
@@ -59,7 +56,7 @@
- +
{foreach name="statusList" item="vo"} diff --git a/application/admin/view/wdsxh/member/level/edit.html b/application/admin/view/wdsxh/member/level/edit.html index 6baa8fc..532895c 100644 --- a/application/admin/view/wdsxh/member/level/edit.html +++ b/application/admin/view/wdsxh/member/level/edit.html @@ -16,13 +16,10 @@
- - + {foreach $benefits as $benefit} + + {/foreach}
@@ -31,7 +28,7 @@
- +
@@ -41,9 +38,9 @@
    - - - + + +
    @@ -59,7 +56,7 @@
    - +
    {foreach name="statusList" item="vo"}