作者 何书鹏

定制风格

正在显示 39 个修改的文件 包含 455 行增加502 行删除
... ... @@ -85,25 +85,25 @@ class Goods extends Backend
/**
* 模特款
*/
public function spec($ids = null)
public function style($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$goods_spec = new \app\common\model\GoodsSpec;
$goods_style = new \app\common\model\GoodsStyle;
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
if(empty($params['goods_spec'])){
if(empty($params['goods_style'])){
$this->error(__('该模板下无规格选项,请在【规格模板管理】里为其添加规格'));
}
$params['goods_spec'] = json_encode($params['goods_spec']);
$params['goods_style'] = json_encode($params['goods_style']);
$params['goods_id'] = $ids;
try {
$goods_spec->where(['goods_id'=>$ids])->delete();
$result = $goods_spec->allowField(true)->save($params);
$goods_style->where(['goods_id'=>$ids])->delete();
$result = $goods_style->allowField(true)->save($params);
if ($result !== false) {
$this->success();
} else {
... ... @@ -117,31 +117,21 @@ class Goods extends Backend
}
$this->error(__('Parameter %s can not be empty', ''));
}
$spec_template_list = \app\admin\model\SpecTemplate::where('id','>',2)->field('id,name')->select();
$goods_spec = $goods_spec->get(['goods_id'=>$ids]);
$this->view->assign('spec_template_list',$spec_template_list);
$this->view->assign('goods_spec',$goods_spec);
$this->assignconfig('goods_spec',!empty($goods_spec['goods_spec']) ? json_decode($goods_spec['goods_spec'],true) : []);
$style_template_list = \app\admin\model\StyleTemplate::where('id','>',2)->field('id,name')->select();
$goods_style = $goods_style->get(['goods_id'=>$ids]);
$this->view->assign('style_template_list',$style_template_list);
$this->view->assign('goods_style',$goods_style);
$this->assignconfig('goods_style',!empty($goods_style['goods_style']) ? json_decode($goods_style['goods_style'],true) : []);
return $this->view->fetch();
}
/**
* 正常显示规格
*/
public function specList()
public function styleList()
{
$spec_template_id = $this->request->request('spec_template_id');
$list = \app\common\model\Spec::specList($spec_template_id);
$this->success(__('成功'),null,compact('list'));
}
/**
* 规格值下规格
*/
public function valueSpecList()
{
$spec_value_id = $this->request->request('spec_value_id');
$list = \app\common\model\Spec::valueSpecList($spec_value_id);
$style_template_id = $this->request->request('style_template_id');
$list = \app\common\model\Style::styleList($style_template_id);
$this->success(__('成功'),null,compact('list'));
}
}
... ...
... ... @@ -6,24 +6,24 @@ use app\common\controller\Backend;
use fast\Tree;
/**
* 格管理
* 定制风格管理
*
* @icon fa fa-circle-o
*/
class Spec extends Backend
class Style extends Backend
{
/**
* Spec模型对象
* @var \app\admin\model\Spec
* Style模型对象
* @var \app\admin\model\Style
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Spec;
$this->view->assign("specTypeList", $this->model->getSpecTypeList());
$this->model = new \app\admin\model\Style;
$this->view->assign("styleTypeList", $this->model->getStyleTypeList());
$this->view->assign("displayModeList", $this->model->getDisplayModeList());
}
... ... @@ -44,20 +44,28 @@ class Spec extends Backend
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = false;
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax()) {
$spec_template_id = $this->request->request("spec_template_id");
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
$style_template_id = $this->request->request("style_template_id");
$display_mode = $this->request->request("display_mode");
if($spec_template_id){
$where['spec_template_id'] = $spec_template_id;
if($style_template_id){
$where['style_template_id'] = $style_template_id;
}
if($display_mode && $display_mode != 'all'){
$where['display_mode'] = $display_mode;
}
$tree = Tree::instance();
$tree->init(collection($this->model->where($where)->order('weigh desc,id desc')->select())->toArray(), 'pid');
$list = $tree->getTreeList($tree->getTreeArray(0), 'spec_name');
$list = $tree->getTreeList($tree->getTreeArray(0), 'style_name');
$total = count($list);
$result = array("total" => $total, "rows" => $list);
... ... @@ -72,22 +80,23 @@ class Spec extends Backend
*/
public function add()
{
// 规格模板ID
$spec_template_id = $this->request->request('spec_template_id');
// 所属上级规格
// 风格模板ID
$style_template_id = $this->request->request('style_template_id');
// 所属上级风格
$where = [
'spec_template_id' => $spec_template_id,
'spec_type' => '1',
'style_template_id' => $style_template_id,
'style_type' => '1',
'display_mode' => '1',
'pid' => 0
];
$tree = Tree::instance();
$tree->init(collection($this->model->where($where)->order('weigh desc,id desc')->select())->toArray(), 'pid');
$specdata = [0 => ['display_mode' => 'all', 'spec_name' => __('None')]];
foreach ($tree->getTreeList($tree->getTreeArray(0), 'spec_name') as $k => $v) {
$specdata[$v['id']] = $v;
$styledata = [0 => ['display_mode' => 'all', 'style_name' => __('None')]];
foreach ($tree->getTreeList($tree->getTreeArray(0), 'style_name') as $k => $v) {
$styledata[$v['id']] = $v;
}
$this->view->assign("spec_template_id", $spec_template_id);
$this->view->assign("parentList", $specdata);
$this->view->assign("style_template_id", $style_template_id);
$this->view->assign("parentList", $styledata);
return parent::add();
}
... ... @@ -112,12 +121,12 @@ class Spec extends Backend
$params = $this->preExcludeFields($params);
if ($params['pid'] != $row['pid']) {
$childrenIds = Tree::instance()->init(collection(\app\common\model\Spec::select())->toArray())->getChildrenIds($row['id'], true);
$childrenIds = Tree::instance()->init(collection(\app\common\model\style::select())->toArray())->getChildrenIds($row['id'], true);
if (in_array($params['pid'], $childrenIds)) {
$this->error(__('父组别不能是它自己'));
}
if (count($childrenIds) > 1) {
$this->error(__('最多二级规格,已有子规格,请勿归到其他规格下'));
$this->error(__('最多二级风格,已有子风格,请勿归到其他风格下'));
}
}
... ... @@ -142,19 +151,20 @@ class Spec extends Backend
}
$this->error(__('Parameter %s can not be empty', ''));
}
// 所属上级
// 所属上级
$where = [
'spec_template_id' => $row['spec_template_id'],
'spec_type' => '1',
'style_template_id' => $row['style_template_id'],
'style_type' => '1',
'display_mode' => '1',
'pid' => 0
];
$tree = Tree::instance();
$tree->init(collection($this->model->where($where)->order('weigh desc,id desc')->select())->toArray(), 'pid');
$specdata = [0 => ['display_mode' => 'all', 'spec_name' => __('None')]];
foreach ($tree->getTreeList($tree->getTreeArray(0), 'spec_name') as $k => $v) {
$specdata[$v['id']] = $v;
$styledata = [0 => ['display_mode' => 'all', 'style_name' => __('None')]];
foreach ($tree->getTreeList($tree->getTreeArray(0), 'style_name') as $k => $v) {
$styledata[$v['id']] = $v;
}
$this->view->assign("parentList", $specdata);
$this->view->assign("parentList", $styledata);
$this->view->assign("row", $row);
return $this->view->fetch();
}
... ...
... ... @@ -5,23 +5,23 @@ namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 格模板管理
* 定制风格模板管理
*
* @icon fa fa-circle-o
*/
class SpecTemplate extends Backend
class StyleTemplate extends Backend
{
/**
* SpecTemplate模型对象
* @var \app\admin\model\SpecTemplate
* StyleTemplate模型对象
* @var \app\admin\model\StyleTemplate
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\SpecTemplate;
$this->model = new \app\admin\model\StyleTemplate;
}
... ...
... ... @@ -6,23 +6,23 @@ use app\common\controller\Backend;
use fast\Tree;
/**
* 规格管理
* 定制风格值管理
*
* @icon fa fa-circle-o
*/
class SpecValue extends Backend
class StyleValue extends Backend
{
/**
* SpecValue模型对象
* @var \app\admin\model\SpecValue
* StyleValue模型对象
* @var \app\admin\model\StyleValue
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\SpecValue;
$this->model = new \app\admin\model\StyleValue;
}
... ... @@ -54,20 +54,15 @@ class SpecValue extends Backend
{
return $this->selectpage();
}
$where['spec_id'] = $this->request->request('spec_id',0);
$style_id = $this->request->request("style_id");
$total = $this->model
->where($where)
->order('weigh desc')
->where('style_id',$style_id)
->count();
$list = $this->model
->where($where)
->order('weigh desc')
->where('style_id',$style_id)
->select();
foreach ($list as $row) {
$row->visible(['id','spec_value','spec_value_image','spec_value_price','updatetime','weigh']);
$row->visible(['id','style_id','style_value_name','style_value_image','style_value_price','updatetime','weigh']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
... ... @@ -82,7 +77,7 @@ class SpecValue extends Backend
*/
public function add()
{
$spec_id = $this->request->request('spec_id');
$style_id = $this->request->request('style_id');
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
... ... @@ -92,29 +87,29 @@ class SpecValue extends Backend
$params[$this->dataLimitField] = $this->auth->id;
}
if(!empty($params['spec_ids'])){
$spec = new \app\common\model\Spec;
$display_mode = $spec->where('id',$params['spec_id'])->value('display_mode');
if(!empty($params['style_ids'])){
$style = new \app\common\model\Style;
$display_mode = $style->where('id',$params['style_id'])->value('display_mode');
if($display_mode == '2'){
$this->error(__('该规格值,不能选择规格值下规格'));
$this->error(__('该风格值为【风格值下显示风格】的值,不能选择【风格值下显示风格】'));
}
$spec_id_arr = explode(',',$params['spec_ids']);
$parentsIds = Tree::instance()->init(collection($spec->select())->toArray())->getParentsIds($params['spec_id'], true);
foreach($spec_id_arr as $v){
// 规格值下规格,不能是所属规格的父规格或所属规格
$style_id_arr = explode(',',$params['style_ids']);
$parentsIds = Tree::instance()->init(collection($style->select())->toArray())->getParentsIds($params['style_id'], true);
foreach($style_id_arr as $v){
// 选项下风格,不能是所属风格的父风格或所属风格
if (in_array($v, $parentsIds)) {
$this->error(__('规格值下规格,不能是所属规格的父规格或所属规格'));
$this->error(__('风格值下风格,不能是所属风格的父风格或所属风格'));
}
// 规格值下的规格,只能出现在一个地方
// 选项下的风格,只能出现在一个地方
$has = $this->model
->alias('v')
->join('spec s','s.id = v.spec_id')
->where("FIND_IN_SET('{$v}', v.spec_ids)")
->field('v.spec_id,s.spec_name')
->join('style s','s.id = v.style_id')
->where("FIND_IN_SET('{$v}', v.style_ids)")
->field('v.style_id,s.style_name')
->find();
if($params['spec_id'] != $has['spec_id']){
$spec_name = $spec->where('id',$v)->value('spec_name');
$this->error(__($spec_name.' 已被 '.$has['spec_name'].' 下规格值使用'));
if($params['style_id'] != $has['style_id']){
$style_name = $style->where('id',$v)->value('style_name');
$this->error(__($style_name.' 已被 '.$has['style_name'].' 下风格值使用'));
}
}
}
... ... @@ -140,8 +135,8 @@ class SpecValue extends Backend
}
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("spec_id", $spec_id);
$this->view->assign("spec_template_id", \app\common\model\Spec::where('id',$spec_id)->value('spec_template_id'));
$this->view->assign("style_id", $style_id);
$this->view->assign("style_template_id", \app\common\model\Style::where('id',$style_id)->value('style_template_id'));
return parent::add();
}
... ... @@ -165,29 +160,29 @@ class SpecValue extends Backend
if ($params) {
$params = $this->preExcludeFields($params);
if(!empty($params['spec_ids'])){
$spec = new \app\common\model\Spec;
$display_mode = $spec->where('id',$params['spec_id'])->value('display_mode');
if(!empty($params['style_ids'])){
$style = new \app\common\model\Style;
$display_mode = $style->where('id',$params['style_id'])->value('display_mode');
if($display_mode == '2'){
$this->error(__('该规格值,不能选择规格值下规格'));
$this->error(__('该风格值为【风格值下显示风格】的值,不能选择【风格值下显示风格】'));
}
$spec_id_arr = explode(',',$params['spec_ids']);
$parentsIds = Tree::instance()->init(collection($spec->select())->toArray())->getParentsIds($params['spec_id'], true);
foreach($spec_id_arr as $v){
// 规格值下规格,不能是所属规格的父规格或所属规格
$style_id_arr = explode(',',$params['style_ids']);
$parentsIds = Tree::instance()->init(collection($style->select())->toArray())->getParentsIds($params['style_id'], true);
foreach($style_id_arr as $v){
// 选项下风格,不能是所属风格的父风格或所属风格
if (in_array($v, $parentsIds)) {
$this->error(__('规格值下规格,不能是所属规格的父规格或所属规格'));
$this->error(__('风格值下风格,不能是所属风格的父风格或所属风格'));
}
// 规格值下的规格,只能出现在一个地方
// 选项下的风格,只能出现在一个地方
$has = $this->model
->alias('v')
->join('spec s','s.id = v.spec_id')
->where("FIND_IN_SET('{$v}', v.spec_ids) and v.spec_id != {$params['spec_id']}")
->field('v.spec_id,s.spec_name')
->join('style s','s.id = v.style_id')
->where("FIND_IN_SET('{$v}', v.style_ids) and v.style_id != {$params['style_id']}")
->field('v.style_id,s.style_name')
->find();
if($has){
$spec_name = $spec->where('id',$v)->value('spec_name');
$this->error(__($spec_name.' 已被 '.$has['spec_name'].' 下规格值使用'));
$style_name = $style->where('id',$v)->value('style_name');
$this->error(__($style_name.' 已被 '.$has['style_name'].' 下风格值使用'));
}
}
}
... ... @@ -214,7 +209,7 @@ class SpecValue extends Backend
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("row", $row);
$this->view->assign("spec_template_id", \app\common\model\Spec::where('id',$row['spec_id'])->value('spec_template_id'));
$this->view->assign("style_template_id", \app\common\model\Style::where('id',$row['style_id'])->value('style_template_id'));
return $this->view->fetch();
}
}
... ...
<?php
return [
'Spec_template_id' => '规格模板ID',
'Pid' => '父ID',
'Spec_name' => '规格组名称',
'Spec_type' => '规格类型',
'Spec_type 1' => '普通',
'Spec_type 2' => '文本',
'Spec_type 3' => '图片',
'Display_mode' => '显示方式',
'Display_mode 1' => '正常显示',
'Display_mode 2' => '规格值下显示',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Weigh' => '权重'
];
<?php
return [
'Spec_id' => '规格组ID',
'Spec_value' => '规格值',
'Spec_value_image' => '规格值图片',
'Spec_value_price' => '规格值价格',
'Spec_ids' => '规格值下的规格组',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Weigh' => '权重'
];
<?php
return [
'Style_template_id' => '定制风格模板ID',
'Pid' => '父ID',
'Style_name' => '风格名称',
'Style_type' => '风格类型',
'Style_type 1' => '普通',
'Style_type 2' => '文本',
'Style_type 3' => '图片',
'Display_mode' => '显示方式',
'Display_mode 1' => '正常显示',
'Display_mode 2' => '风格值下显示',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Weigh' => '权重'
];
... ...
<?php
return [
'Style_id' => '风格ID',
'Style_value_name' => '风格值名称',
'Style_value_desc' => '风格值描述',
'Style_value_image' => '风格值图片',
'Style_value_price' => '风格值价格',
'Style_ids' => '风格值下的风格',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Weigh' => '权重'
];
... ...
... ... @@ -5,7 +5,7 @@ namespace app\admin\model;
use think\Model;
class Spec extends Model
class Style extends Model
{
... ... @@ -13,7 +13,7 @@ class Spec extends Model
// 表名
protected $name = 'spec';
protected $name = 'style';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
... ... @@ -25,7 +25,7 @@ class Spec extends Model
// 追加属性
protected $append = [
'spec_type_text',
'style_type_text',
'display_mode_text'
];
... ... @@ -39,9 +39,9 @@ class Spec extends Model
}
public function getSpecTypeList()
public function getStyleTypeList()
{
return ['1' => __('Spec_type 1'), '2' => __('Spec_type 2'), '3' => __('Spec_type 3')];
return ['1' => __('Style_type 1'), '2' => __('Style_type 2'), '3' => __('Style_type 3')];
}
public function getDisplayModeList()
... ... @@ -50,10 +50,10 @@ class Spec extends Model
}
public function getSpecTypeTextAttr($value, $data)
public function getStyleTypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['spec_type']) ? $data['spec_type'] : '');
$list = $this->getSpecTypeList();
$value = $value ? $value : (isset($data['style_type']) ? $data['style_type'] : '');
$list = $this->getStyleTypeList();
return isset($list[$value]) ? $list[$value] : '';
}
... ...
... ... @@ -5,7 +5,7 @@ namespace app\admin\model;
use think\Model;
class SpecTemplate extends Model
class StyleTemplate extends Model
{
... ... @@ -13,7 +13,7 @@ class SpecTemplate extends Model
// 表名
protected $name = 'spec_template';
protected $name = 'style_template';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
... ...
... ... @@ -5,7 +5,7 @@ namespace app\admin\model;
use think\Model;
class SpecValue extends Model
class StyleValue extends Model
{
... ... @@ -13,7 +13,7 @@ class SpecValue extends Model
// 表名
protected $name = 'spec_value';
protected $name = 'style_value';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
... ...
... ... @@ -4,7 +4,7 @@ namespace app\admin\validate;
use think\Validate;
class Spec extends Validate
class Style extends Validate
{
/**
* 验证规则
... ...
... ... @@ -4,7 +4,7 @@ namespace app\admin\validate;
use think\Validate;
class SpecTemplate extends Validate
class StyleTemplate extends Validate
{
/**
* 验证规则
... ...
... ... @@ -4,7 +4,7 @@ namespace app\admin\validate;
use think\Validate;
class SpecValue extends Validate
class StyleValue extends Validate
{
/**
* 验证规则
... ...
<form id="spec-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('规格模板')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-spec_template_id" data-rule="required" class="form-control selectpicker" name="row[spec_template_id]">
{foreach name="spec_template_list" item="vo"}
<option value="{$vo.id}" {in name="vo.id" value="$goods_spec['spec_template_id']"}selected{/in}>{$vo.name}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
<form id="model-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<form id="style-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Category_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('定制风格模板')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-category_id" data-rule="required" data-source="category/selectpage" data-params='{"custom[type]":"goods","custom[id]":"{$category_id}"}' class="form-control selectpage" name="row[category_id]" type="text" value="">
<select id="c-style_template_id" data-rule="required" class="form-control selectpicker" name="row[style_template_id]">
{foreach name="style_template_list" item="vo"}
<option value="{$vo.id}" {in name="vo.id" value="$goods_style['style_template_id']"}selected{/in}>{$vo.name}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group layer-footer">
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_template_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_template_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_template_id" data-rule="required" data-source="spec_template/index" data-params='{"custom[id]":"{$spec_template_id}"}' class="form-control selectpage" name="row[spec_template_id]" type="text" value="{$spec_template_id}">
<input id="c-style_template_id" data-rule="required" data-source="style_template/index" data-params='{"custom[id]":"{$style_template_id}"}' class="form-control selectpage" name="row[style_template_id]" type="text" value="{$style_template_id}">
</div>
</div>
<div class="form-group">
... ... @@ -11,23 +11,23 @@
<div class="col-xs-12 col-sm-8">
<select id="c-pid" data-rule="required" class="form-control selectpicker" name="row[pid]">
{foreach name="parentList" item="vo"}
<option data-display_mode="{$vo.display_mode}" value="{$key}" {in name="key" value=""}selected{/in}>{$vo.spec_name}</option>
<option data-display_mode="{$vo.display_mode}" value="{$key}" {in name="key" value=""}selected{/in}>{$vo.style_name}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_name')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_name" data-rule="required" class="form-control" name="row[spec_name]" type="text" value="">
<input id="c-style_name" data-rule="required" class="form-control" name="row[style_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_type')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-spec_type" data-rule="required" class="form-control selectpicker" name="row[spec_type]">
{foreach name="specTypeList" item="vo"}
<select id="c-style_type" data-rule="required" class="form-control selectpicker" name="row[style_type]">
{foreach name="styleTypeList" item="vo"}
<option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
{/foreach}
</select>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_template_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_template_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_template_id" data-rule="required" data-source="spec_template/index" data-params='{"custom[id]":"{$row.spec_template_id}"}' class="form-control selectpage" name="row[spec_template_id]" type="text" value="{$row.spec_template_id|htmlentities}">
<input id="c-style_template_id" data-rule="required" data-source="style_template/index" data-params='{"custom[id]":"{$row.style_template_id}"}' class="form-control selectpage" name="row[style_template_id]" type="text" value="{$row.style_template_id|htmlentities}">
</div>
</div>
<div class="form-group">
... ... @@ -11,24 +11,24 @@
<div class="col-xs-12 col-sm-8">
<select id="c-pid" data-rule="required" class="form-control selectpicker" name="row[pid]">
{foreach name="parentList" item="vo"}
<option data-display_mode="{$vo.display_mode}" value="{$key}" {in name="key" value="$row.pid"}selected{/in}>{$vo.spec_name}</option>
<option data-display_mode="{$vo.display_mode}" value="{$key}" {in name="key" value="$row.pid"}selected{/in}>{$vo.style_name}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_name')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_name" data-rule="required" class="form-control" name="row[spec_name]" type="text" value="{$row.spec_name|htmlentities}">
<input id="c-style_name" data-rule="required" class="form-control" name="row[style_name]" type="text" value="{$row.style_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_type')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-spec_type" data-rule="required" class="form-control selectpicker" name="row[spec_type]">
{foreach name="specTypeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.spec_type"}selected{/in}>{$vo}</option>
<select id="c-style_type" data-rule="required" class="form-control selectpicker" name="row[style_type]">
{foreach name="styleTypeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.style_type"}selected{/in}>{$vo}</option>
{/foreach}
</select>
... ...
... ... @@ -17,12 +17,12 @@
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('spec/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('spec/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('spec/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('spec/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('style/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('style/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('style/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('style/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<div class="dropdown btn-group {:$auth->check('spec/multi')?'':'hide'}">
<div class="dropdown btn-group {:$auth->check('style/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
... ... @@ -33,8 +33,8 @@
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('spec/edit')}"
data-operate-del="{:$auth->check('spec/del')}"
data-operate-edit="{:$auth->check('style/edit')}"
data-operate-del="{:$auth->check('style/del')}"
width="100%">
</table>
</div>
... ...
... ... @@ -7,14 +7,14 @@
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('spec_template/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('spec_template/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('style_template/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('style_template/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('spec_template/edit')}"
data-operate-del="{:$auth->check('spec_template/del')}"
data-operate-edit="{:$auth->check('style_template/edit')}"
data-operate-del="{:$auth->check('style_template/del')}"
width="100%">
</table>
</div>
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_id" data-rule="required" data-source="spec/selectpage" data-params='{"custom[id]":"{$spec_id}"}' data-field="spec_name" class="form-control selectpage" name="row[spec_id]" type="text" value="{$spec_id}">
<input id="c-style_id" data-rule="required" data-source="style/selectpage" data-params='{"custom[id]":"{$style_id}"}' data-field="style_name" class="form-control selectpage" name="row[style_id]" type="text" value="{$style_id}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_value')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_value_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_value" data-rule="required" class="form-control" name="row[spec_value]" type="text" value="">
<input id="c-style_value_name" data-rule="required" class="form-control" name="row[style_value_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_value_image')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_value_desc')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-spec_value_image" class="form-control" size="50" name="row[spec_value_image]" type="text" value="">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-spec_value_image" class="btn btn-danger plupload" data-input-id="c-spec_value_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-spec_value_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-spec_value_image" class="btn btn-primary fachoose" data-input-id="c-spec_value_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-spec_value_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-spec_value_image"></ul>
<input id="c-style_value_desc" class="form-control" name="row[style_value_desc]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_value_price')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_value_image')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_value_price" data-rule="required" class="form-control" step="0.01" name="row[spec_value_price]" type="number" value="0.00">
<div class="input-group">
<input id="c-style_value_image" class="form-control" size="50" name="row[style_value_image]" type="text" value="">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-style_value_image" class="btn btn-danger plupload" data-input-id="c-style_value_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-style_value_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-style_value_image" class="btn btn-primary fachoose" data-input-id="c-style_value_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-style_value_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-style_value_image"></ul>
</div>
</div>
<div class="form-group">
<label for="c-spec_value_description" class="control-label col-xs-12 col-sm-2">{:__('规格值描述')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_value_price')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-spec_value_description" class="form-control" name="row[spec_value_description]"></textarea>
<input id="c-style_value_price" data-rule="required" class="form-control" step="0.01" name="row[style_value_price]" type="number" value="0.00">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_ids')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_ids')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_ids" data-source="spec/selectpage" data-params='{"custom[display_mode]":"2","custom[spec_template_id]":"{$spec_template_id}"}' data-field="spec_name" data-multiple="true" class="form-control selectpage" name="row[spec_ids]" type="text" value="">
<input id="c-style_ids" data-source="style/selectpage" data-params='{"custom[display_mode]":"2","custom[style_template_id]":"{$style_template_id}"}' data-field="style_name" data-multiple="true" class="form-control selectpage" name="row[style_ids]" type="text" value="">
</div>
</div>
<div class="form-group">
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_id" data-rule="required" data-source="spec/selectpage" data-params='{"custom[id]":"{$row.spec_id}"}' data-field="spec_name" class="form-control selectpage" name="row[spec_id]" type="text" value="{$row.spec_id|htmlentities}">
<input id="c-style_id" data-rule="required" data-source="style/selectpage" data-params='{"custom[id]":"{$row.style_id}"}' data-field="style_name" class="form-control selectpage" name="row[style_id]" type="text" value="{$row.style_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_value')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_value_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_value" data-rule="required" class="form-control" name="row[spec_value]" type="text" value="{$row.spec_value|htmlentities}">
<input id="c-style_value_name" data-rule="required" class="form-control" name="row[style_value_name]" type="text" value="{$row.style_value_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_value_image')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_value_desc')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-spec_value_image" class="form-control" size="50" name="row[spec_value_image]" type="text" value="{$row.spec_value_image|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-spec_value_image" class="btn btn-danger plupload" data-input-id="c-spec_value_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-spec_value_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-spec_value_image" class="btn btn-primary fachoose" data-input-id="c-spec_value_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-spec_value_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-spec_value_image"></ul>
<input id="c-style_value_desc" class="form-control" name="row[style_value_desc]" type="text" value="{$row.style_value_desc|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_value_price')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_value_image')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_value_price" data-rule="required" class="form-control" step="0.01" name="row[spec_value_price]" type="number" value="{$row.spec_value_price|htmlentities}">
<div class="input-group">
<input id="c-style_value_image" class="form-control" size="50" name="row[style_value_image]" type="text" value="{$row.style_value_image|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-style_value_image" class="btn btn-danger plupload" data-input-id="c-style_value_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-style_value_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-style_value_image" class="btn btn-primary fachoose" data-input-id="c-style_value_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-style_value_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-style_value_image"></ul>
</div>
</div>
<div class="form-group">
<label for="c-spec_value_description" class="control-label col-xs-12 col-sm-2">{:__('规格值描述')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_value_price')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-spec_value_description" class="form-control" name="row[spec_value_description]">{$row.spec_value_description|htmlentities}</textarea>
<input id="c-style_value_price" data-rule="required" class="form-control" step="0.01" name="row[style_value_price]" type="number" value="{$row.style_value_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Spec_ids')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Style_ids')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-spec_ids" data-source="spec/selectpage" data-params='{"custom[display_mode]":"2","custom[spec_template_id]":"{$spec_template_id}"}' data-field="spec_name" data-multiple="true" class="form-control selectpage" name="row[spec_ids]" type="text" value="{$row.spec_ids|htmlentities}">
<input id="c-style_ids" data-source="style/selectpage" data-params='{"custom[display_mode]":"2","custom[style_template_id]":"{$style_template_id}"}' data-field="style_name" data-multiple="true" class="form-control selectpage" name="row[style_ids]" type="text" value="{$row.style_ids|htmlentities}">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -7,12 +7,12 @@
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('spec_value/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('spec_value/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('spec_value/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('spec_value/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('style_value/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('style_value/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('style_value/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('style_value/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<div class="dropdown btn-group {:$auth->check('spec_value/multi')?'':'hide'}">
<div class="dropdown btn-group {:$auth->check('style_value/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
... ... @@ -23,8 +23,8 @@
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('spec_value/edit')}"
data-operate-del="{:$auth->check('spec_value/del')}"
data-operate-edit="{:$auth->check('style_value/edit')}"
data-operate-del="{:$auth->check('style_value/del')}"
width="100%">
</table>
</div>
... ...
... ... @@ -4,7 +4,7 @@ namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\Goods;
use app\common\model\GoodsSpec;
use app\common\model\GoodsStyle;
use app\common\controller\Wechat;
use think\Db;
... ... @@ -46,7 +46,7 @@ class Cart extends Api
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="goods_id", type="integer", required=true, description="商品ID")
* @ApiParams (name="goods_num", type="integer", required=true, description="商品数量")
* @ApiParams (name="goods_spec", type="object", sample="{'1':'11','5':'15','7':'2','14':'25','15':'\/uploads\/20200711\/3689359dcdf1146d234930cae4958110.jpg','13':'21','12':'18'}", description="商品规格 {'规格组ID':'规格值'}")
* @ApiParams (name="goods_style", type="object", sample="{'1':'11','5':'15','7':'2','14':'25','15':'\/uploads\/20200711\/3689359dcdf1146d234930cae4958110.jpg','13':'21','12':'18'}", description="商品规格 {'风格ID':'风格值'}")
* @ApiParams (name="user_size_id", type="integer", description="用户尺寸ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
... ... @@ -97,11 +97,11 @@ class Cart extends Api
}
/**
* 购物车-修改
* 购物车-修改定制风
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="cart_id", type="integer", required=true, description="购物车ID")
* @ApiParams (name="goods_spec", type="object", required=true, sample="{'1':'11','5':'15','7':'2','14':'25','15':'\/uploads\/20200711\/3689359dcdf1146d234930cae4958110.jpg','13':'21','12':'18'}", description="商品规格 {'规格组ID':'规格值'}")
* @ApiParams (name="goods_style", type="object", required=true, sample="{'1':'11','5':'15','7':'2','14':'25','15':'\/uploads\/20200711\/3689359dcdf1146d234930cae4958110.jpg','13':'21','12':'18'}", description="商品规格 {'风格ID':'规格值'}")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -110,17 +110,17 @@ class Cart extends Api
'msg':'返回成功'
})
*/
public function editGoodsSpec(){
public function editGoodsStyle(){
$cart_id = $this->request->request('cart_id',0);
$goods_spec = $this->request->request('goods_spec','','htmlspecialchars_decode');
$goods_style = $this->request->request('goods_style','','htmlspecialchars_decode');
$cart = $this->model->get($cart_id);
empty($cart) && $this->error(__('购物车信息不存在'));
empty($goods_spec) && $this->error(__('请选择您的定制信息'));
$model_spec = GoodsSpec::get(['goods_id'=>$cart['goods_id'],'goods_spec'=>$goods_spec]);
empty($goods_style) && $this->error(__('请选择您的定制信息'));
$model_spec = GoodsStyle::get(['goods_id'=>$cart['goods_id'],'goods_style'=>$goods_style]);
$cart->make_type = !$model_spec ? '2' : '1';
$cart->goods_spec = $goods_spec;
$goods_spec_arr = json_decode($goods_spec,true);
$cart->goods_price = $cart['goods']['goods_price'] + array_sum(\app\common\model\SpecValue::where('id','in',$goods_spec_arr)->column('spec_value_price'));
$cart->goods_style = $goods_style;
$goods_style_arr = json_decode($goods_style,true);
$cart->goods_price = $cart['goods']['goods_price'] + array_sum(\app\common\model\SpecValue::where('id','in',$goods_style_arr)->column('spec_value_price'));
$cart->save();
$this->success(__('成功'));
}
... ...
... ... @@ -7,7 +7,7 @@ use app\common\model\Banner;
use app\common\model\Coupon;
use app\common\model\Category;
use app\common\model\Goods;
use app\common\model\GoodsSpec;
use app\common\model\GoodsStyle;
use app\common\model\UserSize;
... ... @@ -158,12 +158,12 @@ class Index extends Api
$goods = Goods::get($goods_id);
empty($goods) && $this->error(__('商品不存在'));
$goods['issale'] == '0' && $this->error(__('商品已下架'));
$goods_spec = GoodsSpec::get(['goods_id'=>$goods_id]);
if($goods_spec){
$goods['goods_price'] = $goods['goods_price'] + $goods_spec['goods_spec_price'];
$goods['goods_spec'] = $goods_spec['goods_spec'];
$goods_style = GoodsStyle::get(['goods_id'=>$goods_id]);
if($goods_style){
$goods['goods_price'] = $goods['goods_price'] + $goods_style['goods_style_price'];
$goods['goods_style'] = $goods_style['goods_style'];
}else{
$goods['goods_spec'] = '';
$goods['goods_style'] = '';
}
// 定制项 1模特款 2自定义
$goods['make_type'] = '1';
... ... @@ -187,7 +187,7 @@ class Index extends Api
}
/**
* 规格-正常显示规
* 定制风
* @ApiMethod (GET)
* @ApiParams (name="goods_id", type="integer", required=true, description="商品ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
... ... @@ -198,14 +198,14 @@ class Index extends Api
'msg':'返回成功'
})
*/
public function specList()
public function styleList()
{
$goods_id = $this->request->request('goods_id');
$goods = Goods::get($goods_id);
empty($goods) && $this->error(__('商品信息不存在'));
$goods_spec = GoodsSpec::get(['goods_id'=>$goods_id]);
empty($goods_spec) && $this->error(__('该商品还未设置模特款'));
$list = \app\common\model\Spec::specList($goods_spec['spec_template_id']);
$goods_style = GoodsStyle::get(['goods_id'=>$goods_id]);
empty($goods_style) && $this->error(__('该商品还未设置模特款'));
$list = \app\common\model\Style::styleList($goods_style['spec_template_id']);
$this->success(__('成功'),compact('list'));
}
}
... ...
... ... @@ -15,7 +15,7 @@ class Cart extends Model
// 追加属性
protected $append = [
'goods_spec_text'
'goods_style_text'
];
// 错误提示
... ... @@ -38,17 +38,17 @@ class Cart extends Model
/**
* 定制项详情
*/
public function getGoodsSpecTextAttr($value,$data){
$goods_spec_text = [];
if(!empty($data['goods_spec'])){
$goods_spec = json_decode(str_replace('\'','"',$data['goods_spec']),true);
foreach($goods_spec as $k => $v){
$spec = Spec::where('id',$k)->field('spec_name,spec_type')->find()->toArray();
$spec['spec_value'] = $spec['spec_type'] == '1' ? SpecValue::where('id',$v)->value('spec_value') : $v;
$goods_spec_text[] = $spec;
public function getGoodsStyleTextAttr($value,$data){
$goods_style_text = [];
if(!empty($data['goods_style'])){
$goods_style = json_decode(str_replace('\'','"',$data['goods_style']),true);
foreach($goods_style as $k => $v){
$style = Style::where('id',$k)->field('style_name,style_type')->find()->toArray();
$style['style_value_name'] = $style['style_type'] == '1' ? StyleValue::where('id',$v)->value('style_value_name') : $v;
$goods_style_text[] = $style;
}
}
return $goods_spec_text;
return $goods_style_text;
}
/**
... ... @@ -67,26 +67,26 @@ class Cart extends Model
$this->setError(__('尺寸信息不存在'));
return false;
}
if(empty($data['goods_spec'])){
if(empty($data['goods_style'])){
$this->setError(__('请选择定制项'));
return false;
}
$data['goods_spec'] = htmlspecialchars_decode($data['goods_spec']);
$goods_spec = GoodsSpec::get(['goods_spec'=>$data['goods_spec']]);
if($goods_spec){
$data['goods_style'] = htmlspecialchars_decode($data['goods_style']);
$goods_style = GoodsStyle::get(['goods_style'=>$data['goods_style']]);
if($goods_style){
$data['make_type'] = '1';
$data['goods_price'] = $goods['goods_price'] + $goods_spec['goods_spec_price'];
$data['goods_price'] = $goods['goods_price'] + $goods_style['goods_style_price'];
}else{
$data['make_type'] = '2';
$goods_spec = json_decode($data['goods_spec'],true);
$data['goods_price'] = $goods['goods_price'] + array_sum(SpecValue::where('id','in',$goods_spec)->column('spec_value_price'));
$goods_style = json_decode($data['goods_style'],true);
$data['goods_price'] = $goods['goods_price'] + array_sum(StyleValue::where('id','in',$goods_style)->column('style_value_price'));
}
}else{
$data['goods_price'] = $goods['goods_price'];
}
if(empty($data['isbuynow'])){
$cart = $this->get([
'goods_spec' => $data['goods_spec'],
'goods_style' => $data['goods_style'],
'user_id' => $user['id'],
'goods_id' => $goods['id'],
'isbuynow' => '0'
... ... @@ -129,8 +129,8 @@ class Cart extends Model
$cart_list[] = $cart->visible([
'id',
'goods_id',
'goods_spec',
'goods_spec_text',
'goods_style',
'goods_style_text',
'goods_price',
'goods_num',
'make_type',
... ...
... ... @@ -4,7 +4,7 @@ namespace app\common\model;
use think\Model;
class GoodsSpec extends Model
class GoodsStyle extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
... ... @@ -13,15 +13,15 @@ class GoodsSpec extends Model
protected $updateTime = 'updatetime';
protected $append = [
'goods_spec_price'
'goods_style_price'
];
/**
* 格价格
* 格价格
*/
public function getGoodsSpecPriceAttr($value, $data)
public function getGoodsStylePriceAttr($value, $data)
{
$goods_spec = !empty($data['goods_spec']) ? json_decode($data['goods_spec'],true) : [];
return array_sum(SpecValue::where('id','in',$goods_spec)->column('spec_value_price'));
$goods_style = !empty($data['goods_style']) ? json_decode($data['goods_style'],true) : [];
return array_sum(StyleValue::where('id','in',$goods_style)->column('style_value_price'));
}
}
... ...
... ... @@ -60,7 +60,7 @@ class Order extends Model
'goods_price' => $goods['goods_price'],
'goods_num' => $goods['goods_num'],
'user_size_id' => !empty($goods['user_size']) ? $goods['user_size']['id'] : 0,
'goods_spec' => $goods['goods_spec']
'goods_style' => $goods['goods_style']
];
}
// 保存订单商品信息
... ...
<?php
namespace app\common\model;
use think\Model;
class Spec extends Model
{
/**
* 正常显示规格
*/
public static function specList($spec_template_id){
// 一级规格组
$list = self::getSpecList(['spec_template_id'=>$spec_template_id,'pid'=>0,'display_mode'=>'1']);
return $list;
}
/**
* 规格值下规格
*/
public static function valueSpecList($spec_value_id)
{
//规格值下规格组ID集合
$spec_ids = SpecValue::where('id',$spec_value_id)->value('spec_ids');
// 一级规格组
$list = self::where('id','in',$spec_ids)
->field('id,pid,spec_name,spec_type')
->order('weigh desc')
->select();
foreach($list as &$v){
// 规格组选项
$v['options'] = self::getOptions($v['id']);
}
return $list;
}
/**
* 身体信息
*/
public static function bodyInfo($spec_template_id){
// 一级规格组
$list = self::getSpecList(['spec_template_id'=>$spec_template_id,'pid'=>0,'display_mode'=>'1']);
return $list;
}
/**
* 获取规格列表
*/
public static function getSpecList($where){
$list = self::where($where)
->order('weigh desc')
->select();
foreach($list as $v){
$v['spec_value_list'] = self::getSpecValueList($v['id']);
$v['two_spec_list'] = self::getSpecList(['pid'=>$v['id']]);
$v->visible(['id','spec_name','spec_type','display_mode'])->append(['spec_value_list','two_spec_list']);
}
$list = collection($list)->toArray();
return $list;
}
/**
* 获取规格值列表
*/
public static function getSpecValueList($spec_id){
$list = SpecValue::where('spec_id',$spec_id)
->order('weigh desc')
->select();
foreach($list as $v){
$v['spec_list'] = self::getSpecList(['id'=>['in',$v['spec_ids']]]);
$v->visible(['id','spec_id','spec_value','spec_value_image','spec_value_description','spec_ids'])->append(['spec_list']);
}
$list = collection($list)->toArray();
return $list;
}
}
<?php
namespace app\common\model;
use think\Model;
class Style extends Model
{
/**
* 获取风格列表
*/
public static function styleList($style_template_id){
// 一级风格
$list = self::getStyleList(['style_template_id'=>$style_template_id,'pid'=>0,'display_mode'=>'1']);
return $list;
}
/**
* 获取风格列表
*/
public static function getStyleList($where){
$list = self::where($where)
->order('weigh desc')
->select();
foreach($list as $v){
$v['style_value_list'] = self::getStyleValueList($v['id']);
$v['two_style_list'] = self::getStyleList(['pid'=>$v['id']]);
$v->visible(['id','style_name','style_type','display_mode'])->append(['style_value_list','two_style_list']);
}
$list = collection($list)->toArray();
return $list;
}
/**
* 获取选项列表
*/
public static function getStyleValueList($style_id){
$list = StyleValue::where('style_id',$style_id)
->order('weigh desc')
->select();
foreach($list as $v){
$v['style_list'] = self::getStyleList(['id'=>['in',$v['style_ids']]]);
$v->visible(['id','style_id','style_value_name','style_value_image','style_value_desc','style_ids'])->append(['style_list']);
}
$list = collection($list)->toArray();
return $list;
}
}
... ...
... ... @@ -4,7 +4,7 @@ namespace app\common\model;
use think\Model;
class SpecValue extends Model
class StyleValue extends Model
{
/**
* 隐藏字段
... ... @@ -15,7 +15,7 @@ class SpecValue extends Model
'updatetime'
];
public function getSpecValueImageAttr($value, $data)
public function getStyleValueImageAttr($value, $data)
{
return !empty($value) ? cdnurl($value,true) : '';
}
... ...
此 diff 太大无法显示。
... ... @@ -48,7 +48,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
title: __('模特款'),
classname: 'btn btn-xs btn-warning btn-dialog',
icon: 'fa fa-file',
url: 'goods/spec?goods_id={id}',
url: 'goods/style?goods_id={id}',
visible: function(row){
if(row.ismake == '1'){
return true;
... ... @@ -71,35 +71,35 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
edit: function () {
Controller.api.bindevent();
},
spec: function () {
style: function () {
Controller.api.bindevent();
setTimeout(function () {
$("#c-spec_template_id").trigger("change");
$("#c-style_template_id").trigger("change");
}, 100);
},
api: {
bindevent: function () {
var goods_spec = Config.goods_spec;
var hidden_spec_list = [];
$(document).on("change", "#c-spec_template_id", function () {
var goods_style = Config.goods_style;
var hidden_style_list = [];
$(document).on("change", "#c-style_template_id", function () {
Fast.api.ajax({
url:'goods/specList',
url:'goods/styleList',
data:{
spec_template_id:$(this).val()
style_template_id:$(this).val()
}
}, function(data, ret){
if(ret.code == 1){
var list = ret.data.list;
var html = '<div class="display_mode_1">';
// 一级规格
html += spec_list(list);
// 一级风格
html += style_list(list);
html += '<div>';
$('.display_mode_1').remove();
$('.layer-footer').before(html);
// 绑定上传事件
Form.events.plupload();
Form.events.faselect();
// 显示隐藏
// 显示隐藏
$("input:checked[type=radio]").trigger("change");
}
return false;
... ... @@ -110,14 +110,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
});
});
// 规格值下规格组
// 选项下风格
$(document).on("change", "input[type=radio]", function () {
var spev_value_id = $(this).val();
var list = hidden_spec_list[spev_value_id];
var style_value_id = $(this).val();
var list = hidden_style_list[style_value_id];
$(this).parent().parent().parent().parent('.form-group').next('.display_mode_2').remove();
if(list.length > 0){
var html = '<div class="display_mode_2">';
html += spec_list(list);
html += style_list(list);
html += '<div>';
$(this).parent().parent().parent().parent('.form-group').after(html);
// 绑定上传事件
... ... @@ -126,22 +126,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
});
// 规格组
function spec_list(list){
// 风格
function style_list(list){
var html = '';
// 一级规格
$.each(list,function(index,spec){
// 一级风格
$.each(list,function(index,style){
html += '<div class="form-group">'+
'<label class="control-label col-xs-12 col-sm-2">'+spec.spec_name+':</label>'+
'<label class="control-label col-xs-12 col-sm-2">'+style.style_name+':</label>'+
'<div class="col-xs-12 col-sm-8">'+
spec_value_list(index,spec);
// 一级规格下二级规格
if(spec.two_spec_list.length > 0){
$.each(spec.two_spec_list,function(index,spec_s){
style_value_list(index,style);
// 一级风格下二级风格
if(style.two_style_list.length > 0){
$.each(style.two_style_list,function(index,style_s){
html += '<div class="form-group">'+
'<label class="control-label col-xs-12 col-sm-2">'+spec_s.spec_name+':</label>'+
'<label class="control-label col-xs-12 col-sm-2">'+style_s.style_name+':</label>'+
'<div class="col-xs-12 col-sm-8">'+
spec_value_list(index,spec_s)+
style_value_list(index,style_s)+
'</div>'+
'</div>';
})
... ... @@ -152,41 +152,41 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
return html;
}
// 规格值
function spec_value_list(index,spec){
// 选项
function style_value_list(index,style){
var html = '';
// 规格下规格值
if(spec.spec_value_list.length > 0){
// 风格下选项
if(style.style_value_list.length > 0){
html += '<div class="radio">';
$.each(spec.spec_value_list,function(index,spec_v){
hidden_spec_list[spec_v.id] = spec_v.spec_list;
var img = spec_v.spec_value_image == '' ? '/assets/img/qrcode.png' : spec_v.spec_value_image;
var checked = goods_spec[spec_v.spec_id] == spec_v.id ? 'checked' : index == 0 ? 'checked' : '';
html += '<label for="'+spec_v.id+'" style="border:1px solid #f1f4f6">'+
'<input id="'+spec_v.id+'" '+checked+' name="row[goods_spec]['+spec_v.spec_id+']" type="radio" value="'+spec_v.id+'">'+
$.each(style.style_value_list,function(index,style_o){
hidden_style_list[style_o.id] = style_o.style_list;
var img = style_o.style_value_image == '' ? '/assets/img/qrcode.png' : style_o.style_value_image;
var checked = goods_style[style_o.style_id] == style_o.id ? 'checked' : index == 0 ? 'checked' : '';
html += '<label for="'+style_o.id+'" style="border:1px solid #f1f4f6">'+
'<input id="'+style_o.id+'" '+checked+' name="row[goods_style]['+style_o.style_id+']" type="radio" value="'+style_o.id+'">'+
'<img width="100px" src="'+img+'">'+
'<p style="text-align:center">'+spec_v.spec_value+'</p>'+
'<p style="text-align:center">'+style_o.style_value_name+'</p>'+
'</label>';
})
html += '</div>';
}
// 规格下文本框
if(spec.spec_type == '2'){
var val = goods_spec[spec.id] == undefined ? '' : goods_spec[spec.id];
html += '<input id="c-'+spec.id+'" data-rule="required" class="form-control" name="row[goods_spec]['+spec.id+']" type="text" value="'+val+'">';
// 风格下文本框
if(style.style_type == '2'){
var val = goods_style[style.id] == undefined ? '' : goods_style[style.id];
html += '<input id="c-'+style.id+'" data-rule="required" class="form-control" name="row[goods_style]['+style.id+']" type="text" value="'+val+'">';
}
// 规格下上传图片
if(spec.spec_type == '3'){
var val = goods_spec[spec.id] == undefined ? '' : goods_spec[spec.id];
// 风格下上传图片
if(style.style_type == '3'){
var val = goods_style[style.id] == undefined ? '' : goods_style[style.id];
html += '<div class="input-group">'+
'<input id="c-'+spec.id+'" data-rule="required" class="form-control" size="50" name="row[goods_spec]['+spec.id+']" type="text" value="'+val+'">'+
'<input id="c-'+style.id+'" data-rule="required" class="form-control" size="50" name="row[goods_style]['+style.id+']" type="text" value="'+val+'">'+
'<div class="input-group-addon no-border no-padding">'+
'<span><button type="button" id="plupload-'+spec.id+'" class="btn btn-danger plupload" data-input-id="c-'+spec.id+'" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-'+spec.id+'"><i class="fa fa-upload"></i> 上传</button></span>'+
'<span><button type="button" id="fachoose-'+spec.id+'" class="btn btn-primary fachoose" data-input-id="c-'+spec.id+'" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>'+
'<span><button type="button" id="plupload-'+style.id+'" class="btn btn-danger plupload" data-input-id="c-'+style.id+'" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-'+style.id+'"><i class="fa fa-upload"></i> 上传</button></span>'+
'<span><button type="button" id="fachoose-'+style.id+'" class="btn btn-primary fachoose" data-input-id="c-'+style.id+'" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>'+
'</div>'+
'<span class="msg-box n-right" for="c-'+spec.id+'"></span>'+
'<span class="msg-box n-right" for="c-'+style.id+'"></span>'+
'</div>'+
'<ul class="row list-inline plupload-preview" id="p-'+spec.id+'"></ul>';
'<ul class="row list-inline plupload-preview" id="p-'+style.id+'"></ul>';
}
return html;
}
... ...
... ... @@ -5,13 +5,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'spec/index' + location.search,
add_url: 'spec/add' + location.search,
edit_url: 'spec/edit',
del_url: 'spec/del',
multi_url: 'spec/multi',
import_url: 'spec/import',
table: 'spec',
index_url: 'style/index' + location.search,
add_url: 'style/add' + location.search,
edit_url: 'style/edit',
del_url: 'style/del',
multi_url: 'style/multi',
import_url: 'style/import',
table: 'style',
}
});
... ... @@ -22,16 +22,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
escape: false,
pagination: false,
commonSearch: false,
search: false,
escape: false,
pagination: false,
commonSearch: false,
search: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'spec_name', title: __('Spec_name')},
{field: 'spec_type', title: __('Spec_type'), searchList: {"1":__('Spec_type 1'),"2":__('Spec_type 2'),"3":__('Spec_type 3')}, formatter: Table.api.formatter.normal},
{field: 'style_name', title: __('Style_name')},
{field: 'style_type', title: __('Style_type'), searchList: {"1":__('Style_type 1'),"2":__('Style_type 2'),"3":__('Style_type 3')}, formatter: Table.api.formatter.normal},
{field: 'display_mode', title: __('Display_mode'), searchList: {"1":__('Display_mode 1'),"2":__('Display_mode 2')}, formatter: Table.api.formatter.normal},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'weigh', title: __('Weigh')},
... ... @@ -44,12 +44,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
buttons: [
{
name: 'detail',
title: __('规格值'),
title: __('风格选项'),
classname: 'btn btn-xs btn-warning btn-dialog',
icon: 'fa fa-list',
url: 'spec_value?spec_id={id}',
url: 'style_value?style_id={id}',
visible: function(row){
if(row.spec_type == '1'){
if(row.style_type == '1'){
return true;
}
}
... ... @@ -63,46 +63,46 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 为表格绑定事件
Table.api.bindevent(table);
//绑定TAB事件
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
// var options = table.bootstrapTable(tableOptions);
var typeStr = $(this).attr("href").replace('#t-', '');
var options = table.bootstrapTable('getOptions');
options.pageNumber = 1;
options.queryParams = function (params) {
// params.filter = JSON.stringify({type: typeStr});
params.display_mode = typeStr;
return params;
};
table.bootstrapTable('refresh', {});
return false;
});
//绑定TAB事件
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
// var options = table.bootstrapTable(tableOptions);
var typeStr = $(this).attr("href").replace('#t-', '');
var options = table.bootstrapTable('getOptions');
options.pageNumber = 1;
options.queryParams = function (params) {
// params.filter = JSON.stringify({type: typeStr});
params.display_mode = typeStr;
return params;
};
table.bootstrapTable('refresh', {});
return false;
});
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
setTimeout(function () {
if($("#c-pid").val() == 0){
$("#c-display_mode").trigger("change");
}
}, 100);
setTimeout(function () {
if($("#c-pid").val() == 0){
$("#c-display_mode").trigger("change");
}
}, 100);
},
api: {
bindevent: function () {
$(document).on("change", "#c-display_mode", function () {
$("#c-pid option[data-display_mode='all']").prop("selected", true);
if($(this).val() == 1){
$("#c-pid option[data-display_mode!='all']").removeClass("hide");
}else{
$("#c-pid option[data-display_mode!='all']").addClass("hide");
}
$("#c-pid").data("selectpicker") && $("#c-pid").selectpicker("refresh");
});
$(document).on("change", "#c-display_mode", function () {
$("#c-pid option[data-display_mode='all']").prop("selected", true);
if($(this).val() == 1){
$("#c-pid option[data-display_mode!='all']").removeClass("hide");
}else{
$("#c-pid option[data-display_mode!='all']").addClass("hide");
}
$("#c-pid").data("selectpicker") && $("#c-pid").selectpicker("refresh");
});
Form.api.bindevent($("form[role=form]"));
}
}
... ...
... ... @@ -5,13 +5,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'spec_template/index' + location.search,
add_url: 'spec_template/add',
edit_url: 'spec_template/edit',
del_url: 'spec_template/del',
multi_url: 'spec_template/multi',
import_url: 'spec_template/import',
table: 'spec_template',
index_url: 'style_template/index' + location.search,
add_url: 'style_template/add',
edit_url: 'style_template/edit',
del_url: 'style_template/del',
multi_url: 'style_template/multi',
import_url: 'style_template/import',
table: 'style_template',
}
});
... ... @@ -41,18 +41,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
title: __('规格列表'),
classname: 'btn btn-xs btn-warning btn-addtabs',
icon: 'fa fa-list',
url: 'spec/index?spec_template_id={id}'
url: 'style/index?style_template_id={id}'
}
],
formatter: function (value, row, index) {
var that = $.extend({}, this);
var table = $(that.table).clone(true);
if(row.id == 1 || row.id == 2){
$(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
}
that.table = table;
return Table.api.formatter.operate.call(that, value, row, index);
}
var that = $.extend({}, this);
var table = $(that.table).clone(true);
if(row.id == 1 || row.id == 2){
$(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
}
that.table = table;
return Table.api.formatter.operate.call(that, value, row, index);
}
},
]
]
... ...
... ... @@ -5,13 +5,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'spec_value/index' + location.search,
add_url: 'spec_value/add' + location.search,
edit_url: 'spec_value/edit',
del_url: 'spec_value/del',
multi_url: 'spec_value/multi',
import_url: 'spec_value/import',
table: 'spec_value',
index_url: 'style_value/index' + location.search,
add_url: 'style_value/add' + location.search,
edit_url: 'style_value/edit',
del_url: 'style_value/del',
multi_url: 'style_value/multi',
import_url: 'style_value/import',
table: 'style_value',
}
});
... ... @@ -22,16 +22,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
pagination: false,
commonSearch: false,
search: false,
pagination: false,
commonSearch: false,
search: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'spec_value', title: __('Spec_value')},
{field: 'spec_value_image', title: __('Spec_value_image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'spec_value_price', title: __('Spec_value_price'), operate:'BETWEEN'},
{field: 'style_value_name', title: __('Style_value_name')},
{field: 'style_value_image', title: __('Style_value_image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'style_value_price', title: __('Style_value_price'), operate:'BETWEEN'},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'weigh', title: __('Weigh')},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
... ...