Commit c05824db by 杨树贤

优化搜索

parent 5c587825
......@@ -36,6 +36,32 @@ class SupplierContactApiController extends Controller
$adminId = $request->user->userId;
$codeId = $request->user->codeId;
// 搜索条件:联系人名称
$supplierConsignee = $request->get('supplier_consignee');
if (!empty($supplierConsignee)) {
$query->where('supplier_consignee', 'like', '%' . $supplierConsignee . '%');
}
// 搜索条件:采购员类型
$channelUserType = $request->get('channel_user_type');
if (!empty($channelUserType)) {
$query->where('channel_user_type', $channelUserType);
}
// 搜索条件:采购员名称
$channelName = $request->get('channel_name');
if (!empty($channelName)) {
// 通过用户名查找codeId,然后用codeId过滤
$adminUserService = new AdminUserService();
$codeIds = $adminUserService->getCodeIdsByName($channelName);
if (!empty($codeIds)) {
$query->whereIn('can_check_uids', $codeIds);
} else {
// 没找到匹配的用户,返回空结果
$query->whereRaw('1=0');
}
}
//大家都可以查看离职的采购员的联系人
$allCanCheckUids = SupplierContactModel::where('supplier_id', $supplierId)->pluck('can_check_uids')->toArray();
$resignedUsers = (new AdminUserService())->getResignedUsers();
......
......@@ -43,6 +43,16 @@ class AdminUserService
return $codeId;
}
// 根据用户名模糊搜索获取codeId列表
public function getCodeIdsByName($userName)
{
$userIds = UserInfoModel::where('name', 'like', '%' . $userName . '%')->pluck('userId')->toArray();
if (empty($userIds)) {
return [];
}
return IntracodeModel::whereIn('admin_id', $userIds)->pluck('code_id')->toArray();
}
public function getAdminIdByUserName($userName)
{
return UserInfoModel::where('name', $userName)->value('userId');
......
......@@ -5,70 +5,111 @@
let admin = layui.admin;
let element = layui.element;
let supplierId = getQueryVariable('supplier_id');
table.render({
elem: '#contactList',
url: '/api/supplier_contact/GetSupplierContactList',
method: 'get',
cellMinWidth: 80,//全局定义常规单元格的最小宽度
where: {
supplier_id: getQueryVariable("supplier_id")
},
size:"sm",
loading: true,
first: true,//不显示首页
last: false,//不显示尾页
cols: [[
{
type: 'checkbox',
},
{
field: 'supplier_consignee',
title: '<span class="require">* </span>联系人',
align: 'center',
width: 150
},
{field: 'supplier_position', title: '<span class="require">* </span>职位', align: 'center', width: 100},
{
field: 'supplier_email',
title: '<span class="require">* </span>邮箱',
align: 'center',
width: 200,
templet: function (data) {
return data.supplier_email ? '<span>' + data.supplier_email + '</span><span style="color: dodgerblue" class="viewContact" type="supplier_email" contact_id="' + data.contact_id + '">查看</span>' : '';
}
},
{
field: 'supplier_mobile',
title: '<span class="require">* </span>手机号',
align: 'center',
width: 180,
templet: function (data) {
return data.supplier_mobile ? '<span>' + data.supplier_mobile + '</span><span style="color: dodgerblue" class="viewContact" type="supplier_mobile" contact_id="' + data.contact_id + '">查看</span>' : '';
}
},
{
field: 'supplier_telephone',
title: '<span class="require">* </span>座机',
align: 'center',
width: 180,
templet: function (data) {
return data.supplier_telephone ? '<span>' + data.supplier_telephone + '</span><span style="color: dodgerblue" class="viewContact" type="supplier_telephone" contact_id="' + data.contact_id + '">查看</span></span>' : '';
}
// 渲染表格
function renderTable(whereParams) {
table.render({
elem: '#contactList',
url: '/api/supplier_contact/GetSupplierContactList',
method: 'get',
cellMinWidth: 80,//全局定义常规单元格的最小宽度
where: whereParams,
size:"sm",
loading: true,
first: true,//不显示首页
last: false,//不显示尾页
cols: [[
{
type: 'checkbox',
},
{
field: 'supplier_consignee',
title: '<span class="require">* </span>联系人',
align: 'center',
width: 150
},
{field: 'supplier_position', title: '<span class="require">* </span>职位', align: 'center', width: 100},
{
field: 'supplier_email',
title: '<span class="require">* </span>邮箱',
align: 'center',
width: 200,
templet: function (data) {
return data.supplier_email ? '<span>' + data.supplier_email + '</span><span style="color: dodgerblue" class="viewContact" type="supplier_email" contact_id="' + data.contact_id + '">查看</span>' : '';
}
},
{
field: 'supplier_mobile',
title: '<span class="require">* </span>手机号',
align: 'center',
width: 180,
templet: function (data) {
return data.supplier_mobile ? '<span>' + data.supplier_mobile + '</span><span style="color: dodgerblue" class="viewContact" type="supplier_mobile" contact_id="' + data.contact_id + '">查看</span>' : '';
}
},
{
field: 'supplier_telephone',
title: '<span class="require">* </span>座机',
align: 'center',
width: 180,
templet: function (data) {
return data.supplier_telephone ? '<span>' + data.supplier_telephone + '</span><span style="color: dodgerblue" class="viewContact" type="supplier_telephone" contact_id="' + data.contact_id + '">查看</span></span>' : '';
}
},
{
field: 'supplier_qq', title: 'QQ', align: 'center', width: 180, templet: function (data) {
return data.supplier_qq ? '<span>' + data.supplier_qq + '</span><span style="color: dodgerblue" class="viewContact" type="supplier_qq" contact_id="' + data.contact_id + '">查看</span>' : '';
}
},
{field: 'supplier_fax', title: '传真', align: 'center', width: 140},
{field: 'channel_name', title: '<span class="require">* </span>采购员', align: 'center', width: 110},
{field: 'channel_user_type_name', title: '<span class="require">* </span>采购员类型', align: 'center', width: 210},
{field: 'working_status', title: '采购员状态', align: 'center', width: 120},
{field: 'add_time', title: '新增时间', align: 'center', width: 150},
{field: 'update_time', title: '更新时间', align: 'center', width: 150},
]],
id: 'contactList',
page: {},
});
}
// 初始渲染
renderTable({
supplier_id: supplierId
});
// 搜索按钮
$('#searchBtn').on('click', function() {
let consignee = $('input[name="supplier_consignee"]').val();
let channelUserType = $('select[name="channel_user_type"]').val();
let channelName = $('input[name="channel_name"]').val();
table.reload('contactList', {
where: {
supplier_id: supplierId,
supplier_consignee: consignee,
channel_user_type: channelUserType,
channel_name: channelName
},
{
field: 'supplier_qq', title: 'QQ', align: 'center', width: 180, templet: function (data) {
return data.supplier_qq ? '<span>' + data.supplier_qq + '</span><span style="color: dodgerblue" class="viewContact" type="supplier_qq" contact_id="' + data.contact_id + '">查看</span>' : '';
}
page: {
curr: 1
}
});
});
// 重置按钮
$('#resetBtn').on('click', function() {
$('input[name="supplier_consignee"]').val('');
$('select[name="channel_user_type"]').val('');
$('input[name="channel_name"]').val('');
form.render('select');
table.reload('contactList', {
where: {
supplier_id: supplierId
},
{field: 'supplier_fax', title: '传真', align: 'center', width: 140},
{field: 'channel_name', title: '<span class="require">* </span>采购员', align: 'center', width: 110},
{field: 'channel_user_type_name', title: '<span class="require">* </span>采购员类型', align: 'center', width: 210},
{field: 'working_status', title: '采购员状态', align: 'center', width: 120},
{field: 'add_time', title: '新增时间', align: 'center', width: 150},
{field: 'update_time', title: '更新时间', align: 'center', width: 150},
]],
id: 'contactList',
page: {},
page: {
curr: 1
}
});
});
//新增联系方式
......
......@@ -2,12 +2,54 @@
.viewContact {
margin-left: 10px;
}
.search-form {
margin-top: 10px;
margin-bottom: 10px;
}
.search-form .layui-form-item {
margin-bottom: 0;
}
</style>
<div class="layui-row">
<blockquote class="layui-elem-quote layui-text">
<b>联系人管理</b>
</blockquote>
{{-- @if($operate == 'update')--}}
{{-- 搜索表单 --}}
<div class="search-form">
<form class="layui-form" lay-filter="searchForm">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label" style="width: 80px;">联系人</label>
<div class="layui-input-inline" style="width: 150px;">
<input type="text" name="supplier_consignee" placeholder="请输入联系人名称" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 100px;">采购员类型</label>
<div class="layui-input-inline" style="width: 150px;">
<select name="channel_user_type">
<option value="">全部</option>
<option value="1">猎芯采购</option>
<option value="2">京东采购</option>
<option value="3">艾奇采购</option>
<option value="4">数据跟单员</option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 80px;">采购员</label>
<div class="layui-input-inline" style="width: 150px;">
<input type="text" name="channel_name" placeholder="请输入采购员名称" class="layui-input">
</div>
</div>
<div class="layui-inline">
<button type="button" class="layui-btn layui-btn-sm" id="searchBtn">搜索</button>
<button type="reset" class="layui-btn layui-btn-primary layui-btn-sm" id="resetBtn">重置</button>
</div>
</div>
</form>
</div>
{{-- @if($operate == 'update')--}}
<div class="layui-btn-group demoTable" style="margin-top: 5px">
@if(checkPerm('AddSupplierContact'))
<button type="button" class="layui-btn layui-btn-sm" id="add_contact">新增</button>
......@@ -22,8 +64,8 @@
<button type="button" class="layui-btn layui-btn-sm" id="set_yunxin_channel_user">设置SKU采购</button>
@endif
</div>
{{-- @endif--}}
{{-- @endif--}}
<table class="layui-table" lay-filter="contactList" id="contactList"></table>
</div>
@include('script.supplier.SupplierContactScript')
\ No newline at end of file
@include('script.supplier.SupplierContactScript')
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