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
6b7855a7
authored
Jul 27, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
共用申请
parent
d065baa4
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
458 additions
and
6 deletions
app/Http/Controllers/Api/SupplierShareApplyApiController.php
app/Http/Controllers/SupplierShareApplyController.php
app/Http/Services/DepartmentService.php
app/Http/Services/SupplierShareApplyService.php
app/Http/Transformers/SupplierShareApplyTransformer.php
app/Http/routes.php
app/Model/DepartmentModel.php
app/Model/SupplierShareApplyModel.php
config/field.php
public/plugins/assets/js/common.js
resources/views/script/ApplySupplierShareScript.blade.php
resources/views/script/SupplierListScript.blade.php
resources/views/web/ApplySupplierShare.blade.php
resources/views/web/SupplierList.blade.php
app/Http/Controllers/Api/SupplierShareApplyApiController.php
0 → 100644
View file @
6b7855a7
<?php
namespace
App\Http\Controllers\Api
;
use
App\Http\Controllers\Controller
;
use
App\Http\Services\AdminUserService
;
use
App\Http\Services\SupplierShareApplyService
;
use
App\Http\Transformers\LogTransformer
;
use
App\Model\LogModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierShareApplyModel
;
use
Illuminate\Http\Request
;
//供应商共享申请
class
SupplierShareApplyApiController
extends
Controller
{
public
function
Entrance
(
Request
$request
,
$id
)
{
$this
->
$id
(
$request
,
$id
);
}
public
function
GetSupplierShareApplyList
(
$request
)
{
$userId
=
$request
->
user
->
userId
;
$applyService
=
new
SupplierShareApplyService
();
$list
=
$applyService
->
getSupplierShareApplyList
(
$userId
);
$this
->
response
(
0
,
'ok'
,
$list
[
'data'
],
$list
[
'total'
]);
}
//校验申请的供应商,并且还要返回所属部门列表
public
function
CheckApplySupplierShare
(
$request
)
{
$supplierName
=
$request
->
get
(
'supplier_name'
);
if
(
empty
(
$supplierName
))
{
$this
->
response
(
-
1
,
'供应商名称不能为空'
);
}
$supplierModel
=
new
SupplierChannelModel
();
$supplier
=
$supplierModel
->
where
(
'supplier_name'
,
$supplierName
)
->
first
();
if
(
empty
(
$supplier
))
{
$this
->
response
(
-
1
,
'没有匹配到存在的供应商'
);
}
$applyService
=
new
SupplierShareApplyService
();
$departments
=
$applyService
->
checkApplySupplierShare
(
$supplier
);
if
(
empty
(
$departments
))
{
$this
->
response
(
-
1
,
'该供应商不存在相关联的部门'
);
}
$this
->
response
(
0
,
'匹配到供应商数据,可以下拉选择你需要申请的部门'
,
$departments
,
$supplier
[
'supplier_id'
]);
}
//保存共用申请
public
function
SaveSupplierShareApply
(
$request
)
{
$map
=
$request
->
only
([
'department_id'
,
'supplier_id'
,
]);
if
(
empty
(
$map
[
'department_id'
])
||
empty
(
$map
[
'supplier_id'
]))
{
$this
->
response
(
-
1
,
'缺少参数'
);
}
$map
[
'apply_user_id'
]
=
$request
->
user
->
userId
;
$applyService
=
new
SupplierShareApplyService
();
$hasNoFinish
=
$applyService
->
checkHasNoFinishApply
(
$map
);
if
(
$hasNoFinish
)
{
$this
->
response
(
-
1
,
'你存在对该供应商的申请,正在审核流程中'
);
}
$result
=
$applyService
->
saveSupplierShareApply
(
$map
);
if
(
!
$result
)
{
$this
->
response
(
-
1
,
'申请失败,系统错误'
);
}
return
$this
->
response
(
0
,
'申请成功'
);
}
}
app/Http/Controllers/SupplierShareApplyController.php
0 → 100644
View file @
6b7855a7
<?php
namespace
App\Http\Controllers
;
use
App\Http\Controllers\Filter\SupplierLogFilter
;
use
App\Http\Services\LogService
;
use
App\Model\LogModel
;
use
App\Model\SupplierLogModel
;
use
Illuminate\Http\Request
;
use
DB
;
class
SupplierShareApplyController
extends
Controller
{
public
function
Entrance
(
Request
$request
,
$id
=
'index'
)
{
if
(
$request
->
path
()
==
'/'
)
{
$path
=
'web/index'
;
}
else
{
$path
=
$request
->
path
();
}
$this
->
data
=
[
'menus'
=>
$request
->
menus
,
'header'
=>
$request
->
user
->
header
,
'username'
=>
$request
->
user
->
email
,
'user_email'
=>
$request
->
user
->
email
,
'uri'
=>
'/'
.
$path
,
'id'
=>
$id
];
return
$this
->
$id
(
$request
);
}
public
function
__call
(
$method
,
$parameters
)
{
return
$this
->
errhtml
(
'Not'
,
'没有这个页面'
);
}
//申请供应商共享
public
function
ApplySupplierShare
(
$request
)
{
return
$this
->
view
(
'申请供应商共享'
);
}
}
app/Http/Services/DepartmentService.php
View file @
6b7855a7
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Services
;
use
App\Model\DepartmentModel
;
use
App\Model\UserInfoModel
;
use
DB
;
...
...
@@ -55,4 +56,27 @@ class DepartmentService
return
$departmentIds
;
}
//根据用户ip获取顶级部门id
public
function
getTopDepartmentByUserId
(
$userId
)
{
$userModel
=
new
UserInfoModel
();
$departmentId
=
$userModel
->
where
(
'userId'
,
$userId
)
->
value
(
'department_id'
);
if
(
empty
(
$departmentId
))
{
return
[];
}
//去department表找到顶级id,也可能本身就是顶级id
$departmentModel
=
new
DepartmentModel
();
$department
=
$departmentModel
->
where
(
'department_id'
,
$departmentId
)
->
first
();
if
(
!
empty
(
$department
))
{
$department
=
$department
->
toArray
();
//找出自己的parent_id,如果是0代表自己就是顶级部门信息了
if
(
$department
[
'parent_id'
]
==
0
)
{
return
$department
;
}
$department
=
$departmentModel
->
where
(
'department_id'
,
$department
[
'parent_id'
])
->
first
()
->
toArray
();
return
$department
;
}
return
[];
}
}
\ No newline at end of file
app/Http/Services/SupplierShareApplyService.php
0 → 100644
View file @
6b7855a7
<?php
namespace
App\Http\Services
;
//后台用户相关信息服务
use
App\Http\Transformers\LogTransformer
;
use
App\Http\Transformers\SupplierShareApplyTransformer
;
use
App\Model\DepartmentModel
;
use
App\Model\LogModel
;
use
App\Model\RedisModel
;
use
App\Model\RegionModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierShareApplyModel
;
use
Illuminate\Support\Facades\DB
;
//用于判断是否已经查看的服务
class
SupplierShareApplyService
{
//通过
const
STATUS_PASS
=
2
;
//待复审
const
STATUS_NEED_REVIEW
=
1
;
//待审核
const
STATUS_PENDING
=
0
;
//审核不通过
const
STATUS_AUDIT_REJECT
=
-
1
;
//复审不通过
const
STATUS_REVIEW_REJECT
=
-
2
;
public
function
getSupplierShareApplyList
(
$userId
)
{
$applyModel
=
new
SupplierShareApplyModel
();
$limit
=
request
()
->
get
(
'limit'
,
10
);
$query
=
$applyModel
::
with
([
'supplier'
=>
function
(
$q
)
{
$q
->
select
([
'supplier_name'
,
'supplier_id'
]);
}])
->
where
(
'create_uid'
,
$userId
)
->
orderBy
(
'id'
,
'desc'
);
$list
=
$query
->
paginate
(
$limit
)
->
toArray
();
$transformer
=
new
SupplierShareApplyTransformer
();
$list
[
'data'
]
=
$transformer
->
transformList
(
$list
[
'data'
]);
return
$list
;
}
public
function
checkApplySupplierShare
(
$supplier
)
{
$supplier
=
$supplier
->
toArray
();
//找出采购,开发员,创建者所属部门,一个供应商可能和多个部门相关,因为采购可能有自营或者联营的
$purchaseUid
=
$supplier
[
'purchase_uid'
];
$channelUids
=
explode
(
','
,
$supplier
[
'channel_uid'
]);
$createUid
=
$supplier
[
'create_uid'
];
$departmentService
=
new
DepartmentService
();
$adminService
=
new
AdminUserService
();
$purchaseUser
=
$adminService
->
getAdminUserInfoByCodeId
(
$purchaseUid
);
$purchaseDepartment
=
$departmentService
->
getTopDepartmentByUserId
(
$purchaseUser
[
'userId'
]);
$createDepartment
=
$departmentService
->
getTopDepartmentByUserId
(
$createUid
);
$allDepartments
=
[];
if
(
!
empty
(
$purchaseDepartment
))
{
$allDepartments
[]
=
$purchaseDepartment
;
}
if
(
!
in_array
(
$createDepartment
,
$allDepartments
))
{
$allDepartments
[]
=
$createDepartment
;
}
if
(
!
empty
(
$channelUids
))
{
foreach
(
$channelUids
as
$channelUid
)
{
$channelUser
=
$adminService
->
getAdminUserInfoByCodeId
(
$channelUid
);
$channelDepartment
=
$departmentService
->
getTopDepartmentByUserId
(
$channelUser
[
'userId'
]);
if
(
!
in_array
(
$channelDepartment
,
$allDepartments
)
&&
!
empty
(
$channelDepartment
))
{
$allDepartments
[]
=
$channelDepartment
;
}
}
}
return
$allDepartments
;
}
//保存申请
public
function
saveSupplierShareApply
(
$map
)
{
$departmentModel
=
new
DepartmentModel
();
$departmentName
=
$departmentModel
->
where
(
'department_id'
,
$map
[
'department_id'
])
->
value
(
'department_name'
);
$data
=
$map
;
$data
[
'department_name'
]
=
$departmentName
;
$data
[
'status'
]
=
0
;
$data
[
'create_time'
]
=
time
();
$data
[
'create_uid'
]
=
$map
[
'apply_user_id'
];
$applyModel
=
new
SupplierShareApplyModel
();
return
$applyModel
->
insert
(
$data
);
}
//校验是否已经有存在的申请
public
function
checkHasNoFinishApply
(
$map
)
{
$applyModel
=
new
SupplierShareApplyModel
();
$count
=
$applyModel
->
where
(
'supplier_id'
,
$map
[
'supplier_id'
])
->
where
(
'apply_user_id'
,
$map
[
'apply_user_id'
])
->
where
(
'department_id'
,
$map
[
'department_id'
])
->
whereNotIn
(
'status'
,
[
$this
::
STATUS_AUDIT_REJECT
,
$this
::
STATUS_REVIEW_REJECT
])
->
count
();
return
$count
;
}
}
\ No newline at end of file
app/Http/Transformers/SupplierShareApplyTransformer.php
0 → 100644
View file @
6b7855a7
<?php
namespace
App\Http\Transformers
;
use
App\Http\Services\LogService
;
class
SupplierShareApplyTransformer
{
public
function
transformList
(
$list
)
{
foreach
(
$list
as
&
$item
)
{
$item
[
'create_time'
]
=
date
(
'Y-m-d H:i:s'
,
$item
[
'create_time'
]);
$item
[
'status_name'
]
=
array_get
(
config
(
'field.SupplierShareApplyStatus'
),
$item
[
'status'
]);
}
unset
(
$item
);
return
$list
;
}
}
\ No newline at end of file
app/Http/routes.php
View file @
6b7855a7
...
...
@@ -19,6 +19,7 @@ Route::group(['middleware' => ['web', 'menu']], function () {
Route
::
match
([
'get'
,
'post'
],
'/supplier_contact/{key}'
,
'SupplierContactController@info'
);
Route
::
match
([
'get'
,
'post'
],
'/supplier_receipt/{key}'
,
'SupplierReceiptController@info'
);
Route
::
match
([
'get'
,
'post'
],
'/supplier_account/{key}'
,
'SupplierAccountController@info'
);
Route
::
match
([
'get'
,
'post'
],
'/supplier_share_apply/{key}'
,
'SupplierShareApplyController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/index/{key}'
,
'IndexController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/sku/{key}'
,
'SkuController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/log/{key}'
,
'LogController@Entrance'
);
...
...
@@ -39,6 +40,7 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route
::
match
([
'get'
,
'post'
],
'/api/supplier_sync_log/{key}'
,
'SupplierSyncLogApiController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/api/supplier_account/{key}'
,
'SupplierAccountApiController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/api/supplier_tag/{key}'
,
'SupplierTagApiController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/api/supplier_share_apply/{key}'
,
'SupplierShareApplyApiController@Entrance'
);
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
$service
=
new
\App\Http\Services\DataService
();
...
...
app/Model/DepartmentModel.php
View file @
6b7855a7
...
...
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
class
DepartmentModel
extends
Model
{
protected
$table
=
'department'
;
protected
$primaryKey
=
'department
I
d'
;
protected
$table
=
'
user_
department'
;
protected
$primaryKey
=
'department
_i
d'
;
public
$timestamps
=
false
;
}
app/Model/SupplierShareApplyModel.php
0 → 100644
View file @
6b7855a7
<?php
namespace
App\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
SupplierShareApplyModel
extends
Model
{
protected
$connection
=
'web'
;
protected
$table
=
'supplier_share_apply'
;
public
$timestamps
=
false
;
public
function
supplier
()
{
return
$this
->
hasOne
(
SupplierChannelModel
::
class
,
'supplier_id'
,
'supplier_id'
);
}
}
config/field.php
View file @
6b7855a7
...
...
@@ -77,4 +77,13 @@ return [
'cooperation_agreement'
,
'other_attachment'
,
],
//-2是复审不通过,-1是初审不通过,0是待审核,1是待复审,2是复审通过
'SupplierShareApplyStatus'
=>
[
-
2
=>
'复审不通过'
,
-
1
=>
'初审不通过'
,
0
=>
'审核中'
,
1
=>
'待复审'
,
2
=>
'复审通过'
]
];
\ No newline at end of file
public/plugins/assets/js/common.js
View file @
6b7855a7
...
...
@@ -75,4 +75,4 @@ function ajax(url, data) {
})
layer
.
closeAll
();
return
result
;
}
\ No newline at end of file
}
resources/views/script/ApplySupplierShareScript.blade.php
0 → 100644
View file @
6b7855a7
<script>
layui
.
use
([
'table'
,
'form'
,
'element'
,
'table'
,
'layer'
,
'admin'
],
function
()
{
let
admin
=
layui
.
admin
;
let
form
=
layui
.
form
;
let
table
=
layui
.
table
table
.
render
({
elem
:
'#applyList'
,
url
:
'/api/supplier_share_apply/GetSupplierShareApplyList'
,
method
:
'post'
,
size
:
'sm'
,
limit
:
10
,
cellMinWidth
:
80
//全局定义常规单元格的最小宽度
,
where
:
{}
,
loading
:
true
,
first
:
true
//不显示首页
,
last
:
false
//不显示尾页
,
cols
:
[[
{
field
:
'supplier_name'
,
title
:
'供应商名称'
,
align
:
'center'
,
templet
:
function
(
d
)
{
return
d
.
supplier
?
d
.
supplier
.
supplier_name
:
''
;
}
},
{
field
:
'department_name'
,
title
:
'被申请部门'
,
width
:
150
,
align
:
'center'
},
{
field
:
'create_time'
,
title
:
'申请时间'
,
width
:
150
,
align
:
'center'
},
{
field
:
'status_name'
,
title
:
'状态'
,
width
:
150
,
align
:
'center'
},
]]
,
id
:
'applyList'
,
page
:
{}
});
//点击校验按钮
$
(
'#check_apply_supplier_share'
).
click
(
function
()
{
let
supplierName
=
$
(
'#supplier_name'
).
val
();
let
url
=
'/api/supplier_share_apply/CheckApplySupplierShare?supplier_name='
+
supplierName
;
let
res
=
ajax
(
url
);
if
(
res
.
err_code
===
0
)
{
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
//设置对应的supplier_id,后端暂时放到res.count这个字段吧...
let
supplierId
=
res
.
count
;
$
(
'#supplier_id'
).
val
(
supplierId
);
//渲染下拉框
let
optionHtml
=
'
<
option
value
=
""
>
请选择一个部门
<
/option>'
;
$
.
each
(
res
.
data
,
function
(
index
,
value
)
{
optionHtml
+=
"
<
option
value
=
'" + value.department_id + "'
>
" + value.department_name + "
<
/option>
"
})
$
(
'#department_id'
).
html
(
optionHtml
);
form
.
render
(
'select'
);
}
else
{
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
}
});
form
.
on
(
'submit(save_supplier_share_apply)'
,
function
(
data
)
{
admin
.
btnLoading
(
'.submit-loading'
);
let
url
=
'/api/supplier_share_apply/SaveSupplierShareApply'
;
let
res
=
ajax
(
url
,
data
.
field
);
if
(
!
res
)
{
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
}
else
{
if
(
res
.
err_code
===
0
)
{
// admin.closeThisDialog();
parent
.
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
}
else
{
admin
.
btnLoading
(
'.submit-loading'
,
false
);
parent
.
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
}
}
return
false
;
});
form
.
on
(
'submit(cancel)'
,
function
(
data
)
{
admin
.
closeThisDialog
();
});
});
</script>
\ No newline at end of file
resources/views/script/SupplierListScript.blade.php
View file @
6b7855a7
...
...
@@ -515,6 +515,19 @@
}
}
});
//共用供应商申请
$
(
"#apply_supplier_share"
).
click
(
function
()
{
layer
.
open
({
type
:
2
,
content
:
'/supplier_share_apply/ApplySupplierShare?view=iframe'
,
area
:
[
'700px'
,
'80%'
],
title
:
'申请共用供应商'
,
end
:
function
()
{
}
});
});
//点击查询按钮
form
.
on
(
'submit(load)'
,
function
(
data
)
{
//罗盘选项会跳回全部
...
...
@@ -539,7 +552,6 @@
layer
.
load
(
1
);
location
.
reload
();
});
});
//检查是否能够审核,因为审核人只能审自己相关部门人员修改的供应商记录
...
...
resources/views/web/ApplySupplierShare.blade.php
0 → 100644
View file @
6b7855a7
<style>
.layui-form-item
{
margin-bottom
:
5px
;
}
</style>
<div
class=
"layui-card"
>
{{--
<div
class=
"layui-card-header"
style=
"height: 90px"
>
--}}
{{--
</div>
--}}
<div
class=
"layui-card-body"
>
<form
class=
"layui-form"
action=
""
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-col-xs8"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
供应商名称 :
</label>
<div
class=
"layui-inline"
style=
"width: 250px"
>
<input
type=
"text"
id=
"supplier_name"
placeholder=
"请输入供应商名称进行校验"
class=
"layui-input"
value=
""
>
</div>
<input
type=
"hidden"
name=
"supplier_id"
id=
"supplier_id"
>
</div>
<div
class=
"layui-col-xs4"
>
<button
type=
"button"
class=
"layui-btn layui-btn-sm"
id=
"check_apply_supplier_share"
>
校验
</button>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
被申请部门 :
</label>
<div
class=
"layui-inline"
style=
"width: 250px"
>
<select
name=
"department_id"
lay-filter=
"department_id"
id=
"department_id"
>
<option
value=
""
>
请选择一个部门
</option>
</select>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
align=
"center"
style=
"margin-top: 20px;text-align: right"
>
<button
type=
"button"
class=
"layui-btn layui-btn-sm layui-btn-info submit-loading"
lay-submit
lay-filter=
"save_supplier_share_apply"
>
确认
</button>
<button
type=
"button"
class=
"layui-btn layui-btn-sm layui-btn-primary"
lay-submit
lay-filter=
"cancel"
>
取消
</button>
</div>
</div>
</form>
</div>
</div>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
步骤 :
</b>
<br>
<b>
1.将你要申请共用的供应商名称粘贴到输入框后点击校验
</b>
<br>
<b>
2.如果校验后系统存在该供应商,下拉框会出现供应商所属部门,选择其中一个进行申请即可
</b>
<br>
</blockquote>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
历史申请 :
</b>
</blockquote>
<table
class=
"layui-table"
id=
"applyList"
lay-filter=
"applyList"
></table>
resources/views/web/SupplierList.blade.php
View file @
6b7855a7
...
...
@@ -39,7 +39,17 @@
金蝶同步
</button>
@endif
@if(checkPerm('ApplySupplierShare'))
{{-- @if(checkPerm('BlockSupplier'))--}}
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
apply_supplier_share
">
共用申请
</button>
@endif
@if(checkPerm('AuditSupplierShare'))
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
audit_supplier_share
">
共用审核
</button>
@endif
</div>
<button type="
button
" id="
refreshWindow
" style="
display
:
none
">刷新页面</button>
<table class="
layui
-
table
" id="
list
" lay-filter="
list
"></table>
...
...
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