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
1c409391
authored
Apr 26, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
审核判断临时供应商
parent
4c29f558
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
154 additions
and
70 deletions
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Services/SupplierAttachmentService.php
app/Http/Services/SupplierService.php
app/Http/Validators/SupplierValidator.php
resources/views/script/AddSupplierScript.blade.php
resources/views/script/UpdateSupplierScript.blade.php
resources/views/script/supplier/ApplyAuditReasonScript.blade.php
resources/views/script/supplier/SupplierBaseScript.blade.php
resources/views/web/AddSupplier.blade.php
resources/views/web/UpdateSupplier.blade.php
resources/views/web/supplier/ApplyAuditReason.blade.php
resources/views/web/supplier/SupplierFile.blade.php
app/Http/Controllers/Api/SupplierApiController.php
View file @
1c409391
...
...
@@ -82,7 +82,14 @@ class SupplierApiController extends Controller
'pay_type'
,
'pay_type_value'
,
'pay_type_extra'
,
'supplier_type'
'supplier_type'
,
//附件
'file_name'
,
'file_url'
,
'field_name'
,
'validity_type'
,
'validity_period'
,
];
public
function
Entrance
(
Request
$request
,
$id
)
...
...
@@ -97,10 +104,13 @@ class SupplierApiController extends Controller
$validator
=
new
SupplierValidator
();
$data
=
$request
->
all
();
//直接提交的不需要做复杂的表单校验
$isAudit
=
false
;
dd
(
$data
);
if
(
request
()
->
get
(
'direct_apply'
))
{
$validateResult
=
$validator
->
checkSave
(
$data
,
true
);
$isAudit
=
true
;
$validateResult
=
$validator
->
checkSave
(
$data
,
$isAudit
);
}
else
{
$validateResult
=
$validator
->
checkSave
(
$data
,
false
);
$validateResult
=
$validator
->
checkSave
(
$data
,
$isAudit
);
}
if
(
$validateResult
)
{
$this
->
response
(
-
1
,
$validateResult
);
...
...
@@ -118,11 +128,20 @@ class SupplierApiController extends Controller
]);
$channel
=
$request
->
only
(
$channelMap
);
$service
=
new
SupplierService
();
$
result
=
$service
->
saveSupplier
(
$channel
);
if
(
!
$
result
)
{
$
supplierId
=
$service
->
saveSupplier
(
$channel
);
if
(
!
$
supplierId
)
{
$this
->
response
(
-
1
,
'操作失败'
);
}
//如果是申请审核,还要去修改审核状态
if
(
$isAudit
)
{
$supplierService
=
new
SupplierService
();
$auditData
[]
=
[
'supplier_id'
=>
$supplierId
,
//供应商类型为临时供应商,才会去存申请理由
'apply_audit_reason'
=>
$channel
[
'supplier_type'
]
==
2
?
$request
->
input
(
'apply_audit_reason'
)
:
''
,
];
$supplierService
->
batchApplyInReviewSupplier
(
$auditData
);
}
$this
->
response
(
0
,
'操作成功'
);
}
...
...
@@ -140,7 +159,6 @@ class SupplierApiController extends Controller
}
$channelMap
=
array_merge
(
$this
->
channelMap
,
config
(
'field.AttachmentFields'
));
$channel
=
$request
->
only
(
$channelMap
);
// dd($channel);
$service
=
new
SupplierService
();
$result
=
$service
->
saveSupplier
(
$channel
);
if
(
!
$result
)
{
...
...
@@ -151,7 +169,8 @@ class SupplierApiController extends Controller
$supplierService
=
new
SupplierService
();
$auditData
[]
=
[
'supplier_id'
=>
$supplierId
,
'apply_audit_reason'
=>
'申请审核'
,
//供应商类型为临时供应商,才会去存申请理由
'apply_audit_reason'
=>
$channel
[
'supplier_type'
]
==
2
?
$request
->
input
(
'apply_audit_reason'
)
:
''
,
];
$supplierService
->
batchApplyInReviewSupplier
(
$auditData
);
}
...
...
app/Http/Services/SupplierAttachmentService.php
View file @
1c409391
...
...
@@ -35,7 +35,7 @@ class SupplierAttachmentService
$attachment
[
'validity_start'
]
=
strtotime
(
trim
(
$validityPeriod
[
0
]));
$attachment
[
'validity_end'
]
=
strtotime
(
trim
(
$validityPeriod
[
1
]));
}
if
(
$attachment
[
'validity_type'
]
==
1
)
{
if
(
$attachment
[
'validity_type'
]
==
1
)
{
$attachment
[
'validity_start'
]
=
$attachment
[
'validity_end'
]
=
0
;
}
$attachment
[
'type_name'
]
=
array_get
(
config
(
'fixed.FileNameMapping'
),
$attachment
[
'field_name'
]);
...
...
@@ -54,13 +54,24 @@ class SupplierAttachmentService
}
//新增附件来源于新增页面,数据要转换
public
static
function
addAttachmentFromAddPage
(
$supplierId
,
$attachmentData
)
public
static
function
addAttachmentFromAddPage
(
$supplierId
,
$attachmentData
)
{
//恢复正常的坐标
$attachmentData
=
array_map
(
function
(
$item
)
{
if
(
is_array
(
$item
))
{
$item
=
array_values
(
$item
);
}
return
$item
;
},
$attachmentData
);
if
(
empty
(
$attachmentData
))
{
return
true
;
}
$attachments
=
[];
foreach
(
count
(
$attachmentData
[
'file_name'
])
as
$key
=>
$value
)
{
foreach
(
$attachmentData
[
'file_name'
]
as
$key
=>
$value
)
{
//最后一个跳过,因为是模板里的数据
if
(
$key
==
(
count
(
$attachmentData
[
'file_name'
])
-
1
))
{
continue
;
}
$attachment
=
[
'supplier_id'
=>
$supplierId
,
'file_name'
=>
$attachmentData
[
'file_name'
][
$key
],
...
...
@@ -69,15 +80,19 @@ class SupplierAttachmentService
'validity_type'
=>
$attachmentData
[
'validity_type'
][
$key
],
'create_uid'
=>
request
()
->
user
->
userId
,
'create_name'
=>
request
()
->
user
->
name
,
'type_name'
=>
array_get
(
config
(
'fi
eld.AttachmentFields
'
),
$attachmentData
[
'field_name'
][
$key
]),
'type_name'
=>
array_get
(
config
(
'fi
xed.FileNameMapping
'
),
$attachmentData
[
'field_name'
][
$key
]),
];
if
(
$attachmentData
[
'validity_period'
]
)
{
$validityPeriod
=
explode
(
'~'
,
$attachmentData
[
'validity_period'
]);
if
(
!
empty
(
$attachmentData
[
'validity_period'
][
$key
])
)
{
$validityPeriod
=
explode
(
'~'
,
$attachmentData
[
'validity_period'
]
[
$key
]
);
$attachment
[
'validity_start'
]
=
strtotime
(
trim
(
$validityPeriod
[
0
]));
$attachment
[
'validity_end'
]
=
strtotime
(
trim
(
$validityPeriod
[
1
]));
}
$attachments
[]
=
$attachment
;
}
return
SupplierAttachmentsModel
::
insert
(
$attachments
);
$attachments
=
array_unique
(
$attachments
);
if
(
!
$attachments
)
{
return
SupplierAttachmentsModel
::
insert
(
$attachments
);
}
return
true
;
}
}
\ No newline at end of file
app/Http/Services/SupplierService.php
View file @
1c409391
...
...
@@ -46,7 +46,7 @@ class SupplierService
}
//走事务
$
dataResult
=
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$channel
,
$model
,
$oldSupplier
)
{
$
supplierId
=
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$channel
,
$model
,
$oldSupplier
)
{
$tagService
=
new
SupplierTagService
();
//获取附加税数据
...
...
@@ -154,7 +154,6 @@ class SupplierService
$contact
[
'admin_id'
]
=
request
()
->
user
->
userId
;
SupplierContactModel
::
insert
(
$contact
);
}
//添加附件
SupplierAttachmentService
::
addAttachmentFromAddPage
(
$supplierId
,
$attachmentData
);
...
...
@@ -248,7 +247,7 @@ class SupplierService
//保存和搜索相关的标签情况
$supplierSearchTagService
=
new
SupplierSearchTagService
();
$supplierSearchTagService
->
saveSupplierSearchTags
(
$supplierId
);
return
true
;
return
$supplierId
;
});
//保存日志
...
...
@@ -274,7 +273,7 @@ class SupplierService
unset
(
$oldSupplier
[
'update_time'
]);
unset
(
$newSupplier
[
'update_time'
]);
if
(
$oldSupplier
==
$newSupplier
)
{
return
$
dataResult
;
return
$
supplierId
;
}
}
...
...
@@ -282,7 +281,7 @@ class SupplierService
'old_supplier'
=>
$oldSupplier
,
'new_supplier'
=>
$newSupplier
]));
return
$
dataResult
;
return
$
supplierId
;
}
...
...
app/Http/Validators/SupplierValidator.php
View file @
1c409391
...
...
@@ -81,7 +81,7 @@ class SupplierValidator
//只有在提交供应商是正式的时候,才会去校验附件
//校验附件这块,新增和修改判断的逻辑不一样
if
(
empty
(
$supplierId
))
{
$attachmentFields
=
$validateData
[
'field_name'
]
;
$attachmentFields
=
array_unique
(
$validateData
[
'field_name'
])
;
}
else
{
$attachmentFields
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplierId
)
->
get
()
->
pluck
(
'field_name'
)
->
toArray
();
...
...
resources/views/script/AddSupplierScript.blade.php
View file @
1c409391
<script>
layui
.
use
([
'table'
,
'form'
,
'element'
,
'layer'
,
'admin'
,
'laydate'
,
'xmSelect'
,
'upload'
],
function
()
{
layui
.
use
([
'table'
,
'form'
,
'element'
,
'layer'
,
'admin'
,
'laydate'
,
'xmSelect'
,
'upload'
],
function
()
{
let
admin
=
layui
.
admin
;
let
form
=
layui
.
form
;
let
laydate
=
layui
.
laydate
;
...
...
@@ -34,13 +34,7 @@
,
shade
:
0.01
});
let
item
=
this
.
item
;
//预读本地文件示例,不支持ie8
obj
.
preview
(
function
(
index
,
file
,
result
)
{
// if (file.type.indexOf('image') !== -1){
// $('#' + item.attr('preview')).attr('src', result); //图片链接(base64)
// }else{
// $('#' + item.attr('preview')).attr('src', '/images/file.png');
// }
});
}
,
done
:
function
(
res
)
{
...
...
@@ -81,29 +75,49 @@
return
false
;
});
form
.
on
(
'select(apply_audit_reason_selector)'
,
function
(
data
)
{
$
(
'#apply_audit_reason'
).
val
(
data
.
value
);
});
form
.
on
(
'submit(addAndApplySupplier)'
,
function
(
data
)
{
if
(
data
.
field
.
supplier_type
===
'2'
)
{
layer
.
open
({
type
:
1
,
area
:
[
'450px'
,
'370px'
],
//宽高
content
:
$
(
'#apply_audit_reason_div'
),
btn
:
[
'保存并申请审核'
,
'取消'
],
btn1
:
function
(
index
,
layero
)
{
//点击保存按钮
addSupplier
(
data
);
layer
.
close
(
index
);
},
});
}
else
{
layer
.
confirm
(
'确定直接申请审核吗?确定后会直接进入审核中的状态,审核完成前无法进行二次修改'
,
function
(
index
)
{
addSupplier
(
data
);
});
}
layer
.
confirm
(
'确定直接申请审核吗?确定后会直接进入审核中的状态,无法进行二次修改,审核完成前无法进行二次修改'
,
function
(
index
)
{
//还要判断
let
url
=
'/api/supplier/AddSupplier?direct_apply=1'
;
let
res
=
ajax
(
url
,
data
.
field
);
if
(
!
res
)
{
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
}
else
{
if
(
res
.
err_code
===
0
)
{
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
admin
.
closeThisTabs
();
}
else
{
let
errMsg
=
res
.
err_msg
;
let
msg
=
''
;
$
.
each
(
errMsg
.
split
(
'|'
),
function
(
index
,
value
)
{
msg
+=
"
<
span
>
" + value + "
<
/span><br>
"
});
layer
.
msg
(
msg
,
{
icon
:
5
})
}
}
});
return
false
;
});
function
addSupplier
(
data
)
{
let
url
=
'/api/supplier/AddSupplier?direct_apply=1'
;
let
res
=
ajax
(
url
,
data
.
field
);
if
(
!
res
)
{
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
}
else
{
if
(
res
.
err_code
===
0
)
{
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
admin
.
closeThisTabs
();
}
else
{
let
errMsg
=
res
.
err_msg
;
let
msg
=
''
;
$
.
each
(
errMsg
.
split
(
'|'
),
function
(
index
,
value
)
{
msg
+=
"
<
span
>
" + value + "
<
/span><br>
"
});
layer
.
msg
(
msg
,
{
icon
:
5
})
}
}
}
});
</script>
\ No newline at end of file
resources/views/script/UpdateSupplierScript.blade.php
View file @
1c409391
...
...
@@ -29,12 +29,34 @@
});
})
form.on('
select
(
apply_audit_reason_selector
)
', function (data) {
$('
#
apply_audit_reason
').val(data.value);
});
form.on('
submit
(
applyAuditSupplier
)
', function (data) {
let confirmMessage = '
确定直接申请审核吗
?
确定后会直接进入审核中的状态
,
审核完成前无法进行二次修改
';
layer.confirm(confirmMessage, function (index) {
data.field.is_audit = 1;
updateSupplier(data);
});
data.field.is_audit = 1;
if (data.field.supplier_type === '
2
') {
layer.open({
type: 1,
area: ['
450
px
', '
370
px
'], //宽高
content: $('
#
apply_audit_reason_div
'),
btn: ['
保存并申请审核
', '
取消
'],
btn1: function (index, layero) {//点击保存按钮
updateSupplier(data);
layer.close(index);
},
});
} else {
layer.confirm('
确定直接申请审核吗
?
确定后会直接进入审核中的状态
,
审核完成前无法进行二次修改
', function (index) {
updateSupplier(data);
});
}
// let confirmMessage = '
确定直接申请审核吗
?
确定后会直接进入审核中的状态
,
审核完成前无法进行二次修改
';
// layer.confirm(confirmMessage, function (index) {
// data.field.is_audit = 1;
// updateSupplier(data);
// });
});
function updateSupplier(data) {
...
...
resources/views/script/supplier/ApplyAuditReasonScript.blade.php
0 → 100644
View file @
1c409391
File mode changed
resources/views/script/supplier/SupplierBaseScript.blade.php
View file @
1c409391
...
...
@@ -70,10 +70,10 @@
let
supplier_type
=
data
.
value
;
if
(
supplier_type
===
'1'
)
{
$
(
'#attachment_required_span'
).
show
();
$
(
'#apply_audit_button'
).
show
();
//
$('#apply_audit_button').show();
}
else
{
$
(
'#attachment_required_span'
).
hide
();
$
(
'#apply_audit_button'
).
hide
();
//
$('#apply_audit_button').hide();
}
});
...
...
resources/views/web/AddSupplier.blade.php
View file @
1c409391
...
...
@@ -34,6 +34,9 @@
<b>
基本信息
</b>
</blockquote>
<form
class=
"layui-form"
action=
""
>
<input
type=
"hidden"
name=
"apply_audit_reason"
id=
"apply_audit_reason"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-col-md5"
>
@inject('singleSelectPresenter','App\Presenters\SingleSelectPresenter')
...
...
@@ -363,6 +366,7 @@
<b>
附件管理
</b>
</blockquote>
@include('web.supplier.SupplierFile')
@include('web.supplier.ApplyAuditReason')
<div
class=
"layui-form-item"
style=
"margin-top: 10px;margin-left: 10px"
>
<p>
<b>
特别说明:
</b>
...
...
resources/views/web/UpdateSupplier.blade.php
View file @
1c409391
...
...
@@ -125,6 +125,7 @@
<div
class=
"layui-tab-content"
>
<div
class=
"layui-tab-item @if(request()->get('tab')=='base_info'||empty(request()->get('tab'))) layui-show @endif"
>
<div
class=
"layui-row"
style=
"padding: 10px"
>
<input
type=
"hidden"
name=
"apply_audit_reason"
id=
"apply_audit_reason"
>
<input
type=
"hidden"
name=
"status"
value=
"{{$supplier['status'] or 0}}"
>
<div
class=
"layui-row"
>
@include('web.supplier.SupplierBase')
...
...
@@ -145,17 +146,6 @@
</div>
</div>
</div>
{{--
<div
class=
"layui-row"
>
--}}
{{--
<div
class=
"layui-col-md3"
>
--}}
{{--
<div
class=
"layui-inline"
>
--}}
{{-- @inject('statusPresenter','App\Presenters\StatusPresenter')--}}
{{-- {!! $statusPresenter->render('trading_method','交易方式 : ',--}}
{{-- isset($supplier)?$supplier['trading_method']:'',config('fixed.TradingMethod'),['required'=>false]) !!}--}}
{{--
</div>
--}}
{{--
</div>
--}}
{{--
<div
class=
"layui-col-md3"
>
--}}
{{--
</div>
--}}
{{--
</div>
--}}
<blockquote
class=
"layui-elem-quote layui-text"
>
<b><span
class=
"require"
>
*
</span>
财务信息
</b>
</blockquote>
...
...
@@ -244,6 +234,6 @@
<div
class=
"layui-tab-item"
>
内容5
</div>
</div>
</div>
</div>
</form>
@include('web.supplier.ApplyAuditReason')
</form>
</div>
resources/views/web/supplier/ApplyAuditReason.blade.php
0 → 100644
View file @
1c409391
<div
id=
"apply_audit_reason_div"
style=
"display:none;"
>
<div
style=
"margin:20px;"
>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
申请审核理由
</b>
(供应商类别为临时的时候,才会让选择申请审核理由)
</blockquote>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
申请理由 :
</label>
<div
class=
"layui-input-inline"
>
<select
lay-filter=
"apply_audit_reason_selector"
>
<option
value=
""
>
请选择
</option>
@foreach (config('field.ApplyAuditReason') as $item)
<option
value=
"{{$item}}"
>
{{$item}}
</option>
@endforeach
</select>
</div>
</div>
</div>
</div>
\ No newline at end of file
resources/views/web/supplier/SupplierFile.blade.php
View file @
1c409391
...
...
@@ -53,9 +53,8 @@
</div>
<div
class=
"layui-col-md7"
>
<label
class=
"layui-form-label"
>
有效期 :
</label>
<div
class=
"layui-input-inline"
style=
"width: 100px"
>
$attachmentFields
<div
class=
"layui-input-inline"
style=
"width: 100px"
>
<select
name=
"validity_type[]"
lay-filter=
"validity_period_selector"
>
<option
value=
""
>
请选择
</option>
<option
value=
"1"
>
长期有效
</option>
<option
value=
"2"
>
自定义
</option>
</select>
...
...
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