Commit cf85ed34 by 杨树贤

Merge branch 'master' into Dev

parents 98aee61f 775542e7
......@@ -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('供应商列表');
}
......
......@@ -85,6 +85,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'
]//不用验证权限的方法
],
......
......@@ -374,6 +374,24 @@
];
cols.push(
);
// 列显示设置 - 从后端Redis hash渲染
let colSettingsData = {!! $colSettings !!};
let colSettingsUserId = '{{request()->user->userId}}';
let colSettingsPageKey = 'supplier_list';
function applyColSettings() {
if (colSettingsData && Object.keys(colSettingsData).length > 0) {
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && colSettingsData[field] !== undefined) {
cols[i].hide = !colSettingsData[field];
}
}
}
}
applyColSettings();
table.render({
elem: '#list'
, url: '/api/supplier/GetSupplierList'
......@@ -462,6 +480,88 @@
admin.putTempData("needFreshDetail_supplier_id=" + supplierId, 1);
}
//列设置
$("#col_setting").click(function () {
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++) {
if (cols[i].type === 'checkbox') continue;
let field = cols[i].field;
let title = cols[i].title || '';
let checked = cols[i].hide ? '' : 'checked';
html += '<div class="layui-form-item" style="display:inline-block;width:33%;margin-bottom:5px;">';
html += '<input type="checkbox" name="' + field + '" lay-skin="primary" title="' + title + '" ' + checked + '>';
html += '</div>';
}
html += '</form></div></div>';
layer.open({
type: 1,
title: '显示列设置',
area: ['600px', '600px'],
content: html,
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 = {};
let checkboxes = layero.find('input[type="checkbox"]');
checkboxes.each(function () {
let name = $(this).attr('name');
let checked = $(this).is(':checked');
settings[name] = checked;
});
//保存到后端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) {
cols[i].hide = !settings[field];
}
}
table.reload('list', {
cols: [cols],
page: {curr: currentPage},
where: whereCondition
});
layer.close(index);
}
});
});
//新增供应商弹窗
$("#add_supplier").click(function () {
index.openTab({
......
......@@ -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,6 +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>
</div>
<button type="button" id="refreshWindow" style="display: none">刷新页面</button>
<table class="layui-table" id="list" lay-filter="list"></table>
......
......@@ -374,6 +374,24 @@
];
cols.push(
);
// 列显示设置 - 从后端Redis hash渲染
let colSettingsData = <?php echo $colSettings; ?>;
let colSettingsUserId = '<?php echo e(request()->user->userId); ?>';
let colSettingsPageKey = 'supplier_list';
function applyColSettings() {
if (colSettingsData && Object.keys(colSettingsData).length > 0) {
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && colSettingsData[field] !== undefined) {
cols[i].hide = !colSettingsData[field];
}
}
}
}
applyColSettings();
table.render({
elem: '#list'
, url: '/api/supplier/GetSupplierList'
......@@ -462,6 +480,88 @@
admin.putTempData("needFreshDetail_supplier_id=" + supplierId, 1);
}
//列设置
$("#col_setting").click(function () {
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++) {
if (cols[i].type === 'checkbox') continue;
let field = cols[i].field;
let title = cols[i].title || '';
let checked = cols[i].hide ? '' : 'checked';
html += '<div class="layui-form-item" style="display:inline-block;width:33%;margin-bottom:5px;">';
html += '<input type="checkbox" name="' + field + '" lay-skin="primary" title="' + title + '" ' + checked + '>';
html += '</div>';
}
html += '</form></div></div>';
layer.open({
type: 1,
title: '显示列设置',
area: ['600px', '600px'],
content: html,
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 = {};
let checkboxes = layero.find('input[type="checkbox"]');
checkboxes.each(function () {
let name = $(this).attr('name');
let checked = $(this).is(':checked');
settings[name] = checked;
});
//保存到后端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) {
cols[i].hide = !settings[field];
}
}
table.reload('list', {
cols: [cols],
page: {curr: currentPage},
where: whereCondition
});
layer.close(index);
}
});
});
//新增供应商弹窗
$("#add_supplier").click(function () {
index.openTab({
......
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