提交 82222632 编写于 作者: D devil

数据列表优化

上级 abef6b0f
...@@ -12,9 +12,9 @@ namespace app\admin\controller; ...@@ -12,9 +12,9 @@ namespace app\admin\controller;
use think\facade\Hook; use think\facade\Hook;
use think\Controller; use think\Controller;
use app\module\FormHandleModule;
use app\service\AdminPowerService; use app\service\AdminPowerService;
use app\service\ConfigService; use app\service\ConfigService;
use app\module\FormHandleModule;
/** /**
* 管理员公共控制器 * 管理员公共控制器
...@@ -39,13 +39,9 @@ class Common extends Controller ...@@ -39,13 +39,9 @@ class Common extends Controller
protected $controller_name; protected $controller_name;
protected $action_name; protected $action_name;
// 输入参数 post // 输入参数 post|get|request
protected $data_post; protected $data_post;
// 输入参数 get
protected $data_get; protected $data_get;
// 输入参数 request
protected $data_request; protected $data_request;
// 分页信息 // 分页信息
...@@ -70,14 +66,14 @@ class Common extends Controller ...@@ -70,14 +66,14 @@ class Common extends Controller
{ {
parent::__construct(); parent::__construct();
// 系统初始化
$this->SystemInit();
// 输入参数 // 输入参数
$this->data_post = input('post.'); $this->data_post = input('post.');
$this->data_get = input('get.'); $this->data_get = input('get.');
$this->data_request = input(); $this->data_request = input();
// 系统初始化
$this->SystemInit();
// 管理员信息 // 管理员信息
$this->admin = session('admin'); $this->admin = session('admin');
...@@ -204,6 +200,12 @@ class Common extends Controller ...@@ -204,6 +200,12 @@ class Common extends Controller
$this->assign('controller_name', $this->controller_name); $this->assign('controller_name', $this->controller_name);
$this->assign('action_name', $this->action_name); $this->assign('action_name', $this->action_name);
// 管理员
$this->assign('admin', $this->admin);
// 权限菜单
$this->assign('left_menu', $this->left_menu);
// 分页信息 // 分页信息
$this->page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1); $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->page_size = MyC('admin_page_number', 10, true);
...@@ -222,12 +224,6 @@ class Common extends Controller ...@@ -222,12 +224,6 @@ class Common extends Controller
$module_js .= file_exists(ROOT_PATH.'static'.DS.$module_js.'.'.$this->action_name.'.js') ? '.'.$this->action_name.'.js' : '.js'; $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 : ''); $this->assign('module_js', file_exists(ROOT_PATH.'static'.DS.$module_js) ? $module_js : '');
// 权限菜单
$this->assign('left_menu', $this->left_menu);
// 用户
$this->assign('admin', $this->admin);
// 图片host地址 // 图片host地址
$this->assign('attachment_host', config('shopxo.attachment_host')); $this->assign('attachment_host', config('shopxo.attachment_host'));
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
namespace app\admin\controller; namespace app\admin\controller;
use think\facade\Hook; use think\facade\Hook;
use app\service\ResourcesService;
use app\service\GoodsService; use app\service\GoodsService;
use app\service\RegionService; use app\service\RegionService;
use app\service\BrandService; use app\service\BrandService;
...@@ -53,12 +52,6 @@ class Goods extends Common ...@@ -53,12 +52,6 @@ class Goods extends Common
*/ */
public function Index() public function Index()
{ {
// 参数
$params = $this->data_request;
// 条件
//$where = GoodsService::GetAdminIndexWhere($params);
// 总数 // 总数
$total = GoodsService::GoodsTotal($this->form_where); $total = GoodsService::GoodsTotal($this->form_where);
...@@ -66,7 +59,7 @@ class Goods extends Common ...@@ -66,7 +59,7 @@ class Goods extends Common
$page_params = array( $page_params = array(
'number' => $this->page_size, 'number' => $this->page_size,
'total' => $total, 'total' => $total,
'where' => $params, 'where' => $this->data_request,
'page' => $this->page, 'page' => $this->page,
'url' => MyUrl('admin/goods/index'), 'url' => MyUrl('admin/goods/index'),
); );
...@@ -81,19 +74,7 @@ class Goods extends Common ...@@ -81,19 +74,7 @@ class Goods extends Common
]; ];
$ret = GoodsService::GoodsList($data_params); $ret = GoodsService::GoodsList($data_params);
// 商品分类 $this->assign('params', $this->data_request);
$this->assign('goods_category_list', GoodsService::GoodsCategoryAll());
// 品牌分类
$this->assign('brand_list', BrandService::CategoryBrand());
// 是否上下架
$this->assign('common_is_shelves_list', lang('common_is_shelves_list'));
// 是否首页推荐
$this->assign('common_is_text_list', lang('common_is_text_list'));
$this->assign('params', $params);
$this->assign('page_html', $page->GetPageHtml()); $this->assign('page_html', $page->GetPageHtml());
$this->assign('data_list', $ret['data']); $this->assign('data_list', $ret['data']);
return $this->fetch(); return $this->fetch();
......
...@@ -32,12 +32,6 @@ class Plugins extends Common ...@@ -32,12 +32,6 @@ class Plugins extends Common
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
// 登录校验
$this->IsLogin();
// 权限校验
$this->IsPower();
} }
/** /**
...@@ -50,7 +44,7 @@ class Plugins extends Common ...@@ -50,7 +44,7 @@ class Plugins extends Common
public function Index() public function Index()
{ {
// 参数 // 参数
$params = input(); $params = $this->GetClassVars();
// 请求参数校验 // 请求参数校验
$p = [ $p = [
...@@ -70,7 +64,7 @@ class Plugins extends Common ...@@ -70,7 +64,7 @@ class Plugins extends Common
'error_msg' => '应用操作方法有误', 'error_msg' => '应用操作方法有误',
], ],
]; ];
$ret = ParamsChecked($params, $p); $ret = ParamsChecked($params['data_request'], $p);
if($ret !== true) if($ret !== true)
{ {
if(IS_AJAX) if(IS_AJAX)
...@@ -83,9 +77,10 @@ class Plugins extends Common ...@@ -83,9 +77,10 @@ class Plugins extends Common
} }
// 应用名称/控制器/方法 // 应用名称/控制器/方法
$pluginsname = $params['pluginsname']; $pluginsname = $params['data_request']['pluginsname'];
$pluginscontrol = strtolower($params['pluginscontrol']); $pluginscontrol = strtolower($params['data_request']['pluginscontrol']);
$pluginsaction = strtolower($params['pluginsaction']); $pluginsaction = strtolower($params['data_request']['pluginsaction']);
unset($params['data_request']['pluginsname'], $params['data_request']['pluginscontrol'], $params['data_request']['pluginsaction']);
// 视图初始化 // 视图初始化
$this->PluginsViewInit($pluginsname, $pluginscontrol, $pluginsaction); $this->PluginsViewInit($pluginsname, $pluginscontrol, $pluginsaction);
...@@ -110,6 +105,28 @@ class Plugins extends Common ...@@ -110,6 +105,28 @@ class Plugins extends Common
} }
} }
/**
* 获取类属性数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-07
* @desc description
*/
public function GetClassVars()
{
$data = [];
$vers = get_class_vars(get_class());
foreach($vers as $k=>$v)
{
if(property_exists($this, $k))
{
$data[$k] = $this->$k;
}
}
return $data;
}
/** /**
* 视图初始化 * 视图初始化
* @author Devil * @author Devil
......
...@@ -48,6 +48,9 @@ class Goods ...@@ -48,6 +48,9 @@ class Goods
'status_field' => 'is_shelves', 'status_field' => 'is_shelves',
'is_search' => 1, 'is_search' => 1,
'search_url' => MyUrl('admin/goods/index'), 'search_url' => MyUrl('admin/goods/index'),
'is_delete' => 1,
'delete_url' => MyUrl('admin/goods/delete'),
'delete_key' => 'ids',
], ],
// 表单配置 // 表单配置
'form' => [ 'form' => [
...@@ -59,16 +62,11 @@ class Goods ...@@ -59,16 +62,11 @@ class Goods
'align' => 'center', 'align' => 'center',
'width' => 80, 'width' => 80,
], ],
[
'view_type' => 'radio',
'align' => 'center',
'width' => 50,
],
[ [
'label' => '商品ID', 'label' => '商品ID',
'view_type' => 'field', 'view_type' => 'field',
'view_key' => 'id', 'view_key' => 'id',
'width' => 80, 'width' => 120,
'search_config' => [ 'search_config' => [
'form_type' => 'input', 'form_type' => 'input',
'form_name' => 'id', 'form_name' => 'id',
...@@ -188,6 +186,20 @@ class Goods ...@@ -188,6 +186,20 @@ class Goods
'where_type' => 'in', 'where_type' => 'in',
], ],
], ],
[
'label' => '生产地',
'view_type' => 'field',
'view_key' => 'place_origin_name',
'search_config' => [
'form_type' => 'select',
'form_name' => 'place_origin',
'data' => RegionService::RegionItems(['pid'=>0]),
'data_key' => 'id',
'data_name' => 'name',
'where_type' => 'in',
'is_multiple' => 1,
],
],
[ [
'label' => '创建时间', 'label' => '创建时间',
'view_type' => 'field', 'view_type' => 'field',
......
<!-- 商品基础信息 --> <!-- 商品基础信息 -->
{{if !empty($module_data)}} {{if !empty($module_data)}}
<div class="goods"> <div class="am-nbfc">
<a href="{{$module_data.goods_url}}" target="_blank" title="{{$module_data.title}}"> <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" /> <img src="{{$module_data['images']}}" class="am-img-thumbnail am-radius am-margin-right-xs am-fl" width="60" height="60" />
</a> </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> <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'])}} {{if !empty($module_data['simple_desc'])}}
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<i class="am-icon-edit"></i> <i class="am-icon-edit"></i>
<span>编辑</span> <span>编辑</span>
</a> </a>
<button type="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}}"> <button type="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}}" data-key="ids">
<i class="am-icon-trash-o"></i> <i class="am-icon-trash-o"></i>
<span>删除</span> <span>删除</span>
</button> </button>
\ No newline at end of file
...@@ -50,8 +50,19 @@ ...@@ -50,8 +50,19 @@
<div class="am-g form-table-operate-top"> <div class="am-g form-table-operate-top">
{{block name="form_operate_top"}} {{block name="form_operate_top"}}
<!-- 公共操作 --> <!-- 公共操作 -->
<a href="{{:MyUrl('admin/goods/index')}}" class="am-btn am-btn-warning am-radius am-btn-sm am-icon-filter"> 重置</a> <!-- 是否开启删除操作 -->
<button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example am-icon-search" data-am-loading="{loadingText:' 搜索中...'}"> 搜索</button> {{if isset($form_table['base']['is_delete']) and $form_table['base']['is_delete'] eq 1}}
<button
type="button"
class="am-btn am-btn-danger am-radius am-btn-xs am-icon-trash-o form-table-operate-top-delete-submit"
data-url="{{if isset($form_table['base']['delete_url'])}}{{$form_table.base.delete_url}}{{/if}}"
data-form="{{if isset($form_table['base']['delete_form'])}}{{$form_table.base.delete_form}}{{/if}}"
data-key="{{if isset($form_table['base']['delete_key'])}}{{$form_table.base.delete_key}}{{/if}}"
data-confirm-title="{{if isset($form_table['base']['confirm_title'])}}{{$form_table.base.confirm_title}}{{/if}}"
data-confirm-msg="{{if isset($form_table['base']['confirm_msg'])}}{{$form_table.base.confirm_msg}}{{/if}}"
data-timeout="{{if isset($form_table['base']['timeout'])}}{{$form_table.base.timeout}}{{/if}}"
> 删除</button>
{{/if}}
<!-- 钩子 --> <!-- 钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
...@@ -73,13 +84,19 @@ ...@@ -73,13 +84,19 @@
} }
} }
{{/php}} {{/php}}
<!-- 是否开启搜索操作 公共搜索操作放在最后面 -->
{{if isset($form_table['base']['is_search']) and $form_table['base']['is_search'] eq 1}}
<a href="{{if isset($form_table['base']['search_url'])}}{{$form_table.base.search_url}}{{/if}}" class="am-btn am-btn-warning am-radius am-btn-sm am-icon-filter"> 重置</a>
<button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example am-icon-search" data-am-loading="{loadingText:' 搜索中...'}"> 搜索</button>
{{/if}}
{{/block}} {{/block}}
</div> </div>
<!-- top operate end --> <!-- top operate end -->
<!-- list start --> <!-- list start -->
<div class="am-scrollable-horizontal am-table-scrollable-horizontal am-margin-top-sm"> <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"> <table class="am-table am-table-striped am-table-hover am-table-bordered am-text-nowrap form-table-data-list">
<thead> <thead>
<tr> <tr>
{{foreach $form_table['form'] as $t}} {{foreach $form_table['form'] as $t}}
...@@ -243,7 +260,14 @@ ...@@ -243,7 +260,14 @@
{{else /}} {{else /}}
<!-- 非数组则直接取值 --> <!-- 非数组则直接取值 -->
{{if isset($data_list[$i][$t['view_key']])}} {{if isset($data_list[$i][$t['view_key']])}}
{{$data_list[$i][$t['view_key']]|raw}} <!-- 是否指定数据转换 -->
{{if !empty($t['view_data']) and is_array($t['view_data']) and isset($t['view_data'][$data_list[$i][$t['view_key']]])}}
{{$t['view_data'][$data_list[$i][$t['view_key']]]}}
<!-- 直接展示数据 -->
{{else /}}
{{$data_list[$i][$t['view_key']]|raw}}
{{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/case}} {{/case}}
...@@ -297,7 +321,7 @@ ...@@ -297,7 +321,7 @@
{{if isset($data_list[$i][$form_table['base']['key_field']])}} {{if isset($data_list[$i][$form_table['base']['key_field']])}}
<div class="form-table-operate-checkbox"> <div class="form-table-operate-checkbox">
<label class="am-checkbox am-secondary am-checkbox-inline"> <label class="am-checkbox am-secondary am-checkbox-inline">
<input type="checkbox" name="{{$t.view_key}}" value="{{$data_list[$i][$form_table['base']['key_field']]}}" {{if !empty($form_params) and isset($form_params[$t['view_key']]) and in_array($data_list[$i][$form_table['base']['key_field']], $form_params[$t['view_key']])}}checked{{/if}} data-am-ucheck /> <input type="checkbox" name="{{$t.view_key}}" value="{{$data_list[$i][$form_table['base']['key_field']]}}" {{if isset($t['is_checked']) and $t['is_checked'] eq 1}}checked{{/if}} data-am-ucheck />
</label> </label>
</div> </div>
{{/if}} {{/if}}
...@@ -306,7 +330,7 @@ ...@@ -306,7 +330,7 @@
{{if isset($data_list[$i][$form_table['base']['key_field']])}} {{if isset($data_list[$i][$form_table['base']['key_field']])}}
<div class="form-table-operate-radio"> <div class="form-table-operate-radio">
<label class="am-radio am-secondary am-radio-inline"> <label class="am-radio am-secondary am-radio-inline">
<input type="radio" name="{{$t.view_key}}" value="{{$data_list[$i][$form_table['base']['key_field']]}}" {{if !empty($form_params) and isset($form_params[$t['view_key']]) and $form_params[$t['view_key']] eq $data_list[$i][$form_table['base']['key_field']]}}checked{{/if}} data-am-ucheck /> <input type="radio" name="{{$t.view_key}}" value="{{$data_list[$i][$form_table['base']['key_field']]}}" {{if isset($t['is_checked']) and $t['is_checked'] eq 1}}checked{{/if}} data-am-ucheck />
</label> </label>
</div> </div>
{{/if}} {{/if}}
...@@ -363,6 +387,10 @@ ...@@ -363,6 +387,10 @@
{{/block}} {{/block}}
<!-- page end --> <!-- page end -->
<!-- extend start -->
{{block name="form_extend"}}{{/block}}
<!-- extend end -->
<!-- content inside top hook --> <!-- content inside top hook -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag"> <div class="plugins-tag">
......
...@@ -27,13 +27,9 @@ class Common extends Controller ...@@ -27,13 +27,9 @@ class Common extends Controller
// 用户信息 // 用户信息
protected $user; protected $user;
// 输入参数 post // 输入参数 post|get|request
protected $data_post; protected $data_post;
// 输入参数 get
protected $data_get; protected $data_get;
// 输入参数 request
protected $data_request; protected $data_request;
/** /**
...@@ -48,14 +44,14 @@ class Common extends Controller ...@@ -48,14 +44,14 @@ class Common extends Controller
{ {
parent::__construct(); parent::__construct();
// 系统运行开始
SystemService::SystemBegin();
// 输入参数 // 输入参数
$this->data_post = input('post.'); $this->data_post = input('post.');
$this->data_get = input('get.'); $this->data_get = input('get.');
$this->data_request = input(); $this->data_request = input();
// 系统运行开始
SystemService::SystemBegin();
// 系统初始化 // 系统初始化
$this->SystemInit(); $this->SystemInit();
......
...@@ -44,6 +44,9 @@ class Plugins extends Common ...@@ -44,6 +44,9 @@ class Plugins extends Common
*/ */
public function Index() public function Index()
{ {
// 参数
$params = $this->GetClassVars();
// 请求参数校验 // 请求参数校验
$p = [ $p = [
[ [
...@@ -69,12 +72,13 @@ class Plugins extends Common ...@@ -69,12 +72,13 @@ class Plugins extends Common
} }
// 应用名称/控制器/方法 // 应用名称/控制器/方法
$pluginsname = $this->data_request['pluginsname']; $pluginsname = $params['data_request']['pluginsname'];
$pluginscontrol = strtolower($this->data_request['pluginscontrol']); $pluginscontrol = strtolower($params['data_request']['pluginscontrol']);
$pluginsaction = strtolower($this->data_request['pluginsaction']); $pluginsaction = strtolower($params['data_request']['pluginsaction']);
unset($params['data_request']['pluginsname'], $params['data_request']['pluginscontrol'], $params['data_request']['pluginsaction']);
// 调用 // 调用
$ret = PluginsService::PluginsControlCall($pluginsname, $pluginscontrol, $pluginsaction, 'api', $this->data_request); $ret = PluginsService::PluginsControlCall($pluginsname, $pluginscontrol, $pluginsaction, 'api', $params);
if($ret['code'] == 0) if($ret['code'] == 0)
{ {
return $ret['data']; return $ret['data'];
...@@ -83,5 +87,27 @@ class Plugins extends Common ...@@ -83,5 +87,27 @@ class Plugins extends Common
// 调用失败 // 调用失败
return $ret; return $ret;
} }
/**
* 获取类属性数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-07
* @desc description
*/
public function GetClassVars()
{
$data = [];
$vers = get_class_vars(get_class());
foreach($vers as $k=>$v)
{
if(property_exists($this, $k))
{
$data[$k] = $this->$k;
}
}
return $data;
}
} }
?> ?>
\ No newline at end of file
...@@ -12,6 +12,7 @@ namespace app\index\controller; ...@@ -12,6 +12,7 @@ namespace app\index\controller;
use think\facade\Hook; use think\facade\Hook;
use think\Controller; use think\Controller;
use app\module\FormHandleModule;
use app\service\SystemService; use app\service\SystemService;
use app\service\GoodsService; use app\service\GoodsService;
use app\service\NavigationService; use app\service\NavigationService;
...@@ -44,6 +45,26 @@ class Common extends Controller ...@@ -44,6 +45,26 @@ class Common extends Controller
// 请求参数 // 请求参数
protected $params; protected $params;
// 当前操作名称
protected $module_name;
protected $controller_name;
protected $action_name;
// 输入参数 post|get|request
protected $data_post;
protected $data_get;
protected $data_request;
// 分页信息
protected $page;
protected $page_size;
// 动态表格
protected $form_table;
protected $form_where;
protected $form_params;
protected $form_error;
/** /**
* 构造方法 * 构造方法
* @author Devil * @author Devil
...@@ -56,6 +77,11 @@ class Common extends Controller ...@@ -56,6 +77,11 @@ class Common extends Controller
{ {
parent::__construct(); parent::__construct();
// 输入参数
$this->data_post = input('post.');
$this->data_get = input('get.');
$this->data_request = input();
// 系统初始化 // 系统初始化
$this->SystemInit(); $this->SystemInit();
...@@ -74,6 +100,9 @@ class Common extends Controller ...@@ -74,6 +100,9 @@ class Common extends Controller
// 视图初始化 // 视图初始化
$this->ViewInit(); $this->ViewInit();
// 动态表格初始化
$this->FormTableInit();
// 公共钩子初始化 // 公共钩子初始化
$this->CommonPluginsInit(); $this->CommonPluginsInit();
} }
...@@ -148,10 +177,7 @@ class Common extends Controller ...@@ -148,10 +177,7 @@ class Common extends Controller
* @desc description * @desc description
*/ */
private function SystemInit() private function SystemInit()
{ {
// 公共参数
$this->params = input();
// 配置信息初始化 // 配置信息初始化
ConfigService::ConfigInit(); ConfigService::ConfigInit();
...@@ -162,9 +188,9 @@ class Common extends Controller ...@@ -162,9 +188,9 @@ class Common extends Controller
} }
// 推荐人 // 推荐人
if(!empty($this->params['referrer'])) if(!empty($this->data_request['referrer']))
{ {
session('share_referrer_id', $this->params['referrer']); session('share_referrer_id', $this->data_request['referrer']);
} }
} }
...@@ -211,7 +237,7 @@ class Common extends Controller ...@@ -211,7 +237,7 @@ class Common extends Controller
public function ViewInit() public function ViewInit()
{ {
// 公共参数 // 公共参数
$this->assign('params', $this->params); $this->assign('params', $this->data_request);
// 价格符号 // 价格符号
$this->assign('price_symbol', config('shopxo.price_symbol')); $this->assign('price_symbol', config('shopxo.price_symbol'));
...@@ -319,6 +345,37 @@ class Common extends Controller ...@@ -319,6 +345,37 @@ class Common extends Controller
$this->assign('is_load_baidu_map_api', 0); $this->assign('is_load_baidu_map_api', 0);
} }
/**
* 动态表格初始化
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-02
* @desc description
*/
public function FormTableInit()
{
// 获取表格模型
$module = FormModulePath($this->data_request);
if(!empty($module))
{
// 调用表格处理
$res = (new FormHandleModule())->Run($module, $this->data_request);
if($res['code'] == 0)
{
$this->form_table = $res['data']['table'];
$this->form_where = $res['data']['where'];
$this->form_params = $res['data']['params'];
$this->assign('form_table', $this->form_table);
$this->assign('form_params', $this->form_params);
} else {
$this->form_error = $res['msg'];
$this->assign('form_error', $this->form_error);
}
}
}
/** /**
* [NavInit 导航初始化] * [NavInit 导航初始化]
* @author Devil * @author Devil
......
...@@ -44,7 +44,7 @@ class Plugins extends Common ...@@ -44,7 +44,7 @@ class Plugins extends Common
public function Index() public function Index()
{ {
// 参数 // 参数
$params = input(); $params = $this->GetClassVars();
// 请求参数校验 // 请求参数校验
$p = [ $p = [
...@@ -77,9 +77,10 @@ class Plugins extends Common ...@@ -77,9 +77,10 @@ class Plugins extends Common
} }
// 应用名称/控制器/方法 // 应用名称/控制器/方法
$pluginsname = $params['pluginsname']; $pluginsname = $params['data_request']['pluginsname'];
$pluginscontrol = strtolower($params['pluginscontrol']); $pluginscontrol = strtolower($params['data_request']['pluginscontrol']);
$pluginsaction = strtolower($params['pluginsaction']); $pluginsaction = strtolower($params['data_request']['pluginsaction']);
unset($params['data_request']['pluginsname'], $params['data_request']['pluginscontrol'], $params['data_request']['pluginsaction']);
// 视图初始化 // 视图初始化
$this->PluginsViewInit($pluginsname, $pluginscontrol, $pluginsaction); $this->PluginsViewInit($pluginsname, $pluginscontrol, $pluginsaction);
...@@ -104,6 +105,28 @@ class Plugins extends Common ...@@ -104,6 +105,28 @@ class Plugins extends Common
} }
} }
/**
* 获取类属性数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-07
* @desc description
*/
public function GetClassVars()
{
$data = [];
$vers = get_class_vars(get_class());
foreach($vers as $k=>$v)
{
if(property_exists($this, $k))
{
$data[$k] = $this->$k;
}
}
return $data;
}
/** /**
* 视图初始化 * 视图初始化
* @author Devil * @author Devil
......
...@@ -56,16 +56,16 @@ class Search extends Common ...@@ -56,16 +56,16 @@ class Search extends Common
$this->ParamsInit(); $this->ParamsInit();
// 品牌列表 // 品牌列表
$this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->params['category_id'], 'keywords'=>$this->params['wd']])); $this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->data_request['category_id'], 'keywords'=>$this->data_request['wd']]));
// 商品分类 // 商品分类
$this->assign('category_list', SearchService::GoodsCategoryList(['category_id'=>$this->params['category_id']])); $this->assign('category_list', SearchService::GoodsCategoryList(['category_id'=>$this->data_request['category_id']]));
// 筛选价格区间 // 筛选价格区间
$this->assign('screening_price_list', SearchService::ScreeningPriceList(['field'=>'id,name'])); $this->assign('screening_price_list', SearchService::ScreeningPriceList(['field'=>'id,name']));
// 参数 // 参数
$this->assign('params', $this->params); $this->assign('params', $this->data_request);
// seo // seo
$this->SetSeo(); $this->SetSeo();
...@@ -86,10 +86,10 @@ class Search extends Common ...@@ -86,10 +86,10 @@ class Search extends Common
*/ */
private function SetSeo() private function SetSeo()
{ {
$seo_title = $this->params['wd']; $seo_title = $this->data_request['wd'];
if(!empty($this->params['category_id'])) if(!empty($this->data_request['category_id']))
{ {
$category = GoodsService::GoodsCategoryRow(['id'=>$this->params['category_id'], 'field'=>'name,seo_title,seo_keywords,seo_desc']); $category = GoodsService::GoodsCategoryRow(['id'=>$this->data_request['category_id'], 'field'=>'name,seo_title,seo_keywords,seo_desc']);
if(!empty($category)) if(!empty($category))
{ {
$seo_title = empty($category['seo_title']) ? $category['name'] : $category['seo_title']; $seo_title = empty($category['seo_title']) ? $category['name'] : $category['seo_title'];
...@@ -118,23 +118,23 @@ class Search extends Common ...@@ -118,23 +118,23 @@ class Search extends Common
private function ParamsInit() private function ParamsInit()
{ {
// 品牌id // 品牌id
$this->params['brand_id'] = isset($this->params['brand_id']) ? intval($this->params['brand_id']) : 0; $this->data_request['brand_id'] = isset($this->data_request['brand_id']) ? intval($this->data_request['brand_id']) : 0;
// 分类id // 分类id
$this->params['category_id'] = isset($this->params['category_id']) ? intval($this->params['category_id']) : 0; $this->data_request['category_id'] = isset($this->data_request['category_id']) ? intval($this->data_request['category_id']) : 0;
// 筛选价格id // 筛选价格id
$this->params['screening_price_id'] = isset($this->params['screening_price_id']) ? intval($this->params['screening_price_id']) : 0; $this->data_request['screening_price_id'] = isset($this->data_request['screening_price_id']) ? intval($this->data_request['screening_price_id']) : 0;
// 搜索关键字 // 搜索关键字
$this->params['wd'] = empty($this->params['wd']) ? '' : (IS_AJAX ? trim($this->params['wd']) : AsciiToStr($this->params['wd'])); $this->data_request['wd'] = empty($this->data_request['wd']) ? '' : (IS_AJAX ? trim($this->data_request['wd']) : AsciiToStr($this->data_request['wd']));
// 排序方式 // 排序方式
$this->params['order_by_field'] = empty($this->params['order_by_field']) ? 'default' : $this->params['order_by_field']; $this->data_request['order_by_field'] = empty($this->data_request['order_by_field']) ? 'default' : $this->data_request['order_by_field'];
$this->params['order_by_type'] = empty($this->params['order_by_type']) ? 'desc' : $this->params['order_by_type']; $this->data_request['order_by_type'] = empty($this->data_request['order_by_type']) ? 'desc' : $this->data_request['order_by_type'];
// 用户信息 // 用户信息
$this->params['user_id'] = isset($this->user['id']) ? $this->user['id'] : 0; $this->data_request['user_id'] = isset($this->user['id']) ? $this->user['id'] : 0;
} }
/** /**
...@@ -157,11 +157,11 @@ class Search extends Common ...@@ -157,11 +157,11 @@ class Search extends Common
$this->ParamsInit(); $this->ParamsInit();
// 获取商品列表 // 获取商品列表
$this->params['keywords'] = $this->params['wd']; $this->data_request['keywords'] = $this->data_request['wd'];
$ret = SearchService::GoodsList($this->params); $ret = SearchService::GoodsList($this->data_request);
// 搜索记录 // 搜索记录
SearchService::SearchAdd($this->params); SearchService::SearchAdd($this->data_request);
// 无数据直接返回 // 无数据直接返回
if(empty($ret['data']['data']) || $ret['code'] != 0) if(empty($ret['data']['data']) || $ret['code'] != 0)
......
...@@ -1790,43 +1790,48 @@ class GoodsService ...@@ -1790,43 +1790,48 @@ class GoodsService
public static function GoodsDelete($params = []) public static function GoodsDelete($params = [])
{ {
// 参数是否有误 // 参数是否有误
if(empty($params['id'])) if(empty($params['ids']))
{ {
return DataReturn('商品id有误', -1); return DataReturn('商品id有误', -1);
} }
// 是否数组
if(!is_array($params['ids']))
{
$params['ids'] = explode(',', $params['ids']);
}
// 开启事务 // 开启事务
Db::startTrans(); Db::startTrans();
// 删除商品 // 删除商品
if(Db::name('Goods')->delete(intval($params['id']))) if(Db::name('Goods')->where(['id'=>$params['ids']])->delete())
{ {
// 商品规格 // 商品规格
if(Db::name('GoodsSpecType')->where(['goods_id'=>intval($params['id'])])->delete() === false) if(Db::name('GoodsSpecType')->where(['goods_id'=>$params['ids']])->delete() === false)
{ {
Db::rollback(); Db::rollback();
return DataReturn('规格类型删除失败', -100); return DataReturn('规格类型删除失败', -100);
} }
if(Db::name('GoodsSpecValue')->where(['goods_id'=>intval($params['id'])])->delete() === false) if(Db::name('GoodsSpecValue')->where(['goods_id'=>$params['ids']])->delete() === false)
{ {
Db::rollback(); Db::rollback();
return DataReturn('规格值删除失败', -100); return DataReturn('规格值删除失败', -100);
} }
if(Db::name('GoodsSpecBase')->where(['goods_id'=>intval($params['id'])])->delete() === false) if(Db::name('GoodsSpecBase')->where(['goods_id'=>$params['ids']])->delete() === false)
{ {
Db::rollback(); Db::rollback();
return DataReturn('规格基础删除失败', -100); return DataReturn('规格基础删除失败', -100);
} }
// 相册 // 相册
if(Db::name('GoodsPhoto')->where(['goods_id'=>intval($params['id'])])->delete() === false) if(Db::name('GoodsPhoto')->where(['goods_id'=>$params['ids']])->delete() === false)
{ {
Db::rollback(); Db::rollback();
return DataReturn('相册删除失败', -100); return DataReturn('相册删除失败', -100);
} }
// app内容 // app内容
if(Db::name('GoodsContentApp')->where(['goods_id'=>intval($params['id'])])->delete() === false) if(Db::name('GoodsContentApp')->where(['goods_id'=>$params['ids']])->delete() === false)
{ {
Db::rollback(); Db::rollback();
return DataReturn('相册删除失败', -100); return DataReturn('相册删除失败', -100);
......
...@@ -241,7 +241,7 @@ class PluginsService ...@@ -241,7 +241,7 @@ class PluginsService
// 调用方法 // 调用方法
$action = ucfirst($action); $action = ucfirst($action);
$obj = new $plugins(); $obj = new $plugins($params);
if(!method_exists($obj, $action)) if(!method_exists($obj, $action))
{ {
return DataReturn('应用方法未定义['.$action.']', -1); return DataReturn('应用方法未定义['.$action.']', -1);
......
此差异已折叠。
/**
* 列表
*/
.goods .goods-images {
width:60px;
height:60px;
float:left;
margin-right:5px;
}
.goods {
overflow: hidden;
}
/** /**
* 详情 * 详情
*/ */
......
...@@ -847,25 +847,32 @@ function FomatFloat(value, pos) ...@@ -847,25 +847,32 @@ function FomatFloat(value, pos)
*/ */
function DataDelete(e) function DataDelete(e)
{ {
// 参数获取
var id = e.attr('data-id'); var id = e.attr('data-id');
var key = e.attr('data-key') || 'id';
var url = e.attr('data-url'); var url = e.attr('data-url');
var view = e.attr('data-view') || 'delete'; var view = e.attr('data-view') || 'delete';
var value = e.attr('data-value') || null; var value = e.attr('data-value') || null;
var ext_delete_tag = e.attr('data-ext-delete-tag') || null; var ext_delete_tag = e.attr('data-ext-delete-tag') || null;
// 参数校验
if((id || null) == null || (url || null) == null) if((id || null) == null || (url || null) == null)
{ {
Prompt('参数配置有误'); Prompt('参数配置有误');
return false; return false;
} }
// 请求数据
var data = {};
data[key] = id;
// 请求删除数据 // 请求删除数据
$.ajax({ $.ajax({
url:url, url:url,
type:'POST', type:'POST',
dataType:"json", dataType:"json",
timeout:e.attr('data-timeout') || 30000, timeout:e.attr('data-timeout') || 30000,
data:{"id":id}, data:data,
success:function(result) success:function(result)
{ {
if(result.code == 0) if(result.code == 0)
...@@ -973,19 +980,25 @@ function ConfirmDataDelete(e) ...@@ -973,19 +980,25 @@ function ConfirmDataDelete(e)
*/ */
function AjaxRequest(e) function AjaxRequest(e)
{ {
// 参数
var id = e.attr('data-id'); var id = e.attr('data-id');
var key = e.attr('data-key') || 'id';
var field = e.attr('data-field') || ''; var field = e.attr('data-field') || '';
var value = e.attr('data-value') || ''; var value = e.attr('data-value') || '';
var url = e.attr('data-url'); var url = e.attr('data-url');
var view = e.attr('data-view') || ''; var view = e.attr('data-view') || '';
// 请求数据
var data = {"value": value, "field": field};
data[key] = id;
// ajax // ajax
$.ajax({ $.ajax({
url:url, url:url,
type:'POST', type:'POST',
dataType:"json", dataType:"json",
timeout:e.attr('data-timeout') || 30000, timeout:e.attr('data-timeout') || 30000,
data:{"id":id, "value": value, "field": field}, data:data,
success:function(result) success:function(result)
{ {
if(result.code == 0) if(result.code == 0)
...@@ -1652,6 +1665,103 @@ $(function() ...@@ -1652,6 +1665,103 @@ $(function()
$(this).attr('data-value', value == 1 ? 0 : 1); $(this).attr('data-value', value == 1 ? 0 : 1);
}); });
// 表格公共删除操作
$('.form-table-operate-top-delete-submit').on('click', function()
{
// 请求 url
var url = $(this).data('url') || null;
if(url == null)
{
Prompt('url参数有误');
return false;
}
// form name 名称
var form = $(this).data('form') || null;
if(form == null)
{
Prompt('form参数有误');
return false;
}
// 获取复选框选中的值
var values = [];
$(document).find('input[name="'+form+'"]').each(function(key, tmp)
{
if($(this).is(':checked'))
{
values.push(tmp.value);
}
});
// 获取单选框的值
if(values.length <= 0)
{
var val = $('input[name="'+form+'"]:checked').val();
if(val != undefined)
{
values.push(val);
}
}
// 是否有选择的数据
if(values.length <= 0)
{
Prompt('请先选中数据');
return false;
}
// 提交字段名称|超时时间|标题|描述
var key = $(this).data('key') || form;
var timeout = $(this).data('timeout') || 30000;
var title = $(this).data('confirm-title') || '温馨提示';
var msg = $(this).data('confirm-msg') || '删除后不可恢复、确认操作吗?';
// 再次确认
AMUI.dialog.confirm({
title: title,
content: msg,
onConfirm: function(result)
{
// 数组转对象
var data = {};
data[key] = {};
for(var i in values)
{
data[key][i] = values[i];
}
// ajax请求操作
$.ajax({
url: url,
type: 'POST',
dataType: "json",
timeout: timeout,
data: data,
success: function(result)
{
if(result.code == 0)
{
// 成功则删除数据列表
Prompt(result.msg, 'success');
for(var i in values)
{
$('#data-list-'+values[i]).remove();
}
} else {
Prompt(result.msg);
}
},
error: function(xhr, type)
{
Prompt('网络异常出错');
}
});
},
onCancel: function(){}
});
});
/** /**
* 页面加载 loading * 页面加载 loading
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册