提交 7ebf0d2c 编写于 作者: D devil

新增动态列表+优化

上级 376fbd69
......@@ -33,6 +33,24 @@ class Common extends Controller
// 左边权限菜单
protected $left_menu;
// 当前操作名称
protected $module_name;
protected $controller_name;
protected $action_name;
// 输入参数 post
protected $data_post;
// 输入参数 get
protected $data_get;
// 输入参数 request
protected $data_request;
// 分页信息
protected $page;
protected $page_size;
/**
* 构造方法
* @author Devil
......@@ -48,6 +66,11 @@ class Common extends Controller
// 系统初始化
$this->SystemInit();
// 输入参数
$this->data_post = input('post.');
$this->data_get = input('get.');
$this->data_request = input();
// 管理员信息
$this->admin = session('admin');
......@@ -92,6 +115,23 @@ class Common extends Controller
// 公共底部钩子
$this->assign('plugins_admin_view_common_bottom_data', Hook::listen('plugins_admin_view_common_bottom', ['hook_name'=>'plugins_admin_view_common_bottom', 'is_backend'=>true, 'admin'=>$this->admin]));
// 公共钩子名称动态处理
$current = 'plugins_view_admin_'.$this->controller_name;
// 内容外部顶部
$this->assign('hook_name_content_top', $current.'_content_top');
// 内容外部底部
$this->assign('hook_name_content_bottom', $current.'_content_bottom');
// 内容内部顶部
$this->assign('hook_name_content_inside_top', $current.'_content_inside_top');
// 内容内部底部
$this->assign('hook_name_content_inside_bottom', $current.'_content_inside_bottom');
// 表格列表顶部操作
$this->assign('hook_name_form_top_operate', $current.'_top_operate');
// 表格列表底部操作
$this->assign('hook_name_form_bottom_operate', $current.'_bottom_operate');
// 表格列表后面操作栏
$this->assign('hook_name_form_list_operate', $current.'_list_operate');
}
/**
......@@ -145,25 +185,31 @@ class Common extends Controller
$this->assign('default_theme', $default_theme);
// 当前操作名称
$module_name = strtolower(request()->module());
$controller_name = strtolower(request()->controller());
$action_name = strtolower(request()->action());
$this->module_name = strtolower(request()->module());
$this->controller_name = strtolower(request()->controller());
$this->action_name = strtolower(request()->action());
// 当前操作名称
$this->assign('module_name', $module_name);
$this->assign('controller_name', $controller_name);
$this->assign('action_name', $action_name);
$this->assign('module_name', $this->module_name);
$this->assign('controller_name', $this->controller_name);
$this->assign('action_name', $this->action_name);
// 分页信息
$this->page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
$this->page_size = MyC('admin_page_number', 10, true);
$this->assign('page', $this->page);
$this->assign('page_size', $this->page_size);
// 价格符号
$this->assign('price_symbol', config('shopxo.price_symbol'));
// 控制器静态文件状态css,js
$module_css = $module_name.DS.$default_theme.DS.'css'.DS.$controller_name;
$module_css .= file_exists(ROOT_PATH.'static'.DS.$module_css.'.'.$action_name.'.css') ? '.'.$action_name.'.css' : '.css';
$module_css = $this->module_name.DS.$default_theme.DS.'css'.DS.$this->controller_name;
$module_css .= file_exists(ROOT_PATH.'static'.DS.$module_css.'.'.$this->action_name.'.css') ? '.'.$this->action_name.'.css' : '.css';
$this->assign('module_css', file_exists(ROOT_PATH.'static'.DS.$module_css) ? $module_css : '');
$module_js = $module_name.DS.$default_theme.DS.'js'.DS.$controller_name;
$module_js .= file_exists(ROOT_PATH.'static'.DS.$module_js.'.'.$action_name.'.js') ? '.'.$action_name.'.js' : '.js';
$module_js = $this->module_name.DS.$default_theme.DS.'js'.DS.$this->controller_name;
$module_js .= file_exists(ROOT_PATH.'static'.DS.$module_js.'.'.$this->action_name.'.js') ? '.'.$this->action_name.'.js' : '.js';
$this->assign('module_js', file_exists(ROOT_PATH.'static'.DS.$module_js) ? $module_js : '');
// 权限菜单
......@@ -180,6 +226,12 @@ class Common extends Controller
// 默认不加载百度地图api
$this->assign('is_load_baidu_map_api', 0);
// 动态表格处理
$obj = new \app\form\GoodsForm();
$table = $obj->Table();
$this->assign('form_table', $table);
//print_r($table);
}
/**
......
......@@ -54,7 +54,7 @@ class Goods extends Common
public function Index()
{
// 参数
$params = input();
$params = $this->data_request;
// 条件
$where = GoodsService::GetAdminIndexWhere($params);
......@@ -63,12 +63,11 @@ class Goods extends Common
$total = GoodsService::GoodsTotal($where);
// 分页
$number = MyC('admin_page_number', 10, true);
$page_params = array(
'number' => $number,
'number' => $this->page_size,
'total' => $total,
'where' => $params,
'page' => isset($params['page']) ? intval($params['page']) : 1,
'page' => $this->page,
'url' => MyUrl('admin/goods/index'),
);
$page = new \base\Page($page_params);
......@@ -77,7 +76,7 @@ class Goods extends Common
$data_params = [
'where' => $where,
'm' => $page->GetPageStarNumber(),
'n' => $number,
'n' => $this->page_size,
'is_category' => 1,
];
$ret = GoodsService::GoodsList($data_params);
......
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\facade\Hook;
use app\service\ArticleService;
/**
* test
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Myinc extends Common
{
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T12:39:08+0800
*/
public function __construct()
{
// 调用父类前置方法
parent::__construct();
// 登录校验
$this->IsLogin();
// 权限校验
$this->IsPower();
}
public function view($template)
{
//return $template;
return $this->fetch($template);
}
}
\ No newline at end of file
<!-- 商品基础信息 -->
{{if !empty($module_data)}}
<div class="goods">
<a href="{{$module_data.goods_url}}" target="_blank" title="{{$module_data.title}}">
<img src="{{$module_data['images']}}" class="am-img-thumbnail am-radius goods-images" />
</a>
<a href="{{$module_data.goods_url}}" target="_blank" title="{{$module_data.title}}" {{if !empty($module_data['title_color'])}} style="color:{{$module_data.title_color}};" {{/if}} class="am-nowrap-initial">{{$module_data.title}}</a>
{{if !empty($module_data['simple_desc'])}}
<p class="am-text-danger am-nowrap-initial">{{$module_data.simple_desc}}</p>
{{/if}}
</div>
{{/if}}
\ No newline at end of file
<!-- 操作栏 -->
<button class="am-btn am-btn-default am-btn-xs am-radius am-btn-block submit-popup" data-url="{{:MyUrl('admin/goods/detail', ['id'=>$module_data['id']])}}">
<i class="am-icon-eye"></i>
<span>详情</span>
</button>
<a class="am-btn am-btn-secondary am-btn-xs am-radius am-btn-block" href="{{:MyUrl('admin/goods/saveinfo', array_merge($params, ['id'=>$module_data['id']]))}}">
<i class="am-icon-edit"></i>
<span>编辑</span>
</a>
<button class="am-btn am-btn-danger am-btn-xs am-radius am-btn-block submit-delete" data-url="{{:MyUrl('admin/goods/delete')}}" data-id="{{$module_data.id}}">
<i class="am-icon-trash-o"></i>
<span>删除</span>
</button>
\ No newline at end of file
{{include file="public/header" /}}
<!-- content top hook -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>{{$hook_name_content_top}}</span>
</div>
{{/if}}
{{php}}
$hook_data = Hook::listen($hook_name_content_top, ['hook_name'=>$hook_name_content_top, 'is_backend'=>true]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
<!-- right content start -->
<div class="content-right">
<div class="content">
<!-- content inside top hook -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>{{$hook_name_content_inside_top}}</span>
</div>
{{/if}}
{{php}}
$hook_data = Hook::listen($hook_name_content_inside_top, ['hook_name'=>$hook_name_content_inside_top, 'is_backend'=>true]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
<!-- form start -->
{{block name="search_form"}}{{/block}}
<!-- form end -->
<!-- top operate start -->
<div class="am-g am-margin-top-sm">
{{block name="form_operate_top"}}
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_admin_goods_top_operate</span>
</div>
{{/if}}
{{php}}
$hook_name = 'plugins_view_admin_goods_top_operate';
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>true]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
{{/block}}
</div>
<!-- top operate end -->
<!-- list start -->
<div class="am-scrollable-horizontal am-table-scrollable-horizontal am-margin-top-sm">
<table class="am-table am-table-striped am-table-hover am-table-bordered am-text-nowrap">
<thead>
<tr>
{{if !empty($form_table['form'])}}
{{foreach $form_table['form'] as $t}}
<!-- 1. 上下居中 -->
<!-- 2. 格子大小 -->
<!-- 3. 内容位置居(左|中|右) -->
<!-- 4. 格子是否固定(left|right 左|右) -->
<th class="
{{if !isset($t['is_middle']) or $t['is_middle'] eq 1}}am-text-middle {{/if}}
{{if !empty($t['grid_size'])}}am-grid-{{$t.grid_size}} {{/if}}
{{if !empty($t['align'])}}am-text-{{$t.align}} {{/if}}
{{if !empty($t['fixed'])}}am-grid-fixed-{{$t.fixed}} {{/if}}
">{{if isset($t['label'])}}{{$t.label}}{{/if}}</th>
{{/foreach}}
{{/if}}
</tr>
</thead>
<tbody>
{{if !empty($data_list) and !empty($form_table['form']) and !empty($form_table['base']) and !empty($form_table['base']['key_field'])}}
<!-- 处理数据数量小于默认数量 -->
{{for start="0" end="(count($data_list) < $page_size ? count($data_list) : $page_size)"}}
<!-- 1. tr 主键id名称 -->
<!-- 2. 是否黄色选中class -->
<tr {{if !empty($form_table['base'])}}
id="data-list-{{if isset($data_list[$i][$form_table['base']['key_field']])}}{{$data_list[$i][$form_table['base']['key_field']]}}{{/if}}"
{{if !empty($form_table['base']['status_field']) and isset($data_list[$i][$form_table['base']['status_field']]) and $data_list[$i][$form_table['base']['status_field']] eq 0}}class="am-active"{{/if}}
{{/if}}>
{{foreach $form_table['form'] as $t}}
<!-- 1. 上下居中 -->
<!-- 2. 格子大小 -->
<!-- 3. 内容位置居(左|中|右) -->
<!-- 4. 格子是否固定(left|right 左|右) -->
<!-- 5. 是否操作列 -->
<td class="
{{if !isset($t['is_middle']) or $t['is_middle'] eq 1}}am-text-middle {{/if}}
{{if !empty($t['grid_size'])}}am-grid-{{$t.grid_size}} {{/if}}
{{if !empty($t['align'])}}am-text-{{$t.align}} {{/if}}
{{if !empty($t['fixed'])}}am-grid-fixed-{{$t.fixed}} {{/if}}
{{if !empty($t['view_type']) and $t['view_type'] eq 'operate'}}am-operate-grid {{/if}}
">
{{if isset($data_list[$i]) and !empty($t['view_type']) and !empty($t['view_key'])}}
<!-- 数据匹配 -->
{{switch $t.view_type}}
{{case field}}
<!-- 如果字段为数组则处理多个字段拼接数据 -->
{{if is_array($t['view_key'])}}
{{foreach $t['view_key'] as $fk=>$fv}}
{{if isset($data_list[$i][$fv])}}
{{$data_list[$i][$fv]}}
<!-- 多个字段拼接数据的的拼接字符 -->
{{if isset($t['view_key_join']) and $fk lt count($t['view_key'])-1}}
{{$t.view_key_join|raw}}
{{/if}}
{{/if}}
{{/foreach}}
{{else /}}
<!-- 非数组则直接取值 -->
{{if isset($data_list[$i][$t['view_key']])}}
{{$data_list[$i][$t['view_key']]|raw}}
{{/if}}
{{/if}}
{{/case}}
{{case module}}
<!-- 从模块加载自定义模块数据 -->
{{:ModuleInclude($t['view_key'], $data_list[$i])}}
{{/case}}
{{case status}}
<!-- 数据状态操作按钮组件 -->
{{if !empty($t['key_field']) and !empty($t['post_url'])}}
<a href="javascript:;"
class="am-icon-btn am-icon-check submit-state {{if $data_list[$i][$t['view_key']] eq 1}}am-success{{else /}}am-default{{/if}}"
data-url="{{$t.post_url}}"
data-id="{{if isset($data_list[$i][$t['key_field']])}}{{$data_list[$i][$t['key_field']]}}{{/if}}"
data-state="{{$data_list[$i][$t['view_key']]}}"
data-is-update-status="{{if isset($t['is_form_su'])}}{{$t.is_form_su}}{{else /}}0{{/if}}"
></a>
{{/if}}
{{/case}}
{{case operate}}
<!-- 是否操作列 -->
<!-- 模块数据 -->
{{:ModuleInclude($t['view_key'], $data_list[$i])}}
<!-- 列表操作钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>{{$hook_name_form_list_operate}}</span>
</div>
{{/if}}
{{php}}
$hook_data = Hook::listen($hook_name_form_list_operate, [
'hook_name' => $hook_name_form_list_operate,
'is_backend' => true,
'id' => isset($data_list[$i][$form_table['base']['key_field']]) ? $data_list[$i][$form_table['base']['key_field']] : 0,
'data' => $data_list[$i],
]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
{{/case}}
{{/switch}}
{{/if}}
</td>
{{/foreach}}
</tr>
{{/for}}
{{/if}}
</tbody>
</table>
{{if empty($data_list)}}
<div class="table-no"><i class="am-icon-warning"></i> 没有相关数据</div>
{{/if}}
</div>
<!-- list end -->
<!-- bottom operate start -->
<div class="am-g am-margin-top-sm">
{{block name="form_operate_bottom"}}
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>{{$hook_name_form_bottom_operate}}</span>
</div>
{{/if}}
{{php}}
$hook_data = Hook::listen($hook_name_form_bottom_operate, ['hook_name'=>$hook_name_form_bottom_operate, 'is_backend'=>true]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
{{/block}}
</div>
<!-- bottom operate end -->
<!-- page start -->
{{block name="form_page"}}
{{if !empty($data_list)}}
{{$page_html|raw}}
{{/if}}
{{/block}}
<!-- page end -->
<!-- content inside top hook -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>{{$hook_name_content_inside_bottom}}</span>
</div>
{{/if}}
{{php}}
$hook_data = Hook::listen($hook_name_content_inside_bottom, ['hook_name'=>$hook_name_content_inside_bottom, 'is_backend'=>true]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
</div>
</div>
<!-- right content end -->
<!-- content bottom hook -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>{{$hook_name_content_bottom}}</span>
</div>
{{/if}}
{{php}}
$hook_data = Hook::listen($hook_name_content_bottom, ['hook_name'=>$hook_name_content_bottom, 'is_backend'=>true]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->
\ No newline at end of file
......@@ -11,6 +11,36 @@
// 应用公共文件
/**
* 模块视图动态加载方法
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-05-25
* @desc description
* @param [string] $template [视图路径]
* @param [mixed] $params [参数数据]
*/
function ModuleInclude($template, $params = [])
{
// 应用控制器
$module = '\app\module\ViewInclude';
if(!class_exists($module))
{
return '模块视图控制器未定义['.$module.']';
}
// 调用方法
$action = 'Run';
$obj = new $module();
if(!method_exists($obj, $action))
{
return '模块视图方法未定义['.$module.'->'.$action.'()]';
}
return $obj->Run($template, $params);
}
/**
* 钩子返回数据处理,是否存在错误
* @author Devil
......
......@@ -8,7 +8,7 @@
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\service;
namespace app\form;
use think\Db;
......@@ -33,18 +33,75 @@ class GoodsForm
*/
public function Table($params = [])
{
$data = [
[
// 标题名称
'label' => '商品信息',
// 展示数据类型(field 字段取值, file 文件引入内容, status 状态操作, )
'view_type' => 'field',
// 展示数据的 key名称
'view_key' => 'title',
// 内容位置(left 居左, center 居中, right 居右)默认 left
'align' => 'left',
// 格子大小(lg 350px, sm 200px, xs 150px)默认空(100px)
'grid_size' => 'lg',
return [
// 基础配置
'base' => [
'key_field' => 'id',
'status_field' => 'is_shelves',
],
// 表单配置
'form' => [
[
'label' => '商品ID',
'view_type' => 'field',
'view_key' => 'id',
],
[
'label' => '商品信息',
'view_type' => 'module',
'view_key' => 'goods/module/info',
'grid_size' => 'lg',
],
[
'label' => '销售价格(元)',
'view_type' => 'field',
'view_key' => 'price',
],
[
'label' => '原价(元)',
'view_type' => 'field',
'view_key' => 'original_price',
],
[
'label' => '库存数量',
'view_type' => 'field',
'view_key' => ['inventory', 'inventory_unit'],
'view_key_join' => ' ',
],
[
'label' => '上下架',
'view_type' => 'status',
'view_key' => 'is_shelves',
'key_field' => 'id',
'post_url' => MyUrl('admin/goods/statusshelves'),
'is_form_su' => 1,
'align' => 'center',
],
[
'label' => '首页推荐',
'view_type' => 'status',
'view_key' => 'is_home_recommended',
'key_field' => 'id',
'post_url' => MyUrl('admin/goods/statushomerecommended'),
'align' => 'center',
],
[
'label' => '商品型号',
'view_type' => 'field',
'view_key' => 'model',
],
[
'label' => '品牌',
'view_type' => 'field',
'view_key' => 'brand_name',
],
[
'label' => '操作',
'view_type' => 'operate',
'view_key' => 'goods/module/operate',
'align' => 'center',
'fixed' => 'right',
],
],
];
}
......
......@@ -230,7 +230,7 @@
{{if !empty($floor['goods'])}}
{{foreach $floor.goods as $goods_key=>$goods}}
<div class="goods-items">
<a href="{{$goods.goods_url}}" target="_blank" class="am-block">
<a href="{{$goods.goods_url}}" target="_blank" class="am-block am-text-center">
<!-- 首页楼层商品内部顶部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
......
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\module;
use think\Controller;
/**
* 视图模块引入
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-05-25
* @desc description
*/
class ViewInclude extends Controller
{
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-05-25
* @desc description
*/
public function __construct()
{
// 调用父类前置方法
parent::__construct();
}
/**
* 运行入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-05-25
* @desc description
* @param [string] $template [模板地址]
* @param [mixed] $params [参数数据]
* @return [string] [模板内容]
*/
public function Run($template, $params = [])
{
$this->assign('module_data', $params);
return $this->fetch($template);
}
}
?>
\ No newline at end of file
......@@ -176,6 +176,9 @@ class GoodsService
*/
public static function HomeFloorList($params = [])
{
// 商品数量
$goods_count = 8;
// 缓存
$key = config('shopxo.cache_goods_floor_list_key');
$data = cache($key);
......@@ -198,7 +201,7 @@ class GoodsService
'g.is_home_recommended' => 1,
'g.is_shelves' => 1,
];
$v['goods_ids'] = Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->where($where)->group('g.id')->order('g.id desc')->limit(8)->column('g.id');
$v['goods_ids'] = Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->where($where)->group('g.id')->order('g.id desc')->limit($goods_count)->column('g.id');
$v['goods'] = [];
}
}
......@@ -215,7 +218,7 @@ class GoodsService
{
if(!empty($v['goods_ids']) && is_array($v['goods_ids']))
{
$res = self::GoodsList(['where'=>['id'=>$v['goods_ids'], 'is_home_recommended'=>1, 'is_shelves'=>1], 'm'=>0, 'n'=>8, 'field'=>'*']);
$res = self::GoodsList(['where'=>['id'=>$v['goods_ids'], 'is_home_recommended'=>1, 'is_shelves'=>1], 'm'=>0, 'n'=>$goods_count, 'field'=>'*']);
$v['goods'] = $res['data'];
}
}
......
......@@ -430,6 +430,7 @@ button.colorpicker-submit img {
*/
.am-table-scrollable-horizontal {
border: 1px solid #ddd;
position: relative;
}
.am-table-scrollable-horizontal .am-table {
border-collapse: collapse;
......@@ -456,50 +457,48 @@ button.colorpicker-submit img {
background: #e8e6e6;
min-width: 100px;
}
.am-table-scrollable-horizontal .am-table tr th.am-grid-lg {
.am-table-scrollable-horizontal .am-table tr .am-grid-lg {
min-width: 350px;
}
.am-table-scrollable-horizontal .am-table tr th.am-grid-sm {
.am-table-scrollable-horizontal .am-table tr .am-grid-sm {
min-width: 200px;
}
.am-table-scrollable-horizontal .am-table tr th.am-grid-xs {
.am-table-scrollable-horizontal .am-table tr .am-grid-xs {
min-width: 150px;
}
.am-table-scrollable-horizontal .am-table tr .am-operate-grid {
width: 100px;
padding: 0;
}
.am-table-scrollable-horizontal .am-table tr .am-operate-grid .am-scrollable-vertical {
height: 45px;
padding: 10px 15px;
resize: none;
overflow-x: hidden;
}
.am-table-scrollable-horizontal .am-table-td-fixed-first th:first-child,
.am-table-scrollable-horizontal .am-table-td-fixed-first td:first-child,
.am-table-scrollable-horizontal .am-table-td-fixed-last th:last-child,
.am-table-scrollable-horizontal .am-table-td-fixed-last td:last-child {
position: absolute;
width: 100px;
}
.am-table-scrollable-horizontal .am-table tr .am-grid-fixed-left,
.am-table-scrollable-horizontal .am-table tr .am-grid-fixed-right {
height: auto;
text-align: center;
z-index: 2;
position: sticky;
}
.am-table-scrollable-horizontal .am-table-td-fixed-first td:first-child,
.am-table-scrollable-horizontal .am-table-td-fixed-last td:last-child {
.am-table-scrollable-horizontal .am-table tr td.am-grid-fixed-left,
.am-table-scrollable-horizontal .am-table tr td.am-grid-fixed-right {
height: auto;
z-index: 2;
position: sticky;
background: #fff;
}
.am-table-scrollable-horizontal .am-table-td-fixed-first th:first-child,
.am-table-scrollable-horizontal .am-table-td-fixed-first td:first-child {
.am-table-scrollable-horizontal .am-table tr .am-grid-fixed-left {
-webkit-box-shadow: 1px 0px 1px #ddd;
-moz-box-shadow: 1px 0px 1px #ddd;
box-shadow: 1px 0px 1px #ddd;
}
.am-table-scrollable-horizontal .am-table tr .am-grid-fixed-right {
-webkit-box-shadow: 0px 0px 1px #ddd;
-moz-box-shadow: 0px 0px 1px #ddd;
box-shadow: 0px 0px 1px #ddd;
}
.am-table-scrollable-horizontal .am-table tr .am-grid-fixed-left-shadow {
-webkit-box-shadow: 5px 0px 10px rgba(136, 136, 136, 0.3);
-moz-box-shadow: 5px 0px 10px rgba(136, 136, 136, 0.3);
box-shadow: 5px 0px 10px rgba(136, 136, 136, 0.3);
left: 0;
}
.am-table-scrollable-horizontal .am-table-td-fixed-last th:last-child,
.am-table-scrollable-horizontal .am-table-td-fixed-last td:last-child {
.am-table-scrollable-horizontal .am-table tr .am-grid-fixed-right-shadow {
-webkit-box-shadow: -5px 0px 10px rgba(136, 136, 136, 0.3);
-moz-box-shadow: -5px 0px 10px rgba(136, 136, 136, 0.3);
box-shadow: -5px 0px 10px rgba(136, 136, 136, 0.3);
right: 0;
}
}
\ No newline at end of file
......@@ -1559,134 +1559,52 @@ function TableContainerInit()
{
if($('.am-table-scrollable-horizontal').length > 0)
{
// th
$('.am-table-scrollable-horizontal > table > thead > tr').each(function(k, v)
{
// 第一列
if($(this).parents('.am-table').hasClass('am-table-td-fixed-first'))
{
$(this).find('>th:first').css('left', $(this).parents('.am-table').offset().left);
// 第一列自定义宽度->默认宽度,设置第二列 padding-left
var first_width = $(this).find('>th').first().data('width') || $(this).find('>th').first().innerWidth();
if(first_width > 0)
{
$(this).find('>th').eq(1).css('min-width', (($(this).find('>th').eq(1).data('width') || 0)+first_width)+'px');
$(this).find('>th').eq(1).css('padding-left', (first_width+10)+'px');
}
}
// 最后一列
if($(this).parents('.am-table').hasClass('am-table-td-fixed-last'))
{
var $obj = $(this).parents('.am-table-scrollable-horizontal');
var width = $(document.body).width();
var left = $obj.offset().left;
var right = width-$obj.width()-left-1;
$(this).find('>th:last').css('right', right);
// 最后一列自定义宽度->默认宽度,设置倒数第二列 padding-right
var last_width = parseInt($(this).find('>th').last().attr('data-width') || $(this).find('>th').last().innerWidth());
if(last_width > 0)
{
// 倒数第二个元素的宽度、默认读取属性宽度
var last_width2 = parseInt($(this).find('>th').eq(-2).attr('data-width') || $(this).find('>th').eq(-2).innerWidth());
// 设置宽度、倒数第二个元素的宽度+最后一个元素的宽度
$(this).find('>th').eq(-2).css('min-width', last_width2+last_width+'px');
// 设置宽度、最后一个元素的宽度+10
$(this).find('>th').eq(-2).css('padding-right', (last_width+10)+'px');
// 设置属性数据
$(this).find('>th').eq(-2).attr('data-width', last_width2);
$(this).find('>th').last().attr('data-width', last_width);
}
}
// 是否自定义宽高
$(this).find('>th').each(function(ks, vs)
{
var width = $(this).data('width') || 0;
if(width > 0)
{
$(this).css('width', width+'px');
}
var height = $(this).data('height') || 0;
if(height > 0)
{
$(this).css('height', height+'px');
}
});
});
// 表格容器距离计算
var $obj = $('.am-table-scrollable-horizontal');
var document_width = $(window).width();
var parent_left = $obj.offset().left;
var parent_width = $obj[0].scrollWidth;
var parent_right = document_width-parent_width-parent_left-2;
// 左固定
$('.am-table-scrollable-horizontal > table .am-grid-fixed-left').each(function(k, v)
{
var width = parseInt($(this).attr('data-width') || $(this).innerWidth());
var left = parseInt($(this).attr('data-left') || $(this).position().left);
$(this).attr('data-width', width);
$(this).attr('data-left', left);
$(this).css({"width":width+"px", "left":left+"px"});
});
// td
$('.am-table-scrollable-horizontal > table > tbody > tr').each(function(k, v)
{
// 容器
var height = $(this).height() || 0;
// 右固定
$('.am-table-scrollable-horizontal > table .am-grid-fixed-right').each(function(k, v)
{
var width = parseInt($(this).attr('data-width') || $(this).innerWidth());
var right = $(this).attr('data-right') || undefined;
if(right == undefined)
{
var left = $(this).offset().left;
var width = $(this).width();
var right = parent_width-left-width-parent_left-4;
if(right < 0)
{
right = 0;
}
} else {
right = parseInt(right);
}
$(this).attr('data-width', width);
$(this).attr('data-right', right);
$(this).css({"width":width+"px", "right":right+"px"});
});
// 自定义高度,仅大于默认高度的时候有效
var z_height = $(this).data('height') || 0;
if(z_height > height)
{
height = z_height;
}
if(height > 0)
{
$(this).find('>td').css('height', height+'px');
// 第一列
if($(this).parents('.am-table').hasClass('am-table-td-fixed-first'))
{
$(this).find('>td:first').css('left', $(this).parents('.am-table').offset().left);
// 第一列自定义宽度->默认宽度,设置第二列 padding-left
var first_width = $(this).find('>td').first().data('width') || $(this).find('>td').first().innerWidth();
if(first_width > 0)
{
$(this).find('>td').eq(1).css('padding-left', (first_width+10)+'px');
}
}
// 最后一列
if($(this).parents('.am-table').hasClass('am-table-td-fixed-last'))
{
var $obj = $(this).parents('.am-table-scrollable-horizontal');
var width = $(document.body).width();
var left = $obj.offset().left;
var right = width-$obj.width()-left-1;
$(this).find('>td:last').css('right', right);
// 最后一列自定义宽度->默认宽度,设置倒数第二列 padding-right
var last_width = parseInt($(this).find('>td').last().attr('data-width') || $(this).find('>td').last().innerWidth());
if(last_width > 0)
{
// 设置宽度、最后一个元素的宽度+10
$(this).find('>td').eq(-2).css('padding-right', (last_width+10)+'px');
}
}
// 操作栏下容器高度
if($(this).find('>td.am-operate-grid .am-scrollable-vertical').length > 0)
{
$(this).find('>td.am-operate-grid .am-scrollable-vertical').css('height', (height-1)+'px');
}
// 是否自定义宽高
$(this).find('>td').each(function(ks, vs)
{
var width = $(this).data('width') || 0;
if(width > 0)
{
$(this).css('width', width+'px');
}
var height = $(this).data('height') || 0;
if(height > 0)
{
$(this).css('height', height+'px');
}
});
}
});
}
// 左边最后一列、右边第一列设置阴影样式
$('.am-table-scrollable-horizontal > table tr').each(function(k, v)
{
$(this).find('.am-grid-fixed-left').last().addClass('am-grid-fixed-left-shadow');
$(this).find('.am-grid-fixed-right').first().addClass('am-grid-fixed-right-shadow');
});
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册