动态表格支持自定义字段和顺序
parent
bfdc457533
commit
296ea2d4e9
|
|
@ -50,6 +50,8 @@ class Common extends Controller
|
|||
protected $form_table;
|
||||
protected $form_where;
|
||||
protected $form_params;
|
||||
protected $form_md5_key;
|
||||
protected $form_user_fields;
|
||||
protected $form_error;
|
||||
|
||||
/**
|
||||
|
|
@ -284,9 +286,13 @@ class Common extends Controller
|
|||
$this->form_table = $ret['data']['table'];
|
||||
$this->form_where = $ret['data']['where'];
|
||||
$this->form_params = $ret['data']['params'];
|
||||
$this->form_md5_key = $ret['data']['md5_key'];
|
||||
$this->form_user_fields = $ret['data']['user_fields'];
|
||||
|
||||
$this->assign('form_table', $this->form_table);
|
||||
$this->assign('form_params', $this->form_params);
|
||||
$this->assign('form_md5_key', $this->form_md5_key);
|
||||
$this->assign('form_user_fields', $this->form_user_fields);
|
||||
} else {
|
||||
$this->form_error = $ret['msg'];
|
||||
$this->assign('form_error', $this->form_error);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
<?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 app\service\FormTableService;
|
||||
|
||||
/**
|
||||
* 动态表单
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class FormTable 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段选择保存
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-08
|
||||
* @desc description
|
||||
*/
|
||||
public function FieldsSelectSave()
|
||||
{
|
||||
$params = $this->data_post;
|
||||
$params['user_id'] = $this->admin['id'];
|
||||
$params['user_type'] = 0;
|
||||
return FormTableService::FieldsSelectSave($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段选择重置
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-08
|
||||
* @desc description
|
||||
*/
|
||||
public function FieldsSelectReset()
|
||||
{
|
||||
$params = $this->data_post;
|
||||
$params['user_id'] = $this->admin['id'];
|
||||
$params['user_type'] = 0;
|
||||
return FormTableService::FieldsSelectReset($params);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -37,4 +37,42 @@
|
|||
{{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}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 字段选择 -->
|
||||
<div class="am-fr am-nbfc">
|
||||
<button type="button" class="am-btn am-btn-default am-radius am-btn-xs am-icon-cog" data-am-modal="{target: '#form-table-fields-popup'}"> 设置</button>
|
||||
<div class="am-popup popup-not-title" id="form-table-fields-popup">
|
||||
<div class="am-popup-inner">
|
||||
<span data-am-modal-close class="am-close am-close-alt am-icon-times"></span>
|
||||
<div class="am-popup-bd am-padding-0">
|
||||
<div class="form-table-fields-select-container">
|
||||
<div class="am-scrollable-vertical form-table-fields-list-container">
|
||||
{{if !empty($form_user_fields)}}
|
||||
<div class="am-alert am-margin-bottom-0">
|
||||
<p>可点击拖拽调整显示顺序</p>
|
||||
</div>
|
||||
<ul class="am-list am-list-static am-list-striped am-margin-bottom-0 form-table-fields-content-container">
|
||||
{{foreach $form_user_fields as $v}}
|
||||
<li>
|
||||
<label class="am-checkbox-inline">
|
||||
<input type="checkbox" name="form_field_checkbox_value" value="{{$v.label}}" data-am-ucheck {{if isset($v['checked']) and $v['checked'] eq 1}}checked{{/if}} />
|
||||
<span>{{$v.label}}</span>
|
||||
</label>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
{{else /}}
|
||||
{{include file="public/not_data" /}}
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="am-padding-sm am-nbfc form-table-fields-button-container">
|
||||
<button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs form-table-field-checkbox-submit" data-value="{{if array_sum(array_column($form_user_fields, 'checked')) gt 0}}1{{else /}}0{{/if}}" data-checked-text="反选" data-not-checked-text="全选">{{if array_sum(array_column($form_user_fields, 'checked')) gt 0}}反选{{else /}}全选{{/if}}</button>
|
||||
<button type="button" class="am-btn am-btn-warning am-btn-xs am-radius am-margin-left-sm submit-ajax" data-url="{{:MyUrl('admin/formtable/fieldsselectreset')}}" data-id="{{$form_md5_key}}" data-key="md5_key" data-view="reload" data-is-confirm="0">重置</button>
|
||||
<button type="button" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example am-fr form-table-field-confirm-submit" data-url="{{:MyUrl('admin/formtable/fieldsselectsave')}}" data-am-loading="{loadingText:'处理中...'}">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<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" data-md5-key="{{$form_md5_key}}">
|
||||
<table class="am-table am-table-striped am-table-hover am-table-bordered am-text-nowrap form-table-data-list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -23,35 +23,28 @@
|
|||
*/
|
||||
function MyInput($key = null, $default = null)
|
||||
{
|
||||
static $data = null;
|
||||
if($data === null)
|
||||
static $params = null;
|
||||
if($params === null)
|
||||
{
|
||||
// raw
|
||||
$raw_data = empty($HTTP_RAW_POST_DATA) ? [] : (!is_array($HTTP_RAW_POST_DATA) ? json_decode($HTTP_RAW_POST_DATA, true) : []);
|
||||
|
||||
// request
|
||||
$request_data = empty($_REQUEST) ? [] : $_REQUEST;
|
||||
|
||||
// input
|
||||
$input_data = file_get_contents("php://input");
|
||||
$input_data = empty($input_data) ? [] : (!is_array($input_data) ? json_decode($input_data, true) : []);
|
||||
|
||||
// 数据合并
|
||||
$data = array_merge($raw_data, $request_data, $input_data);
|
||||
$params = input();
|
||||
if(empty($params))
|
||||
{
|
||||
$params = file_get_contents("php://input");
|
||||
}
|
||||
}
|
||||
|
||||
// 是否指定key
|
||||
if(!empty($key))
|
||||
if(!empty($key) && is_array($params))
|
||||
{
|
||||
if(array_key_exists($key, $data))
|
||||
if(array_key_exists($key, $params))
|
||||
{
|
||||
return is_array($data[$key]) ? $data[$key] : htmlspecialchars(trim($data[$key]));
|
||||
return is_array($params[$key]) ? $params[$key] : htmlspecialchars(trim($params[$key]));
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
// 未指定key则返回所有数据
|
||||
return $data;
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ class Common extends Controller
|
|||
protected $form_table;
|
||||
protected $form_where;
|
||||
protected $form_params;
|
||||
protected $form_md5_key;
|
||||
protected $form_user_fields;
|
||||
protected $form_error;
|
||||
|
||||
/**
|
||||
|
|
@ -429,9 +431,13 @@ class Common extends Controller
|
|||
$this->form_table = $ret['data']['table'];
|
||||
$this->form_where = $ret['data']['where'];
|
||||
$this->form_params = $ret['data']['params'];
|
||||
$this->form_md5_key = $ret['data']['md5_key'];
|
||||
$this->form_user_fields = $ret['data']['user_fields'];
|
||||
|
||||
$this->assign('form_table', $this->form_table);
|
||||
$this->assign('form_params', $this->form_params);
|
||||
$this->assign('form_md5_key', $this->form_md5_key);
|
||||
$this->assign('form_user_fields', $this->form_user_fields);
|
||||
} else {
|
||||
$this->form_error = $ret['msg'];
|
||||
$this->assign('form_error', $this->form_error);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
<?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\index\controller;
|
||||
|
||||
use app\service\FormTableService;
|
||||
|
||||
/**
|
||||
* 动态表单
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class FormTable 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段选择保存
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-08
|
||||
* @desc description
|
||||
*/
|
||||
public function FieldsSelectSave()
|
||||
{
|
||||
$params = $this->data_post;
|
||||
$params['user_id'] = $this->user['id'];
|
||||
$params['user_type'] = 1;
|
||||
return FormTableService::FieldsSelectSave($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段选择重置
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-08
|
||||
* @desc description
|
||||
*/
|
||||
public function FieldsSelectReset()
|
||||
{
|
||||
$params = $this->data_post;
|
||||
$params['user_id'] = $this->user['id'];
|
||||
$params['user_type'] = 1;
|
||||
return FormTableService::FieldsSelectReset($params);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -46,6 +46,9 @@
|
|||
<!-- 复制插件 -->
|
||||
<script type='text/javascript' src="{{$public_host}}static/common/lib/clipboard/clipboard.min.js?v={{:MyC('home_static_cache_version')}}"></script>
|
||||
|
||||
<!-- 元素拖拽排序插件 -->
|
||||
<script type='text/javascript' src="{{$public_host}}static/common/lib/dragsort/jquery.dragsort-0.5.2.min.js?v={{:MyC('home_static_cache_version')}}"></script>
|
||||
|
||||
<!-- ueditor 编辑器 -->
|
||||
<script type='text/javascript' src="{{$public_host}}static/common/lib/ueditor/ueditor.config.js?v={{:MyC('home_static_cache_version')}}"></script>
|
||||
<script type='text/javascript' src="{{$public_host}}static/common/lib/ueditor/ueditor.all.js?v={{:MyC('home_static_cache_version')}}"></script>
|
||||
|
|
|
|||
|
|
@ -37,4 +37,44 @@
|
|||
{{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}}
|
||||
|
||||
<!-- 字段选择 -->
|
||||
{{if !empty($user)}}
|
||||
<div class="am-fr am-nbfc">
|
||||
<button type="button" class="am-btn am-btn-default am-radius am-btn-xs am-icon-cog" data-am-modal="{target: '#form-table-fields-popup'}"> 设置</button>
|
||||
<div class="am-popup popup-not-title" id="form-table-fields-popup">
|
||||
<div class="am-popup-inner">
|
||||
<span data-am-modal-close class="am-close am-close-alt am-icon-times"></span>
|
||||
<div class="am-popup-bd am-padding-0">
|
||||
<div class="form-table-fields-select-container">
|
||||
<div class="am-scrollable-vertical form-table-fields-list-container">
|
||||
{{if !empty($form_user_fields)}}
|
||||
<div class="am-alert am-margin-bottom-0">
|
||||
<p>可点击拖拽调整显示顺序</p>
|
||||
</div>
|
||||
<ul class="am-list am-list-static am-list-striped am-margin-bottom-0 form-table-fields-content-container">
|
||||
{{foreach $form_user_fields as $v}}
|
||||
<li>
|
||||
<label class="am-checkbox-inline">
|
||||
<input type="checkbox" name="form_field_checkbox_value" value="{{$v.label}}" data-am-ucheck {{if isset($v['checked']) and $v['checked'] eq 1}}checked{{/if}} />
|
||||
<span>{{$v.label}}</span>
|
||||
</label>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
{{else /}}
|
||||
{{include file="public/not_data" /}}
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="am-padding-sm am-nbfc form-table-fields-button-container">
|
||||
<button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs form-table-field-checkbox-submit" data-value="{{if array_sum(array_column($form_user_fields, 'checked')) gt 0}}1{{else /}}0{{/if}}" data-checked-text="反选" data-not-checked-text="全选">{{if array_sum(array_column($form_user_fields, 'checked')) gt 0}}反选{{else /}}全选{{/if}}</button>
|
||||
<button type="button" class="am-btn am-btn-warning am-btn-xs am-radius am-margin-left-sm submit-ajax" data-url="{{:MyUrl('index/formtable/fieldsselectreset')}}" data-id="{{$form_md5_key}}" data-key="md5_key" data-view="reload" data-is-confirm="0">重置</button>
|
||||
<button type="button" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example am-fr form-table-field-confirm-submit" data-url="{{:MyUrl('index/formtable/fieldsselectsave')}}" data-am-loading="{loadingText:'处理中...'}">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<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" data-md5-key="{{$form_md5_key}}">
|
||||
<table class="am-table am-table-striped am-table-hover am-table-bordered am-text-nowrap form-table-data-list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ namespace app\module;
|
|||
|
||||
use think\Controller;
|
||||
use think\facade\Hook;
|
||||
use app\service\FormTableService;
|
||||
|
||||
/**
|
||||
* 动态表格处理
|
||||
|
|
@ -31,8 +32,12 @@ class FormHandleModule
|
|||
public $out_params;
|
||||
// 条件参数
|
||||
public $where_params;
|
||||
// md5key
|
||||
public $md5_key;
|
||||
// 搜索条件
|
||||
public $where;
|
||||
// 用户选择字段字段
|
||||
public $user_fields;
|
||||
|
||||
/**
|
||||
* 运行入口
|
||||
|
|
@ -101,6 +106,9 @@ class FormHandleModule
|
|||
]);
|
||||
}
|
||||
|
||||
// md5key
|
||||
$this->FromMd5Key($module, $action);
|
||||
|
||||
// 基础条件
|
||||
$this->BaseWhereHandle();
|
||||
|
||||
|
|
@ -110,15 +118,99 @@ class FormHandleModule
|
|||
// 基础数据结尾处理
|
||||
$this->FormBaseLastHandle();
|
||||
|
||||
// 用户字段选择处理
|
||||
$this->FormFieldsUserSelect();
|
||||
|
||||
// 数据返回
|
||||
$data = [
|
||||
'table' => $this->form_data,
|
||||
'where' => $this->where,
|
||||
'params' => $this->where_params,
|
||||
'table' => $this->form_data,
|
||||
'where' => $this->where,
|
||||
'params' => $this->where_params,
|
||||
'md5_key' => $this->md5_key,
|
||||
'user_fields' => $this->user_fields,
|
||||
];
|
||||
return DataReturn('success', 0, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段用户选择处理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-09
|
||||
* @desc description
|
||||
*/
|
||||
public function FormFieldsUserSelect()
|
||||
{
|
||||
// 当前用户选择的字段
|
||||
$ret = FormTableService::FieldsSelectData(['md5_key'=>$this->md5_key]);
|
||||
if(empty($ret['data']))
|
||||
{
|
||||
// 未设置则读取所有带label的字段、默认显示
|
||||
$this->user_fields = array_filter(array_map(function($value)
|
||||
{
|
||||
if(!empty($value['label']) && $value['view_type'] != 'operate')
|
||||
{
|
||||
return ['label'=>$value['label'], 'checked'=>1];
|
||||
}
|
||||
}, $this->form_data['form']));
|
||||
} else {
|
||||
$this->user_fields = $ret['data'];
|
||||
}
|
||||
|
||||
// 如用户已选择字段则排除数据
|
||||
if(!empty($this->user_fields))
|
||||
{
|
||||
$data = [];
|
||||
// 无标题元素放在前面
|
||||
foreach($this->form_data['form'] as $v)
|
||||
{
|
||||
if(empty($v['label']))
|
||||
{
|
||||
$data[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
// 根据用户选择顺序追加数据
|
||||
$temp_form = array_column($this->form_data['form'], null, 'label');
|
||||
foreach($this->user_fields as $v)
|
||||
{
|
||||
if(array_key_exists($v['label'], $temp_form))
|
||||
{
|
||||
$temp = $temp_form[$v['label']];
|
||||
$temp['is_list'] = $v['checked'];
|
||||
$data[] = $temp;
|
||||
}
|
||||
}
|
||||
|
||||
// 操作元素放在最后面
|
||||
foreach($this->form_data['form'] as $v)
|
||||
{
|
||||
if(isset($v['view_type']) && $v['view_type'] == 'operate')
|
||||
{
|
||||
$data[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$this->form_data['form'] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单md5key值
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-08
|
||||
* @desc description
|
||||
* @param [string] $module [模块位置]
|
||||
* @param [string] $action [模块方法(默认 Run 方法,可自动匹配控制器方法名)]
|
||||
*/
|
||||
public function FromMd5Key($module, $action)
|
||||
{
|
||||
$this->md5_key = md5($module.'\\'.$action);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格数据处理
|
||||
* @author Devil
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class BrandService
|
|||
$m = isset($params['m']) ? intval($params['m']) : 0;
|
||||
$n = isset($params['n']) ? intval($params['n']) : 10;
|
||||
|
||||
// 获取品牌列表
|
||||
// 获取列表
|
||||
$data = Db::name('Brand')->where($where)->order($order_by)->limit($m, $n)->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,177 @@
|
|||
<?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\service;
|
||||
|
||||
use think\Db;
|
||||
use app\service\UserService;
|
||||
|
||||
/**
|
||||
* 动态表格服务层
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class FormTableService
|
||||
{
|
||||
/**
|
||||
* 用户字段选择保存
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-08
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function FieldsSelectSave($params = [])
|
||||
{
|
||||
// 参数校验
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user_id',
|
||||
'error_msg' => '用户id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'in',
|
||||
'key_name' => 'user_type',
|
||||
'checked_data' => [0,1],
|
||||
'error_msg' => '用户类型有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'md5_key',
|
||||
'error_msg' => '数据key有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'fields',
|
||||
'error_msg' => '请选择字段',
|
||||
],
|
||||
];
|
||||
$ret = ParamsChecked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 数据
|
||||
$data = [
|
||||
'user_id' => intval($params['user_id']),
|
||||
'user_type' => intval($params['user_type']),
|
||||
'md5_key' => $params['md5_key'],
|
||||
'fields' => empty($params['fields']) ? '' : (is_array($params['fields']) ? json_encode($params['fields'], JSON_UNESCAPED_UNICODE) : $params['fields']),
|
||||
'add_time' => time(),
|
||||
'upd_time' => time(),
|
||||
];
|
||||
if(Db::name('FormTableUserFields')->insertGetId($data) <= 0)
|
||||
{
|
||||
return DataReturn('操作失败', -100);
|
||||
}
|
||||
return DataReturn('操作成功', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户字段选择重置
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-08
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function FieldsSelectReset($params = [])
|
||||
{
|
||||
// 参数校验
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user_id',
|
||||
'error_msg' => '用户id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'in',
|
||||
'key_name' => 'user_type',
|
||||
'checked_data' => [0,1],
|
||||
'error_msg' => '用户类型有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'md5_key',
|
||||
'error_msg' => '数据key有误',
|
||||
],
|
||||
];
|
||||
$ret = ParamsChecked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 数据删除
|
||||
$where = [
|
||||
'user_id' => intval($params['user_id']),
|
||||
'user_type' => intval($params['user_type']),
|
||||
'md5_key' => $params['md5_key'],
|
||||
];
|
||||
if(Db::name('FormTableUserFields')->where($where)->delete() === false)
|
||||
{
|
||||
return DataReturn('操作失败', -100);
|
||||
}
|
||||
return DataReturn('操作成功', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户选择的字段数据
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-08
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function FieldsSelectData($params = [])
|
||||
{
|
||||
// 模块
|
||||
$module_name = strtolower(request()->module());
|
||||
|
||||
// 当前用户
|
||||
if($module_name == 'admin')
|
||||
{
|
||||
$admin = session('admin');
|
||||
$user_id = empty($admin['id']) ? 0 : $admin['id'];
|
||||
$user_type = 0;
|
||||
} else {
|
||||
$user = UserService::LoginUserInfo();
|
||||
$user_id = empty($user['id']) ? 0 : $user['id'];
|
||||
$user_type = 1;
|
||||
}
|
||||
if(empty($user_id))
|
||||
{
|
||||
return DataReturn('用户信息有误', -1);
|
||||
}
|
||||
if(empty($params['md5_key']))
|
||||
{
|
||||
return DataReturn('数据key有误', -1);
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
$where = [
|
||||
'user_id' => $user_id,
|
||||
'user_type' => $user_type,
|
||||
'md5_key' => $params['md5_key'],
|
||||
];
|
||||
// 获取数据
|
||||
$data = Db::name('FormTableUserFields')->where($where)->order('id desc')->find();
|
||||
$data = empty($data['fields']) ? [] : json_decode($data['fields'], true);
|
||||
return DataReturn('处理成功', 0, $data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -151,6 +151,7 @@ return array (
|
|||
array (
|
||||
0 => 'app\\plugins\\answers\\Hook',
|
||||
1 => 'app\\plugins\\blog\\Hook',
|
||||
2 => 'app\\plugins\\speedplaceorder\\Hook',
|
||||
),
|
||||
);
|
||||
?>
|
||||
|
|
@ -8,11 +8,13 @@
|
|||
4. 新增附件、css/js静态可配置CDN域名
|
||||
5. 网站首页可后台控制配置
|
||||
6. 新增SESSION和数据缓存配置Redis(独立配置)
|
||||
7. 新增支付接口异步推送日志记录
|
||||
|
||||
web端
|
||||
1. 后台菜单支持自定义url地址、并支持钩子自动添加
|
||||
2. 后台区块数据统计新增当月、上月维度
|
||||
3. 新增插件路由短地址规则
|
||||
4. 动态表格列表支持自定义显示字段和拖拽排序
|
||||
|
||||
小程序
|
||||
1. QQ小程序支持微信支付
|
||||
|
|
@ -22,6 +24,7 @@ web端
|
|||
插件
|
||||
1. 汇率插件支持货币自由切换
|
||||
2. 新增IEPay新西兰货币支付(支付宝+微信)
|
||||
3. 新增博客插件、写文章增加商城的搜索引擎收录、关联推荐商品
|
||||
|
||||
|
||||
+=========================================================+
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -286,7 +286,10 @@ class Behavior
|
|||
*/
|
||||
public function GetUserCookie()
|
||||
{
|
||||
if(!empty($_COOKIE['behavior_user_cookie'])) return $_COOKIE['behavior_user_cookie'];
|
||||
if(!empty($_COOKIE['behavior_user_cookie']))
|
||||
{
|
||||
return $_COOKIE['behavior_user_cookie'];
|
||||
}
|
||||
|
||||
$user_cookie = $this->GetUserNumberRand();
|
||||
setcookie('behavior_user_cookie', $user_cookie);
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class Weixin
|
|||
$client_type = ApplicationClientType();
|
||||
|
||||
// 微信中打开
|
||||
if($client_type == 'h5' && IsWeixinEnv())
|
||||
if($client_type == 'h5' && IsWeixinEnv() && (empty($params['user']) || empty($params['user']['weixin_web_openid'])))
|
||||
{
|
||||
exit(header('location:'.PluginsHomeUrl('weixinwebauthorization', 'pay', 'index', input())));
|
||||
}
|
||||
|
|
@ -436,7 +436,7 @@ class Weixin
|
|||
// 微信中打开
|
||||
if($client_type == 'h5' && IsWeixinEnv())
|
||||
{
|
||||
$type_all['pc'] = $type_all['weixin'];
|
||||
$type_all['h5'] = $type_all['weixin'];
|
||||
}
|
||||
|
||||
return isset($type_all[$client_type]) ? $type_all[$client_type] : '';
|
||||
|
|
|
|||
|
|
@ -637,6 +637,31 @@ button.colorpicker-submit img {
|
|||
margin-top: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格-字段选择
|
||||
*/
|
||||
.form-table-fields-select-container {
|
||||
height: 100%;
|
||||
}
|
||||
.form-table-fields-list-container {
|
||||
height: calc(100% - 50px);
|
||||
}
|
||||
.form-table-fields-content-container li {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
.form-table-fields-content-container li:first-child {
|
||||
border-top: 0;
|
||||
}
|
||||
.form-table-fields-button-container {
|
||||
border-top: 1px solid #dedede;
|
||||
height: 50px;
|
||||
}
|
||||
.form-table-fields-button-container .form-table-field-confirm-submit {
|
||||
width: calc(100% - 130px);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共联动地区组件样式
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1638,13 +1638,14 @@ function FormTableContainerInit()
|
|||
* @version 1.0.0
|
||||
* @date 2020-07-26
|
||||
* @desc description
|
||||
* @param {[string]} form [表单名称]
|
||||
* @param {[string]} form [表单名称]
|
||||
* @param {[string]} tag [表单父级标签class或id]
|
||||
*/
|
||||
function FromTableCheckedValues(form)
|
||||
function FromTableCheckedValues(form, tag)
|
||||
{
|
||||
// 获取复选框选中的值
|
||||
var values = [];
|
||||
$('.am-table-scrollable-horizontal').find('input[name="'+form+'"]').each(function(key, tmp)
|
||||
$(tag).find('input[name="'+form+'"]').each(function(key, tmp)
|
||||
{
|
||||
if($(this).is(':checked'))
|
||||
{
|
||||
|
|
@ -1655,7 +1656,7 @@ function FromTableCheckedValues(form)
|
|||
// 获取单选选中的值
|
||||
if(values.length <= 0)
|
||||
{
|
||||
var val = $('.am-table-scrollable-horizontal input[name="'+form+'"]:checked').val();
|
||||
var val = $(tag).find('input[name="'+form+'"]:checked').val();
|
||||
if(val != undefined)
|
||||
{
|
||||
values.push(val);
|
||||
|
|
@ -1686,6 +1687,83 @@ $(function()
|
|||
// 表格初始化
|
||||
FormTableContainerInit();
|
||||
|
||||
// 表格字段拖拽排序
|
||||
if($('ul.form-table-fields-content-container').length > 0)
|
||||
{
|
||||
$('ul.form-table-fields-content-container').dragsort({ dragSelector: 'li', placeHolderTemplate: '<li class="drag-sort-dotted am-margin-left-sm"></li>'});
|
||||
}
|
||||
|
||||
// 表格字段选择确认
|
||||
$('.form-table-field-confirm-submit').on('click', function()
|
||||
{
|
||||
// 获取复选框选中的值
|
||||
var fields = [];
|
||||
$('.form-table-fields-list-container').find('input[name="form_field_checkbox_value"]').each(function(key, tmp)
|
||||
{
|
||||
fields.push({
|
||||
"label": tmp.value,
|
||||
"checked": $(this).is(':checked') ? 1 : 0
|
||||
});
|
||||
});
|
||||
|
||||
// 是否有选择的数据
|
||||
if(fields.length <= 0)
|
||||
{
|
||||
Prompt('请先选择数据');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 表单唯一md5key
|
||||
var md5_key = $('.am-table-scrollable-horizontal').data('md5-key') || '';
|
||||
|
||||
// ajax请求操作
|
||||
var $button = $(this);
|
||||
$button.button('loading');
|
||||
$.ajax({
|
||||
url: $button.data('url'),
|
||||
type: 'POST',
|
||||
dataType: "json",
|
||||
data: {"fields": fields, "md5_key": md5_key},
|
||||
success: function(result)
|
||||
{
|
||||
if(result.code == 0)
|
||||
{
|
||||
Prompt(result.msg, 'success');
|
||||
setTimeout(function()
|
||||
{
|
||||
window.location.reload();
|
||||
}, 1500);
|
||||
|
||||
} else {
|
||||
$button.button('reset');
|
||||
Prompt(result.msg);
|
||||
}
|
||||
},
|
||||
error: function(xhr, type)
|
||||
{
|
||||
$button.button('reset');
|
||||
Prompt('网络异常出错');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 表格字段复选框操作 全选/反选
|
||||
$('.form-table-field-checkbox-submit').on('click', function()
|
||||
{
|
||||
var value = parseInt($(this).attr('data-value')) || 0;
|
||||
if(value == 1)
|
||||
{
|
||||
var not_checked_text = $(this).data('not-checked-text') || '全选';
|
||||
$(this).text(not_checked_text);
|
||||
$('.form-table-fields-list-container ul li').find('input[type="checkbox"]').uCheck('uncheck');
|
||||
} else {
|
||||
var checked_text = $(this).data('checked-text') || '反选';
|
||||
$(this).text(checked_text);
|
||||
$('.form-table-fields-list-container ul li').find('input[type="checkbox"]').uCheck('check');
|
||||
}
|
||||
$(this).attr('data-value', value == 1 ? 0 : 1);
|
||||
});
|
||||
|
||||
// 表格复选框操作 全选/反选
|
||||
$('.form-table-operate-checkbox-submit').on('click', function()
|
||||
{
|
||||
|
|
@ -1723,7 +1801,7 @@ $(function()
|
|||
}
|
||||
|
||||
// 是否有选择的数据
|
||||
var values = FromTableCheckedValues(form);
|
||||
var values = FromTableCheckedValues(form, '.am-table-scrollable-horizontal');
|
||||
if(values.length <= 0)
|
||||
{
|
||||
Prompt('请先选中数据');
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ $(function()
|
|||
$('.batch-pay-submit').on('click', function()
|
||||
{
|
||||
// 是否有选择的数据
|
||||
var values = FromTableCheckedValues('order_form_checkbox_value');
|
||||
var values = FromTableCheckedValues('order_form_checkbox_value', '.am-table-scrollable-horizontal');
|
||||
if(values.length <= 0)
|
||||
{
|
||||
Prompt('请先选中数据');
|
||||
|
|
|
|||
Loading…
Reference in New Issue