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
2cb12144
authored
Apr 17, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
转移供应商联系人完成
parent
04172cec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
16 deletions
app/Http/Controllers/Api/SupplierContactApiController.php
resources/views/script/TransferSupplierScript.blade.php
app/Http/Controllers/Api/SupplierContactApiController.php
View file @
2cb12144
...
@@ -174,12 +174,52 @@ class SupplierContactApiController extends Controller
...
@@ -174,12 +174,52 @@ class SupplierContactApiController extends Controller
}
}
//转移供应商联系人
//转移供应商联系人
public
function
TransferSupplierContact
(
$
supplierId
,
$originCanCheckUid
,
$newCanCheckUid
)
public
function
TransferSupplierContact
(
$
request
)
{
{
return
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$supplierId
,
$originCanCheckUid
,
$newCanCheckUid
)
{
$supplierId
=
$request
->
input
(
'supplier_id'
);
//直接去批量修改即可
$originCanCheckUids
=
$request
->
input
(
'can_check_uids'
);
return
SupplierContactModel
::
where
(
'supplier_id'
,
$supplierId
)
->
where
(
'can_check_uids'
,
$originCanCheckUid
)
$newCanCheckUids
=
$request
->
input
(
'new_can_check_uids'
);
->
update
([
'can_check_uids'
=>
$newCanCheckUid
]);
if
(
empty
(
$supplierId
))
{
$this
->
response
(
-
1
,
'供应商id不能为空'
);
}
if
(
empty
(
$originCanCheckUids
)
||
empty
(
$newCanCheckUids
))
{
$this
->
response
(
-
1
,
'采购员信息不完整'
);
}
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$supplierId
,
$originCanCheckUids
,
$newCanCheckUids
)
{
//还要先去判断这个人是否存在于采购员里面,不存在的话还要去新增
$supplier
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
first
()
->
toArray
();
$channelUid
=
explode
(
','
,
$supplier
[
'channel_uid'
]);
if
(
in_array
(
$originCanCheckUids
,
$channelUid
))
{
//删除
$channelUid
=
array_filter
(
$channelUid
,
function
(
$value
)
use
(
$originCanCheckUids
)
{
return
$value
!=
$originCanCheckUids
;
});
}
if
(
!
in_array
(
$newCanCheckUids
,
$channelUid
))
{
$channelUid
[]
=
$newCanCheckUids
;
}
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$supplierId
,
$channelUid
,
$originCanCheckUids
,
$newCanCheckUids
)
{
//还要判断是否是芯链采购员
if
(
SupplierChannelModel
::
where
(
'yunxin_channel_uid'
,
$originCanCheckUids
)
->
where
(
'supplier_id'
,
$supplierId
)
->
exists
())
{
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'yunxin_channel_uid'
=>
$newCanCheckUids
]);
}
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'channel_uid'
=>
implode
(
','
,
$channelUid
),
]);
//最后直接去批量修改即可
return
SupplierContactModel
::
where
(
'supplier_id'
,
$supplierId
)
->
where
(
'can_check_uids'
,
$originCanCheckUids
)
->
update
([
'can_check_uids'
=>
$newCanCheckUids
]);
});
});
});
$this
->
response
(
0
,
'转移供应商联系人成功'
);
}
}
}
}
resources/views/script/TransferSupplierScript.blade.php
View file @
2cb12144
...
@@ -5,23 +5,31 @@
...
@@ -5,23 +5,31 @@
let
table
=
layui
.
table
let
table
=
layui
.
table
let
element
=
layui
.
element
;
let
element
=
layui
.
element
;
form
.
on
(
'submit(
block
Supplier)'
,
function
(
data
)
{
form
.
on
(
'submit(
transfer
Supplier)'
,
function
(
data
)
{
admin
.
showLoading
({
admin
.
showLoading
({
type
:
3
,
type
:
3
,
});
});
let
url
=
'/api/supplier/transferSupplier?supplier_id='
+
getQueryVariable
(
'supplier_id'
);
let
url
=
'/api/supplier_contact/TransferSupplierContact?supplier_id='
+
getQueryVariable
(
'supplier_id'
);
let
res
=
ajax
(
url
,
data
);
let
res
=
$
.
get
(
url
,
data
.
field
,
function
(
res
)
{
if
(
!
res
)
{
if
(
!
res
)
{
admin
.
removeLoading
();
admin
.
removeLoading
();
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
}
else
{
if
(
res
.
err_code
===
0
)
{
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
}
else
{
}
else
{
admin
.
removeLoading
();
admin
.
removeLoading
();
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
res
=
JSON
.
parse
(
res
);
if
(
res
.
err_code
===
0
)
{
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
setTimeout
(
function
()
{
admin
.
closeThisDialog
();
},
500
);
}
else
{
admin
.
removeLoading
();
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
return
false
;
}
}
}
}
});
return
false
;
return
false
;
});
});
});
});
...
...
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