作者 耿培杰

修改后台添加商品

... ... @@ -110,10 +110,9 @@ class Goods extends Backend
}
if (empty($params['category_one_id'])) $this->error('一级分类不能为空');
if (empty($params['category_two_id'])) $this->error('二级分类不能为空');
if (empty($params['category_three_id'])) $this->error('三级分类不能为空');
$params['category_one_id'] = ',' . $params['category_one_id'] . ',';
$params['category_two_id'] = ',' . $params['category_two_id'] . ',';
$params['category_three_id'] = ',' . $params['category_three_id'] . ',';
if (!empty($params['category_three_id'])) $params['category_three_id'] = ',' . $params['category_three_id'] . ',';
if (!empty($params['category_group_ids'])) $params['category_group_ids'] = ',' . $params['category_group_ids'] . ',';
if ($params['is_group'] == 1) {
if (empty($params['group_num'])) $this->error('团购人数不能为空');
... ... @@ -181,10 +180,9 @@ class Goods extends Backend
}
if (empty($params['category_one_id'])) $this->error('一级分类不能为空');
if (empty($params['category_two_id'])) $this->error('二级分类不能为空');
if (empty($params['category_three_id'])) $this->error('三级分类不能为空');
$params['category_one_id'] = ',' . $params['category_one_id'] . ',';
$params['category_two_id'] = ',' . $params['category_two_id'] . ',';
$params['category_three_id'] = ',' . $params['category_three_id'] . ',';
if (!empty($params['category_three_id'])) $params['category_three_id'] = ',' . $params['category_three_id'] . ',';
if (!empty($params['category_group_ids'])) $params['category_group_ids'] = ',' . $params['category_group_ids'] . ',';
if ($params['is_group'] == 1) {
if (empty($params['group_num'])) $this->error('团购人数不能为空');
... ...
... ... @@ -2,6 +2,7 @@
namespace app\admin\controller;
use app\admin\model\User;
use app\api\model\UserTicket;
use app\common\controller\Backend;
use think\Db;
... ... @@ -26,6 +27,7 @@ class Ticket extends Backend
$this->view->assign("settingShareList", $this->model->getSettingShareList());
$this->view->assign("settingMonthList", $this->model->getSettingMonthList());
$this->view->assign("typeList", $this->model->getTypeList());
$this->view->assign("selectTypeList", ['1'=>'全部','2'=>'普通用户','3'=>'会员','4'=>'员工','5'=>'一级代理','6'=>'二级代理','7'=>'三级代理','8'=>'指定用户']);
}
/**
... ... @@ -155,8 +157,20 @@ class Ticket extends Backend
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
$userModel = new User();
$where = [];
$userTicketModel = new UserTicket();
$userIds = explode(',',$params['user_ids']);
if ($params['type'] == 8 && !$params['user_ids']) $this->error('用户不能为空');
elseif ($params['type'] == 2) $where['type'] = 1;
elseif ($params['type'] == 3) $where['type'] = 2;
elseif ($params['type'] == 4) $where['type'] = 3;
elseif ($params['type'] == 5) $where['type'] = 4;
elseif ($params['type'] == 6) $where['type'] = 5;
elseif ($params['type'] == 7) $where['type'] = 6;
else $userIds = explode(',',$params['user_ids']);
if (empty($userIds)) $userIds = $userModel->where($where)->column('id');
if (!$userIds) $this->error('暂无此类型用户');
//默认全部用户
$ticketInfo = $this->model->where('id',$params['ticket_id'])->find();
$data = [];
... ...
... ... @@ -6,11 +6,22 @@
<input id="c-ticket_id" data-rule="required" data-source="ticket/index" data-field="ch_name" class="form-control selectpage" name="row[ticket_id]" type="text" value="">
</div>
</div>
<div class="form-group type">
<label class="control-label col-xs-12 col-sm-2">类型:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" class="form-control selectpicker" name="row[type]">
{foreach name="selectTypeList" item="vo"}
<option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
{/foreach}
</select>
<div class="form-group user">
</div>
</div>
<div class="form-group user" style="display: none">
<label class="control-label col-xs-12 col-sm-2">选择用户:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_ids" data-rule="required" data-source="user/user/index" data-multiple="true" data-field="nickname" class="form-control selectpage" name="row[user_ids]" type="text" value="">
<input id="c-user_ids" data-source="user/user/index" data-multiple="true" data-field="nickname" class="form-control selectpage" name="row[user_ids]" type="text" value="">
</div>
</div>
<div class="form-group layer-footer">
... ...
... ... @@ -16,6 +16,7 @@ class Evaluate extends Model
public function getImagesAttr($value)
{
if (!$value) return [];
$arr = explode(',', $value);
$data = [];
foreach ($arr as $k => $v) {
... ...
... ... @@ -107,6 +107,7 @@ class Goods extends Model
public function getImagesAttr($value)
{
if (!$value) return [];
$arr = explode(',', $value);
$data = [];
foreach ($arr as $k => $v) {
... ...
... ... @@ -15,6 +15,7 @@ class IntegralGoods extends Model
public function getImagesAttr($value)
{
if (!$value) return [];
$arr = explode(',', $value);
$data = [];
foreach ($arr as $k => $v) {
... ...
... ... @@ -25,16 +25,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'category_one_id', title: __('Category_one_id'),visible:false},
{field: 'category_two_id', title: __('Category_two_id'),visible:false},
{field: 'category_three_id', title: __('Category_three_id'),visible:false},
{field: 'category_group_ids', title: __('Category_group_ids'),visible:false},
{field: 'category_one_id', title: __('Category_one_id'),visible:false, operate:false},
{field: 'category_two_id', title: __('Category_two_id'),visible:false, operate:false},
{field: 'category_three_id', title: __('Category_three_id'),visible:false, operate:false},
{field: 'category_group_ids', title: __('Category_group_ids'),visible:false, operate:false},
{field: 'country_id', title: __('Country_id'),visible:false},
{field: 'brand_id', title: __('Brand_id'),visible:false},
{field: 'level_id', title: __('Level_id'),visible:false},
{field: 'part_id', title: __('Part_id'),visible:false},
{field: 'category2_id', title: __('Category2_id'),visible:false},
{field: 'depot_id', title: __('Depot_id'),visible:false},
{field: 'brand_id', title: __('Brand_id'),visible:false, operate:false},
{field: 'level_id', title: __('Level_id'),visible:false, operate:false},
{field: 'part_id', title: __('Part_id'),visible:false, operate:false},
{field: 'category2_id', title: __('Category2_id'),visible:false, operate:false},
{field: 'depot_id', title: __('Depot_id'),visible:false, operate:false},
{field: 'ch_name', title: __('Ch_name')},
{field: 'en_name', title: __('En_name')},
{field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate:false},
... ...
... ... @@ -79,6 +79,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
},
grant: function () {
Controller.api.bindevent();
$('#c-type').change(function () {
var type = $('#c-type').val();
if (type === '8') $('.user').show();
else{
$('.user').hide();
$('#c-user_ids').val('');
$("#user_ids_text").val('');
$(".user .selected_tag").remove();
}
});
},
api: {
bindevent: function () {
... ...