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
d95eeaf8
authored
Aug 07, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' into ysx-SKU上传同步芯链选项交互优化&新建供应商期货默认项更改-20250804
parents
6718b5ba
3d7ac1b2
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
346 additions
and
156 deletions
.codeiumignore
app/Console/Commands/SupplierRecallMailRemind.php
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Controllers/Api/SupplierContractApiController.php
app/Http/Controllers/Filter/SupplierFilter.php
app/Http/Controllers/SupplierContractController.php
app/Http/Controllers/SupplierController.php
app/Http/Services/SupplierContactService.php
app/Http/Services/SupplierContractService.php
app/Http/Validators/SupplierValidator.php
app/Http/routes.php
config/field.php
config/validate.php
resources/views/script/SupplierDetailScript.blade.php
resources/views/script/UpdateSupplierContactScript.blade.php
resources/views/script/supplier/SupplierPayTypeScript.blade.php
resources/views/web/SupplierDetail.blade.php
resources/views/web/supplier/SupplierPayType.blade.php
.codeiumignore
View file @
d95eeaf8
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
vendor/
storage/
public/
app/Console/Commands/SupplierRecallMailRemind.php
View file @
d95eeaf8
...
...
@@ -28,14 +28,66 @@ class SupplierRecallMailRemind extends Command
*/
protected
$description
=
'寄售召回期邮件提醒(提前30天、7天)'
;
/**
* 上传CSV文件到文件系统
*
* @param string $filePath
* @param string $fileName
* @return string|null
*/
private
function
uploadCsvFile
(
$filePath
,
$fileName
)
{
try
{
// 检查文件是否存在
if
(
!
file_exists
(
$filePath
))
{
return
null
;
}
// 创建cURL文件对象
$cfile
=
curl_file_create
(
$filePath
,
'text/csv'
,
$fileName
);
// 准备POST数据
$post
=
[
[
'name'
=>
'file'
,
'contents'
=>
fopen
(
$filePath
,
'r'
),
],
];
$client
=
new
\GuzzleHttp\Client
();
$response
=
$client
->
request
(
'POST'
,
'https://files.ichunt.net/uploadFile?sys_type=5&create_uid=1000'
,
[
'multipart'
=>
$post
,
]);
// 检查是否有错误
if
(
$response
->
getStatusCode
()
!==
200
)
{
$error
=
$response
->
getBody
()
->
getContents
();
$this
->
error
(
"文件上传失败:
{
$error
}
"
);
return
null
;
}
// 解析响应
$result
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
// 检查上传是否成功
if
(
isset
(
$result
[
'code'
])
&&
$result
[
'code'
]
==
0
&&
isset
(
$result
[
'data'
][
'oss_file_url'
]))
{
return
$result
[
'data'
][
'oss_file_url'
];
}
else
{
$errorMsg
=
isset
(
$result
[
'msg'
])
?
$result
[
'msg'
]
:
'未知错误'
;
$this
->
error
(
"文件上传失败:
{
$errorMsg
}
"
);
return
null
;
}
}
catch
(
\Exception
$e
)
{
$this
->
error
(
"文件上传异常: "
.
$e
->
getMessage
());
return
null
;
}
}
public
function
handle
()
{
$today
=
Carbon
::
today
();
$contracts
=
SupplierContractModel
::
with
(
'supplier'
)
->
where
(
'recall_time'
,
'!='
,
0
)
->
get
();
// $contracts = SupplierContractModel::with('supplier')->where('recall_time', '!=', 0)->get();
$contracts
=
SupplierContractModel
::
with
(
'supplier'
)
->
where
(
'recall_time'
,
0
)
->
get
();
$adminUserService
=
new
AdminUserService
();
$messageService
=
new
MessageService
();
$remindDays
=
[
30
,
7
];
foreach
(
$contracts
as
$contract
)
{
//判断有没有上架的sku,通过搜索接口查询
$map
[
'p'
]
=
1
;
...
...
@@ -45,46 +97,44 @@ class SupplierRecallMailRemind extends Command
$url
=
env
(
'ES_SKU_URL'
,
''
);
$map
[
'show_status'
]
=
1
;
$map
[
'no_rule'
]
=
1122
;
try
{
$url
=
base64_encode
(
$url
.
'?'
.
http_build_query
(
$map
));
$return
=
curl
(
config
(
'website.FootstoneCurlUrl'
)
.
$url
);
$data
=
json_decode
(
$return
,
true
);
if
(
isset
(
$data
[
'error_code'
])
&&
$data
[
'error_code'
]
==
0
)
{
$searchResult
=
$data
[
'data'
][
'goods_id'
];
$skuDataList
=
[];
$redis
=
new
RedisModel
();
$spuRedis
=
Redis
::
connection
(
'spu'
);
foreach
(
$searchResult
as
$goodsId
)
{
$sku
=
json_decode
(
$redis
->
hget
(
'sku'
,
$goodsId
),
true
);
if
(
empty
(
$sku
))
{
continue
;
}
$spu
=
json_decode
(
$spuRedis
->
hget
(
'spu'
,
$sku
[
'spu_id'
]),
true
);
//去获取标准品牌名称
$standardBrandId
=
$spu
[
's_brand_id'
];
$standardBrand
=
$redis
->
hget
(
'standard_brand'
,
$standardBrandId
);
if
(
empty
(
$standardBrand
))
{
continue
;
}
$skuDataList
[]
=
[
'spu_name'
=>
$spu
[
'spu_name'
],
'brand_name'
=>
$standardBrand
[
'brand_name'
],
'stock'
=>
$sku
[
'stock'
],
];
$url
=
base64_encode
(
$url
.
'?'
.
http_build_query
(
$map
));
$return
=
curl
(
config
(
'website.FootstoneCurlUrl'
)
.
$url
);
$data
=
json_decode
(
$return
,
true
);
if
(
isset
(
$data
[
'error_code'
])
&&
$data
[
'error_code'
]
==
0
)
{
$searchResult
=
$data
[
'data'
][
'goods_id'
];
$skuDataList
=
[];
$redis
=
new
RedisModel
();
$spuRedis
=
Redis
::
connection
(
'spu'
);
foreach
(
$searchResult
as
$goodsId
)
{
$sku
=
json_decode
(
$redis
->
hget
(
'sku'
,
$goodsId
),
true
);
if
(
empty
(
$sku
))
{
continue
;
}
$spu
=
json_decode
(
$spuRedis
->
hget
(
'spu'
,
$sku
[
'spu_id'
]),
true
);
//去获取标准品牌名称
$standardBrandId
=
$spu
[
's_brand_id'
];
$standardBrand
=
$redis
->
hget
(
'standard_brand'
,
$standardBrandId
);
if
(
empty
(
$standardBrand
))
{
continue
;
}
}
else
{
$searchResult
=
[];
$standardBrand
=
json_decode
(
$standardBrand
,
true
);
$skuDataList
[]
=
[
'spu_name'
=>
$spu
[
'spu_name'
],
'brand_name'
=>
$standardBrand
[
'brand_name'
],
'stock'
=>
$sku
[
'stock'
],
];
}
}
catch
(
\Exception
$e
)
{
return
$e
->
getMessage
()
;
}
else
{
$searchResult
=
[]
;
}
if
(
empty
(
$searchResult
))
{
continue
;
}
$recallDate
=
Carbon
::
createFromTimestamp
(
$contract
->
recall_time
);
$diff
=
$today
->
diffInDays
(
$recallDate
,
false
);
if
(
!
in_array
(
$diff
,
$remindDays
))
{
continue
;
//
continue;
}
$supplier
=
$contract
->
supplier
;
...
...
@@ -102,8 +152,16 @@ class SupplierRecallMailRemind extends Command
// 采购经理
$manager
=
null
;
if
(
!
empty
(
$purchaseUser
->
department_id
))
{
$departmentIds
=
DB
::
table
(
'department'
)
->
where
(
'parent'
,
$purchaseUser
->
department_id
)
->
orWhere
(
'departmentId'
,
$purchaseUser
->
department_id
)
->
pluck
(
'departmentId'
);
if
(
empty
(
$departmentIds
))
{
continue
;
}
$departmentIds
=
$departmentIds
->
toArray
();
$manager
=
DB
::
table
(
'user_info'
)
->
where
(
'department_id'
,
$purchaseUser
->
department_id
)
->
where
In
(
'department_id'
,
$departmentIds
)
->
where
(
'position_name'
,
'采购经理'
)
->
first
();
if
(
$manager
&&
!
empty
(
$manager
->
email
))
{
...
...
@@ -111,7 +169,7 @@ class SupplierRecallMailRemind extends Command
}
// 采购总监
$director
=
DB
::
table
(
'user_position'
)
->
where
(
'department_id'
,
$purchaseUser
->
department_id
)
->
where
In
(
'department_id'
,
$departmentIds
)
->
where
(
'position_name'
,
'采购总监'
)
->
first
();
if
(
$director
)
{
...
...
@@ -127,20 +185,51 @@ class SupplierRecallMailRemind extends Command
$subject
=
"【寄售召回提醒】距离召回期仅剩
{
$diff
}
天"
;
$content
=
"请及时提醒供应商召回寄售商品
\n
供应商名称:
{
$supplierName
}
\n
召回期:
{
$recallTimeStr
}
"
;
if
(
empty
(
$skuDataList
))
{
continue
;
}
//生成csv
$csvFileName
=
'supplier_recall_skus_'
.
$supplier
->
id
.
'_'
.
time
()
.
'.csv'
;
$csvFilePath
=
storage_path
(
'app/'
.
$csvFileName
);
// 创建CSV文件
$fp
=
fopen
(
$csvFilePath
,
'w'
);
// 添加BOM头以支持中文
fwrite
(
$fp
,
"
\xEF\xBB\xBF
"
);
// 写入标题行
fputcsv
(
$fp
,
[
'商品名称'
,
'品牌'
,
'库存'
]);
// 写入数据行
foreach
(
$skuDataList
as
$sku
)
{
fputcsv
(
$fp
,
[
$sku
[
'spu_name'
],
$sku
[
'brand_name'
],
$sku
[
'stock'
]]);
}
fclose
(
$fp
);
// 上传CSV文件到文件系统
$fileUrl
=
$this
->
uploadCsvFile
(
$csvFilePath
,
$csvFileName
);
// 删除临时CSV文件
if
(
file_exists
(
$csvFilePath
))
{
unlink
(
$csvFilePath
);
}
// 组装邮件数据
$data
=
[
'data'
=>
[
'title'
=>
$subject
,
'content'
=>
$content
,
'content'
=>
$content
.
(
$fileUrl
?
"
\n
CSV文件:
{
$fileUrl
}
"
:
''
)
,
]
];
// 发送邮件
foreach
(
$toEmails
as
$to
)
{
$messageService
->
sendMessage
(
'supplier_recall_remind'
,
$data
,
$to
,
true
);
}
foreach
(
$ccEmails
as
$cc
)
{
$messageService
->
sendMessage
(
'supplier_recall_remind'
,
$data
,
$cc
,
true
);
}
dump
(
$data
);
dump
(
$toEmails
,
$ccEmails
);
// // 发送邮件
// foreach ($toEmails as $to) {
// $messageService->sendMessage('supplier_recall_remind', $data, $to, true);
// }
// foreach ($ccEmails as $cc) {
// $messageService->sendMessage('supplier_recall_remind', $data, $cc, true);
// }
$this
->
info
(
"已发送提醒:供应商
{
$supplierName
}
,召回期
{
$recallTimeStr
}
,剩余
{
$diff
}
天"
);
}
}
...
...
app/Http/Controllers/Api/SupplierApiController.php
View file @
d95eeaf8
...
...
@@ -20,6 +20,7 @@ use App\Http\Services\SyncSupplierService;
use
App\Http\Validators\SupplierValidator
;
use
App\Http\Services\StandardBrandService
;
use
App\Http\Services\SupplierAuditService
;
use
App\Http\Services\SupplierContactService
;
use
App\Http\Transformers\SupplierTransformer
;
use
App\Http\Controllers\Filter\SupplierFilter
;
use
App\Http\Services\SupplierStatisticsService
;
...
...
@@ -511,6 +512,8 @@ class SupplierApiController extends Controller
$result
=
$service
->
allocateChannelUser
(
$supplierId
,
$channelUid
,
$channelUserType
);
}
}
$supplierContactService
=
new
SupplierContactService
();
$supplierContactService
->
updateSupplierCodeData
(
$supplierId
);
}
if
(
!
$result
)
{
...
...
app/Http/Controllers/Api/SupplierContractApiController.php
View file @
d95eeaf8
...
...
@@ -42,16 +42,16 @@ class SupplierContractApiController extends Controller
$validator
=
\Validator
::
make
(
$data
,
[
'supplier_id'
=>
'required|integer'
,
'end_time'
=>
'required|date'
,
'recall_time'
=>
'required|date'
,
'commission_rate'
=>
'numeric|max:100|min:1'
,
'check_date'
=>
'required|integer|min:1|max:31'
],
[
'supplier_id.required'
=>
'供应商ID不能为空'
,
'supplier_id.integer'
=>
'供应商ID必须为整数'
,
'start_time.required'
=>
'合同开始时间不能为空'
,
'start_time.date'
=>
'合同开始时间必须为日期格式'
,
'end_time.required'
=>
'合同结束时间不能为空'
,
'end_time.date'
=>
'合同结束时间必须为日期格式'
,
'end_time.after'
=>
'合同结束时间必须大于合同开始时间'
,
'recall_time.required'
=>
'召回期不能为空'
,
'recall_time.date'
=>
'召回期必须为日期格式'
,
'commission_rate.required'
=>
'抽佣比率不能为空'
,
'commission_rate.numeric'
=>
'抽佣比率必须为数字'
,
'commission_rate.max'
=>
'抽佣比率不能大于100'
,
...
...
app/Http/Controllers/Filter/SupplierFilter.php
View file @
d95eeaf8
...
...
@@ -262,10 +262,10 @@ class SupplierFilter
});
// 额外显示的特殊状态(如果有权限)
if
(
$canViewBlockSupplier
)
{
if
(
$canViewBlockSupplier
&&
!
checkPerm
(
'ViewAllSupplier'
)
)
{
$mainQuery
->
orWhere
(
'status'
,
SupplierChannelModel
::
STATUS_BLOCK
);
}
if
(
$canViewDisableSupplier
)
{
if
(
$canViewDisableSupplier
&&
!
checkPerm
(
'ViewAllSupplier'
)
)
{
$mainQuery
->
orWhere
(
'status'
,
SupplierChannelModel
::
STATUS_DISABLE
);
}
});
...
...
app/Http/Controllers/SupplierContractController.php
View file @
d95eeaf8
...
...
@@ -59,6 +59,7 @@ class SupplierContractController extends Controller
$contract
=
$model
->
with
(
'supplier'
)
->
where
(
'id'
,
$id
)
->
first
()
->
toArray
();
$contract
[
'start_time'
]
=
date
(
'Y-m-d H:i:s'
,
$contract
[
'start_time'
]);
$contract
[
'end_time'
]
=
date
(
'Y-m-d H:i:s'
,
$contract
[
'end_time'
]);
$contract
[
'recall_time'
]
=
$contract
[
'recall_time'
]
?
date
(
'Y-m-d H:i:s'
,
$contract
[
'recall_time'
])
:
''
;
$this
->
data
[
'contract'
]
=
$contract
;
}
$this
->
data
[
'supplierList'
]
=
$supplierList
;
...
...
app/Http/Controllers/SupplierController.php
View file @
d95eeaf8
...
...
@@ -203,7 +203,6 @@ class SupplierController extends Controller
}
else
{
$this
->
data
[
'title'
]
=
'添加供应商'
;
}
return
$this
->
view
(
'新增供应商'
);
}
...
...
@@ -248,7 +247,7 @@ class SupplierController extends Controller
$supplier
[
'customer_tags'
]
=
$customerTags
?
implode
(
','
,
$customerTags
[
'list'
])
:
''
;
$supplierModel
=
new
SupplierChannelModel
();
$supplierModel
->
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'customer_tags'
=>
$supplier
[
'customer_tags'
]
?:
''
,
'customer_tags'
=>
$supplier
[
'customer_tags'
]
?:
''
,
]);
$this
->
data
[
'supplier'
]
=
$supplier
;
$this
->
data
[
'address'
]
=
$supplierService
->
getAddress
(
$supplierId
);
...
...
app/Http/Services/SupplierContactService.php
View file @
d95eeaf8
...
...
@@ -5,6 +5,7 @@ namespace App\Http\Services;
use
App\Model\LogModel
;
use
App\Model\RedisModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierContactModel
;
...
...
@@ -98,6 +99,8 @@ class SupplierContactService
$logService
->
AddLog
(
$contact
[
'supplier_id'
],
LogModel
::
UPDATE_OPERATE
,
'修改供应商基本资料'
,
$content
,
$remark
);
}
$this
->
updateSupplierCodeData
(
$supplierId
);
return
$result
;
}
...
...
@@ -197,4 +200,18 @@ class SupplierContactService
}
return
$result
;
}
public
function
updateSupplierCodeData
(
$supplierId
)
{
//还要把采购员的列表写到特定redis字段给商品新增服务使用
$supplier
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
select
([
'supplier_code'
,
'channel_uid'
])
->
first
();
$redis
=
new
RedisModel
();
$supplierCodeData
=
$redis
->
hget
(
'supplier_code'
,
$supplier
->
supplier_code
);
if
(
$supplierCodeData
)
{
$supplierCodeData
=
json_decode
(
$supplierCodeData
,
true
);
$supplierCodeData
[
'channel_uid'
]
=
$supplier
->
channel_uid
;
$redis
->
hset
(
'supplier_code'
,
$supplier
->
supplier_code
,
json_encode
(
$supplierCodeData
));
}
}
}
app/Http/Services/SupplierContractService.php
View file @
d95eeaf8
...
...
@@ -33,6 +33,7 @@ class SupplierContractService
try
{
\DB
::
connection
(
'web'
)
->
beginTransaction
();
$data
[
'end_time'
]
=
strtotime
(
$data
[
'end_time'
]);
$data
[
'recall_time'
]
=
strtotime
(
$data
[
'recall_time'
]);
// 检查是否已存在相同供应商的合同
if
(
empty
(
$data
[
'id'
]))
{
...
...
@@ -61,6 +62,7 @@ class SupplierContractService
'end_time'
=>
'合同有效期'
,
'commission_rate'
=>
'抽佣比率'
,
'check_date'
=>
'对账日期'
,
'recall_time'
=>
'召回期'
,
];
$diffArr
=
[];
$oldData
=
$oldData
->
toArray
();
...
...
@@ -124,7 +126,7 @@ class SupplierContractService
}
catch
(
\Exception
$e
)
{
\DB
::
connection
(
'web'
)
->
rollBack
();
\Log
::
error
(
json_encode
(
$e
->
getMessage
())
.
' '
.
$e
->
getLine
());
return
$e
->
getMessage
();
return
$e
->
getMessage
()
.
' '
.
$e
->
getLine
()
;
}
}
...
...
app/Http/Validators/SupplierValidator.php
View file @
d95eeaf8
...
...
@@ -295,7 +295,7 @@ class SupplierValidator
//如果付款方式为账期,那么月结天数一定要选
if
(
$validateData
[
'pay_type'
]
==
1
)
{
if
(
!
array_get
(
$validateData
,
'pay_type_value'
))
{
$errorMessageList
[]
=
'付款方式选择账期,
月结天数必须设置
'
;
$errorMessageList
[]
=
'付款方式选择账期,
具体的付款周期值必填
'
;
}
}
...
...
app/Http/routes.php
View file @
d95eeaf8
...
...
@@ -15,9 +15,10 @@
use
App\Model\RedisModel
;
use
App\Http\Services\CrmService
;
use
App\Http\Services\SkuService
;
use
App\Http\Services\DataService
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierContractModel
;
use
App\Http\Services\CompanyService
;
use
App\Http\Services\DataService
;
use
Illuminate\Support\Facades\Route
;
use
App\Http\Services\DepartmentService
;
...
...
@@ -90,5 +91,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
DataService
::
repairSupplierCpTime
(
);
SupplierContractModel
::
where
(
'id'
,
22
)
->
update
([
'recall_time'
=>
0
]
);
});
config/field.php
View file @
d95eeaf8
...
...
@@ -373,4 +373,10 @@ return [
5
=>
'4年内'
,
6
=>
'5年内'
,
],
'SupplierPayTypeExtra'
=>
[
'天'
=>
'月结'
,
'当月'
=>
'当月'
,
'当周'
=>
'当周'
,
]
];
config/validate.php
View file @
d95eeaf8
...
...
@@ -60,5 +60,8 @@ return [
'sign_com_id'
=>
'签约公司id'
,
'sign_com_name'
=>
'签约公司名称'
,
'sku_optional_batch_text'
=>
'SKU可选批次'
,
'pay_type_name'
=>
'付款周期'
,
'pay_type_value'
=>
'付款周期值'
,
'pay_type_extra'
=>
'付款周期类型'
,
]
];
resources/views/script/SupplierDetailScript.blade.php
View file @
d95eeaf8
...
...
@@ -63,8 +63,6 @@
});
});
{{
--
index
.
setTabTitle
(
'供应商详情 - {{$supplier['
supplier_code
'] or ''}}'
);
--
}}
function
openLogView
()
{
// 打开右侧面板
layer
.
open
({
...
...
@@ -80,7 +78,7 @@
@
if
(
checkPerm
(
'SupplierLog'
))
setTimeout
(
function
()
{
openLogView
();
},
100
);
},
100
0
);
@
endif
//判断是否要切换tab
...
...
resources/views/script/UpdateSupplierContactScript.blade.php
0 → 100644
View file @
d95eeaf8
<script>
layui
.
use
([
'table'
,
'form'
,
'element'
,
'layer'
,
'admin'
],
function
()
{
let
admin
=
layui
.
admin
;
let
form
=
layui
.
form
;
let
element
=
layui
.
element
;
$
(
'#supplier_email'
).
blur
(
function
()
{
let
value
=
$
(
this
).
val
();
value
=
value
.
trim
();
if
(
value
!==
''
)
{
let
reg
=
/^
([
a-zA-Z0-9_-
])
+@
([
a-zA-Z0-9_-
])
+
(
.
[
a-zA-Z0-9_-
])
+/
;
if
(
!
reg
.
test
(
value
)){
layer
.
msg
(
'邮箱格式不对'
,
{
icon
:
5
});
}
}
});
form
.
on
(
'submit(load)'
,
function
(
data
)
{
// layer.confirm('确定要保存联系人吗?一旦保存,该供应商就会再次进入审核阶段', function (index) {
let
supplierId
=
getQueryVariable
(
'supplier_id'
);
let
url
=
'/api/supplier_contact/SaveSupplierContact?supplier_id='
+
supplierId
;
let
res
=
ajax
(
url
,
data
.
field
);
if
(
!
res
)
{
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
}
else
{
if
(
res
.
err_code
===
0
)
{
admin
.
putTempData
(
"needFreshList"
,
1
);
admin
.
closeThisDialog
();
parent
.
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
});
}
else
{
parent
.
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
}
}
});
return
false
;
// });
});
</script>
\ No newline at end of file
resources/views/script/supplier/SupplierPayTypeScript.blade.php
View file @
d95eeaf8
...
...
@@ -2,6 +2,21 @@
layui
.
use
([
'table'
,
'form'
,
'element'
,
'layer'
,
'admin'
],
function
()
{
let
admin
=
layui
.
admin
;
let
form
=
layui
.
form
;
// 页面加载时初始化,确保当周期类型为空时,对应的下拉框不显示
$
(
document
).
ready
(
function
()
{
// 检查所有周期类型选择框,如果值为空,则隐藏对应的子选项
$
(
'select[name="pay_type_extra"]'
).
each
(
function
()
{
const
payTypeExtra
=
$
(
this
).
val
();
const
parentDiv
=
$
(
this
).
parents
(
'.pay_type_div'
);
// 如果周期类型为空,隐藏所有子选项
if
(
!
payTypeExtra
)
{
parentDiv
.
find
(
'.pay_type_1_days_div, .pay_type_1_monthly_div, .pay_type_1_weekly_div'
).
hide
();
}
});
});
//要根据付款类型的不同选项,切换不同的显示
form
.
on
(
'select(pay_type)'
,
function
(
data
)
{
const
payType
=
data
.
value
;
...
...
@@ -9,6 +24,7 @@
parentDiv
.
find
(
'.pay_type_'
+
payType
+
'_div'
).
show
();
parentDiv
.
find
(
'.pay_type_'
+
payType
+
'_div'
).
find
(
'.valueInput'
).
first
().
attr
(
'name'
,
'pay_type_value'
);
parentDiv
.
find
(
'.pay_type_'
+
payType
+
'_div'
).
find
(
'.valueInput'
).
eq
(
1
).
attr
(
'name'
,
'pay_type_extra'
);
$
(
'.pay_type_1_days_div, .pay_type_1_monthly_div, .pay_type_1_weekly_div'
).
hide
();
if
(
payType
===
'1'
)
{
parentDiv
.
find
(
'.pay_type_2_div'
).
hide
();
parentDiv
.
find
(
'.pay_type_2_div'
).
find
(
'.valueInput'
).
attr
(
'name'
,
''
);
...
...
@@ -50,27 +66,50 @@
}
});
$
(
document
).
on
(
'click'
,
'.delete_pay_type'
,
function
()
{
let
count
=
$
(
'.pay_type_div'
).
size
();
if
(
count
<=
1
)
{
layer
.
msg
(
'至少要保留一个付款方式'
,
{
icon
:
5
});
return
;
// 处理周期类型选择变化
form
.
on
(
'select(pay_type_extra)'
,
function
(
data
)
{
const
payTypeExtra
=
data
.
value
;
// 隐藏所有子选项
$
(
'.pay_type_1_days_div, .pay_type_1_monthly_div, .pay_type_1_weekly_div'
).
hide
();
// 清空所有值
$
(
'#pay_type_value, #pay_type_value_monthly, #pay_type_value_weekly'
).
val
(
''
);
// 根据选择的类型显示对应的选项
if
(
payTypeExtra
===
'天'
)
{
$
(
'.pay_type_1_days_div'
).
show
();
}
else
if
(
payTypeExtra
===
'当月'
)
{
$
(
'.pay_type_1_monthly_div'
).
show
();
}
else
if
(
payTypeExtra
===
'当周'
)
{
$
(
'.pay_type_1_weekly_div'
).
show
();
}
else
{
// 当周期类型为空时,确保所有子选项都隐藏
$
(
'.pay_type_1_days_div, .pay_type_1_monthly_div, .pay_type_1_weekly_div'
).
hide
();
}
var
self
=
$
(
this
);
layer
.
confirm
(
'确定要删除付款方式吗?'
,
function
(
index
)
{
self
.
parents
(
'.pay_type_div'
).
remove
();
layer
.
closeAll
();
});
});
$
(
document
).
on
(
'click'
,
'.add_pay_type'
,
function
()
{
$
(
'#pay_type_div_list'
).
append
(
$
(
'#pay_type_template'
).
html
());
//不知道为什么元素的name总会变来变去,所以手动固定死,确保提交的时候,顺序和名称都是对的
$
(
"input[name^='pay_type_value[']"
).
attr
(
'name'
,
'pay_type_value'
)
$
(
"input[name^='pay_type_extra[']"
).
attr
(
'name'
,
'pay_type_extra'
)
$
(
"select[name^='pay_type[']"
).
attr
(
'name'
,
'pay_type'
)
// 更新隐藏字段值
$
(
'[name="pay_type_extra"]'
).
val
(
payTypeExtra
);
form
.
render
(
'select'
);
});
// 处理days
form
.
on
(
'select(pay_type_days)'
,
function
(
data
)
{
const
value
=
data
.
value
;
$
(
'[name="pay_type_value"]'
).
val
(
value
);
});
// 处理月结天数选择
form
.
on
(
'select(pay_type_monthly)'
,
function
(
data
)
{
const
value
=
data
.
value
;
$
(
'[name="pay_type_value"]'
).
val
(
value
);
});
// 处理当周结星期选择
form
.
on
(
'select(pay_type_weekly)'
,
function
(
data
)
{
const
value
=
data
.
value
;
$
(
'[name="pay_type_value"]'
).
val
(
value
);
});
});
</script>
\ No newline at end of file
</script>
resources/views/web/SupplierDetail.blade.php
View file @
d95eeaf8
...
...
@@ -257,7 +257,7 @@
<div
class=
"layui-col-md3"
>
付款周期 :{{$supplier['pay_type_name'] }}
@if($supplier['pay_type'] == 1)
(
月结{{$supplier['pay_type_value'].$supplier['pay_type_extra
']}})
(
{{'按'.$supplier['pay_type_extra'].' '.$supplier['pay_type_value
']}})
@endif
</div>
</div>
...
...
resources/views/web/supplier/SupplierPayType.blade.php
View file @
d95eeaf8
...
...
@@ -6,96 +6,88 @@
<div
class=
"layui-col-md3"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('settlement_type','结算方式 : ',
!empty($supplier)?$supplier['settlement_type']:'',config('field.SettlementType'),['required'=>true]) !!}
!empty($supplier)?$supplier['settlement_type']:'',config('field.SettlementType'),['required'=>true]) !!}
</div>
<div
class=
"layui-col-md
3
"
>
<div
class=
"layui-col-md
2
"
>
<div
class=
"layui-inline"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('pay_type','付款周期 : ',
!empty($supplier)?$supplier['pay_type']:'',config('fixed.SupplierPayType'),['required'=>true
]) !!}
!empty($supplier)?$supplier['pay_type']:'',config('fixed.SupplierPayType'),['required'=>true,'width'=>'120px'
]) !!}
</div>
</div>
<div
class=
"layui-col-md6"
style=
"width:500px;margin-bottom: 3px;margin-left: -20px;"
>
<div
class=
"layui-row"
>
@if (!empty($supplier)
&&
$supplier['pay_type']==1)
<div
class=
"pay_type_1_div"
>
<div
class=
"layui-row"
style=
""
>
<span
class=
"require"
>
*
</span>
月结 :
&
nbsp
<div
class=
"layui-input-inline"
style=
"width: 80px;"
>
<input
class=
"layui-input valueInput"
type=
"hidden"
name=
"pay_type_value"
value=
"{{$supplier['pay_type_value'] or ''}}"
>
<select
lay-filter=
"pay_type_month"
>
<option
value=
""
>
请选择
</option>
<option
value=
"7"
@
if
($
supplier
['
pay_type_value
']==
7
)
selected=
'selected'
@
endif
>
7
</option>
<option
value=
"15"
@
if
($
supplier
['
pay_type_value
']==
15
)
selected=
'selected'
@
endif
>
15
</option>
<option
value=
"30"
@
if
($
supplier
['
pay_type_value
']==
30
)
selected=
'selected'
@
endif
>
30
</option>
<option
value=
"45"
@
if
($
supplier
['
pay_type_value
']==
45
)
selected=
'selected'
@
endif
>
45
</option>
<option
value=
"60"
@
if
($
supplier
['
pay_type_value
']==
60
)
selected=
'selected'
@
endif
>
60
</option>
<option
value=
"90"
@
if
($
supplier
['
pay_type_value
']==
90
)
selected=
'selected'
@
endif
>
90
</option>
</select>
</div>
&
nbsp天
<input
type=
"hidden"
class=
"valueInput"
name=
"pay_type_extra"
value=
"天"
>
</div>
</div>
@else
<div
class=
"pay_type_1_div"
style=
"display: none"
>
<div
class=
"layui-row"
>
<span
class=
"require"
>
*
</span>
月结 :
&
nbsp
<div
class=
"layui-input-inline"
style=
"width: 80px;"
>
<input
class=
"layui-input valueInput"
type=
"hidden"
name=
"pay_type_value"
>
<select
lay-filter=
"pay_type_month"
>
<option
value=
""
>
请选择
</option>
<option
value=
"7"
>
7
</option>
<option
value=
"15"
>
15
</option>
<option
value=
"30"
>
30
</option>
<option
value=
"45"
>
45
</option>
<option
value=
"60"
>
60
</option>
<option
value=
"90"
>
90
</option>
</select>
</div>
&
nbsp天
<input
type=
"hidden"
class=
"valueInput"
name=
"pay_type_extra"
value=
"天"
>
</div>
<div
class=
"layui-col-md7"
style=
"width:500px;margin-bottom: 3px;margin-left: -30px;display: flex;align-items: center;"
>
{{-- 周期类型选择 --}}
<div
class=
"layui-inline pay_type_1_div pay_type_extra_div"
style=
"margin-left: -20px; @if(!empty($supplier)&&$supplier['pay_type_extra']!='')display: block;@else display: none;@endif"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('pay_type_extra','周期类型 : ',
!empty($supplier)?$supplier['pay_type_extra']:'',config('field.SupplierPayTypeExtra'),['required'=>true,'width'=>'80px']) !!}
</div>
{{-- 月结天数选择 --}}
<div
class=
"pay_type_1_div pay_type_1_days_div"
style=
"@if(!empty($supplier)&&$supplier['pay_type']==1 && $supplier['pay_type_extra']=='天' || (!empty($supplier)&&$supplier['pay_type_extra']=='月结'))display: block;@else display: none;@endif margin-bottom: 8px;"
>
<div
class=
"layui-row"
style=
""
>
<div
class=
"layui-input-inline"
style=
"width: 80px;"
>
<input
class=
"layui-input valueInput"
type=
"hidden"
id=
"pay_type_value"
value=
"{{$supplier['pay_type_value'] or ''}}"
>
<select
lay-filter=
"pay_type_days"
>
<option
value=
""
>
请选择
</option>
<option
value=
"7"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='
7
'
)
selected=
'selected'
@
endif
>
7
</option>
<option
value=
"15"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='
15
'
)
selected=
'selected'
@
endif
>
15
</option>
<option
value=
"30"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='
30
'
)
selected=
'selected'
@
endif
>
30
</option>
<option
value=
"45"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='
45
'
)
selected=
'selected'
@
endif
>
45
</option>
<option
value=
"60"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='
60
'
)
selected=
'selected'
@
endif
>
60
</option>
<option
value=
"90"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='
90
'
)
selected=
'selected'
@
endif
>
90
</option>
</select>
</div>
@endif
&
nbsp天
</div>
</div>
@if (!empty($supplier)
&&
$supplier['pay_type']==2)
<div
class=
"pay_type_2_div"
>
<input
type=
"hidden"
class=
"valueInput"
name=
"pay_type_value"
>
<input
type=
"hidden"
class=
"valueInput"
name=
"pay_type_extra"
value=
""
>
{{-- 当月结日期选择 --}}
<div
class=
"pay_type_1_div pay_type_1_monthly_div"
style=
"@if(!empty($supplier)&&$supplier['pay_type']==1 && $supplier['pay_type_extra']=='当月')display: block;@else display: none;@endif margin-bottom: 8px;"
>
<div
class=
"layui-row"
style=
""
>
<div
class=
"layui-input-inline"
style=
"width: 80px;"
>
<input
class=
"layui-input valueInput"
type=
"hidden"
id=
"pay_type_value_monthly"
value=
"{{$supplier['pay_type_value'] or ''}}"
>
<select
lay-filter=
"pay_type_monthly"
>
<option
value=
""
>
请选择
</option>
@for($i = 1; $i
<
=
31
;
$
i
++)
<
option
value=
"{{$i.'号'}}"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')==$
i
)
selected=
'selected'
@
endif
>
{{$i}}
</option>
@endfor
</select>
</div>
@else
<div
class=
"pay_type_2_div"
style=
"display: none"
>
<input
type=
"hidden"
class=
"valueInput"
name=
""
>
<input
type=
"hidden"
class=
"valueInput"
name=
""
value=
""
>
&
nbsp号
</div>
</div>
{{-- 当周结星期选择 --}}
<div
class=
"pay_type_1_div pay_type_1_weekly_div"
style=
"@if(!empty($supplier)&&$supplier['pay_type']==1 && $supplier['pay_type_extra']=='当周')display: block;@else display: none;@endif margin-bottom: 8px;"
>
<div
class=
"layui-row"
style=
""
>
<div
class=
"layui-input-inline"
style=
"width: 80px;"
>
<input
class=
"layui-input valueInput"
type=
"hidden"
id=
"pay_type_value_weekly"
value=
"{{$supplier['pay_type_value'] or ''}}"
>
<select
lay-filter=
"pay_type_weekly"
>
<option
value=
""
>
请选择
</option>
<option
value=
"周一"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='周一'
)
selected=
'selected'
@
endif
>
周一
</option>
<option
value=
"周二"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='周二'
)
selected=
'selected'
@
endif
>
周二
</option>
<option
value=
"周三"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='周三'
)
selected=
'selected'
@
endif
>
周三
</option>
<option
value=
"周四"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='周四'
)
selected=
'selected'
@
endif
>
周四
</option>
<option
value=
"周五"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='周五'
)
selected=
'selected'
@
endif
>
周五
</option>
<option
value=
"周六"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='周六'
)
selected=
'selected'
@
endif
>
周六
</option>
<option
value=
"周日"
@
if
(!
empty
($
supplier
)&&
array_get
($
supplier
,'
pay_type_value
')=='周日'
)
selected=
'selected'
@
endif
>
周日
</option>
</select>
</div>
@endif
</div>
<input
type=
"hidden"
class=
"valueInput"
name=
"pay_type_value"
value=
"{{$supplier['pay_type_value'] or ''}}"
>
<input
type=
"hidden"
class=
"valueInput"
name=
"pay_type_extra"
value=
"{{$supplier['pay_type_extra'] or ''}}"
>
</div>
@if (!empty($supplier)
&&
array_get($supplier,'pay_type')==2)
<div
class=
"pay_type_2_div"
>
<input
type=
"hidden"
class=
"valueInput"
name=
"pay_type_value"
value=
"{{$supplier['pay_type_value'] or ''}}"
>
<input
type=
"hidden"
class=
"valueInput"
name=
"pay_type_extra"
value=
"{{$supplier['pay_type_extra'] or ''}}"
>
</div>
@else
<div
class=
"pay_type_2_div"
style=
"display: none"
>
<input
type=
"hidden"
class=
"valueInput"
name=
""
>
<input
type=
"hidden"
class=
"valueInput"
name=
""
value=
""
>
</div>
@endif
</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