Commit cf8c9ea1 by 杨树贤

Merge branch 'master' into ysx-CRM转化供应商流程-20260518

parents 100d148e 07205bd0
...@@ -11,3 +11,5 @@ Homestead.json ...@@ -11,3 +11,5 @@ Homestead.json
/storage/framework/views /storage/framework/views
/storage /storage
CLAUDE.md CLAUDE.md
/.windsurf
/skills-lock.json
...@@ -7,6 +7,7 @@ use App\Http\Services\AdminUserService; ...@@ -7,6 +7,7 @@ use App\Http\Services\AdminUserService;
use App\Http\Services\CompanyService; use App\Http\Services\CompanyService;
use App\Http\Services\StandardBrandService; use App\Http\Services\StandardBrandService;
use App\Model\BrandModel; use App\Model\BrandModel;
use App\Model\RedisModel;
use App\Model\StandardBrandModel; use App\Model\StandardBrandModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
...@@ -120,4 +121,33 @@ class CommonApiController extends Controller ...@@ -120,4 +121,33 @@ class CommonApiController extends Controller
$this->response(0, 'ok', $result); $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());
}
} }
...@@ -60,16 +60,59 @@ class SkuApiController extends Controller ...@@ -60,16 +60,59 @@ class SkuApiController extends Controller
$supplierCode = $request->get('supplier_code'); $supplierCode = $request->get('supplier_code');
$brandId = $request->get('brand_ids'); $brandId = $request->get('brand_ids');
$brandId = str_replace(',', '', $brandId); $brandId = str_replace(',', '', $brandId);
// $updateTime = $request->get('update_time');
if (empty($supplierCode)) { if (empty($supplierCode)) {
$this->response(-1, '请选择供应商'); $this->response(-1, '请选择供应商');
} }
// $startTime = $endTime = 0;
// if ($updateTime) { $supplier = SupplierChannelModel::where('supplier_code', $supplierCode)->first();
// $updateTime = explode('~', $updateTime); if (empty($supplier)) {
// $startTime = $updateTime[0]; $this->response(-1, '供应商不存在');
// $endTime = $updateTime[1]; }
// }
if (!checkPerm('ViewAllSku')) {
$userId = $request->user->userId;
$codeId = $request->user->codeId;
$canViewSubordinate = checkPerm('ViewSubordinateSku');
if ($canViewSubordinate) {
$departmentService = new \App\Http\Services\DepartmentService();
$subordinateUserIds = $departmentService->getSubordinateUserIds($userId);
$adminUserService = new \App\Http\Services\AdminUserService();
$subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds)->toArray();
$subordinateCodeIds[] = $codeId;
$isAuthorized = false;
if (in_array($supplier->purchase_uid, $subordinateCodeIds)) {
$isAuthorized = true;
}
if (!empty($supplier->channel_uid)) {
$channelUids = explode(',', trim($supplier->channel_uid, ','));
foreach ($channelUids as $channelUid) {
if (in_array($channelUid, $subordinateCodeIds)) {
$isAuthorized = true;
break;
}
}
}
if (!$isAuthorized) {
$this->response(-1, '无权限操作该供应商的SKU');
}
} else {
$isAuthorized = false;
if ($supplier->purchase_uid == $codeId) {
$isAuthorized = true;
}
if (!empty($supplier->channel_uid)) {
$channelUids = explode(',', trim($supplier->channel_uid, ','));
if (in_array($codeId, $channelUids)) {
$isAuthorized = true;
}
}
if (!$isAuthorized) {
$this->response(-1, '无权限操作该供应商的SKU');
}
}
}
$uploadLogId = SkuUploadLogModel::where('supplier_code', $supplierCode) $uploadLogId = SkuUploadLogModel::where('supplier_code', $supplierCode)
->where('status', SkuUploadLogModel::STATUS_HANDLED)->orderBy('id', 'desc') ->where('status', SkuUploadLogModel::STATUS_HANDLED)->orderBy('id', 'desc')
...@@ -89,7 +132,6 @@ class SkuApiController extends Controller ...@@ -89,7 +132,6 @@ class SkuApiController extends Controller
'log_id' => $uploadLogId, 'log_id' => $uploadLogId,
"down_type" => 1, "down_type" => 1,
]; ];
//改成队列
(new SkuService())->batchOffShelfSkuQueue($data); (new SkuService())->batchOffShelfSkuQueue($data);
$this->response(0, '批量下架任务已经发送,请等待任务完成,期间你可以刷新列表查看下架情况'); $this->response(0, '批量下架任务已经发送,请等待任务完成,期间你可以刷新列表查看下架情况');
} }
...@@ -131,6 +173,59 @@ class SkuApiController extends Controller ...@@ -131,6 +173,59 @@ class SkuApiController extends Controller
'operate_type', 'operate_type',
'cp_time', 'cp_time',
]); ]);
$supplierCodes = explode(',', $data['supplier_codes']);
if (!checkPerm('ViewAllSku')) {
$userId = $request->user->userId;
$codeId = $request->user->codeId;
$canViewSubordinate = checkPerm('ViewSubordinateSku');
if ($canViewSubordinate) {
$departmentService = new \App\Http\Services\DepartmentService();
$subordinateUserIds = $departmentService->getSubordinateUserIds($userId);
$adminUserService = new \App\Http\Services\AdminUserService();
$subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds)->toArray();
$subordinateCodeIds[] = $codeId;
$suppliers = SupplierChannelModel::whereIn('supplier_code', $supplierCodes)->get();
foreach ($suppliers as $supplier) {
$isAuthorized = false;
if (in_array($supplier->purchase_uid, $subordinateCodeIds)) {
$isAuthorized = true;
}
if (!empty($supplier->channel_uid)) {
$channelUids = explode(',', trim($supplier->channel_uid, ','));
foreach ($channelUids as $channelUid) {
if (in_array($channelUid, $subordinateCodeIds)) {
$isAuthorized = true;
break;
}
}
}
if (!$isAuthorized) {
$this->response(-1, '无权限操作供应商 ' . $supplier->supplier_code . ' 的SKU');
}
}
} else {
$suppliers = SupplierChannelModel::whereIn('supplier_code', $supplierCodes)->get();
foreach ($suppliers as $supplier) {
$isAuthorized = false;
if ($supplier->purchase_uid == $codeId) {
$isAuthorized = true;
}
if (!empty($supplier->channel_uid)) {
$channelUids = explode(',', trim($supplier->channel_uid, ','));
if (in_array($codeId, $channelUids)) {
$isAuthorized = true;
}
}
if (!$isAuthorized) {
$this->response(-1, '无权限操作供应商 ' . $supplier->supplier_code . ' 的SKU');
}
}
}
}
if ($data['operate_type'] == SkuService::OPERATE_TYPE_PUTAWAY) { if ($data['operate_type'] == SkuService::OPERATE_TYPE_PUTAWAY) {
if ($data['is_long_term'] == -1 && empty($data['cp_time'])) { if ($data['is_long_term'] == -1 && empty($data['cp_time'])) {
$this->response(-1, '请设置上架有效期'); $this->response(-1, '请设置上架有效期');
......
...@@ -21,7 +21,6 @@ class SkuListFilter ...@@ -21,7 +21,6 @@ class SkuListFilter
$map = array_map(function ($item) { $map = array_map(function ($item) {
return trim($item); return trim($item);
}, $map); }, $map);
//dd($map);
//只获取专卖的数据 //只获取专卖的数据
$map['supplier_id'] = 17; $map['supplier_id'] = 17;
if ((!empty($map['create_time']))) { if ((!empty($map['create_time']))) {
...@@ -32,18 +31,38 @@ class SkuListFilter ...@@ -32,18 +31,38 @@ class SkuListFilter
unset($map['create_time']); unset($map['create_time']);
} }
$userId = request()->user->userId; $userId = request()->user->userId;
$codeId = request()->user->codeId;
if (checkPerm('ViewAllSku')) { if (checkPerm('ViewAllSku')) {
} else if (checkPerm('ViewSubordinateSku')) { } else if (checkPerm('ViewSubordinateSku')) {
//查看下级
$departmentService = new DepartmentService(); $departmentService = new DepartmentService();
//下属用户id(结果包括自己的id)
$subordinateUserIds = $departmentService->getSubordinateUserIds($userId); $subordinateUserIds = $departmentService->getSubordinateUserIds($userId);
$adminUserService = new AdminUserService(); $adminUserService = new AdminUserService();
$subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds); $subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds);
$subordinateCodeIds = $subordinateCodeIds->toArray(); $subordinateCodeIds = $subordinateCodeIds->toArray();
$map['encoded/eqs'] = implode(',', $subordinateCodeIds); // $map['encoded/eqs'] = implode(',', $subordinateCodeIds);
$supplierCodes = SupplierChannelModel::where(function ($query) use ($subordinateCodeIds) {
$query->whereIn('purchase_uid', $subordinateCodeIds)
->orWhereRaw("channel_uid REGEXP '" . implode('|', $subordinateCodeIds) . "'");
})->whereNotNull('supplier_code')->where('supplier_code', '!=', '')->pluck('supplier_code')->toArray();
if (!empty($supplierCodes)) {
$map['canal_new/eqs'] = implode(',', $supplierCodes);
} else {
$map['canal_new/eqs'] = 'NO_MATCH';
}
} else {
// $map['encoded/condition'] = $codeId;
$supplierCodes = SupplierChannelModel::where(function ($query) use ($codeId) {
$query->where('purchase_uid', $codeId)
->orWhere('channel_uid', 'like', '%' . $codeId . '%');
})->whereNotNull('supplier_code')->where('supplier_code', '!=', '')->pluck('supplier_code')->toArray();
if (!empty($supplierCodes)) {
$map['canal_new/eqs'] = implode(',', $supplierCodes);
} else { } else {
$map['encoded/condition'] = request()->user->codeId; $map['canal_new/eqs'] = 'NO_MATCH';
}
} }
if ((!empty($map['update_time']))) { if ((!empty($map['update_time']))) {
$times = explode('~', $map['update_time']); $times = explode('~', $map['update_time']);
...@@ -74,22 +93,6 @@ class SkuListFilter ...@@ -74,22 +93,6 @@ class SkuListFilter
unset($map['data_channel_uid']); unset($map['data_channel_uid']);
} }
//根据数据维护员(purchase_uid)查询对应的供应商编码,多个一起请求
if (!empty($map['purchase_uid'])) {
$supplierCodes = SupplierChannelModel::where('purchase_uid', $map['purchase_uid'])
->whereNotNull('supplier_code')
->where('supplier_code', '!=', '')
->pluck('supplier_code')
->toArray();
if (!empty($supplierCodes)) {
$map['canal_new/eqs'] = implode(',', $supplierCodes);
} else {
// 没有匹配的供应商,传一个不存在的值以确保查不到数据
$map['canal_new/eqs'] = 'NO_MATCH';
}
unset($map['purchase_uid']);
}
if (!empty($map['source_type'])) { if (!empty($map['source_type'])) {
switch ($map['source_type']) { switch ($map['source_type']) {
case 'all': case 'all':
......
...@@ -22,17 +22,16 @@ class SupplierAccountFilter ...@@ -22,17 +22,16 @@ class SupplierAccountFilter
if (!checkPerm('ViewAllSupplierAccount')) { if (!checkPerm('ViewAllSupplierAccount')) {
if (checkPerm('ViewSubSupplierAccount')) { if (checkPerm('ViewSubSupplierAccount')) {
$departmentService = new DepartmentService(); $departmentService = new DepartmentService();
//下属用户id(结果包括自己的id)
$subordinateUserIds = $departmentService->getSubordinateUserIds($request->user->userId); $subordinateUserIds = $departmentService->getSubordinateUserIds($request->user->userId);
$adminUserService = new AdminUserService(); $adminUserService = new AdminUserService();
$subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds); $subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds);
$subordinateCodeIds = $subordinateCodeIds->toArray(); $subordinateCodeIds = $subordinateCodeIds->toArray();
$likeSqlRaw = implode('|', $subordinateCodeIds); $likeSqlRaw = implode('|', $subordinateCodeIds);
$supplierIds = SupplierChannelModel::whereRaw(DB::raw("(channel_uid REGEXP '$likeSqlRaw')"))->pluck('supplier_id')->toArray(); $inCodeIdSql = implode(',', $subordinateCodeIds);
$supplierIds = SupplierChannelModel::whereRaw(DB::raw("(channel_uid REGEXP '$likeSqlRaw' OR purchase_uid IN ($inCodeIdSql))"))->pluck('supplier_id')->toArray();
$query->whereIn('supplier_id', $supplierIds); $query->whereIn('supplier_id', $supplierIds);
} else { } else {
//否则只能查看自己的 $supplierIds = SupplierChannelModel::whereRaw(DB::raw("(channel_uid REGEXP '$codeId' OR purchase_uid = '$codeId')"))->pluck('supplier_id')->toArray();
$supplierIds = SupplierChannelModel::whereRaw(DB::raw("(channel_uid REGEXP '$codeId')"))->pluck('supplier_id')->toArray();
$query->whereIn('supplier_id', $supplierIds); $query->whereIn('supplier_id', $supplierIds);
} }
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use function foo\func;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\NationModel; use App\Model\NationModel;
use App\Model\RedisModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Model\IntracodeModel; use App\Model\IntracodeModel;
use App\Http\Services\LogService; use App\Http\Services\LogService;
...@@ -119,6 +119,12 @@ class SupplierController extends Controller ...@@ -119,6 +119,12 @@ class SupplierController extends Controller
//获取创建人部门树 //获取创建人部门树
$this->data['createUserDepartmentList'] = (new DepartmentService())->getCreateUserDepartmentListForXmSelect(); $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('供应商列表'); return $this->view('供应商列表');
} }
......
...@@ -44,9 +44,7 @@ class SkuService extends BaseService ...@@ -44,9 +44,7 @@ class SkuService extends BaseService
die(); die();
} }
try { try {
// $return = curl($url, $map, 1); $return = curl($url, $map, 1);
$url = base64_encode($url . '?' . http_build_query($map));
$return = curl(config('website.FootstoneCurlUrl') . $url);
} catch (\Exception $e) { } catch (\Exception $e) {
return $e->getMessage(); return $e->getMessage();
} }
......
...@@ -9,6 +9,7 @@ use App\Http\Transformers\SupplierTransformer; ...@@ -9,6 +9,7 @@ use App\Http\Transformers\SupplierTransformer;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\SkuUploadLogModel; use App\Model\SkuUploadLogModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
class SkuUploadLogService class SkuUploadLogService
{ {
...@@ -26,7 +27,6 @@ class SkuUploadLogService ...@@ -26,7 +27,6 @@ class SkuUploadLogService
return $list; return $list;
} }
//获取上传次数
public function getSkuUploadLogCount($supplierId) public function getSkuUploadLogCount($supplierId)
{ {
$supplierCode = SupplierChannelModel::where('supplier_id', $supplierId)->value('supplier_code'); $supplierCode = SupplierChannelModel::where('supplier_id', $supplierId)->value('supplier_code');
......
...@@ -463,6 +463,16 @@ class SyncSupplierService ...@@ -463,6 +463,16 @@ class SyncSupplierService
} }
} }
} }
if (!empty($supplier['purchase_uid'])) {
$purchaseUids = explode(',', $supplier['purchase_uid']);
$purchaseUserList = (new AdminUserService())->getAdminUserListByCodeIds($purchaseUids);
foreach ($purchaseUserList as $purchaseUser) {
if (!empty($purchaseUser['email'])) {
(new MessageService())->sendMessage('supplier_entity_notice_purchase', $data, $purchaseUser['email'], true);
}
}
}
} }
} }
} }
...@@ -85,6 +85,8 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Api'], function () { ...@@ -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/checkSupplierApply', 'ExternalApiController@checkSupplierApply');
Route::match(['get', 'post'], '/api/external/applySupplier', 'ExternalApiController@applySupplier'); Route::match(['get', 'post'], '/api/external/applySupplier', 'ExternalApiController@applySupplier');
Route::match(['get', 'post'], '/api/external/checkSupplierAccountExist', 'ExternalApiController@checkSupplierAccountExist'); 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 [ ...@@ -17,6 +17,8 @@ return [
'BatchUpdateSkuStatus', 'BatchUpdateSkuStatus',
'GetAuditFlow', 'GetAuditFlow',
'ViewAccountLog', 'ViewAccountLog',
'SaveColSettings',
'GetColSettings',
'TempTemp' 'TempTemp'
]//不用验证权限的方法 ]//不用验证权限的方法
], ],
......
...@@ -361,6 +361,24 @@ ...@@ -361,6 +361,24 @@
]; ];
cols.push( 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({ table.render({
elem: '#list' elem: '#list'
, url: '/api/supplier/GetSupplierList' , url: '/api/supplier/GetSupplierList'
...@@ -449,6 +467,88 @@ ...@@ -449,6 +467,88 @@
admin.putTempData("needFreshDetail_supplier_id=" + supplierId, 1); 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 () { $("#add_supplier").click(function () {
index.openTab({ index.openTab({
......
...@@ -82,6 +82,10 @@ ...@@ -82,6 +82,10 @@
@if(checkPerm('ConfirmCrmSupplier') && checkPerm('ViewConfirmSupplier')) @if(checkPerm('ConfirmCrmSupplier') && checkPerm('ViewConfirmSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="confirm_crm_supplier">确认客户转化供应商</button> <button type="button" class="layui-btn layui-btn-sm" id="confirm_crm_supplier">确认客户转化供应商</button>
@endif @endif
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="col_setting">展示列设置</button>
@if(checkPerm('ConfirmCrmSupplier') && checkPerm('ViewConfirmSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="confirm_crm_supplier">确认客户转化供应商</button>
@endif
</div> </div>
<button type="button" id="refreshWindow" style="display: none">刷新页面</button> <button type="button" id="refreshWindow" style="display: none">刷新页面</button>
<table class="layui-table" id="list" lay-filter="list"></table> <table class="layui-table" id="list" lay-filter="list"></table>
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
<?php if(checkPerm('ConfirmCrmSupplier') && checkPerm('ViewConfirmSupplier')): ?> <?php if(checkPerm('ConfirmCrmSupplier') && checkPerm('ViewConfirmSupplier')): ?>
<button type="button" class="layui-btn layui-btn-sm" id="confirm_crm_supplier">确认客户转化供应商</button> <button type="button" class="layui-btn layui-btn-sm" id="confirm_crm_supplier">确认客户转化供应商</button>
<?php endif; ?> <?php endif; ?>
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="col_setting">展示列设置</button>
</div> </div>
<button type="button" id="refreshWindow" style="display: none">刷新页面</button> <button type="button" id="refreshWindow" style="display: none">刷新页面</button>
<table class="layui-table" id="list" lay-filter="list"></table> <table class="layui-table" id="list" lay-filter="list"></table>
......
...@@ -361,6 +361,24 @@ ...@@ -361,6 +361,24 @@
]; ];
cols.push( 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({ table.render({
elem: '#list' elem: '#list'
, url: '/api/supplier/GetSupplierList' , url: '/api/supplier/GetSupplierList'
...@@ -449,6 +467,88 @@ ...@@ -449,6 +467,88 @@
admin.putTempData("needFreshDetail_supplier_id=" + supplierId, 1); 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 () { $("#add_supplier").click(function () {
index.openTab({ 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