Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3ac6ba49
authored
Jan 08, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
创建部门筛选需求
parent
34255c38
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
104 additions
and
6 deletions
app/Http/Controllers/Filter/SupplierFilter.php
app/Http/Controllers/SupplierController.php
app/Http/Services/AdminUserService.php
app/Http/Services/DepartmentService.php
app/Http/Transformers/SupplierTransformer.php
app/Http/routes.php
app/Model/SupplierChannelModel.php
app/Model/UserInfoModel.php
resources/views/script/SupplierListScript.blade.php
resources/views/web/supplier/SupplierListFilter.blade.php
app/Http/Controllers/Filter/SupplierFilter.php
View file @
3ac6ba49
...
@@ -8,6 +8,7 @@ use App\Http\Services\AdminUserService;
...
@@ -8,6 +8,7 @@ use App\Http\Services\AdminUserService;
use
App\Http\Services\DepartmentService
;
use
App\Http\Services\DepartmentService
;
use
App\Model\SupplierAttachmentsModel
;
use
App\Model\SupplierAttachmentsModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\UserInfoModel
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
class
SupplierFilter
class
SupplierFilter
...
@@ -189,6 +190,14 @@ 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字符串的供应商名称的数据
//默认过滤带有-1字符串的供应商名称的数据
$query
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
);
$query
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
);
return
$query
;
return
$query
;
...
...
app/Http/Controllers/SupplierController.php
View file @
3ac6ba49
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Http\Services\DepartmentService
;
use
App\Http\Services\LogService
;
use
App\Http\Services\LogService
;
use
App\Http\Services\RegionService
;
use
App\Http\Services\RegionService
;
use
App\Http\Services\SkuUploadLogService
;
use
App\Http\Services\SkuUploadLogService
;
...
@@ -101,6 +102,10 @@ class SupplierController extends Controller
...
@@ -101,6 +102,10 @@ class SupplierController extends Controller
];
];
}
}
$this
->
data
[
'supplierTypeData'
]
=
$supplierTypeData
;
$this
->
data
[
'supplierTypeData'
]
=
$supplierTypeData
;
//获取创建人部门树
$this
->
data
[
'createUserDepartmentList'
]
=
(
new
DepartmentService
())
->
getCreateUserDepartmentListForXmSelect
();
return
$this
->
view
(
'供应商列表'
);
return
$this
->
view
(
'供应商列表'
);
}
}
...
...
app/Http/Services/AdminUserService.php
View file @
3ac6ba49
...
@@ -114,4 +114,6 @@ class AdminUserService
...
@@ -114,4 +114,6 @@ class AdminUserService
$intraCodeModel
=
new
IntracodeModel
();
$intraCodeModel
=
new
IntracodeModel
();
return
$intraCodeModel
->
getEncodeByUserIds
(
$userIds
);
return
$intraCodeModel
->
getEncodeByUserIds
(
$userIds
);
}
}
}
\ No newline at end of file
}
app/Http/Services/DepartmentService.php
View file @
3ac6ba49
...
@@ -7,6 +7,7 @@ use App\Model\BrandModel;
...
@@ -7,6 +7,7 @@ use App\Model\BrandModel;
use
App\Model\DepartmentModel
;
use
App\Model\DepartmentModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierContactModel
;
use
App\Model\SupplierContactModel
;
use
App\Model\UserDepartmentModel
;
use
App\Model\UserInfoModel
;
use
App\Model\UserInfoModel
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
...
@@ -120,4 +121,40 @@ class DepartmentService
...
@@ -120,4 +121,40 @@ class DepartmentService
$departmentName
=
DepartmentModel
::
where
(
'department_id'
,
$departmentId
)
->
value
(
'department_name'
);
$departmentName
=
DepartmentModel
::
where
(
'department_id'
,
$departmentId
)
->
value
(
'department_name'
);
return
$departmentName
;
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
;
}
}
app/Http/Transformers/SupplierTransformer.php
View file @
3ac6ba49
...
@@ -33,6 +33,9 @@ class SupplierTransformer
...
@@ -33,6 +33,9 @@ class SupplierTransformer
//获取基石上传记录情况,展示第一次上传时间和最后一次上传时间
//获取基石上传记录情况,展示第一次上传时间和最后一次上传时间
$lastUploadSkuTimes
=
SkuService
::
getUploadTimeBySupplierCodes
(
array_column
(
$list
,
'supplier_code'
),
'last'
);
$lastUploadSkuTimes
=
SkuService
::
getUploadTimeBySupplierCodes
(
array_column
(
$list
,
'supplier_code'
),
'last'
);
//创建人部门map
$createUserDepartmentNameMap
=
(
new
DepartmentService
())
->
getDepartmentNameMapByUserIds
(
array_column
(
$list
,
'create_uid'
));
foreach
(
$list
as
&
$supplier
)
{
foreach
(
$list
as
&
$supplier
)
{
$supplier
[
'viewed'
]
=
array_get
(
$viewData
,
$supplier
[
'supplier_id'
],
false
);
$supplier
[
'viewed'
]
=
array_get
(
$viewData
,
$supplier
[
'supplier_id'
],
false
);
$supplier
=
$this
->
getStockupType
(
$supplier
);
$supplier
=
$this
->
getStockupType
(
$supplier
);
...
@@ -84,6 +87,8 @@ class SupplierTransformer
...
@@ -84,6 +87,8 @@ class SupplierTransformer
$supplier
[
'blacklist_time'
]
=
date
(
'Y-m-d H:i:s'
,
$supplier
[
'blacklist'
][
'add_time'
]);
$supplier
[
'blacklist_time'
]
=
date
(
'Y-m-d H:i:s'
,
$supplier
[
'blacklist'
][
'add_time'
]);
$supplier
[
'blacklist_reason'
]
=
$supplier
[
'blacklist'
][
'reason'
];
$supplier
[
'blacklist_reason'
]
=
$supplier
[
'blacklist'
][
'reason'
];
}
}
//创建人部门
$supplier
[
'create_user_department_name'
]
=
array_get
(
$createUserDepartmentNameMap
,
$supplier
[
'create_uid'
]);
}
}
unset
(
$supplier
);
unset
(
$supplier
);
return
$list
;
return
$list
;
...
...
app/Http/routes.php
View file @
3ac6ba49
...
@@ -82,5 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
...
@@ -82,5 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
(
new
\App\Http\Services\DataService
())
->
exportSupplierDataForLevel
();
(
new
DepartmentService
())
->
getCreateUserDepartmentList
();
});
});
app/Model/SupplierChannelModel.php
View file @
3ac6ba49
...
@@ -86,4 +86,6 @@ class SupplierChannelModel extends Model
...
@@ -86,4 +86,6 @@ class SupplierChannelModel extends Model
{
{
return
SupplierChannelModel
::
whereIn
(
'is_type'
,
0
)
->
get
()
->
toArray
();
return
SupplierChannelModel
::
whereIn
(
'is_type'
,
0
)
->
get
()
->
toArray
();
}
}
}
}
app/Model/UserInfoModel.php
View file @
3ac6ba49
...
@@ -9,4 +9,9 @@ class UserInfoModel extends Model
...
@@ -9,4 +9,9 @@ class UserInfoModel extends Model
protected
$table
=
'user_info'
;
protected
$table
=
'user_info'
;
protected
$primaryKey
=
'userId'
;
protected
$primaryKey
=
'userId'
;
public
$timestamps
=
false
;
public
$timestamps
=
false
;
public
function
department
()
{
return
$this
->
hasOne
(
DepartmentModel
::
class
,
'department_id'
,
'department_id'
);
}
}
}
resources/views/script/SupplierListScript.blade.php
View file @
3ac6ba49
<script>
<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
$
=
layui
.
jquery
;
let
Split
=
layui
.
Split
;
let
Split
=
layui
.
Split
;
// 水平分割,需要分割的元素(id)、默认大小(百分比)、最小值(单位px)
// 水平分割,需要分割的元素(id)、默认大小(百分比)、最小值(单位px)
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
let
form
=
layui
.
form
;
let
form
=
layui
.
form
;
let
index
=
layui
.
index
;
let
index
=
layui
.
index
;
let
admin
=
layui
.
admin
;
let
admin
=
layui
.
admin
;
let
xmSelect
=
layui
.
xmSelect
;
let
initCondition
=
{
source_type
:
'all'
};
let
initCondition
=
{
source_type
:
'all'
};
let
whereCondition
=
initCondition
;
let
whereCondition
=
initCondition
;
...
@@ -104,6 +105,30 @@
...
@@ -104,6 +105,30 @@
whereCondition
.
source_type
=
getQueryVariable
(
'source_type'
);
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
=
[
let
cols
=
[
{
type
:
'checkbox'
,
fixed
:
true
},
{
type
:
'checkbox'
,
fixed
:
true
},
{
{
...
@@ -221,6 +246,7 @@
...
@@ -221,6 +246,7 @@
}
}
},
},
{
field
:
'create_name'
,
title
:
'创建人'
,
align
:
'center'
,
width
:
70
},
{
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
:
'update_time'
,
title
:
'最近修改时间'
,
align
:
'center'
,
width
:
145
},
{
field
:
'supplier_type_name'
,
title
:
'供应商类别'
,
align
:
'center'
,
width
:
110
},
{
field
:
'supplier_type_name'
,
title
:
'供应商类别'
,
align
:
'center'
,
width
:
110
},
{
field
:
'create_time'
,
title
:
'创建时间'
,
align
:
'center'
,
width
:
145
},
{
field
:
'create_time'
,
title
:
'创建时间'
,
align
:
'center'
,
width
:
145
},
...
@@ -802,4 +828,6 @@
...
@@ -802,4 +828,6 @@
function
clearTypeFilter
()
{
function
clearTypeFilter
()
{
$
(
'.main_filter'
).
attr
(
'class'
,
'main_filter'
);
$
(
'.main_filter'
).
attr
(
'class'
,
'main_filter'
);
}
}
</script>
</script>
resources/views/web/supplier/SupplierListFilter.blade.php
View file @
3ac6ba49
...
@@ -325,11 +325,18 @@
...
@@ -325,11 +325,18 @@
@inject('statusPresenter','App\Presenters\StatusPresenter')
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('is_entity','实体名单','',config('field.IsEntity')) !!}
{!! $statusPresenter->render('is_entity','实体名单','',config('field.IsEntity')) !!}
</div>
</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-row"
>
<div
class=
"layui-inline"
style=
"width: 600px"
>
<div
class=
"layui-inline"
style=
"width: 600px"
>
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'创建时间','sku_create_time' => '首次上传sku时间']) !!}
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'创建时间','sku_create_time' => '首次上传sku时间']) !!}
</div>
</div>
</div>
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment