Commit 3ac6ba49 by 杨树贤

创建部门筛选需求

parent 34255c38
......@@ -8,6 +8,7 @@ use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService;
use App\Model\SupplierAttachmentsModel;
use App\Model\SupplierChannelModel;
use App\Model\UserInfoModel;
use Illuminate\Support\Facades\DB;
class SupplierFilter
......@@ -189,6 +190,14 @@ class SupplierFilter
}
}
//搜索创建部门的数据
if (!empty($map['create_user_department'])) {
$map['create_user_department'] = explode(',', $map['create_user_department']);
//先去找出所有的创建人uid
$userIds = UserInfoModel::whereIn('department_id',$map['create_user_department'])->pluck('userId')->toArray();
$query->whereIn('create_uid',$userIds);
}
//默认过滤带有-1字符串的供应商名称的数据
$query->whereRaw('supplier_name NOT LIKE "%-1"');
return $query;
......
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Services\DepartmentService;
use App\Http\Services\LogService;
use App\Http\Services\RegionService;
use App\Http\Services\SkuUploadLogService;
......@@ -101,6 +102,10 @@ class SupplierController extends Controller
];
}
$this->data['supplierTypeData'] = $supplierTypeData;
//获取创建人部门树
$this->data['createUserDepartmentList'] = (new DepartmentService())->getCreateUserDepartmentListForXmSelect();
return $this->view('供应商列表');
}
......
......@@ -114,4 +114,6 @@ class AdminUserService
$intraCodeModel = new IntracodeModel();
return $intraCodeModel->getEncodeByUserIds($userIds);
}
}
\ No newline at end of file
}
......@@ -7,6 +7,7 @@ use App\Model\BrandModel;
use App\Model\DepartmentModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use App\Model\UserDepartmentModel;
use App\Model\UserInfoModel;
use Illuminate\Support\Facades\DB;
......@@ -120,4 +121,40 @@ class DepartmentService
$departmentName = DepartmentModel::where('department_id', $departmentId)->value('department_name');
return $departmentName;
}
}
\ No newline at end of file
public function getDepartmentNameMapByUserIds($userIds)
{
$userIds = array_unique($userIds);
$userIddepartmentIdMap = UserInfoModel::whereIn('userId', $userIds)->pluck('department_id', 'userId')->toArray();
$departmentIds = array_values($userIddepartmentIdMap);
$departmentNameDepartmentIdMap = DepartmentModel::whereIn('department_id', $departmentIds)->pluck('department_name', 'department_id')->toArray();
//找到对应的关系
$result = [];
foreach ($userIddepartmentIdMap as $userId => $departmentId) {
$result[$userId] = array_get($departmentNameDepartmentIdMap,$departmentId,'');
}
return $result;
}
public function getCreateUserDepartmentListForXmSelect()
{
$departmentList = [];
$topDepartmentList = DB::table('user_department')->where('parent_id', 8)->select('department_id',
'department_name')->get();
foreach ($topDepartmentList as $topDepartment) {
$data = [
'name' => $topDepartment['department_name'],
'value' => $topDepartment['department_id'],
];
$childrenDepartmentList = UserDepartmentModel::where('parent_id', $topDepartment['department_id'])
->selectRaw('department_id as value , department_name as name')->get()->toArray();
$data['children'] = $childrenDepartmentList;
$departmentList[] = $data;
}
return $departmentList;
}
}
......@@ -33,6 +33,9 @@ class SupplierTransformer
//获取基石上传记录情况,展示第一次上传时间和最后一次上传时间
$lastUploadSkuTimes = SkuService::getUploadTimeBySupplierCodes(array_column($list, 'supplier_code'), 'last');
//创建人部门map
$createUserDepartmentNameMap = (new DepartmentService())->getDepartmentNameMapByUserIds(array_column($list,'create_uid'));
foreach ($list as &$supplier) {
$supplier['viewed'] = array_get($viewData, $supplier['supplier_id'], false);
$supplier = $this->getStockupType($supplier);
......@@ -84,6 +87,8 @@ class SupplierTransformer
$supplier['blacklist_time'] = date('Y-m-d H:i:s', $supplier['blacklist']['add_time']);
$supplier['blacklist_reason'] = $supplier['blacklist']['reason'];
}
//创建人部门
$supplier['create_user_department_name'] = array_get($createUserDepartmentNameMap,$supplier['create_uid']);
}
unset($supplier);
return $list;
......
......@@ -82,5 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\DataService())->exportSupplierDataForLevel();
(new DepartmentService())->getCreateUserDepartmentList();
});
......@@ -86,4 +86,6 @@ class SupplierChannelModel extends Model
{
return SupplierChannelModel::whereIn('is_type', 0)->get()->toArray();
}
}
......@@ -9,4 +9,9 @@ class UserInfoModel extends Model
protected $table='user_info';
protected $primaryKey = 'userId';
public $timestamps = false;
public function department()
{
return $this->hasOne(DepartmentModel::class, 'department_id', 'department_id');
}
}
<script>
layui.use(['table', 'form', 'element', 'layer', 'Split', 'admin', 'index'], function () {
layui.use(['table', 'form', 'element', 'layer', 'Split', 'admin', 'index','xmSelect'], function () {
let $ = layui.jquery;
let Split = layui.Split;
// 水平分割,需要分割的元素(id)、默认大小(百分比)、最小值(单位px)
......@@ -9,6 +9,7 @@
let form = layui.form;
let index = layui.index;
let admin = layui.admin;
let xmSelect = layui.xmSelect;
let initCondition = {source_type: 'all'};
let whereCondition = initCondition;
......@@ -104,6 +105,30 @@
whereCondition.source_type = getQueryVariable('source_type');
}
var createUserDepartmentSelector = xmSelect.render({
el: '#create_user_department',
autoRow: true,
name: 'create_user_department',
filterable: true,
tree: {
show: true,
showFolderIcon: true,
showLine: true,
indent: 20,
expandedKeys: true,
},
size: 'mini',
toolbar: {
show: true,
list: ['ALL', 'CLEAR']
},
height: 'auto',
data: function () {
//这个数据在对应的blade页面下面...
return {!! json_encode($createUserDepartmentList) !!};
}
})
let cols = [
{type: 'checkbox', fixed: true},
{
......@@ -221,6 +246,7 @@
}
},
{field: 'create_name', title: '创建人', align: 'center', width: 70},
{field: 'create_user_department_name', title: '创建部门', align: 'center', width: 100},
{field: 'update_time', title: '最近修改时间', align: 'center', width: 145},
{field: 'supplier_type_name', title: '供应商类别', align: 'center', width: 110},
{field: 'create_time', title: '创建时间', align: 'center', width: 145},
......@@ -802,4 +828,6 @@
function clearTypeFilter() {
$('.main_filter').attr('class', 'main_filter');
}
</script>
......@@ -325,11 +325,18 @@
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('is_entity','实体名单','',config('field.IsEntity')) !!}
</div>
<div class="layui-inline">
<label class="layui-form-label">创建部门</label>
<div class="layui-input-inline">
<div id="create_user_department" style="width: 150px"></div>
</div>
</div>
<div class="layui-row">
<div class="layui-inline" style="width: 600px">
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'创建时间','sku_create_time' => '首次上传sku时间']) !!}
</div>
</div>
</div>
......
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