Commit 775542e7 by 杨树贤

记住设置列

parent 89ad92a1
......@@ -7,6 +7,7 @@ use App\Http\Services\AdminUserService;
use App\Http\Services\CompanyService;
use App\Http\Services\StandardBrandService;
use App\Model\BrandModel;
use App\Model\RedisModel;
use App\Model\StandardBrandModel;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request;
......@@ -120,4 +121,33 @@ class CommonApiController extends Controller
$this->response(0, 'ok', $result);
}
//保存列表列显示设置
public function SaveColSettings(Request $request)
{
$userId = $request->input('user_id', 0);
$pageKey = $request->input('page_key', '');
$settings = $request->input('settings', '');
if (empty($userId) || empty($pageKey) || empty($settings)) {
$this->response(-1, '参数错误');
}
$redis = new RedisModel();
$hashKey = 'col_settings:' . $pageKey;
$redis->hset($hashKey, $userId, $settings);
$this->response(0, 'ok');
}
//获取列表列显示设置
public function GetColSettings(Request $request)
{
$userId = $request->input('user_id', 0);
$pageKey = $request->input('page_key', '');
if (empty($userId) || empty($pageKey)) {
$this->response(-1, '参数错误');
}
$redis = new RedisModel();
$hashKey = 'col_settings:' . $pageKey;
$settings = $redis->hget($hashKey, $userId);
$this->response(0, 'ok', $settings ? json_decode($settings, true) : new \stdClass());
}
}
......@@ -2,9 +2,9 @@
namespace App\Http\Controllers;
use function foo\func;
use App\Model\LogModel;
use App\Model\NationModel;
use App\Model\RedisModel;
use Illuminate\Http\Request;
use App\Model\IntracodeModel;
use App\Http\Services\LogService;
......@@ -119,6 +119,12 @@ class SupplierController extends Controller
//获取创建人部门树
$this->data['createUserDepartmentList'] = (new DepartmentService())->getCreateUserDepartmentListForXmSelect();
//获取列显示设置
$redis = new RedisModel();
$hashKey = 'col_settings:supplier_list';
$colSettings = $redis->hget($hashKey, $request->user->userId);
$this->data['colSettings'] = $colSettings ? $colSettings : '{}';
return $this->view('供应商列表');
}
......
......@@ -84,6 +84,8 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/external/checkSupplierApply', 'ExternalApiController@checkSupplierApply');
Route::match(['get', 'post'], '/api/external/applySupplier', 'ExternalApiController@applySupplier');
Route::match(['get', 'post'], '/api/external/checkSupplierAccountExist', 'ExternalApiController@checkSupplierAccountExist');
Route::match(['get', 'post'], '/api/external/SaveColSettings', 'CommonApiController@SaveColSettings');
Route::match(['get', 'post'], '/api/external/GetColSettings', 'CommonApiController@GetColSettings');
});
//同步相关的接口
......
......@@ -17,6 +17,8 @@ return [
'BatchUpdateSkuStatus',
'GetAuditFlow',
'ViewAccountLog',
'SaveColSettings',
'GetColSettings',
'TempTemp'
]//不用验证权限的方法
],
......
......@@ -360,17 +360,17 @@
cols.push(
);
// 列显示设置缓存
let colSettingsKey = 'supplier_list_col_settings_{{request()->user->userId}}';
// 列显示设置 - 从后端Redis hash渲染
let colSettingsData = {!! $colSettings !!};
let colSettingsUserId = '{{request()->user->userId}}';
let colSettingsPageKey = 'supplier_list';
function applyColSettings() {
let settings = localStorage.getItem(colSettingsKey);
if (settings) {
settings = JSON.parse(settings);
if (colSettingsData && Object.keys(colSettingsData).length > 0) {
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && settings[field] !== undefined) {
cols[i].hide = !settings[field];
if (field && colSettingsData[field] !== undefined) {
cols[i].hide = !colSettingsData[field];
}
}
}
......@@ -467,7 +467,12 @@
//列设置
$("#col_setting").click(function () {
let html = '<div style="padding: 15px; max-height: 700px; overflow-y: auto;">';
let html = '<div style="padding: 15px;">';
html += '<div style="margin-bottom: 10px;">';
html += '<button type="button" class="layui-btn layui-btn-xs layui-btn-info" id="col_select_all">全选</button>';
html += '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="col_invert_select">反选</button>';
html += '</div>';
html += '<div style="max-height: 600px; overflow-y: auto;">';
html += '<form class="layui-form" lay-filter="colSettingForm">';
for (let i = 0; i < cols.length; i++) {
......@@ -480,7 +485,7 @@
html += '</div>';
}
html += '</form></div>';
html += '</form></div></div>';
layer.open({
type: 1,
......@@ -490,6 +495,18 @@
btn: ['确定', '取消'],
success: function (layero, index) {
form.render('checkbox', 'colSettingForm');
//全选
layero.find('#col_select_all').on('click', function () {
layero.find('input[type="checkbox"]').prop('checked', true);
form.render('checkbox', 'colSettingForm');
});
//反选
layero.find('#col_invert_select').on('click', function () {
layero.find('input[type="checkbox"]').each(function () {
$(this).prop('checked', !$(this).is(':checked'));
});
form.render('checkbox', 'colSettingForm');
});
},
yes: function (index, layero) {
let settings = {};
......@@ -499,8 +516,21 @@
let checked = $(this).is(':checked');
settings[name] = checked;
});
localStorage.setItem(colSettingsKey, JSON.stringify(settings));
//保存到后端Redis
$.ajax({
url: '/api/external/SaveColSettings',
type: 'post',
data: {
user_id: colSettingsUserId,
page_key: colSettingsPageKey,
settings: JSON.stringify(settings)
},
dataType: 'json',
async: false
});
colSettingsData = settings;
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && settings[field] !== undefined) {
......
......@@ -82,6 +82,7 @@
@if(checkPerm('ConfirmCrmSupplier') && checkPerm('ViewConfirmSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="confirm_crm_supplier">确认客户转化供应商</button>
@endif
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="col_setting">展示列设置</button>
</div>
<button type="button" id="refreshWindow" style="display: none">刷新页面</button>
<table class="layui-table" id="list" lay-filter="list"></table>
......
......@@ -82,7 +82,7 @@
<?php if(checkPerm('ConfirmCrmSupplier') && checkPerm('ViewConfirmSupplier')): ?>
<button type="button" class="layui-btn layui-btn-sm" id="confirm_crm_supplier">确认客户转化供应商</button>
<?php endif; ?>
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="col_setting">列设置</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="col_setting">展示列设置</button>
</div>
<button type="button" id="refreshWindow" style="display: none">刷新页面</button>
<table class="layui-table" id="list" lay-filter="list"></table>
......
......@@ -360,17 +360,17 @@
cols.push(
);
// 列显示设置缓存
let colSettingsKey = 'supplier_list_col_settings_<?php echo e(request()->user->userId); ?>';
// 列显示设置 - 从后端Redis hash渲染
let colSettingsData = <?php echo $colSettings; ?>;
let colSettingsUserId = '<?php echo e(request()->user->userId); ?>';
let colSettingsPageKey = 'supplier_list';
function applyColSettings() {
let settings = localStorage.getItem(colSettingsKey);
if (settings) {
settings = JSON.parse(settings);
if (colSettingsData && Object.keys(colSettingsData).length > 0) {
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && settings[field] !== undefined) {
cols[i].hide = !settings[field];
if (field && colSettingsData[field] !== undefined) {
cols[i].hide = !colSettingsData[field];
}
}
}
......@@ -467,7 +467,12 @@
//列设置
$("#col_setting").click(function () {
let html = '<div style="padding: 15px; max-height: 700px; overflow-y: auto;">';
let html = '<div style="padding: 15px;">';
html += '<div style="margin-bottom: 10px;">';
html += '<button type="button" class="layui-btn layui-btn-xs layui-btn-info" id="col_select_all">全选</button>';
html += '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="col_invert_select">反选</button>';
html += '</div>';
html += '<div style="max-height: 600px; overflow-y: auto;">';
html += '<form class="layui-form" lay-filter="colSettingForm">';
for (let i = 0; i < cols.length; i++) {
......@@ -480,7 +485,7 @@
html += '</div>';
}
html += '</form></div>';
html += '</form></div></div>';
layer.open({
type: 1,
......@@ -490,6 +495,18 @@
btn: ['确定', '取消'],
success: function (layero, index) {
form.render('checkbox', 'colSettingForm');
//全选
layero.find('#col_select_all').on('click', function () {
layero.find('input[type="checkbox"]').prop('checked', true);
form.render('checkbox', 'colSettingForm');
});
//反选
layero.find('#col_invert_select').on('click', function () {
layero.find('input[type="checkbox"]').each(function () {
$(this).prop('checked', !$(this).is(':checked'));
});
form.render('checkbox', 'colSettingForm');
});
},
yes: function (index, layero) {
let settings = {};
......@@ -499,8 +516,21 @@
let checked = $(this).is(':checked');
settings[name] = checked;
});
localStorage.setItem(colSettingsKey, JSON.stringify(settings));
//保存到后端Redis
$.ajax({
url: '/api/external/SaveColSettings',
type: 'post',
data: {
user_id: colSettingsUserId,
page_key: colSettingsPageKey,
settings: JSON.stringify(settings)
},
dataType: 'json',
async: false
});
colSettingsData = settings;
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && settings[field] !== undefined) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment