提交 89579a91 编写于 作者: D devil

数据列表模块优化

上级 7ebf0d2c
<?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)}}
<select class="am-radius chosen-select" multiple name="category_id" data-placeholder="商品分类...">
{{foreach $module_data as $v}}
<option value="{{$v.id}}" {{if !empty($module_params['category_id']) and $v['id'] eq $module_params['category_id']}}selected{{/if}}>{{$v.name}}</option>
{{if !empty($v['items'])}}
{{foreach $v.items as $vs}}
<option style="padding-left: 15px;" value="{{$vs.id}}" {{if !empty($module_params['category_id']) and $vs['id'] eq $module_params['category_id']}}selected{{/if}}>{{$vs.name}}</option>
{{if !empty($vs['items'])}}
{{foreach $vs.items as $vss}}
<option style="padding-left: 30px;" value="{{$vss.id}}" {{if !empty($module_params['category_id']) and $vss['id'] eq $module_params['category_id']}}selected{{/if}}>{{$vss.name}}</option>
{{/foreach}}
{{/if}}
{{/foreach}}
{{/if}}
{{/foreach}}
</select>
{{/if}}
\ No newline at end of file
......@@ -22,7 +22,7 @@
<!-- right content start -->
<div class="content-right">
<div class="content">
<div class="content form-table-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">
......@@ -48,8 +48,13 @@
<!-- form end -->
<!-- top operate start -->
<div class="am-g am-margin-top-sm">
<div class="am-g am-margin-top-sm form-table-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="{spinner:'circle-o-notch', loadingText:'搜索中...'}"> 搜索</button>
<!-- 钩子 -->
{{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>
......@@ -89,10 +94,91 @@
{{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($t['label'])}}{{$t.label}}{{/if}}</th>
{{/foreach}}
{{/if}}
</tr>
{{if isset($form_table['base']) and isset($form_table['base']['is_search']) and $form_table['base']['is_search'] eq 1}}
<tr class="form-table-search">
{{foreach $form_table['form'] as $t}}
<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 !empty($t['search_config']) and !empty($t['search_config']['form_type']) and !empty($t['search_config']['form_name'])}}
{{switch $t.search_config.form_type}}
{{case input}}
<!-- 输入 -->
<input type="text" class="am-form-field am-radius" autocomplete="off" name="{{$t.search_config.form_name}}" placeholder="{{if empty($t['search_config']['placeholder'])}}请输入{{if !empty($t['label'])}}{{$t.label}}{{/if}}{{else /}}{{$t.search_config.placeholder}}{{/if}}" />
{{/case}}
{{case select}}
<!-- 选择 -->
<select name="{{$t.search_config.form_name}}" class="chosen-select am-text-left" data-placeholder="{{if empty($t['search_config']['placeholder'])}}请选择{{if !empty($t['label'])}}{{$t.label}}{{/if}}{{else /}}{{$t.search_config.placeholder}}{{/if}}" {{if isset($t['search_config']['is_multiple']) and $t['search_config']['is_multiple'] eq 1}}multiple{{/if}}>
{{if isset($t['search_config']['is_seat_select']) and $t['search_config']['is_seat_select'] eq 1 and (!isset($t['search_config']['is_multiple']) or $t['search_config']['is_multiple'] neq 1)}}
<option value="{{if isset($t['search_config']['seat_select_value'])}}{{$t.search_config.seat_select_value}}{{/if}}">
{{if empty($t['search_config']['seat_select_text'])}}{{if empty($t['search_config']['placeholder'])}}请选择{{if !empty($t['label'])}}{{$t.label}}{{/if}}{{else /}}{{$t.search_config.placeholder}}{{/if}}{{else /}}{{$t.search_config.seat_select_text}}{{/if}}
</option>
{{/if}}
{{if !empty($t['search_config']['data']) and is_array($t['search_config']['data'])}}
{{foreach $t['search_config']['data'] as $v}}
<option value="{{if empty($t['search_config']['data_key'])}}{{if isset($v['id'])}}{{$v.id}}{{/if}}{{else /}}{{if isset($v[$t['search_config']['data_key']])}}{{$v[$t['search_config']['data_key']]}}{{/if}}{{/if}}" >
{{if empty($t['search_config']['data_name'])}}
{{if isset($v['name'])}}
{{$v.name}}
{{/if}}
{{else /}}
{{if isset($v[$t['search_config']['data_name']])}}
{{$v[$t['search_config']['data_name']]}}
{{/if}}
{{/if}}
</option>
{{/foreach}}
{{/if}}
</select>
{{/case}}
{{case section}}
<!-- 区间 -->
<div class="form-table-search-section">
<input type="number" step="0.01" class="am-form-field am-radius am-inline-block" autocomplete="off" name="{{$t.search_config.form_name}}[]" placeholder="最小" />
<span>-</span>
<input type="number" step="0.01" class="am-form-field am-radius am-inline-block" autocomplete="off" name="{{$t.search_config.form_name}}[]" placeholder="最大" />
</div>
{{/case}}
{{case datetime}}
<div class="form-table-search-section form-table-search-time">
<input type="text" autocomplete="off" class="am-form-field am-input-sm am-radius am-inline-block Wdate" id="form-table-search-time-start-{{$t.search_config.form_name}}" name="{{$t.search_config.form_name}}[]" placeholder="开始" value="" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd H:mm:ss',maxDate:'#F{$dp.$D(\'form-table-search-time-end-{{$t.search_config.form_name}}\');}'})" autocomplete="off" />
<span>-</span>
<input type="text" autocomplete="off" class="am-form-field am-input-sm am-radius am-inline-block Wdate" id="form-table-search-time-end-{{$t.search_config.form_name}}" name="{{$t.search_config.form_name}}[]" placeholder="结束" value="" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd H:mm:ss',minDate:'#F{$dp.$D(\'form-table-search-time-start-{{$t.search_config.form_name}}\');}'})" autocomplete="off" />
</div>
{{/case}}
{{case date}}
<div class="form-table-search-section form-table-search-time">
<input type="text" autocomplete="off" class="am-form-field am-input-sm am-radius am-inline-block Wdate" id="form-table-search-time-start-{{$t.search_config.form_name}}" name="{{$t.search_config.form_name}}[]" placeholder="开始" value="" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'form-table-search-time-end-{{$t.search_config.form_name}}\',{d:-1});}'})" autocomplete="off" />
<span>-</span>
<input type="text" autocomplete="off" class="am-form-field am-input-sm am-radius am-inline-block Wdate" id="form-table-search-time-end-{{$t.search_config.form_name}}" name="{{$t.search_config.form_name}}[]" placeholder="结束" value="" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'form-table-search-time-start-{{$t.search_config.form_name}}\',{d:+1});}'})" autocomplete="off" />
</div>
{{/case}}
{{case time}}
<div class="form-table-search-section form-table-search-time">
<input type="text" autocomplete="off" class="am-form-field am-input-sm am-radius am-inline-block Wdate" id="form-table-search-time-start" name="{{$t.search_config.form_name}}[]" placeholder="开始" value="" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'HH:mm:ss'})" autocomplete="off" />
<span>-</span>
<input type="text" autocomplete="off" class="am-form-field am-input-sm am-radius am-inline-block Wdate" id="form-table-search-time-end" name="{{$t.search_config.form_name}}[]" placeholder="结束" value="" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'HH:mm:ss'})" autocomplete="off" />
</div>
{{/case}}
{{case module}}
<!-- 从模块加载自定义模块数据 -->
{{:ModuleInclude($t['search_config']['form_name'], isset($t['search_config']['data']) ? $t['search_config']['data'] : [], isset($params) ? $params : [])}}
{{/case}}
{{/switch}}
{{/if}}
</td>
{{/foreach}}
</tr>
{{/if}}
</thead>
<tbody>
{{if !empty($data_list) and !empty($form_table['form']) and !empty($form_table['base']) and !empty($form_table['base']['key_field'])}}
......@@ -141,7 +227,7 @@
{{/case}}
{{case module}}
<!-- 从模块加载自定义模块数据 -->
{{:ModuleInclude($t['view_key'], $data_list[$i])}}
{{:ModuleInclude($t['view_key'], $data_list[$i], isset($params) ? $params : [])}}
{{/case}}
{{case status}}
<!-- 数据状态操作按钮组件 -->
......
......@@ -11,6 +11,9 @@
namespace app\form;
use think\Db;
use app\service\GoodsService;
use app\service\RegionService;
use app\service\BrandService;
/**
* 商品表单
......@@ -38,6 +41,7 @@ class GoodsForm
'base' => [
'key_field' => 'id',
'status_field' => 'is_shelves',
'is_search' => 1,
],
// 表单配置
'form' => [
......@@ -51,22 +55,63 @@ class GoodsForm
'view_type' => 'module',
'view_key' => 'goods/module/info',
'grid_size' => 'lg',
'search_config' => [
'form_type' => 'input',
'form_name' => 'title|simple_desc|seo_title|seo_keywords|seo_keywords',
'placeholder' => '请输入名称/简述/SEO信息'
],
// 'search_config' => [
// // input, select, datetime, date, time, section
// 'form_type' => 'select',
// // 表单字段名称
// 'form_name' => 'category_id',
// // 提示信息
// 'placeholder' => '商品分类...',
// // 是否开启占位选择框
// 'is_seat_select' => 1,
// // 选择占位值(默认空)
// 'seat_select_value' => '',
// // 选择占位文本(默认 placeholder 值)
// 'seat_select_text' => '商品分类...',
// // 条件数据
// 'data' => [],
// // 数据 key 字段名称(默认取 id)
// 'data_key' => 'id',
// // 数据 name 字段名称(默认取 name)
// 'data_name' => 'name',
// // 数据默认选中值
// 'default' => '',
// ],
],
[
'label' => '销售价格(元)',
'view_type' => 'field',
'view_key' => 'price',
'search_config' => [
'form_type' => 'section',
'form_name' => 'min_price',
],
],
[
'label' => '原价(元)',
'view_type' => 'field',
'view_key' => 'original_price',
'search_config' => [
// 表单字段名称
'form_name' => 'min_original_price',
'form_type' => 'section',
],
],
[
'label' => '库存数量',
'view_type' => 'field',
'view_key' => ['inventory', 'inventory_unit'],
'view_key_join' => ' ',
'search_config' => [
'form_type' => 'section',
'form_name' => 'inventory',
],
],
[
'label' => '上下架',
......@@ -76,6 +121,14 @@ class GoodsForm
'post_url' => MyUrl('admin/goods/statusshelves'),
'is_form_su' => 1,
'align' => 'center',
'search_config' => [
'form_type' => 'select',
'form_name' => 'is_shelves',
'data' => lang('common_is_shelves_list'),
'data_key' => 'id',
'data_name' => 'name',
'is_multiple' => 1,
],
],
[
'label' => '首页推荐',
......@@ -84,16 +137,55 @@ class GoodsForm
'key_field' => 'id',
'post_url' => MyUrl('admin/goods/statushomerecommended'),
'align' => 'center',
'search_config' => [
'form_type' => 'select',
'form_name' => 'is_home_recommended',
'data' => lang('common_is_text_list'),
'data_key' => 'id',
'data_name' => 'name',
'is_multiple' => 1,
],
],
[
'label' => '商品型号',
'view_type' => 'field',
'view_key' => 'model',
'search_config' => [
'form_type' => 'input',
'form_name' => 'model',
],
],
[
'label' => '商品分类',
'view_type' => 'field',
'view_key' => 'category_text',
'search_config' => [
'form_type' => 'module',
'form_name' => 'lib/module/goods_category',
'data' => GoodsService::GoodsCategoryAll(),
],
],
[
'label' => '品牌',
'view_type' => 'field',
'view_key' => 'brand_name',
'search_config' => [
'form_type' => 'select',
'form_name' => 'brand_id',
'data' => BrandService::CategoryBrand(),
'data_key' => 'id',
'data_name' => 'name',
'is_seat_select' => 1,
],
],
[
'label' => '创建时间',
'view_type' => 'field',
'view_key' => 'add_time',
'search_config' => [
'form_type' => 'datetime',
'form_name' => 'add_time',
],
],
[
'label' => '操作',
......@@ -117,6 +209,49 @@ class GoodsForm
*/
public function Search($params = [])
{
return [
// 基础配置
'base' => [
'url' => MyUrl('admin/goods/index'),
'method' => 'POST',
'is_more' => 1,
],
// 大搜索框
'search' => [
'placeholder' => '标题/型号',
'submit_text' => '搜索一下',
'loading_text' => '搜索中哦...',
'form_name' => 'keywords',
],
// 更多条件
'more' => [
[
// 标题名称
'label' => '分类',
// 表单字段名称
'form_name' => 'category_id',
// select, input
'form_type' => 'select',
// 提示信息
'placeholder' => '商品分类...',
// 是否开启占位选择框
'is_seat_select' => 1,
// 选择占位值
'seat_select_value' => '',
// 数据
'data' => [],
// 数据 key 字段名称
'data_key' => 'id',
// 数据 name 字段名称
'data_name' => 'name',
// 数据默认选中值
'default' => '',
],
],
];
}
}
\ No newline at end of file
......@@ -189,8 +189,8 @@ return array(
// 是否上架/下架
'common_is_shelves_list' => array(
0 => array('id' => 0, 'name' => '下架'),
1 => array('id' => 1, 'name' => '上架', 'checked' => true),
0 => array('id' => 0, 'name' => '下架'),
1 => array('id' => 1, 'name' => '上架', 'checked' => true),
),
// 是否
......
......@@ -44,12 +44,14 @@ class ViewInclude extends Controller
* @date 2020-05-25
* @desc description
* @param [string] $template [模板地址]
* @param [mixed] $params [参数数据]
* @param [mixed] $data [请求数据]
* @param [mixed] $params [请求参数]
* @return [string] [模板内容]
*/
public function Run($template, $params = [])
public function Run($template, $data = [], $params = [])
{
$this->assign('module_data', $params);
$this->assign('module_data', $data);
$this->assign('module_params', $params);
return $this->fetch($template);
}
}
......
......@@ -426,7 +426,7 @@ button.colorpicker-submit img {
}
/**
* 表格样式
* 表格-基础样式
*/
.am-table-scrollable-horizontal {
border: 1px solid #ddd;
......@@ -445,6 +445,8 @@ button.colorpicker-submit img {
.am-table-scrollable-horizontal .am-table > tfoot > tr > td {
padding: 12px;
line-height: 20px;
min-width: 150px;
max-width: 150px;
}
.am-table-scrollable-horizontal .am-table .am-nowrap-initial {
white-space: initial;
......@@ -461,13 +463,13 @@ button.colorpicker-submit img {
min-width: 350px;
}
.am-table-scrollable-horizontal .am-table tr .am-grid-sm {
min-width: 200px;
min-width: 250px;
}
.am-table-scrollable-horizontal .am-table tr .am-grid-xs {
min-width: 150px;
min-width: 200px;
}
.am-table-scrollable-horizontal .am-table tr .am-operate-grid {
width: 100px;
min-width: 120px;
}
.am-table-scrollable-horizontal .am-table tr .am-grid-fixed-left,
.am-table-scrollable-horizontal .am-table tr .am-grid-fixed-right {
......@@ -478,7 +480,7 @@ button.colorpicker-submit img {
.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;
z-index: 1011;
position: sticky;
background: #fff;
}
......@@ -501,4 +503,44 @@ button.colorpicker-submit img {
-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);
}
/**
* 表格-相关样式
*/
.form-table-operate-top > .am-btn:not(:last-child) {
margin-right: 10px;
}
/**
* 表格-搜索条件
*/
.form-table-search {
background: #eee;
}
.form-table-search td {
padding: 8px !important;
}
.form-table-search-section input {
width: calc(50% - 8px);
}
.form-table-search-time > i {
position: absolute;
margin: 4px 0px 0px -15px;
}
/**
* 下拉选择器
*/
.chosen-container-multi .chosen-choices li.search-choice {
margin: 3px 3px 3px 0;
padding: 2px 13px 1px 2px;
}
.chosen-container-multi .chosen-choices li.search-field input[type="text"] {
margin: 0;
}
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
top: 2px;
right: 0px;
}
\ No newline at end of file
.Wdate{
background:#fff url(datePicker.gif) no-repeat right !important;
background:#fff url(datePicker.gif) no-repeat right 5px center !important;
padding-right: 25px;
}
.Wdate::-ms-clear{display:none;}
.WdateFmtErr{
font-weight:bold;
color:red;
font-weight: bold;
color: red;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册