Commit 77caa55a by mushishixian

附件管理

parent 076d0c01
...@@ -37,31 +37,6 @@ class CommonApiController extends Controller ...@@ -37,31 +37,6 @@ class CommonApiController extends Controller
return $this->response(0, 'ok', $brandList); return $this->response(0, 'ok', $brandList);
} }
public function upload($request)
{
$upload = $request->file('qualification_photos');
$ext = $upload->getClientOriginalExtension();
$fileName = time() . '.' . $ext;
$upload->move(storage_path("uploads"), $fileName);
$path = storage_path("uploads") . '/' . $fileName;
$result = UploadToOss($path);
$result = json_decode($result, true);
unlink($path);
if (!empty($result) && $result['code'] === 200) {
echo json_encode([
'code' => 200,
'src' => $result['data'][0],
'msg' => 'ok',
]);
} else {
echo json_encode([
'code' => -1,
'msg' => '上传失败',
]);
}
exit();
}
private function SearchBrand($request) private function SearchBrand($request)
{ {
$brandName = $request->input('brand_name'); $brandName = $request->input('brand_name');
......
...@@ -6,18 +6,15 @@ use App\Http\Controllers\Controller; ...@@ -6,18 +6,15 @@ use App\Http\Controllers\Controller;
use App\Http\Controllers\Filter\SupplierFilter; use App\Http\Controllers\Filter\SupplierFilter;
use App\Http\Services\AdminUserService; use App\Http\Services\AdminUserService;
use App\Http\Services\LogService; use App\Http\Services\LogService;
use App\Http\Services\MessageService;
use App\Http\Services\SupplierAuditService; use App\Http\Services\SupplierAuditService;
use App\Http\Services\SupplierService; use App\Http\Services\SupplierService;
use App\Http\Services\SyncSupplierService; use App\Http\Services\SyncSupplierService;
use App\Http\Transformers\SupplierTransformer; use App\Http\Transformers\SupplierTransformer;
use App\Http\Validators\SupplierValidator; use App\Http\Validators\SupplierValidator;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
//通用API,比如获取品牌列表,分类列表等
class SupplierApiController extends Controller class SupplierApiController extends Controller
{ {
...@@ -64,7 +61,6 @@ class SupplierApiController extends Controller ...@@ -64,7 +61,6 @@ class SupplierApiController extends Controller
//附加费 //附加费
'cn', 'cn',
'hk', 'hk',
// 'status',
//商品上传规则 //商品上传规则
'sku_upload_ruler', 'sku_upload_ruler',
...@@ -73,6 +69,7 @@ class SupplierApiController extends Controller ...@@ -73,6 +69,7 @@ class SupplierApiController extends Controller
//标签 //标签
'system_tags', 'system_tags',
'customer_tags', 'customer_tags',
]; ];
public function Entrance(Request $request, $id) public function Entrance(Request $request, $id)
...@@ -100,6 +97,8 @@ class SupplierApiController extends Controller ...@@ -100,6 +97,8 @@ class SupplierApiController extends Controller
'supplier_fax', 'supplier_fax',
'can_check_uids' 'can_check_uids'
]); ]);
//附件
$channelMap = array_merge($channelMap, config('field.AttachmentFields'));
$channel = $request->only($channelMap); $channel = $request->only($channelMap);
$service = new SupplierService(); $service = new SupplierService();
$result = $service->saveSupplier($channel); $result = $service->saveSupplier($channel);
...@@ -209,9 +208,6 @@ class SupplierApiController extends Controller ...@@ -209,9 +208,6 @@ class SupplierApiController extends Controller
if (!$result) { if (!$result) {
$this->response(-1, '修改状态失败'); $this->response(-1, '修改状态失败');
} }
//发送短信
// $messageService = new MessageService();
// $messageService->sendSupplierMessage($supplierId, $status);
//发送队列消息同步到金蝶 //发送队列消息同步到金蝶
$service = new SyncSupplierService(); $service = new SyncSupplierService();
$service->syncSupplierToErp($supplierId); $service->syncSupplierToErp($supplierId);
...@@ -426,7 +422,7 @@ class SupplierApiController extends Controller ...@@ -426,7 +422,7 @@ class SupplierApiController extends Controller
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '拉黑', '拉黑供应商'); $logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '拉黑', '拉黑供应商');
$this->response(0, '拉黑成功'); $this->response(0, '拉黑成功');
} else { } else {
$this->response(-1, '拉黑操作失败 '); $this->response(-1, '拉黑操作失败');
} }
} }
...@@ -473,6 +469,6 @@ class SupplierApiController extends Controller ...@@ -473,6 +469,6 @@ class SupplierApiController extends Controller
$supplierIds = explode(',', $supplierIds); $supplierIds = explode(',', $supplierIds);
$supplierService = new SupplierService(); $supplierService = new SupplierService();
$supplierService->batchApplyInReviewSupplier($supplierIds); $supplierService->batchApplyInReviewSupplier($supplierIds);
$this->response(0, '批量申请审核成功'); $this->response(0, '申请审核成功');
} }
} }
...@@ -4,6 +4,8 @@ namespace App\Http\Controllers; ...@@ -4,6 +4,8 @@ namespace App\Http\Controllers;
use App\Http\Services\LogService; use App\Http\Services\LogService;
use App\Http\Services\RegionService; use App\Http\Services\RegionService;
use App\Http\Services\SupplierAttachmentService;
use App\Http\Services\SupplierAuditService;
use App\Http\Services\SupplierService; use App\Http\Services\SupplierService;
use App\Http\Services\SupplierStatisticsService; use App\Http\Services\SupplierStatisticsService;
use App\Http\Services\SupplierTagService; use App\Http\Services\SupplierTagService;
...@@ -164,6 +166,8 @@ class SupplierController extends Controller ...@@ -164,6 +166,8 @@ class SupplierController extends Controller
$this->data['province_city'] = [$supplier['province_id'], $supplier['city_id']]; $this->data['province_city'] = [$supplier['province_id'], $supplier['city_id']];
$this->data['supplier'] = $supplier; $this->data['supplier'] = $supplier;
$this->data['address'] = $supplierService->getAddress($supplierId); $this->data['address'] = $supplierService->getAddress($supplierId);
$supplierAttachmentService = new SupplierAttachmentService();
$this->data['attachment'] = $supplierAttachmentService->getAttachment($supplierId);
return $this->view('编辑供应商'); return $this->view('编辑供应商');
} }
......
...@@ -99,30 +99,6 @@ class LogService ...@@ -99,30 +99,6 @@ class LogService
$content = 'Sku审核规则由 [ ' . $oldValue . ' ] 改成 [ ' . $newValue . ' ];'; $content = 'Sku审核规则由 [ ' . $oldValue . ' ] 改成 [ ' . $newValue . ' ];';
$result[] = $content; $result[] = $content;
} }
if ($key == 'qualification_photos') {
$oldFiles = json_decode($oldSupplier['qualification_photos'], true);
$oldFileNames = array_map(function ($file) {
return $file['file_name'];
}, $oldFiles);
$newFiles = json_decode($newSupplier['qualification_photos'], true);
$newFileNames = array_map(function ($file) {
return $file['file_name'];
}, $newFiles);
//对比文件名变化
$diffKeys = array_keys(array_diff_assoc($newFileNames, $oldFileNames));
$content = '';
foreach ($diffKeys as $key) {
$oldFileName = array_get($oldFileNames, $key);
$oldFileName = $oldFileName == '选择文件上传' ? ' ' : $oldFileName;
$newFileName = array_get($newFileNames, $key);
if ($newFileName == "选择文件上传") {
continue;
}
$content .= array_get(config('fixed.FileNameMapping'),
$key) . '由 [ ' . $oldFileName . ' ] 修改为 [' . $newFileName . ']; ';
}
$result[] = $content;
}
if ($key == 'extra_fee') { if ($key == 'extra_fee') {
$oldFee = json_decode($oldSupplier['extra_fee'], true); $oldFee = json_decode($oldSupplier['extra_fee'], true);
$newFee = json_decode($newSupplier['extra_fee'], true); $newFee = json_decode($newSupplier['extra_fee'], true);
......
<?php
namespace App\Http\Services;
//后台用户相关信息服务
use App\Model\RedisModel;
use App\Model\SupplierAttachmentModel;
use Illuminate\Support\Facades\DB;
//用于判断是否已经查看的服务
class SupplierAttachmentService
{
public function getAttachment($supplierId)
{
$attachmentModel = new SupplierAttachmentModel();
$attachmentData = $attachmentModel->where('supplier_id', $supplierId)->first();
$attachment = [];
if (!empty($attachmentData)) {
$attachment = json_decode($attachmentData,true);
$attachment = array_map(function ($item) {
return json_decode($item, true);
}, $attachment);
}
return $attachment;
}
public function saveAttachment($supplierId, $attachment)
{
$attachmentModel = new SupplierAttachmentModel();
$attachmentData = $attachmentModel->where('supplier_id', $supplierId)->first();
if (!empty($attachmentData)) {
$attachment['update_time'] = time();
$attachmentModel->where('supplier_id', $supplierId)->update($attachment);
}else{
$attachment['create_time'] = time();
$attachment['supplier_id'] = $supplierId;
$attachmentModel->insert($attachment);
}
}
}
\ No newline at end of file
...@@ -51,11 +51,11 @@ class SupplierService ...@@ -51,11 +51,11 @@ class SupplierService
public function saveSupplier($channel) public function saveSupplier($channel)
{ {
$supplierTransformer = new SupplierTransformer();
//先处理下数据 //先处理下数据
$channel = $this->transformData($channel); $channel = $supplierTransformer->transformFormData($channel);
$logService = new LogService(); $logService = new LogService();
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
$supplierTransformer = new SupplierTransformer();
//获取未修改前的供应商,做数据比较存储 //获取未修改前的供应商,做数据比较存储
$oldSupplier = $newSupplier = []; $oldSupplier = $newSupplier = [];
if (!empty($channel['supplier_id'])) { if (!empty($channel['supplier_id'])) {
...@@ -74,10 +74,10 @@ class SupplierService ...@@ -74,10 +74,10 @@ class SupplierService
$address = array_only($channel, $address = array_only($channel,
['supplier_id', 'shipping_address', 'return_address', 'return_consignee', 'return_phone']); ['supplier_id', 'shipping_address', 'return_address', 'return_consignee', 'return_phone']);
//插入 $attachment = $channel['attachment'];
unset($channel['hk'], $channel['cn'], $channel['return_phone'], $channel['return_address'], unset($channel['hk'], $channel['cn'], $channel['return_phone'], $channel['return_address'],
$channel['return_consignee'], $channel['shipping_address'], $channel['cn_delivery_time_period'], $channel['return_consignee'], $channel['shipping_address'], $channel['cn_delivery_time_period'],
$channel['us_delivery_time_period']); $channel['us_delivery_time_period'], $channel['attachment']);
$skuAuditRulerService = new SupplierSkuAuditRulerService(); $skuAuditRulerService = new SupplierSkuAuditRulerService();
$channel['sku_audit_ruler'] = $skuAuditRulerService->getSkuAuditRulerForDB($channel['sku_audit_ruler']); $channel['sku_audit_ruler'] = $skuAuditRulerService->getSkuAuditRulerForDB($channel['sku_audit_ruler']);
...@@ -148,6 +148,9 @@ class SupplierService ...@@ -148,6 +148,9 @@ class SupplierService
$tagService->saveTags($supplierId, 14, $channel['system_tags'], $oldSystemTags); $tagService->saveTags($supplierId, 14, $channel['system_tags'], $oldSystemTags);
$tagService->saveTags($supplierId, 4, $channel['customer_tags'], $oldCustomerTags); $tagService->saveTags($supplierId, 4, $channel['customer_tags'], $oldCustomerTags);
} }
//保存附件
$attachmentService = new SupplierAttachmentService();
$attachmentService->saveAttachment($supplierId, $attachment);
//保存生成的内部编码 //保存生成的内部编码
$this->saveSupplierCode($supplierId); $this->saveSupplierCode($supplierId);
//重新生成外部显示的编码 //重新生成外部显示的编码
...@@ -189,88 +192,12 @@ class SupplierService ...@@ -189,88 +192,12 @@ class SupplierService
return $dataResult; return $dataResult;
} }
//处理数据
public function transformData($channel)
{
if (!empty($channel['stockup_type'])) {
$stockupType = array_keys($channel['stockup_type']);
$stockupType = !empty($stockupType) ? implode(",", $stockupType) : '';
$channel['stockup_type'] = $stockupType;
}
if (!empty($channel['currency'])) {
if ($channel['currency'] != 1) {
$channel['tax_number'] = '';
}
}
if (empty($channel['purchase_uid'])) {
unset($channel['purchase_uid']);
}
if (!empty($channel['system_tags'])) {
$channel['system_tags'] = rtrim($channel['system_tags'], ',');
}
if (!empty($channel['customer_tags'])) {
$channel['customer_tags'] = rtrim($channel['customer_tags'], ',');
}
$channel['cn_ratio'] = empty($channel['cn_ratio']) ? 1 : $channel['cn_ratio'];
$channel['us_ratio'] = empty($channel['us_ratio']) ? 1 : $channel['us_ratio'];
$channel['cn_delivery_time'] = $channel['cn_delivery_time'] ? $channel['cn_delivery_time'] . $channel['cn_delivery_time_period'] : '';
$channel['us_delivery_time'] = $channel['us_delivery_time'] ? $channel['us_delivery_time'] . $channel['us_delivery_time_period'] : '';
$channel['qualification_photos'] = $this->getPhotosData($channel['upload_file']);
unset($channel['upload_file']);
$channel['established_time'] = strtotime($channel['established_time']);
//省市选择的处理
if (!empty($channel['province_city'])) {
$regionData = explode(',', $channel['province_city']);
$channel['province_id'] = !empty($regionData[0]) ? $regionData[0] : 0;
$channel['city_id'] = !empty($regionData[1]) ? $regionData[1] : 0;
}
//判断所在区域,如果不是中国,则要把省市去掉
if ($channel['region'] != 2) {
$channel['province_id'] = $channel['city_id'] = 0;
}
unset($channel['province_city']);
$skuUploadRulerService = new SupplierSkuUploadRulerService();
$channel['sku_upload_ruler'] = $skuUploadRulerService->getSkuUploadRulerForDB($channel['sku_upload_ruler']);
return $channel;
}
public function getPhotosData($uploadFiles)
{
$data = [];
foreach ($uploadFiles as $name => $file) {
if (empty($file)) {
$data[$name] = [
'name' => $name,
'url' => '',
'file_name' => ''
];
} else {
$file = explode('|_|', $file);
$data[$name] = [
'name' => $name,
'url' => $file[0],
'file_name' => $file[1],
];
}
}
$data = json_encode($data);
return $data;
}
//报错供应商编码,包括系统生成的和自定义规则生成的 //报错供应商编码,包括系统生成的和自定义规则生成的
private function saveSupplierCode($supplierId) private function saveSupplierCode($supplierId)
{ {
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
$supplier = $model->where('supplier_id', $supplierId)->first(); $supplier = $model->where('supplier_id', $supplierId)->first();
if (!empty($supplier)) { if (!empty($supplier)) {
$supplier = $supplier->toArray();
$supplierCode = 'L' . str_pad($supplierId, 7, "0", STR_PAD_LEFT); $supplierCode = 'L' . str_pad($supplierId, 7, "0", STR_PAD_LEFT);
return $model->where('supplier_id', $supplierId)->update([ return $model->where('supplier_id', $supplierId)->update([
'supplier_code' => $supplierCode, 'supplier_code' => $supplierCode,
......
...@@ -30,7 +30,7 @@ class SupplierTransformer ...@@ -30,7 +30,7 @@ class SupplierTransformer
$supplier = $this->getStockupType($supplier); $supplier = $this->getStockupType($supplier);
$supplier['supplier_group'] = array_get(config('fixed.SupplierGroup'), $supplier['supplier_group'], '未设置'); $supplier['supplier_group'] = array_get(config('fixed.SupplierGroup'), $supplier['supplier_group'], '未设置');
$supplier['region_name'] = array_get(config('fixed.Region'), $supplier['region']); $supplier['region_name'] = array_get(config('fixed.Region'), $supplier['region']);
$supplier['create_time'] = $supplier['create_time']?date('Y-m-d H:i:s', $supplier['create_time']):''; $supplier['create_time'] = $supplier['create_time'] ? date('Y-m-d H:i:s', $supplier['create_time']) : '';
$supplier['audit_time'] = $supplier['audit_time'] ? date('Y-m-d H:i:s', $supplier['audit_time']) : ''; $supplier['audit_time'] = $supplier['audit_time'] ? date('Y-m-d H:i:s', $supplier['audit_time']) : '';
$supplier['update_time'] = $supplier['update_time'] ? date('Y-m-d H:i:s', $supplier['update_time']) : ''; $supplier['update_time'] = $supplier['update_time'] ? date('Y-m-d H:i:s', $supplier['update_time']) : '';
$supplier['channel_username'] = $this->getChannelUserNames($supplier['channel_uid']); $supplier['channel_username'] = $this->getChannelUserNames($supplier['channel_uid']);
...@@ -91,7 +91,6 @@ class SupplierTransformer ...@@ -91,7 +91,6 @@ class SupplierTransformer
} }
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$users = $intracodeModel->getSampleEncode(true); $users = $intracodeModel->getSampleEncode(true);
$supplier['qualification_photos'] = trim($supplier['qualification_photos']);
$supplier['stockup_type_data'] = $this->transformStockupTypeData($supplier['stockup_type']); $supplier['stockup_type_data'] = $this->transformStockupTypeData($supplier['stockup_type']);
$supplier['established_time'] = !empty($supplier['established_time']) ? date('Y-m-d', $supplier['established_time'] = !empty($supplier['established_time']) ? date('Y-m-d',
$supplier['established_time']) : ''; $supplier['established_time']) : '';
...@@ -107,8 +106,7 @@ class SupplierTransformer ...@@ -107,8 +106,7 @@ class SupplierTransformer
$supplier['create_time'] = $supplier['create_time'] ? date('Y-m-d H:i:s', $supplier['create_time']) : ''; $supplier['create_time'] = $supplier['create_time'] ? date('Y-m-d H:i:s', $supplier['create_time']) : '';
$supplier['channel_username'] = $this->getChannelUserNames($supplier['channel_uid']); $supplier['channel_username'] = $this->getChannelUserNames($supplier['channel_uid']);
$supplier['purchase_username'] = array_get($users, $supplier['purchase_uid']); $supplier['purchase_username'] = array_get($users, $supplier['purchase_uid']);
$supplier['yunxin_channel_username'] = array_get($users, array_get($supplier,'yunxin_channel_uid')); $supplier['yunxin_channel_username'] = array_get($users, array_get($supplier, 'yunxin_channel_uid'));
$supplier['qualification_photos'] = $this->getPhotosDataForForm($supplier['qualification_photos']);
$uploadRulerService = new SupplierSkuUploadRulerService(); $uploadRulerService = new SupplierSkuUploadRulerService();
$supplier['sku_upload_ruler'] = $uploadRulerService->getSkuUploadRuler($supplier['sku_upload_ruler']); $supplier['sku_upload_ruler'] = $uploadRulerService->getSkuUploadRuler($supplier['sku_upload_ruler']);
$ruleService = new SupplierSkuAuditRulerService(); $ruleService = new SupplierSkuAuditRulerService();
...@@ -153,26 +151,6 @@ class SupplierTransformer ...@@ -153,26 +151,6 @@ class SupplierTransformer
return $supplier; return $supplier;
} }
private function getPhotosDataForForm($photos)
{
if (empty($photos)) {
return [];
}
$photos = json_decode($photos, true);
if (empty($photos['business_license'])) {
return [];
}
$data = [];
foreach ($photos as $name => $photo) {
$data[$name] = [
'value' => $photo['url'] . '|_|' . $photo['file_name'],
'file_name' => $photo['file_name'] ?: '选择文件上传',
'url' => $photo['url'],
];
}
return $data;
}
private function getStockupType($supplier) private function getStockupType($supplier)
{ {
$supplier['stockup_type'] = explode(',', $supplier['stockup_type']); $supplier['stockup_type'] = explode(',', $supplier['stockup_type']);
...@@ -201,4 +179,65 @@ class SupplierTransformer ...@@ -201,4 +179,65 @@ class SupplierTransformer
return []; return [];
} }
//转换表单数据
public function transformFormData($channel)
{
if (!empty($channel['stockup_type'])) {
$stockupType = array_keys($channel['stockup_type']);
$stockupType = !empty($stockupType) ? implode(",", $stockupType) : '';
$channel['stockup_type'] = $stockupType;
}
if (!empty($channel['currency'])) {
if ($channel['currency'] != 1) {
$channel['tax_number'] = '';
}
}
if (empty($channel['purchase_uid'])) {
unset($channel['purchase_uid']);
}
if (!empty($channel['system_tags'])) {
$channel['system_tags'] = rtrim($channel['system_tags'], ',');
}
if (!empty($channel['customer_tags'])) {
$channel['customer_tags'] = rtrim($channel['customer_tags'], ',');
}
$channel['cn_ratio'] = empty($channel['cn_ratio']) ? 1 : $channel['cn_ratio'];
$channel['us_ratio'] = empty($channel['us_ratio']) ? 1 : $channel['us_ratio'];
$channel['cn_delivery_time'] = $channel['cn_delivery_time'] ? $channel['cn_delivery_time'] . $channel['cn_delivery_time_period'] : '';
$channel['us_delivery_time'] = $channel['us_delivery_time'] ? $channel['us_delivery_time'] . $channel['us_delivery_time_period'] : '';
unset($channel['upload_file']);
$channel['established_time'] = strtotime($channel['established_time']);
//省市选择的处理
if (!empty($channel['province_city'])) {
$regionData = explode(',', $channel['province_city']);
$channel['province_id'] = !empty($regionData[0]) ? $regionData[0] : 0;
$channel['city_id'] = !empty($regionData[1]) ? $regionData[1] : 0;
}
//判断所在区域,如果不是中国,则要把省市去掉
if ($channel['region'] != 2) {
$channel['province_id'] = $channel['city_id'] = 0;
}
unset($channel['province_city']);
$skuUploadRulerService = new SupplierSkuUploadRulerService();
$channel['sku_upload_ruler'] = $skuUploadRulerService->getSkuUploadRulerForDB($channel['sku_upload_ruler']);
$attachment = [];
$attachmentFields = config('field.AttachmentFields');
foreach ($channel as $key=>$field) {
if (in_array($key, $attachmentFields)) {
$attachment[$key] = $field;
unset($channel[$key]);
}
}
$channel['attachment'] = $attachment;
return $channel;
}
} }
\ No newline at end of file
...@@ -28,7 +28,7 @@ class SupplierValidator ...@@ -28,7 +28,7 @@ class SupplierValidator
'return_address' => 'max:100', 'return_address' => 'max:100',
'return_consignee' => 'max:50', 'return_consignee' => 'max:50',
'return_phone' => 'max:50', 'return_phone' => 'max:50',
'upload_file.business_license' => 'required', 'business_license' => 'required',
'cn_ratio' => 'min:1', 'cn_ratio' => 'min:1',
'us_ratio' => 'min:1', 'us_ratio' => 'min:1',
]; ];
...@@ -99,7 +99,7 @@ class SupplierValidator ...@@ -99,7 +99,7 @@ class SupplierValidator
'region.required' => '所在区域不能为空', 'region.required' => '所在区域不能为空',
'purchase_uid.required' => '渠道开发员不能为空', 'purchase_uid.required' => '渠道开发员不能为空',
'cn_ratio.min' => '人民币系数必须是大于1的浮点数', 'cn_ratio.min' => '人民币系数必须是大于1的浮点数',
'upload_file.business_license.required' => '营业执照不能为空', 'business_license.required' => '营业执照不能为空',
'us_ratio.min' => '美金系数必须是大于1的浮点数', 'us_ratio.min' => '美金系数必须是大于1的浮点数',
'us_delivery_time.regex' => '香港货期格式不正确', 'us_delivery_time.regex' => '香港货期格式不正确',
'cn_delivery_time.regex' => '大陆货期格式不正确', 'cn_delivery_time.regex' => '大陆货期格式不正确',
......
...@@ -57,5 +57,19 @@ return [ ...@@ -57,5 +57,19 @@ return [
'SupplierAccountType' => [ 'SupplierAccountType' => [
0 => '其它', 0 => '其它',
1 => '云芯商家' 1 => '云芯商家'
] ],
'AttachmentFields' => [
'business_license',
'billing_information',
'registration_certificate',
'incorporation_certificate',
'certification_notice',
'supplier_survey',
'proxy_certificate',
'quality_assurance_agreement',
'confidentiality_agreement',
'cooperation_agreement',
'other_attachment',
],
]; ];
\ No newline at end of file
...@@ -249,9 +249,13 @@ ...@@ -249,9 +249,13 @@
layer.msg('你没有复审供应商的权限', {icon: 5}) layer.msg('你没有复审供应商的权限', {icon: 5})
return return
} }
if (status === 0) {
layer.msg('该供应商还没有申请审核', {icon: 5});
return;
}
if (status !== 1 && status !== -1) { if (status !== 1 && status !== -1) {
layer.msg('该供应商已经被审核', {icon: 5}) layer.msg('该供应商已经被审核', {icon: 5});
return return;
} }
// if (status === -1) { // if (status === -1) {
// layer.msg('要审核中的供应商才可以审核', {icon: 5}); // layer.msg('要审核中的供应商才可以审核', {icon: 5});
......
{{Autograph()}} {{Autograph()}}
<script> <script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'upload'], function () { layui.use(['table', 'form', 'element', 'layer', 'admin', 'upload'], function () {
let table = layui.table;
let form = layui.form;
let admin = layui.admin;
let element = layui.element;
let upload = layui.upload; let upload = layui.upload;
let layer = layui.layer; let layer = layui.layer;
let form = layui.form;
let fileName = ''; let fileName = '';
var loadIndex = 0; var loadIndex = 0;
let fileType = '';
//监听附件上传选择,有值才显示上传按钮
form.on('select(file_type_selector)', function (data) {
fileType = data.value;
if (data.value) {
$('#disable_upload_button').hide();
$('#upload_button').show();
} else {
$('#disable_upload_button').show();
$('#upload_button').hide();
}
});
upload.render({ upload.render({
elem: '.uploadButton' elem: '#upload_button'
, url: '{{config('website.UploadUrl')}}' //改成您自己的上传接口 , url: '{{config('website.UploadUrl')}}' //改成您自己的上传接口
, accept: 'file' //文件 , accept: 'file' //文件
, field: 'upload' , field: 'upload'
...@@ -24,6 +35,7 @@ ...@@ -24,6 +35,7 @@
, exts: 'jpg|png|bmp|jpeg|zip|pdf' , exts: 'jpg|png|bmp|jpeg|zip|pdf'
, size: 20000 , size: 20000
, before: function () { , before: function () {
} }
, choose: function (obj) { , choose: function (obj) {
var files = this.files = obj.pushFile(); var files = this.files = obj.pushFile();
...@@ -33,15 +45,46 @@ ...@@ -33,15 +45,46 @@
} }
, done: function (res, index, upload) { , done: function (res, index, upload) {
if (res.code === 200) { if (res.code === 200) {
this.item.parent().find('.upload_obj').val(res.data[0] + '|_|' + fileName); //动态添加js
this.item.parent().find('.uploadButton').text(fileName); let fileTemplateObj = $('#file_template')
fileTemplateObj.find('a').attr('href', res.data[0]);
fileTemplateObj.find('a').text(fileName);
let fileTemplate = fileTemplateObj.html();
$('#' + fileType + '_div').show();
$('#' + fileType + '_file_div').append(fileTemplate);
setFileTypeValue(fileType);
} else { } else {
layer.msg('上传接口异常,请重试或者联系管理员 . ' + res.message); layer.msg('上传接口异常,请重试或者联系管理员 . ' + res.message);
} }
// console.log(this.files[index]);
delete this.files[index]; delete this.files[index];
layer.close(loadIndex); layer.close(loadIndex);
} }
}); });
//删除文件操作
$(document).on('click', '.delete_file', function () {
let fileType = $(this).parent().parent().parent().find('input').attr('id');
//找出对应的div删除
$(this).parent().remove();
setFileTypeValue(fileType)
});
//遍历找出文件list复制到表单域
function setFileTypeValue(fileType) {
let fileTypeObj = $('#' + fileType);
let fileTypeDiv = $('#' + fileType + '_div');
let fileValueArr = [];
fileTypeDiv.find('a').each(function () {
let url = $(this).attr('href');
let fileName = $(this).text();
let fileValueMap = {
file_name: fileName,
url: url,
name: fileType
}
fileValueArr.push(fileValueMap)
})
fileTypeObj.val(JSON.stringify(fileValueArr));
}
}); });
</script> </script>
\ No newline at end of file
...@@ -58,14 +58,16 @@ ...@@ -58,14 +58,16 @@
<button type="button" style="margin-bottom: 25px;margin-top: 5px" <button type="button" style="margin-bottom: 25px;margin-top: 5px"
class="layui-btn layui-btn layui-btn-disabled">待复审,不能修改 class="layui-btn layui-btn layui-btn-disabled">待复审,不能修改
</button> </button>
@elseif($supplier['status']==\App\Model\SupplierChannelModel::STATUS_PASSED||$supplier['status']==\App\Model\SupplierChannelModel::STATUS_REJECT) @elseif($supplier['status']==\App\Model\SupplierChannelModel::STATUS_PASSED||$supplier['status']==\App\Model\SupplierChannelModel::STATUS_REJECT
||$supplier['status']==\App\Model\SupplierChannelModel::STATUS_PENDING)
<a id="updateSupplierUrl" <a id="updateSupplierUrl"
style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">修改</a> style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">修改</a>
@endif @endif
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_DISABLE) @if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_DISABLE)
@if (checkPerm('CancelDisableSupplier')) @if (checkPerm('CancelDisableSupplier'))
<button id="cancel_disable_supplier" <button id="cancel_disable_supplier"
style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">取消禁用</button> style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">取消禁用
</button>
@endif @endif
@endif @endif
...@@ -146,15 +148,15 @@ ...@@ -146,15 +148,15 @@
</div> </div>
</div> </div>
<div class="layui-row" style="width: 700px"> <div class="layui-row" style="width: 700px">
@foreach($supplier['qualification_photos'] as $name=>$file) {{-- @foreach($supplier['qualification_photos'] as $name=>$file)--}}
@if(!empty($file['url'])) {{-- @if(!empty($file['url']))--}}
<div class="layui-col-md6"> {{-- <div class="layui-col-md6">--}}
{{array_get(config('fixed.FileNameMapping'),$name)}} :<a {{-- {{array_get(config('fixed.FileNameMapping'),$name)}} :<a--}}
style="color: dodgerblue" href="{{$file['url']}}" target="_blank"> {{-- style="color: dodgerblue" href="{{$file['url']}}" target="_blank">--}}
{{$file['file_name']}}</a> {{-- {{$file['file_name']}}</a>--}}
</div> {{-- </div>--}}
@endif {{-- @endif--}}
@endforeach {{-- @endforeach--}}
</div> </div>
<hr/> <hr/>
<blockquote class="layui-elem-quote layui-text"> <blockquote class="layui-elem-quote layui-text">
......
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