mirror of
https://github.com/crmeb/CRMEB.git
synced 2025-12-18 07:42:55 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
65cd47571a
@ -8,6 +8,7 @@ use app\admin\model\store\StoreProductAttr;
|
||||
use app\admin\model\store\StoreProductAttrResult;
|
||||
use app\admin\model\store\StoreProductRelation;
|
||||
use app\admin\model\system\SystemConfig;
|
||||
use service\JsonService;
|
||||
use traits\CurdControllerTrait;
|
||||
use service\UtilService as Util;
|
||||
use service\JsonService as Json;
|
||||
@ -41,43 +42,87 @@ class StoreProduct extends AuthController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = Util::getMore([
|
||||
['type',$this->request->param('type')],
|
||||
['cate_id',''],
|
||||
['is_show',''],
|
||||
['store_name',''],
|
||||
['sales',''],
|
||||
['export',0]
|
||||
],$this->request);
|
||||
$this->assign('cate',CategoryModel::getTierList());
|
||||
|
||||
$type=$this->request->param('type');
|
||||
//获取分类
|
||||
$this->assign('cate',CategoryModel::getTierList());
|
||||
//出售中产品
|
||||
$data = ['is_show'=>1,'is_del'=>0];
|
||||
$onsale = ProductModel::where($data)->count();
|
||||
$onsale = ProductModel::where(['is_show'=>1,'is_del'=>0])->count();
|
||||
//待上架产品
|
||||
$data = ['is_show'=>0,'is_del'=>0];
|
||||
$forsale = ProductModel::where($data)->count();
|
||||
$forsale = ProductModel::where(['is_show'=>0,'is_del'=>0])->count();
|
||||
//仓库中产品
|
||||
$data = ['is_del'=>0];
|
||||
$warehouse = ProductModel::where($data)->count();
|
||||
$warehouse = ProductModel::where(['is_del'=>0])->count();
|
||||
//已经售馨产品
|
||||
$data = ['p.is_show'=>1,'p.is_del'=>0,'pav.stock|p.stock'=>0];
|
||||
$outofstock = ProductModel::alias('p')
|
||||
->join('StoreProductAttrValue pav','p.id=pav.product_id','LEFT')
|
||||
->where($data)->count();
|
||||
$outofstock = ProductModel::getModelObject()->where(ProductModel::setData(4))->count();
|
||||
//警戒库存
|
||||
$data = ['p.is_show'=>1,'p.is_del'=>0,'pav.stock|p.stock'=>['elt',1]];
|
||||
$policeforce = ProductModel::alias('p')
|
||||
->join('StoreProductAttrValue pav','p.id=pav.product_id','LEFT')
|
||||
->where($data)->count();
|
||||
$policeforce =ProductModel::getModelObject()->where(ProductModel::setData(5))->count();
|
||||
//回收站
|
||||
$data = ['is_del'=>1];
|
||||
$recycle = ProductModel::where($data)->count();
|
||||
$this->assign(compact('where','onsale','forsale','warehouse','outofstock','policeforce','recycle'));
|
||||
$this->assign(ProductModel::systemPage($where,$this->adminInfo));
|
||||
$recycle = ProductModel::where(['is_del'=>1])->count();
|
||||
|
||||
$this->assign(compact('type','onsale','forsale','warehouse','outofstock','policeforce','recycle'));
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步查找产品
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function product_ist(){
|
||||
$where=Util::getMore([
|
||||
['page',1],
|
||||
['limit',20],
|
||||
['store_name',''],
|
||||
['cate_id',''],
|
||||
['excel',0],
|
||||
['type',$this->request->param('type')]
|
||||
]);
|
||||
return JsonService::successlayui(ProductModel::ProductList($where));
|
||||
}
|
||||
/**
|
||||
* 设置单个产品上架|下架
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function set_show($is_show='',$id=''){
|
||||
($is_show=='' || $id=='') && JsonService::fail('缺少参数');
|
||||
$res=ProductModel::where(['id'=>$id])->update(['is_show'=>(int)$is_show]);
|
||||
if($res){
|
||||
return JsonService::successful($is_show==1 ? '上架成功':'下架成功');
|
||||
}else{
|
||||
return JsonService::fail($is_show==1 ? '上架失败':'下架失败');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 快速编辑
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function set_product($field='',$id='',$value=''){
|
||||
$field=='' || $id=='' || $value=='' && JsonService::fail('缺少参数');
|
||||
if(ProductModel::where(['id'=>$id])->update([$field=>$value]))
|
||||
return JsonService::successful('保存成功');
|
||||
else
|
||||
return JsonService::fail('保存失败');
|
||||
}
|
||||
/**
|
||||
* 设置批量产品上架
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function product_show(){
|
||||
$post=Util::postMore([
|
||||
['ids',[]]
|
||||
]);
|
||||
if(empty($post['ids'])){
|
||||
return JsonService::fail('请选择需要上架的产品');
|
||||
}else{
|
||||
$res=ProductModel::where('id','in',$post['ids'])->update(['is_show'=>1]);
|
||||
if($res)
|
||||
return JsonService::successful('上架成功');
|
||||
else
|
||||
return JsonService::fail('上架失败');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
|
||||
@ -27,82 +27,101 @@ class StoreProduct extends ModelBasic
|
||||
use ModelTrait;
|
||||
|
||||
/**
|
||||
* @param $where
|
||||
* 获取连表查询条件
|
||||
* @param $type
|
||||
* @return array
|
||||
*/
|
||||
public static function systemPage($where,$adminInfo){
|
||||
$model = new self;
|
||||
$model = $model->alias('p');
|
||||
if($where['store_name'] != '') $model = $model->where('p.store_name|p.keyword|p.id','LIKE',"%$where[store_name]%");
|
||||
if($where['cate_id'] != '') $model = $model->where('p.cate_id','LIKE',"%$where[cate_id]%");
|
||||
switch ($where['type']){
|
||||
public static function setData($type){
|
||||
switch ((int)$type){
|
||||
case 1:
|
||||
$data = ['p.is_show'=>1,'is_del'=>0];
|
||||
$model = $model->where($data);
|
||||
$data = ['p.is_show'=>1,'p.is_del'=>0];
|
||||
break;
|
||||
case 2:
|
||||
$data = ['p.is_show'=>0,'is_del'=>0];
|
||||
$model = $model->where($data);
|
||||
$data = ['p.is_show'=>0,'p.is_del'=>0];
|
||||
break;
|
||||
case 3:
|
||||
$data = ['p.is_del'=>0];
|
||||
$model = $model->where($data);
|
||||
break;
|
||||
case 4:
|
||||
$data = ['p.is_show'=>1,'p.is_del'=>0,'pav.stock|p.stock'=>0];
|
||||
$model = $model->where($data);
|
||||
break;
|
||||
case 5:
|
||||
$data = ['p.is_show'=>1,'p.is_del'=>0,'pav.stock|p.stock'=>['elt',1]];
|
||||
$model = $model->where($data);
|
||||
break;
|
||||
case 6:
|
||||
$data = ['p.is_del'=>1];
|
||||
$model = $model->where($data);
|
||||
break;
|
||||
};
|
||||
$model = $model->field('p.*,sum("pav.stock") as vstock');
|
||||
$model = $model->join('StoreProductAttrValue pav','p.id=pav.product_id','LEFT');
|
||||
return isset($data) ? $data: [];
|
||||
}
|
||||
/**
|
||||
* 获取连表MOdel
|
||||
* @param $model
|
||||
* @return object
|
||||
*/
|
||||
public static function getModelObject($where=[]){
|
||||
$model=new self();
|
||||
$model=$model->alias('p')->join('StoreProductAttrValue pav','p.id=pav.product_id','LEFT');
|
||||
if(!empty($where)){
|
||||
$model=$model->group('p.id');
|
||||
$order = '';
|
||||
if($where['sales'] != '') $order .= $where['sales'];
|
||||
$order .= 'p.id desc';
|
||||
$model = $model->order($order);
|
||||
if($where['export'] == 1){
|
||||
$list = $model->select()->toArray();
|
||||
$export = [];
|
||||
foreach ($list as $index=>$item){
|
||||
$cateName = CategoryModel::where('id','IN',$item['cate_id'])->column('cate_name','id'); if(is_array($cateName)){ $cateNameStr = implode(',',$cateName); }
|
||||
$export[] = [
|
||||
$item['store_name'],
|
||||
$item['store_info'],
|
||||
$cateName,
|
||||
'¥'.$item['price'],
|
||||
$item['stock'],
|
||||
$item['sales'],
|
||||
StoreProductRelation::where('product_id',$item['id'])->where('type','like')->count(),
|
||||
StoreProductRelation::where('product_id',$item['id'])->where('type','collect')->count()
|
||||
];
|
||||
$list[$index] = $item;
|
||||
if(isset($where['type']) && $where['type']!='' && ($data=self::setData($where['type']))){
|
||||
$model = $model->where($data);
|
||||
}
|
||||
PHPExcelService::setExcelHeader(['产品名称','产品简介','产品分类','价格','库存','销量','点赞人数','收藏人数'])
|
||||
->setExcelTile('产品导出','产品信息'.time(),'操作人昵称:'.$adminInfo['real_name'].' 生成时间:'.date('Y-m-d H:i:s',time()))
|
||||
->setExcelContent($export)
|
||||
->ExcelSave();
|
||||
if(isset($where['store_name']) && $where['store_name']!=''){
|
||||
$model = $model->where('p.store_name|p.keyword|p.id','LIKE',"%$where[store_name]%");
|
||||
}
|
||||
return self::page($model,function($item){
|
||||
if(isset($where['cate_id']) && trim($where['cate_id'])!=''){
|
||||
$model = $model->where('p.cate_id','LIKE',"%$where[cate_id]%");
|
||||
}
|
||||
if(isset($where['order']) && $where['order']!=''){
|
||||
$model = $model->order(self::setOrder($where['order']));
|
||||
}
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/*
|
||||
* 获取产品列表
|
||||
* @param $where array
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public static function ProductList($where){
|
||||
$model=self::getModelObject($where)->field(['p.*','sum(pav.stock) as vstock']);
|
||||
if($where['excel']==0) $model=$model->page((int)$where['page'],(int)$where['limit']);
|
||||
$data=($data=$model->select()) && count($data) ? $data->toArray():[];
|
||||
foreach ($data as &$item){
|
||||
$cateName = CategoryModel::where('id','IN',$item['cate_id'])->column('cate_name','id');
|
||||
if(is_array($cateName)){
|
||||
$item['cate_name'] = implode(',',$cateName); }
|
||||
$item['cate_name']=is_array($cateName) ? implode(',',$cateName) : '';
|
||||
$item['collect'] = StoreProductRelation::where('product_id',$item['id'])->where('type','collect')->count();//收藏
|
||||
$item['like'] = StoreProductRelation::where('product_id',$item['id'])->where('type','like')->count();//点赞
|
||||
$item['stock'] = self::getStock($item['id'])>0?self::getStock($item['id']):$item['stock'];//库存
|
||||
$item['stock_attr'] = self::getStock($item['id'])>0 ? true : false;//库存
|
||||
$item['sales_attr'] = self::getSales($item['id']);//属性销量
|
||||
$item['visitor'] = Db::name('store_visit')->where('product_id',$item['id'])->where('product_type','product')->count();
|
||||
|
||||
},$where);
|
||||
}
|
||||
if($where['excel']==1){
|
||||
$export = [];
|
||||
foreach ($data as $index=>$item){
|
||||
$export[] = [
|
||||
$item['store_name'],
|
||||
$item['store_info'],
|
||||
$item['cate_name'],
|
||||
'¥'.$item['price'],
|
||||
$item['stock'],
|
||||
$item['sales'],
|
||||
$item['like'],
|
||||
$item['collect']
|
||||
];
|
||||
}
|
||||
PHPExcelService::setExcelHeader(['产品名称','产品简介','产品分类','价格','库存','销量','点赞人数','收藏人数'])
|
||||
->setExcelTile('产品导出','产品信息'.time(),' 生成时间:'.date('Y-m-d H:i:s',time()))
|
||||
->setExcelContent($export)
|
||||
->ExcelSave();
|
||||
}
|
||||
$count=self::getModelObject($where)->count();
|
||||
return compact('count','data');
|
||||
}
|
||||
|
||||
public static function getChatrdata($type,$data){
|
||||
$legdata=['销量','数量','点赞','收藏'];
|
||||
$model=self::setWhereType(self::order('id desc'),$type);
|
||||
@ -361,7 +380,7 @@ class StoreProduct extends ModelBasic
|
||||
->select();
|
||||
$count=self::setWhere($where)->where('a.is_pay',1)->group('a.product_id')->count();
|
||||
foreach ($data as &$item){
|
||||
$item['sum_price']=bcdiv($item['num_product'],$item['price'],true);
|
||||
$item['sum_price']=bcdiv($item['num_product'],$item['price'],2);
|
||||
}
|
||||
return compact('data','count');
|
||||
}
|
||||
|
||||
@ -1,373 +1,344 @@
|
||||
{extend name="public/container"}
|
||||
{block name="head_top"}
|
||||
<link href="{__FRAME_PATH}css/plugins/iCheck/custom.css" rel="stylesheet">
|
||||
<script src="{__PLUG_PATH}moment.js"></script>
|
||||
<link rel="stylesheet" href="{__PLUG_PATH}daterangepicker/daterangepicker.css">
|
||||
<script src="{__PLUG_PATH}daterangepicker/daterangepicker.js"></script>
|
||||
<script src="{__ADMIN_PATH}frame/js/plugins/iCheck/icheck.min.js"></script>
|
||||
<link href="{__FRAME_PATH}css/plugins/footable/footable.core.css" rel="stylesheet">
|
||||
<script src="{__PLUG_PATH}sweetalert2/sweetalert2.all.min.js"></script>
|
||||
<script src="{__FRAME_PATH}js/plugins/footable/footable.all.min.js"></script>
|
||||
{/block}
|
||||
{block name="content"}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
|
||||
<div class="ibox">
|
||||
<div class="ibox-title">
|
||||
<button type="button" class="btn btn-w-m btn-primary" onclick="$eb.createModalFrame(this.innerText,'{:Url('create')}',{h:760,w:900})">添加产品</button>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="row">
|
||||
<div class="m-b m-l">
|
||||
<form action="" class="form-inline" id="form">
|
||||
<div class="ibox">
|
||||
<div class="input-group">
|
||||
<select name="cate_id" aria-controls="editable" class="form-control input-sm">
|
||||
<option value="">所有分类</option>
|
||||
{volist name="cate" id="vo"}
|
||||
<option value="{$vo.id}" {eq name="where.cate_id" value="$vo.id"}selected="selected"{/eq}>{$vo.html}{$vo.cate_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
<span class="input-group-btn">
|
||||
<input type="hidden" name="export" value="0">
|
||||
<input type="hidden" name="is_show" value="{$where.is_show}" />
|
||||
<input type="text" name="store_name" value="{$where.store_name}" placeholder="请输入产品名称,关键字,编号" class="input-sm form-control" size="38">
|
||||
<button type="submit" id="no_export" class="btn btn-sm btn-primary"> <i class="fa fa-search" ></i> 搜索</button>
|
||||
<button type="submit" id="export" class="btn btn-sm btn-info btn-outline"> <i class="fa fa-exchange" ></i> Excel导出</button></span>
|
||||
<script>
|
||||
$('#export').on('click',function(){
|
||||
$('input[name=export]').val(1);
|
||||
});
|
||||
$('#no_export').on('click',function(){
|
||||
$('input[name=export]').val(0);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-btn-group" data-name="type">-->
|
||||
<!-- 默认 layui-btn-primary 高亮 layui-btn-radius-->
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-primary" type="button" data-value="1">出售中产品({$onsale})</button>-->
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-primary" type="button" data-value="2">待上架产品({$forsale})</button>-->
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-primary" type="button" data-value="3">仓库中产品({$warehouse})</button>-->
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-primary" type="button" data-value="4">已经售馨产品({$outofstock})</button>-->
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-primary" type="button" data-value="5">警戒库存({$policeforce})</button>-->
|
||||
<!-- <button class="layui-btn layui-btn-sm layui-btn-primary" type="button" data-value="6">产品回收站({$recycle})</button>-->
|
||||
<!-- <input class="search-item-value" type="hidden" name="type" value="{$where.type}" />-->
|
||||
<!-- </div>-->
|
||||
<div class="search-item protype" data-name="type">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-white" type="button" data-value="1">出售中产品({$onsale})</button>
|
||||
<button class="btn btn-white" type="button" data-value="2">待上架产品({$forsale})</button>
|
||||
<button class="btn btn-white" type="button" data-value="3">仓库中产品({$warehouse})</button>
|
||||
<button class="btn btn-white" type="button" data-value="4">已经售馨产品({$outofstock})</button>
|
||||
<button class="btn btn-white" type="button" data-value="5">警戒库存({$policeforce})</button>
|
||||
<button class="btn btn-white" type="button" data-value="6">产品回收站({$recycle})</button>
|
||||
</div>
|
||||
<input class="search-item-value" type="hidden" name="type" value="{$where.type}" />
|
||||
</div>
|
||||
<input type="hidden" name="sales" value="{$where.sales}" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive" style="overflow:visible">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">编号</th>
|
||||
<th class="text-center">产品图片</th>
|
||||
<th class="text-center">产品名称</th>
|
||||
<th class="text-center">产品价格</th>
|
||||
<th class="text-center">虚拟销量</th>
|
||||
<th class="text-center">商品访客数</th>
|
||||
<th class="text-center">商品浏览量</th>
|
||||
<th class="text-center">
|
||||
<div class="btn-group">
|
||||
<button data-toggle="dropdown" class="btn btn-white btn-xs dropdown-toggle" style="font-weight: bold;background-color: #f5f5f6;border: solid 0;"
|
||||
aria-expanded="false">销量
|
||||
<span class="stair caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu search-item" data-name="sales">
|
||||
<li data-value="" {eq name="where.sales" value=""}style="color:#1ab394"{/eq}>
|
||||
<a class="save_mark" href="javascript:void(0);" >
|
||||
<i class="fa fa-arrows-v"></i>默认
|
||||
</a>
|
||||
<div class="layui-fluid" style="background: #fff">
|
||||
<div class="layui-tab layui-tab-brief" lay-filter="tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li lay-id="list" {eq name='type' value='1'}class="layui-this" {/eq} >
|
||||
<a href="{eq name='type' value='1'}javascript:;{else}{:Url('index',['type'=>1])}{/eq}">出售中产品({$onsale})</a>
|
||||
</li>
|
||||
<li data-value="p.sales desc," {eq name="where.sales" value="p.sales desc,"}style="color:#1ab394"{/eq}>
|
||||
<a class="save_mark" href="javascript:void(0);" >
|
||||
<i class="fa fa-sort-numeric-desc"></i>降序
|
||||
</a>
|
||||
<li lay-id="list" {eq name='type' value='2'}class="layui-this" {/eq}>
|
||||
<a href="{eq name='type' value='2'}javascript:;{else}{:Url('index',['type'=>2])}{/eq}">待上架产品({$forsale})</a>
|
||||
</li>
|
||||
<li data-value="p.sales asc," {eq name="where.sales" value="p.sales asc,"}style="color:#1ab394"{/eq}>
|
||||
<a class="save_mark" href="javascript:void(0);">
|
||||
<i class="fa fa-sort-numeric-asc"></i>升序
|
||||
</a>
|
||||
<li lay-id="list" {eq name='type' value='3'}class="layui-this" {/eq}>
|
||||
<a href="{eq name='type' value='3'}javascript:;{else}{:Url('index',['type'=>3])}{/eq}">仓库中产品({$warehouse})</a>
|
||||
</li>
|
||||
<li lay-id="list" {eq name='type' value='4'}class="layui-this" {/eq}>
|
||||
<a href="{eq name='type' value='4'}javascript:;{else}{:Url('index',['type'=>4])}{/eq}">已经售馨产品({$outofstock})</a>
|
||||
</li>
|
||||
<li lay-id="list" {eq name='type' value='5'}class="layui-this" {/eq}>
|
||||
<a href="{eq name='type' value='5'}javascript:;{else}{:Url('index',['type'=>5])}{/eq}">警戒库存({$policeforce})</a>
|
||||
</li>
|
||||
<li lay-id="list" {eq name='type' value='6'}class="layui-this" {/eq}>
|
||||
<a href="{eq name='type' value='6'}javascript:;{else}{:Url('index',['type'=>6])}{/eq}">产品回收站({$recycle})</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</th>
|
||||
<th class="text-center">库存</th>
|
||||
<th class="text-center">排序</th>
|
||||
<th class="text-center">点赞</th>
|
||||
<th class="text-center">收藏</th>
|
||||
<th class="text-center" width="5%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="">
|
||||
{volist name="list" id="vo"}
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<label class="checkbox-inline i-checks">
|
||||
<input type="checkbox" name="id[]" value="{$vo.id}">
|
||||
</label>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<img src="{$vo.image}" alt="{$vo.store_name}" class="open_image" data-image="{$vo.image}" style="width: 50px;height: 50px;cursor: pointer;">
|
||||
</td>
|
||||
<td class="text-left">
|
||||
{$vo.store_name}<br>
|
||||
价格:{$vo.price}<br>
|
||||
分类:{$vo.cate_name}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="edit-price edit-price-{$vo.id}" data-id="{$vo.id}">{$vo.price}</span>
|
||||
<input type="number" name="price" data-id="{$vo.id}" class="price price-{$vo.id}" value="{$vo.price}" style="display: none">
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{$vo.ficti}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{$vo.visitor}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{$vo.browse}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{$vo.sales}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="edit-stock edit-stock-{$vo.id}" data-attr="{$vo.stock_attr}" data-name="{$vo.store_name}" data-id="{$vo.id}">{$vo.stock}</span>
|
||||
<input type="number" name="stock" data-id="{$vo.id}" data-attr="{$vo.stock_attr}" class="stock stock-{$vo.id}" value="{$vo.stock}" style="display: none">
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{$vo.sort}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="btn btn-xs btn-white" {if condition="$vo['collect'] gt 0"}onclick="$eb.createModalFrame('点赞','{:Url('collect',array('id'=>$vo['id']))}')"{/if} style="cursor: pointer">
|
||||
<i class="fa fa-thumbs-up"></i> {$vo.collect}
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="btn btn-xs btn-white" {if condition="$vo['like'] gt 0"}onclick="$eb.createModalFrame('收藏','{:Url('like',array('id'=>$vo['id']))}')"{/if} style="cursor: pointer">
|
||||
<i class="fa fa-heart"></i> {$vo.like}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<div class="input-group-btn js-group-btn" style="min-width: 136px;">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-success btn-xs" aria-expanded="false" onclick="$eb.createModalFrame('{$vo.store_name}-属性','{:Url('attr',array('id'=>$vo['id']))}',{h:700,w:800})">
|
||||
<div class="layui-row layui-col-space15" id="app">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form layui-form-pane" action="">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">所有分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cate_id">
|
||||
<option value=" ">全部</option>
|
||||
{volist name='cate' id='vo'}
|
||||
<option value="{$vo.id}">{$vo.html}{$vo.cate_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">产品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="store_name" class="layui-input" placeholder="请输入产品名称,关键字,编号">
|
||||
<input type="hidden" name="type" value="{$type}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
|
||||
<i class="layui-icon layui-icon-search"></i>搜索</button>
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm export" lay-submit="export" lay-filter="export">
|
||||
<i class="fa fa-floppy-o" style="margin-right: 3px;"></i>导出</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--产品列表-->
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="alert alert-info" role="alert">
|
||||
列表[产品价格],[虚拟销量],[库存]可进行快速修改,双击或者单击进入编辑模式,失去焦点可进行自动保存
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
</div>
|
||||
<div class="layui-btn-container">
|
||||
{switch name='type'}
|
||||
{case value="1"}
|
||||
<button class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('create')}',{h:760,w:900})">添加产品</button>
|
||||
{/case}
|
||||
{case value="2"}
|
||||
<button class="layui-btn layui-btn-sm" data-type="show">批量上架</button>
|
||||
{/case}
|
||||
{/switch}
|
||||
</div>
|
||||
<table class="layui-hide" id="List" lay-filter="List"></table>
|
||||
<!--图片-->
|
||||
<script type="text/html" id="image">
|
||||
<img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
|
||||
</script>
|
||||
<!--上架|下架-->
|
||||
<script type="text/html" id="checkboxstatus">
|
||||
<input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='上架|下架' {{ d.is_show == 1 ? 'checked' : '' }}>
|
||||
</script>
|
||||
<!--收藏-->
|
||||
<script type="text/html" id="like">
|
||||
<span><i class="layui-icon layui-icon-praise"></i> {{d.like}}</span>
|
||||
</script>
|
||||
<!--点赞-->
|
||||
<script type="text/html" id="collect">
|
||||
<span><i class="layui-icon layui-icon-star"></i> {{d.collect}}</span>
|
||||
</script>
|
||||
<!--产品名称-->
|
||||
<script type="text/html" id="store_name">
|
||||
<h4>{{d.store_name}}</h4>
|
||||
<p>价格:{{d.price}}</p>
|
||||
{{# if(d.cate_name!=''){ }}
|
||||
<p>分类:{{d.cate_name}}</p>
|
||||
{{# } }}
|
||||
<p>访客量:{{d.visitor}}</p>
|
||||
<p>浏览量:{{d.browse}}</p>
|
||||
</script>
|
||||
<!--操作-->
|
||||
<script type="text/html" id="act">
|
||||
<button type="button" class="layui-btn layui-btn-xs btn-success" onclick="$eb.createModalFrame('{{d.store_name}}-属性','{:Url('attr')}?id={{d.id}}',{h:700,w:800})">
|
||||
属性
|
||||
</button>
|
||||
<button class="btn btn-default btn-xs" aria-expanded="false" onclick="$eb.createModalFrame('{$vo.store_name}-编辑','{:Url('edit',array('id'=>$vo['id']))}')">
|
||||
<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('{{d.store_name}}-编辑','{:Url('edit')}?id={{d.id}}')">
|
||||
编辑
|
||||
</button>
|
||||
<button data-toggle="dropdown" class="btn btn-warning btn-xs dropdown-toggle"
|
||||
aria-expanded="false">操作
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span class="caret"></span></button>
|
||||
<ul class="layui-nav-child layui-anim layui-anim-upbit">
|
||||
<li>
|
||||
<a href="javascript:void(0);" class="" onclick="$eb.createModalFrame(this.innerText,'{:Url('edit_content',array('id'=>$vo['id']))}')">
|
||||
<a href="javascript:void(0);" class="" onclick="$eb.createModalFrame(this.innerText,'{:Url('edit_content')}?id={{d.id}}')">
|
||||
<i class="fa fa-pencil"></i> 编辑内容</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:void(0);" onclick="$eb.createModalFrame(this.innerText,'{:Url('ump.store_seckill/seckill',array('id'=>$vo['id']))}')"">
|
||||
<a href="javascript:void(0);" onclick="$eb.createModalFrame(this.innerText,'{:Url('ump.store_seckill/seckill')}?id={{d.id}}')"">
|
||||
<i class="fa fa-gavel"></i> 开启秒杀</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:void(0);" class="delstor" data-url="{:Url('delete',array('id'=>$vo['id']))}">
|
||||
<a href="javascript:void(0);" onclick="$eb.createModalFrame(this.innerText,'{:Url('ump.store_bargain/bargain')}?id={{d.id}}')">
|
||||
<i class="fa fa-sort-amount-asc"></i> 开启砍价</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:void(0);" onclick="$eb.createModalFrame(this.innerText,'{:Url('ump.store_combination/combination')}?id={{d.id}}')">
|
||||
<i class="fa fa-hand-lizard-o"></i> 开启拼团</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:void(0);" lay-event='delstor'>
|
||||
<i class="fa fa-trash"></i> 删除
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{:Url('store.storeProductReply/index',array('product_id'=>$vo['id']))}">
|
||||
<a href="{:Url('store.storeProductReply/index')}?product_id={{d.id}}">
|
||||
<i class="fa fa-warning"></i> 评论查看
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- <p>-->
|
||||
<!-- <button class="btn btn-primary btn-sm this-all" type="button">全选</button>-->
|
||||
<!-- <button class="btn btn-primary btn-sm this-up" type="button">取消</button>-->
|
||||
<!-- <button class="btn btn-primary btn-sm updatetype" type="button">分类</button>-->
|
||||
<!-- <button class="btn btn-primary btn-sm" type="button">库存</button>-->
|
||||
<!-- <button class="btn btn-primary btn-sm" type="button">上架</button>-->
|
||||
<!-- <button class="btn btn-primary btn-sm" type="button">下架</button>-->
|
||||
<!-- <button class="btn btn-primary btn-sm" type="button">删除</button>-->
|
||||
<!-- <button class="btn btn-primary btn-sm" type="button">运费</button>-->
|
||||
<!-- </p>-->
|
||||
</div>
|
||||
{include file="public/inner_page"}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
{block name="script"}
|
||||
</div>
|
||||
<script src="{__ADMIN_PATH}js/layuiList.js"></script>
|
||||
<script>
|
||||
$('.search-item>li').on('click', function () {
|
||||
var that = $(this), value = that.data('value'), p = that.parent(), name = p.data('name'), form = $('#form');
|
||||
form.find('input[name="' + name + '"]').val(value);
|
||||
$('input[name=export]').val(0);
|
||||
form.submit();
|
||||
});
|
||||
$('.price').on('blur',function () {
|
||||
var id = $(this).data('id');
|
||||
var price = $(this).val();
|
||||
$('.edit-price-'+id).show();
|
||||
$(this).hide();
|
||||
$eb.axios.post("{:Url('store.store_product/edit_product_price')}",{id:id,price:price}).then(function(res){
|
||||
if(res.status == 200 && res.data.code == 200) {
|
||||
$eb.layer.msg(res.data.msg);
|
||||
$('.edit-price-'+id).html(price);
|
||||
}else{
|
||||
$eb.layer.msg(res.data.msg);
|
||||
var type=<?=$type?>;
|
||||
//实例化form
|
||||
layList.form.render();
|
||||
//加载列表
|
||||
layList.tableList('List',"{:Url('product_ist',['type'=>$type])}",function (){
|
||||
var join=new Array();
|
||||
switch (parseInt(type)){
|
||||
case 1:case 3:case 4:case 5:
|
||||
join=[
|
||||
{field: 'id', title: 'ID', sort: true,event:'id',width:'4%'},
|
||||
{field: 'image', title: '产品图片',templet:'#image'},
|
||||
{field: 'store_name', title: '产品名称',templet:'#store_name'},
|
||||
{field: 'price', title: '产品价格',edit:'price'},
|
||||
{field: 'ficti', title: '虚拟销量',edit:'ficti'},
|
||||
{field: 'stock', title: '库存',edit:'stock'},
|
||||
{field: 'sort', title: '排序',edit:'sort'},
|
||||
{field: 'sales', title: '销量',sort: true,event:'sales'},
|
||||
{field: 'collect', title: '点赞',templet:'#like'},
|
||||
{field: 'like', title: '收藏',templet:'#collect'},
|
||||
{field: 'status', title: '状态',templet:"#checkboxstatus"},
|
||||
{field: 'right', title: '操作',align:'center',toolbar:'#act',width:'10%'},
|
||||
];
|
||||
break;
|
||||
case 2:
|
||||
join=[
|
||||
{type:'checkbox'},
|
||||
{field: 'id', title: 'ID', sort: true,event:'id',width:'4%'},
|
||||
{field: 'image', title: '产品图片',templet:'#image'},
|
||||
{field: 'store_name', title: '产品名称',templet:'#store_name'},
|
||||
{field: 'price', title: '产品价格',edit:'price'},
|
||||
{field: 'ficti', title: '虚拟销量',edit:'ficti'},
|
||||
{field: 'stock', title: '库存',edit:'stock'},
|
||||
{field: 'sort', title: '排序',edit:'sort'},
|
||||
{field: 'sales', title: '销量',sort: true,event:'sales'},
|
||||
{field: 'status', title: '状态',templet:"#checkboxstatus"},
|
||||
{field: 'right', title: '操作',align:'center',toolbar:'#act',width:'10%'},
|
||||
];
|
||||
break;
|
||||
case 6:
|
||||
join=[
|
||||
{field: 'id', title: '产品ID', sort: true,event:'id'},
|
||||
{field: 'image', title: '产品图片',templet:'#image'},
|
||||
{field: 'store_name', title: '产品名称',templet:'#store_name'},
|
||||
{field: 'price', title: '产品价格',edit:'price'},
|
||||
{field: 'ficti', title: '虚拟销量',edit:'ficti'},
|
||||
{field: 'stock', title: '库存',edit:'stock'},
|
||||
{field: 'sort', title: '排序',edit:'sort'},
|
||||
{field: 'sales', title: '销量',sort: true,event:'sales'},
|
||||
{field: 'status', title: '状态',templet:"#checkboxstatus"},
|
||||
{field: 'right', title: '操作',align:'center',toolbar:'#act',width:'10%'},
|
||||
];
|
||||
break;
|
||||
}
|
||||
}).catch(function(err){
|
||||
$eb.layer.msg(err);
|
||||
});
|
||||
});
|
||||
$('.edit-price').on('dblclick',function () {
|
||||
var id = $(this).data('id');
|
||||
$('.price-'+id).show();
|
||||
$('.price-'+id).focus();
|
||||
$(this).hide();
|
||||
return join;
|
||||
})
|
||||
$('.stock').on('blur',function () {
|
||||
var attr = $(this).data('attr');
|
||||
if(!attr){
|
||||
var id = $(this).data('id');
|
||||
var stock = $(this).val();
|
||||
$('.edit-stock-'+id).show();
|
||||
$(this).hide();
|
||||
$eb.axios.post("{:Url('store.store_product/edit_product_stock')}",{id:id,stock:stock}).then(function(res){
|
||||
if(res.status == 200 && res.data.code == 200) {
|
||||
$eb.layer.msg(res.data.msg);
|
||||
$('.edit-stock-'+id).html(stock);
|
||||
}else{
|
||||
$eb.layer.msg(res.data.msg);
|
||||
}
|
||||
}).catch(function(err){
|
||||
$eb.layer.msg(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
$('.edit-stock').on('dblclick',function () {
|
||||
var id = $(this).data('id');
|
||||
var attr = $(this).data('attr');
|
||||
var storeName = $(this).data('name');
|
||||
if(attr) $eb.createModalFrame(storeName+'-属性',"{:Url('attr')}?id="+id+",'{h:700,w:800}");
|
||||
else{
|
||||
$('.stock-'+id).show();
|
||||
$('.stock-'+id).focus();
|
||||
//excel下载
|
||||
layList.search('export',function(where){
|
||||
location.href=layList.U({c:'store.store_product',a:'product_ist',q:{
|
||||
cate_id:where.cate_id,
|
||||
store_name:where.store_name,
|
||||
type:where.type,
|
||||
excel:1
|
||||
}});
|
||||
})
|
||||
//下拉框
|
||||
$(document).click(function (e) {
|
||||
$('.layui-nav-child').hide();
|
||||
})
|
||||
function dropdown(that){
|
||||
var oEvent = arguments.callee.caller.arguments[0] || event;
|
||||
oEvent.stopPropagation();
|
||||
var offset = $(that).offset();
|
||||
var index = $(that).parents('tr').data('index');
|
||||
$('.layui-nav-child').each(function (key) {
|
||||
if (key != index) {
|
||||
$(this).hide();
|
||||
}
|
||||
})
|
||||
//产品状态查找
|
||||
$('.protype>.btn-group>.btn').on('click', function () {
|
||||
var that = $(this), value = that.data('value'), p = that.parent().parent(), name = p.data('name'), form = $('#form');
|
||||
form.find('input[name="' + name + '"]').val(value);
|
||||
$('input[name=export]').val(0);
|
||||
form.submit();
|
||||
});
|
||||
//产品状态默认加载
|
||||
$('.protype').each(function(){
|
||||
var form = $('#form'),value=form.find('input[name="type"]').val(),dom = $('[data-value="'+value+'"]');
|
||||
dom.eq(0).removeClass('btn-white').addClass('btn-primary')
|
||||
.siblings().addClass('btn-white').removeClass('btn-primary btn-sm');
|
||||
});
|
||||
//全选
|
||||
$('.this-all').on('click',function () {
|
||||
$('input[name="id[]"]').each(function(){
|
||||
$(this).checked = true;
|
||||
$(this).parent().addClass('checked');
|
||||
// $eb.layer.msg('dsfds');
|
||||
});
|
||||
});
|
||||
//取消
|
||||
$('.this-up').on('click',function () {
|
||||
$('input[name="id[]"]').each(function(){
|
||||
$(this).checked = false;
|
||||
$(this).parent().removeClass('checked');
|
||||
});
|
||||
});
|
||||
//修改分类
|
||||
$('.updatetype').on('click',function () {
|
||||
var chk_value =[];
|
||||
$('input[name="id[]"]:checked').each(function(){
|
||||
chk_value.push($(this).val());
|
||||
});
|
||||
if(chk_value.length < 1){
|
||||
$eb.message('请选择商品');
|
||||
return false;
|
||||
if($(document).height() < offset.top+$(that).next('ul').height()){
|
||||
$(that).next('ul').css({
|
||||
'padding': 10,
|
||||
'top': offset.top-$(that).next('ul').height()-30,
|
||||
'min-width': 'inherit',
|
||||
'left': offset.left - $(that).width() / 2,
|
||||
'position': 'fixed'
|
||||
}).toggle();
|
||||
}else{
|
||||
$(that).next('ul').css({
|
||||
'padding': 10,
|
||||
'top': offset.top + 30,
|
||||
'min-width': 'inherit',
|
||||
'left': offset.left - $(that).width() / 2,
|
||||
'position': 'fixed'
|
||||
}).toggle();
|
||||
}
|
||||
console.log(chk_value);
|
||||
var str = chk_value.join(',');
|
||||
var url = "http://"+window.location.host+"/admin/store.store_coupon/grant/id/"+str;
|
||||
$eb.createModalFrame(this.innerText,url,{'w':800});
|
||||
|
||||
});
|
||||
//获取选择框值
|
||||
function getcheckvalue() {
|
||||
var chk_value =[];
|
||||
$('input[name="id[]"]:checked').each(function(){
|
||||
chk_value.push($(this).val());
|
||||
});
|
||||
if(chk_value.length < 1){
|
||||
$eb.message('请选择商品');
|
||||
return false;
|
||||
}
|
||||
return chk_value;
|
||||
//快速编辑
|
||||
layList.edit(function (obj) {
|
||||
var id=obj.data.id,value=obj.value;
|
||||
switch (obj.field) {
|
||||
case 'price':
|
||||
action.set_product('price',id,value);
|
||||
break;
|
||||
case 'stock':
|
||||
action.set_product('stock',id,value);
|
||||
break;
|
||||
case 'sort':
|
||||
action.set_product('sort',id,value);
|
||||
break;
|
||||
case 'ficti':
|
||||
action.set_product('ficti',id,value);
|
||||
break;
|
||||
}
|
||||
//浮动防止遮盖
|
||||
$('.js-group-btn').on('click',function(){
|
||||
$('.js-group-btn').css({zIndex:1});
|
||||
$(this).css({zIndex:2});
|
||||
});
|
||||
//复选框
|
||||
$('.i-checks').iCheck({
|
||||
checkboxClass: 'icheckbox_square-green',
|
||||
//上下加产品
|
||||
layList.switch('is_show',function (odj,value) {
|
||||
if(odj.elem.checked==true){
|
||||
layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:1,id:value}}),function (res) {
|
||||
layList.msg(res.msg);
|
||||
});
|
||||
|
||||
//删除产品
|
||||
$('.delstor').on('click',function(){
|
||||
window.t = $(this);
|
||||
var _this = $(this),url =_this.data('url');
|
||||
}else{
|
||||
layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:0,id:value}}),function (res) {
|
||||
layList.msg(res.msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
//点击事件绑定
|
||||
layList.tool(function (event,data,obj) {
|
||||
switch (event) {
|
||||
case 'delstor':
|
||||
var url=layList.U({c:'store.store_product',a:'delete',q:{id:data.id}});
|
||||
$eb.$swal('delete',function(){
|
||||
$eb.axios.get(url).then(function(res){
|
||||
console.log(res);
|
||||
if(res.status == 200 && res.data.code == 200) {
|
||||
$eb.$swal('success',res.data.msg);
|
||||
_this.parents('tr').remove();
|
||||
obj.del();
|
||||
}else
|
||||
return Promise.reject(res.data.msg || '删除失败')
|
||||
}).catch(function(err){
|
||||
$eb.$swal('error',err);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
//点击产品图放大
|
||||
$(".open_image").on('click',function (e) {
|
||||
var image = $(this).data('image');
|
||||
$eb.openImage(image);
|
||||
break;
|
||||
case 'open_image':
|
||||
$eb.openImage(data.image);
|
||||
break;
|
||||
}
|
||||
})
|
||||
//排序
|
||||
layList.sort(function (obj) {
|
||||
var type = obj.type;
|
||||
switch (obj.field){
|
||||
case 'id':
|
||||
layList.reload({order: layList.order(type,'p.id')},true,null,obj);
|
||||
break;
|
||||
case 'sales':
|
||||
layList.reload({order: layList.order(type,'p.sales')},true,null,obj);
|
||||
break;
|
||||
}
|
||||
});
|
||||
//查询
|
||||
layList.search('search',function(where){
|
||||
layList.reload(where);
|
||||
});
|
||||
//自定义方法
|
||||
var action={
|
||||
set_product:function(field,id,value){
|
||||
layList.baseGet(layList.Url({c:'store.store_product',a:'set_product',q:{field:field,id:id,value:value}}),function (res) {
|
||||
layList.msg(res.msg);
|
||||
});
|
||||
},
|
||||
show:function(){
|
||||
var ids=layList.getCheckData().getIds('id');
|
||||
if(ids.length){
|
||||
layList.basePost(layList.Url({c:'store.store_product',a:'product_show'}),{ids:ids},function (res) {
|
||||
layList.msg(res.msg);
|
||||
layList.reload();
|
||||
});
|
||||
}else{
|
||||
layList.msg('请选择要上架的产品');
|
||||
}
|
||||
}
|
||||
};
|
||||
//多选事件绑定
|
||||
$('.layui-btn-container').find('button').each(function () {
|
||||
var type=$(this).data('type');
|
||||
$(this).on('click',function(){
|
||||
action[type] && action[type]();
|
||||
})
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user