Commit d95eeaf8 by 杨树贤

Merge branch 'master' into ysx-SKU上传同步芯链选项交互优化&新建供应商期货默认项更改-20250804

parents 6718b5ba 3d7ac1b2
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv) # Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
vendor/ vendor/
storage/
public/
...@@ -28,14 +28,66 @@ class SupplierRecallMailRemind extends Command ...@@ -28,14 +28,66 @@ class SupplierRecallMailRemind extends Command
*/ */
protected $description = '寄售召回期邮件提醒(提前30天、7天)'; 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() public function handle()
{ {
$today = Carbon::today(); $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(); $adminUserService = new AdminUserService();
$messageService = new MessageService(); $messageService = new MessageService();
$remindDays = [30, 7]; $remindDays = [30, 7];
foreach ($contracts as $contract) { foreach ($contracts as $contract) {
//判断有没有上架的sku,通过搜索接口查询 //判断有没有上架的sku,通过搜索接口查询
$map['p'] = 1; $map['p'] = 1;
...@@ -45,9 +97,8 @@ class SupplierRecallMailRemind extends Command ...@@ -45,9 +97,8 @@ class SupplierRecallMailRemind extends Command
$url = env('ES_SKU_URL', ''); $url = env('ES_SKU_URL', '');
$map['show_status'] = 1; $map['show_status'] = 1;
$map['no_rule'] = 1122; $map['no_rule'] = 1122;
try { $url = base64_encode($url . '?' . http_build_query($map));
$url = base64_encode($url.'?'.http_build_query($map)); $return = curl(config('website.FootstoneCurlUrl') . $url);
$return = curl(config('website.FootstoneCurlUrl').$url);
$data = json_decode($return, true); $data = json_decode($return, true);
if (isset($data['error_code']) && $data['error_code'] == 0) { if (isset($data['error_code']) && $data['error_code'] == 0) {
$searchResult = $data['data']['goods_id']; $searchResult = $data['data']['goods_id'];
...@@ -66,6 +117,7 @@ class SupplierRecallMailRemind extends Command ...@@ -66,6 +117,7 @@ class SupplierRecallMailRemind extends Command
if (empty($standardBrand)) { if (empty($standardBrand)) {
continue; continue;
} }
$standardBrand = json_decode($standardBrand, true);
$skuDataList[] = [ $skuDataList[] = [
'spu_name' => $spu['spu_name'], 'spu_name' => $spu['spu_name'],
'brand_name' => $standardBrand['brand_name'], 'brand_name' => $standardBrand['brand_name'],
...@@ -75,16 +127,14 @@ class SupplierRecallMailRemind extends Command ...@@ -75,16 +127,14 @@ class SupplierRecallMailRemind extends Command
} else { } else {
$searchResult = []; $searchResult = [];
} }
} catch (\Exception $e) {
return $e->getMessage();
}
if (empty($searchResult)) { if (empty($searchResult)) {
continue; continue;
} }
$recallDate = Carbon::createFromTimestamp($contract->recall_time); $recallDate = Carbon::createFromTimestamp($contract->recall_time);
$diff = $today->diffInDays($recallDate, false); $diff = $today->diffInDays($recallDate, false);
if (!in_array($diff, $remindDays)) { if (!in_array($diff, $remindDays)) {
continue; // continue;
} }
$supplier = $contract->supplier; $supplier = $contract->supplier;
...@@ -102,8 +152,16 @@ class SupplierRecallMailRemind extends Command ...@@ -102,8 +152,16 @@ class SupplierRecallMailRemind extends Command
// 采购经理 // 采购经理
$manager = null; $manager = null;
if (!empty($purchaseUser->department_id)) { 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') $manager = DB::table('user_info')
->where('department_id', $purchaseUser->department_id) ->whereIn('department_id', $departmentIds)
->where('position_name', '采购经理') ->where('position_name', '采购经理')
->first(); ->first();
if ($manager && !empty($manager->email)) { if ($manager && !empty($manager->email)) {
...@@ -111,7 +169,7 @@ class SupplierRecallMailRemind extends Command ...@@ -111,7 +169,7 @@ class SupplierRecallMailRemind extends Command
} }
// 采购总监 // 采购总监
$director = DB::table('user_position') $director = DB::table('user_position')
->where('department_id', $purchaseUser->department_id) ->whereIn('department_id', $departmentIds)
->where('position_name', '采购总监') ->where('position_name', '采购总监')
->first(); ->first();
if ($director) { if ($director) {
...@@ -127,20 +185,51 @@ class SupplierRecallMailRemind extends Command ...@@ -127,20 +185,51 @@ class SupplierRecallMailRemind extends Command
$subject = "【寄售召回提醒】距离召回期仅剩{$diff}天"; $subject = "【寄售召回提醒】距离召回期仅剩{$diff}天";
$content = "请及时提醒供应商召回寄售商品\n供应商名称:{$supplierName}\n召回期:{$recallTimeStr}"; $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 = [
'data' => [ 'data' => [
'title' => $subject, 'title' => $subject,
'content' => $content, 'content' => $content . ($fileUrl ? "\nCSV文件: {$fileUrl}" : ''),
] ]
]; ];
// 发送邮件 dump($data);
foreach ($toEmails as $to) { dump($toEmails,$ccEmails);
$messageService->sendMessage('supplier_recall_remind', $data, $to, true); // // 发送邮件
} // foreach ($toEmails as $to) {
foreach ($ccEmails as $cc) { // $messageService->sendMessage('supplier_recall_remind', $data, $to, true);
$messageService->sendMessage('supplier_recall_remind', $data, $cc, true); // }
} // foreach ($ccEmails as $cc) {
// $messageService->sendMessage('supplier_recall_remind', $data, $cc, true);
// }
$this->info("已发送提醒:供应商{$supplierName},召回期{$recallTimeStr},剩余{$diff}天"); $this->info("已发送提醒:供应商{$supplierName},召回期{$recallTimeStr},剩余{$diff}天");
} }
} }
......
...@@ -20,6 +20,7 @@ use App\Http\Services\SyncSupplierService; ...@@ -20,6 +20,7 @@ use App\Http\Services\SyncSupplierService;
use App\Http\Validators\SupplierValidator; use App\Http\Validators\SupplierValidator;
use App\Http\Services\StandardBrandService; use App\Http\Services\StandardBrandService;
use App\Http\Services\SupplierAuditService; use App\Http\Services\SupplierAuditService;
use App\Http\Services\SupplierContactService;
use App\Http\Transformers\SupplierTransformer; use App\Http\Transformers\SupplierTransformer;
use App\Http\Controllers\Filter\SupplierFilter; use App\Http\Controllers\Filter\SupplierFilter;
use App\Http\Services\SupplierStatisticsService; use App\Http\Services\SupplierStatisticsService;
...@@ -511,6 +512,8 @@ class SupplierApiController extends Controller ...@@ -511,6 +512,8 @@ class SupplierApiController extends Controller
$result = $service->allocateChannelUser($supplierId, $channelUid, $channelUserType); $result = $service->allocateChannelUser($supplierId, $channelUid, $channelUserType);
} }
} }
$supplierContactService = new SupplierContactService();
$supplierContactService->updateSupplierCodeData($supplierId);
} }
if (!$result) { if (!$result) {
......
...@@ -42,16 +42,16 @@ class SupplierContractApiController extends Controller ...@@ -42,16 +42,16 @@ class SupplierContractApiController extends Controller
$validator = \Validator::make($data, [ $validator = \Validator::make($data, [
'supplier_id' => 'required|integer', 'supplier_id' => 'required|integer',
'end_time' => 'required|date', 'end_time' => 'required|date',
'recall_time' => 'required|date',
'commission_rate' => 'numeric|max:100|min:1', 'commission_rate' => 'numeric|max:100|min:1',
'check_date' => 'required|integer|min:1|max:31' 'check_date' => 'required|integer|min:1|max:31'
], [ ], [
'supplier_id.required' => '供应商ID不能为空', 'supplier_id.required' => '供应商ID不能为空',
'supplier_id.integer' => '供应商ID必须为整数', 'supplier_id.integer' => '供应商ID必须为整数',
'start_time.required' => '合同开始时间不能为空',
'start_time.date' => '合同开始时间必须为日期格式',
'end_time.required' => '合同结束时间不能为空', 'end_time.required' => '合同结束时间不能为空',
'end_time.date' => '合同结束时间必须为日期格式', 'end_time.date' => '合同结束时间必须为日期格式',
'end_time.after' => '合同结束时间必须大于合同开始时间', 'recall_time.required' => '召回期不能为空',
'recall_time.date' => '召回期必须为日期格式',
'commission_rate.required' => '抽佣比率不能为空', 'commission_rate.required' => '抽佣比率不能为空',
'commission_rate.numeric' => '抽佣比率必须为数字', 'commission_rate.numeric' => '抽佣比率必须为数字',
'commission_rate.max' => '抽佣比率不能大于100', 'commission_rate.max' => '抽佣比率不能大于100',
......
...@@ -262,10 +262,10 @@ class SupplierFilter ...@@ -262,10 +262,10 @@ class SupplierFilter
}); });
// 额外显示的特殊状态(如果有权限) // 额外显示的特殊状态(如果有权限)
if ($canViewBlockSupplier) { if ($canViewBlockSupplier && !checkPerm('ViewAllSupplier')) {
$mainQuery->orWhere('status', SupplierChannelModel::STATUS_BLOCK); $mainQuery->orWhere('status', SupplierChannelModel::STATUS_BLOCK);
} }
if ($canViewDisableSupplier) { if ($canViewDisableSupplier && !checkPerm('ViewAllSupplier')) {
$mainQuery->orWhere('status', SupplierChannelModel::STATUS_DISABLE); $mainQuery->orWhere('status', SupplierChannelModel::STATUS_DISABLE);
} }
}); });
......
...@@ -59,6 +59,7 @@ class SupplierContractController extends Controller ...@@ -59,6 +59,7 @@ class SupplierContractController extends Controller
$contract = $model->with('supplier')->where('id', $id)->first()->toArray(); $contract = $model->with('supplier')->where('id', $id)->first()->toArray();
$contract['start_time'] = date('Y-m-d H:i:s', $contract['start_time']); $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['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['contract'] = $contract;
} }
$this->data['supplierList'] = $supplierList; $this->data['supplierList'] = $supplierList;
......
...@@ -203,7 +203,6 @@ class SupplierController extends Controller ...@@ -203,7 +203,6 @@ class SupplierController extends Controller
} else { } else {
$this->data['title'] = '添加供应商'; $this->data['title'] = '添加供应商';
} }
return $this->view('新增供应商'); return $this->view('新增供应商');
} }
...@@ -248,7 +247,7 @@ class SupplierController extends Controller ...@@ -248,7 +247,7 @@ class SupplierController extends Controller
$supplier['customer_tags'] = $customerTags ? implode(',', $customerTags['list']) : ''; $supplier['customer_tags'] = $customerTags ? implode(',', $customerTags['list']) : '';
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
$supplierModel->where('supplier_id', $supplierId)->update([ $supplierModel->where('supplier_id', $supplierId)->update([
'customer_tags' => $supplier['customer_tags']?:'', 'customer_tags' => $supplier['customer_tags'] ?: '',
]); ]);
$this->data['supplier'] = $supplier; $this->data['supplier'] = $supplier;
$this->data['address'] = $supplierService->getAddress($supplierId); $this->data['address'] = $supplierService->getAddress($supplierId);
......
...@@ -5,6 +5,7 @@ namespace App\Http\Services; ...@@ -5,6 +5,7 @@ namespace App\Http\Services;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel; use App\Model\SupplierContactModel;
...@@ -98,6 +99,8 @@ class SupplierContactService ...@@ -98,6 +99,8 @@ class SupplierContactService
$logService->AddLog($contact['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark); $logService->AddLog($contact['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark);
} }
$this->updateSupplierCodeData($supplierId);
return $result; return $result;
} }
...@@ -197,4 +200,18 @@ class SupplierContactService ...@@ -197,4 +200,18 @@ class SupplierContactService
} }
return $result; 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));
}
}
} }
...@@ -33,6 +33,7 @@ class SupplierContractService ...@@ -33,6 +33,7 @@ class SupplierContractService
try { try {
\DB::connection('web')->beginTransaction(); \DB::connection('web')->beginTransaction();
$data['end_time'] = strtotime($data['end_time']); $data['end_time'] = strtotime($data['end_time']);
$data['recall_time'] = strtotime($data['recall_time']);
// 检查是否已存在相同供应商的合同 // 检查是否已存在相同供应商的合同
if (empty($data['id'])) { if (empty($data['id'])) {
...@@ -61,6 +62,7 @@ class SupplierContractService ...@@ -61,6 +62,7 @@ class SupplierContractService
'end_time' => '合同有效期', 'end_time' => '合同有效期',
'commission_rate' => '抽佣比率', 'commission_rate' => '抽佣比率',
'check_date' => '对账日期', 'check_date' => '对账日期',
'recall_time' => '召回期',
]; ];
$diffArr = []; $diffArr = [];
$oldData = $oldData->toArray(); $oldData = $oldData->toArray();
...@@ -124,7 +126,7 @@ class SupplierContractService ...@@ -124,7 +126,7 @@ class SupplierContractService
} catch (\Exception $e) { } catch (\Exception $e) {
\DB::connection('web')->rollBack(); \DB::connection('web')->rollBack();
\Log::error(json_encode($e->getMessage()) . ' ' . $e->getLine()); \Log::error(json_encode($e->getMessage()) . ' ' . $e->getLine());
return $e->getMessage(); return $e->getMessage().' '.$e->getLine();
} }
} }
......
...@@ -295,7 +295,7 @@ class SupplierValidator ...@@ -295,7 +295,7 @@ class SupplierValidator
//如果付款方式为账期,那么月结天数一定要选 //如果付款方式为账期,那么月结天数一定要选
if ($validateData['pay_type'] == 1) { if ($validateData['pay_type'] == 1) {
if (!array_get($validateData, 'pay_type_value')) { if (!array_get($validateData, 'pay_type_value')) {
$errorMessageList[] = '付款方式选择账期,月结天数必须设置'; $errorMessageList[] = '付款方式选择账期,具体的付款周期值必填';
} }
} }
......
...@@ -15,9 +15,10 @@ ...@@ -15,9 +15,10 @@
use App\Model\RedisModel; use App\Model\RedisModel;
use App\Http\Services\CrmService; use App\Http\Services\CrmService;
use App\Http\Services\SkuService; use App\Http\Services\SkuService;
use App\Http\Services\DataService;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContractModel;
use App\Http\Services\CompanyService; use App\Http\Services\CompanyService;
use App\Http\Services\DataService;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use App\Http\Services\DepartmentService; use App\Http\Services\DepartmentService;
...@@ -90,5 +91,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -90,5 +91,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
DataService::repairSupplierCpTime(); SupplierContractModel::where('id', 22)->update(['recall_time' => 0]);
}); });
...@@ -373,4 +373,10 @@ return [ ...@@ -373,4 +373,10 @@ return [
5 => '4年内', 5 => '4年内',
6 => '5年内', 6 => '5年内',
], ],
'SupplierPayTypeExtra' => [
'天' => '月结',
'当月' => '当月',
'当周' => '当周',
]
]; ];
...@@ -60,5 +60,8 @@ return [ ...@@ -60,5 +60,8 @@ return [
'sign_com_id' => '签约公司id', 'sign_com_id' => '签约公司id',
'sign_com_name' => '签约公司名称', 'sign_com_name' => '签约公司名称',
'sku_optional_batch_text' => 'SKU可选批次', 'sku_optional_batch_text' => 'SKU可选批次',
'pay_type_name' => '付款周期',
'pay_type_value' => '付款周期值',
'pay_type_extra' => '付款周期类型',
] ]
]; ];
...@@ -63,8 +63,6 @@ ...@@ -63,8 +63,6 @@
}); });
}); });
{{--index.setTabTitle('供应商详情 - {{$supplier['supplier_code'] or ''}}');--}}
function openLogView() { function openLogView() {
// 打开右侧面板 // 打开右侧面板
layer.open({ layer.open({
...@@ -80,7 +78,7 @@ ...@@ -80,7 +78,7 @@
@if(checkPerm('SupplierLog')) @if(checkPerm('SupplierLog'))
setTimeout(function () { setTimeout(function () {
openLogView(); openLogView();
}, 100); }, 1000);
@endif @endif
//判断是否要切换tab //判断是否要切换tab
......
<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
...@@ -2,6 +2,21 @@ ...@@ -2,6 +2,21 @@
layui.use(['table', 'form', 'element', 'layer', 'admin'], function () { layui.use(['table', 'form', 'element', 'layer', 'admin'], function () {
let admin = layui.admin; let admin = layui.admin;
let form = layui.form; 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) { form.on('select(pay_type)', function (data) {
const payType = data.value; const payType = data.value;
...@@ -9,6 +24,7 @@ ...@@ -9,6 +24,7 @@
parentDiv.find('.pay_type_' + payType + '_div').show(); 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').first().attr('name', 'pay_type_value');
parentDiv.find('.pay_type_' + payType + '_div').find('.valueInput').eq(1).attr('name', 'pay_type_extra'); 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') { if (payType === '1') {
parentDiv.find('.pay_type_2_div').hide(); parentDiv.find('.pay_type_2_div').hide();
parentDiv.find('.pay_type_2_div').find('.valueInput').attr('name', ''); parentDiv.find('.pay_type_2_div').find('.valueInput').attr('name', '');
...@@ -50,26 +66,49 @@ ...@@ -50,26 +66,49 @@
} }
}); });
$(document).on('click', '.delete_pay_type', function () { // 处理周期类型选择变化
let count = $('.pay_type_div').size(); form.on('select(pay_type_extra)', function (data) {
if (count <= 1) { const payTypeExtra = data.value;
layer.msg('至少要保留一个付款方式', {icon: 5}); // 隐藏所有子选项
return; $('.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(); $('[name="pay_type_extra"]').val(payTypeExtra);
layer.closeAll();
form.render('select');
}); });
// 处理days
form.on('select(pay_type_days)', function (data) {
const value = data.value;
$('[name="pay_type_value"]').val(value);
}); });
$(document).on('click', '.add_pay_type', function () { // 处理月结天数选择
$('#pay_type_div_list').append($('#pay_type_template').html()); form.on('select(pay_type_monthly)', function (data) {
//不知道为什么元素的name总会变来变去,所以手动固定死,确保提交的时候,顺序和名称都是对的 const value = data.value;
$("input[name^='pay_type_value[']").attr('name','pay_type_value') $('[name="pay_type_value"]').val(value);
$("input[name^='pay_type_extra[']").attr('name','pay_type_extra') });
$("select[name^='pay_type[']").attr('name','pay_type')
form.render('select'); // 处理当周结星期选择
form.on('select(pay_type_weekly)', function (data) {
const value = data.value;
$('[name="pay_type_value"]').val(value);
}); });
}); });
......
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
<div class="layui-col-md3"> <div class="layui-col-md3">
付款周期 :{{$supplier['pay_type_name'] }} 付款周期 :{{$supplier['pay_type_name'] }}
@if($supplier['pay_type'] == 1) @if($supplier['pay_type'] == 1)
(月结{{$supplier['pay_type_value'].$supplier['pay_type_extra']}}) ({{'按'.$supplier['pay_type_extra'].' '.$supplier['pay_type_value']}})
@endif @endif
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment