Commit bacd100a by 杨树贤

Merge branch 'ysx-呆料库存管理-供应商侧-20260602' into Dev

parents d4f153d1 cb4d42e1
...@@ -333,6 +333,9 @@ class SkuApiController extends Controller ...@@ -333,6 +333,9 @@ class SkuApiController extends Controller
if (empty($goodsLabel)) { if (empty($goodsLabel)) {
$this->response(-1, '请选择显示类型'); $this->response(-1, '请选择显示类型');
} }
if ((string)$goodsLabel === (string)SkuService::GOODS_LABEL_DEAD_STOCK) {
$this->response(-1, '呆料库存不可以设置显示类型');
}
(new SkuService())->batchUpdateGoodsLabel($type, $supplierCode, $skuIds, $goodsLabel); (new SkuService())->batchUpdateGoodsLabel($type, $supplierCode, $skuIds, $goodsLabel);
$text = $type == 1 ? '设置显示类型成功' : '批量设置供应SKU商显示类型任务已开始,请等待任务完成'; $text = $type == 1 ? '设置显示类型成功' : '批量设置供应SKU商显示类型任务已开始,请等待任务完成';
......
...@@ -108,6 +108,7 @@ class SupplierApiController extends Controller ...@@ -108,6 +108,7 @@ class SupplierApiController extends Controller
'sku_optional_batch', 'sku_optional_batch',
'nation_id', 'nation_id',
'supplier_source', 'supplier_source',
'reverse_purchaser',
]; ];
public function Entrance(Request $request, $id) public function Entrance(Request $request, $id)
...@@ -481,6 +482,26 @@ class SupplierApiController extends Controller ...@@ -481,6 +482,26 @@ class SupplierApiController extends Controller
$this->response(0, '批量分配数据维护员成功'); $this->response(0, '批量分配数据维护员成功');
} }
//批量分配逆向采购员
public function BatchAllocateReversePurchaser($request)
{
$reversePurchaser = trim($request->get('reverse_purchaser'));
$supplierIds = $request->get('supplier_ids');
$supplierIds = explode(',', $supplierIds);
if (empty($reversePurchaser)) {
$this->response(-1, '请选择逆向采购员');
}
$hasCrmSupplier = SupplierChannelModel::whereIn('supplier_id', $supplierIds)
->where('supplier_source', SupplierChannelModel::SUPPLIER_SOURCE_CRM)
->exists();
if ($hasCrmSupplier) {
$this->response(-1, 'CRM来源的供应商不允许分配逆向采购员');
}
$supplierService = new SupplierService();
$supplierService->batchAllocateReversePurchaser($supplierIds, $reversePurchaser);
$this->response(0, '批量分配逆向采购员成功');
}
//分配采购员(支持批量操作) //分配采购员(支持批量操作)
public function BatchAllocateChannelUser($request) public function BatchAllocateChannelUser($request)
{ {
......
...@@ -7,6 +7,7 @@ use GuzzleHttp\Client; ...@@ -7,6 +7,7 @@ use GuzzleHttp\Client;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\TagsModel; use App\Model\TagsModel;
use App\Model\BrandModel; use App\Model\BrandModel;
use App\Model\RedisModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Model\IntracodeModel; use App\Model\IntracodeModel;
use App\Model\SupplierLogModel; use App\Model\SupplierLogModel;
...@@ -67,6 +68,10 @@ class SkuController extends Controller ...@@ -67,6 +68,10 @@ class SkuController extends Controller
$intraCodeModel = new IntracodeModel(); $intraCodeModel = new IntracodeModel();
$this->data['userCodes'] = $intraCodeModel->getSampleEncode(); $this->data['userCodes'] = $intraCodeModel->getSampleEncode();
$this->data['createUserDepartmentList'] = (new DepartmentService())->getCreateUserDepartmentListForXmSelect(); $this->data['createUserDepartmentList'] = (new DepartmentService())->getCreateUserDepartmentListForXmSelect();
$redis = new RedisModel();
$hashKey = 'col_settings:sku_list';
$colSettings = $redis->hget($hashKey, $request->user->userId);
$this->data['colSettings'] = $colSettings ? $colSettings : '{}';
return $this->view('供应商日志'); return $this->view('供应商日志');
} }
......
...@@ -228,7 +228,8 @@ class SupplierController extends Controller ...@@ -228,7 +228,8 @@ class SupplierController extends Controller
{ {
$intraCodeModel = new IntracodeModel(); $intraCodeModel = new IntracodeModel();
$userCodes = $intraCodeModel->getSampleEncode(); $userCodes = $intraCodeModel->getSampleEncode();
$this->data['userCodes'] = $intraCodeModel->getChannelUsersEncode(); $channelUserCodes = $intraCodeModel->getChannelUsersEncode();
$this->data['userCodes'] = $channelUserCodes;
$this->data['user'] = $userCodes; $this->data['user'] = $userCodes;
$this->data['purchase_users'] = []; $this->data['purchase_users'] = [];
$this->data['operate'] = 'update'; $this->data['operate'] = 'update';
...@@ -349,6 +350,24 @@ class SupplierController extends Controller ...@@ -349,6 +350,24 @@ class SupplierController extends Controller
return $this->view('批量分配数据维护员'); return $this->view('批量分配数据维护员');
} }
//批量分配逆向采购员
public function BatchAllocateReversePurchaser($request)
{
$supplierIds = $request->get('supplier_ids');
$this->data['supplierIds'] = $supplierIds;
$supplierIds = explode(',', $supplierIds);
$model = new SupplierChannelModel();
$suppliers = $model->whereIn('supplier_id', $supplierIds)->get()->toArray();
$transformer = new SupplierTransformer();
$suppliers = $transformer->transformList($suppliers);
$this->data['suppliers'] = $suppliers;
$intraCodeModel = new IntracodeModel();
$this->data['reversePurchaserOptions'] = $this->buildReversePurchaseUserOptions(
$intraCodeModel->getChannelUsersEncode(false)
);
return $this->view('批量分配逆向采购员');
}
//批量添加采购员 //批量添加采购员
public function AllocateChannelUser($request) public function AllocateChannelUser($request)
{ {
...@@ -474,6 +493,23 @@ class SupplierController extends Controller ...@@ -474,6 +493,23 @@ class SupplierController extends Controller
return $this->view('转化供应商确认'); return $this->view('转化供应商确认');
} }
private function buildReversePurchaseUserOptions($userCodes, $currentValue = '')
{
$options = [];
foreach ($userCodes as $label) {
$plainName = preg_replace('/\(\d+\).*$/', '', $label);
$plainName = trim($plainName);
if ($plainName === '') {
continue;
}
$options[$plainName] = $label;
}
if ($currentValue !== '' && !isset($options[$currentValue])) {
$options[$currentValue] = $currentValue;
}
return $options;
}
//导出供应商详情表格 //导出供应商详情表格
public function PrintSupplier($request) public function PrintSupplier($request)
{ {
......
...@@ -273,6 +273,7 @@ class SupplierSyncController extends BaseSyncController ...@@ -273,6 +273,7 @@ class SupplierSyncController extends BaseSyncController
'supplier_type' => SupplierChannelModel::SUPPLIER_TYPE_OFFICIAL, // 正式供应商 'supplier_type' => SupplierChannelModel::SUPPLIER_TYPE_OFFICIAL, // 正式供应商
'is_business_abnormal' => -1, // 默认无异常 'is_business_abnormal' => -1, // 默认无异常
'has_legal_ID_card' => -1, // 默认无法人身份证 'has_legal_ID_card' => -1, // 默认无法人身份证
'sku_upload_ruler' => json_encode(SupplierService::normalizeCrmSkuUploadRuler(config('fixed.SkuUploadDefaultRuler'))),
'apply_uid' => $applyUid, 'apply_uid' => $applyUid,
// 状态设为待确认 // 状态设为待确认
'status' => SupplierChannelModel::STATUS_CONFIRM, 'status' => SupplierChannelModel::STATUS_CONFIRM,
...@@ -307,6 +308,7 @@ class SupplierSyncController extends BaseSyncController ...@@ -307,6 +308,7 @@ class SupplierSyncController extends BaseSyncController
'supplier_code' => $supplierCode, 'supplier_code' => $supplierCode,
'supplier_sn' => 'FOO' . ltrim($supplierCode, 'L'), 'supplier_sn' => 'FOO' . ltrim($supplierCode, 'L'),
]); ]);
(new SupplierService())->saveSkuUploadRulerToRedis($supplierId, $channel['sku_upload_ruler']);
// 提交审批到审核中心(在事务中,失败则回滚) // 提交审批到审核中心(在事务中,失败则回滚)
$auditService = new SupplierAuditService(); $auditService = new SupplierAuditService();
......
...@@ -8,6 +8,7 @@ use App\Model\LogModel; ...@@ -8,6 +8,7 @@ use App\Model\LogModel;
use App\Model\TagsModel; use App\Model\TagsModel;
use App\Model\RedisModel; use App\Model\RedisModel;
use App\Model\IntracodeModel; use App\Model\IntracodeModel;
use App\Model\SupplierExtendModel;
use App\Model\SkuUploadLogModel; use App\Model\SkuUploadLogModel;
use App\Model\ManualPutawaySkuLog; use App\Model\ManualPutawaySkuLog;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
...@@ -20,6 +21,7 @@ use PhpAmqpLib\Connection\AMQPStreamConnection; ...@@ -20,6 +21,7 @@ use PhpAmqpLib\Connection\AMQPStreamConnection;
class SkuService extends BaseService class SkuService extends BaseService
{ {
const GOODS_LABEL_DEAD_STOCK = 7;
const OPERATE_TYPE_PUTAWAY = 1; const OPERATE_TYPE_PUTAWAY = 1;
const OPERATE_TYPE_OFF_SHELVES = -1; const OPERATE_TYPE_OFF_SHELVES = -1;
...@@ -182,14 +184,19 @@ class SkuService extends BaseService ...@@ -182,14 +184,19 @@ class SkuService extends BaseService
$canalList = array_filter(array_unique(array_column($list, 'canal'))); $canalList = array_filter(array_unique(array_column($list, 'canal')));
if (!empty($canalList)) { if (!empty($canalList)) {
$suppliers = SupplierChannelModel::whereIn('supplier_code', $canalList) $suppliers = SupplierChannelModel::whereIn('supplier_code', $canalList)
->pluck('purchase_uid', 'supplier_code') ->get(['supplier_code', 'purchase_uid', 'supplier_id'])
->keyBy('supplier_code')
->toArray(); ->toArray();
$reversePurchaserMap = SupplierExtendModel::getReversePurchaserBySupplierIds(array_column($suppliers, 'supplier_id'));
$intraCodeModel = new IntracodeModel(); $intraCodeModel = new IntracodeModel();
$users = $intraCodeModel->getSampleEncode(true); $users = $intraCodeModel->getSampleEncode(true);
foreach ($list as &$item) { foreach ($list as &$item) {
$canal = array_get($item, 'canal'); $canal = array_get($item, 'canal');
$purchaseUid = array_get($suppliers, $canal, ''); $supplier = array_get($suppliers, $canal, []);
$purchaseUid = array_get($supplier, 'purchase_uid', '');
$supplierId = array_get($supplier, 'supplier_id', 0);
$item['purchase_username'] = array_get($users, $purchaseUid, ''); $item['purchase_username'] = array_get($users, $purchaseUid, '');
$item['reverse_purchaser'] = array_get($reversePurchaserMap, $supplierId, '');
} }
unset($item); unset($item);
} }
......
...@@ -14,6 +14,7 @@ use App\Model\SupplierAddressModel; ...@@ -14,6 +14,7 @@ use App\Model\SupplierAddressModel;
use App\Model\SupplierAttachmentsModel; use App\Model\SupplierAttachmentsModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel; use App\Model\SupplierContactModel;
use App\Model\SupplierExtendModel;
use App\Model\SupplierReceiptModel; use App\Model\SupplierReceiptModel;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
...@@ -68,6 +69,9 @@ class SupplierService ...@@ -68,6 +69,9 @@ class SupplierService
$supplierTransformer = new SupplierTransformer(); $supplierTransformer = new SupplierTransformer();
//先处理下数据 //先处理下数据
$channel = $supplierTransformer->transformPostData($channel); $channel = $supplierTransformer->transformPostData($channel);
$hasReversePurchaserField = array_key_exists('reverse_purchaser', $channel);
$reversePurchaser = $hasReversePurchaserField ? array_get($channel, 'reverse_purchaser', '') : null;
unset($channel['reverse_purchaser']);
$logService = new LogService(); $logService = new LogService();
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
...@@ -84,7 +88,7 @@ class SupplierService ...@@ -84,7 +88,7 @@ class SupplierService
$isDirectApply = request()->get('direct_apply'); $isDirectApply = request()->get('direct_apply');
//走事务 //走事务
$supplierId = DB::connection('web')->transaction(function () use ($channel, $model, $oldSupplier, &$needAudit, $isDirectApply, &$address) { $supplierId = DB::connection('web')->transaction(function () use ($channel, $hasReversePurchaserField, $reversePurchaser, $model, $oldSupplier, &$needAudit, $isDirectApply, &$address) {
//是否直接申请审核,如果是直接申请审核,那就变成待审核 //是否直接申请审核,如果是直接申请审核,那就变成待审核
// $isDirectApply 已经从外部传入 // $isDirectApply 已经从外部传入
...@@ -204,6 +208,9 @@ class SupplierService ...@@ -204,6 +208,9 @@ class SupplierService
//插入sku上传规则 //插入sku上传规则
$this->saveSkuUploadRulerToRedis($supplierId, $channel['sku_upload_ruler']); $this->saveSkuUploadRulerToRedis($supplierId, $channel['sku_upload_ruler']);
if ($hasReversePurchaserField) {
$this->saveReversePurchaser($supplierId, $reversePurchaser);
}
//添加联系人 //添加联系人
//要有数据才新增,麻烦得要死 //要有数据才新增,麻烦得要死
...@@ -282,10 +289,17 @@ class SupplierService ...@@ -282,10 +289,17 @@ class SupplierService
$channel['system_tags'] = trim(implode(',', $channel['system_tags']), ','); $channel['system_tags'] = trim(implode(',', $channel['system_tags']), ',');
if (array_get($oldSupplier, 'supplier_source') == SupplierChannelModel::SUPPLIER_SOURCE_CRM) {
$channel['sku_upload_ruler'] = json_encode(self::normalizeCrmSkuUploadRuler($channel['sku_upload_ruler']));
}
// 防御:禁止编辑时覆盖 supplier_source,防止被意外改为0 // 防御:禁止编辑时覆盖 supplier_source,防止被意外改为0
unset($channel['supplier_source']); unset($channel['supplier_source']);
$model->where('supplier_id', $supplierId)->update($channel); $model->where('supplier_id', $supplierId)->update($channel);
if ($hasReversePurchaserField) {
$this->saveReversePurchaser($supplierId, $reversePurchaser);
}
$supplierAddressService = new SupplierAddressService(); $supplierAddressService = new SupplierAddressService();
//保存地址 //保存地址
...@@ -628,6 +642,58 @@ class SupplierService ...@@ -628,6 +642,58 @@ class SupplierService
return true; return true;
} }
public function allocateReversePurchaser($supplierId, $reversePurchaser)
{
return DB::connection('web')->transaction(function () use ($supplierId, $reversePurchaser) {
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first();
if (empty($supplier)) {
return false;
}
$supplier = $supplier->toArray();
if ($supplier['supplier_source'] == SupplierChannelModel::SUPPLIER_SOURCE_CRM) {
throw new \Exception('CRM来源的供应商不允许分配逆向采购员');
}
$extend = SupplierExtendModel::where('supplier_id', $supplierId)->first();
$previousReversePurchaser = $extend ? $extend['reverse_purchaser'] : '';
$time = time();
if ($extend) {
SupplierExtendModel::where('supplier_id', $supplierId)->update([
'reverse_purchaser' => $reversePurchaser,
'update_time' => $time,
]);
} else {
SupplierExtendModel::insert([
'supplier_id' => $supplierId,
'reverse_purchaser' => $reversePurchaser,
'create_time' => $time,
'update_time' => $time,
]);
}
SupplierChannelModel::where('supplier_id', $supplierId)->update([
'update_time' => $time,
]);
$logService = new LogService();
$content = "将逆向采购员由 [{$previousReversePurchaser}] 改为 [{$reversePurchaser}]";
$logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '分配逆向采购员', $content);
return true;
});
}
public function batchAllocateReversePurchaser($supplierIds, $reversePurchaser)
{
foreach ($supplierIds as $supplierId) {
if (empty($supplierId)) {
continue;
}
$this->allocateReversePurchaser($supplierId, $reversePurchaser);
}
return true;
}
//批量分配线上采购员 //批量分配线上采购员
public function batchAllocateYunxinChannelUser($supplierIds, $yunxinChannelUid) public function batchAllocateYunxinChannelUser($supplierIds, $yunxinChannelUid)
{ {
...@@ -958,6 +1024,57 @@ class SupplierService ...@@ -958,6 +1024,57 @@ class SupplierService
return '{"allow_stock_lte_0":0,"allow_moq_lte_0":0,"allow_stock_lt_moq":0,"allow_price_null":0,"futures_allow_stock_lte_0":0,"futures_allow_moq_lte_0":0,"futures_allow_price_null":0}'; return '{"allow_stock_lte_0":0,"allow_moq_lte_0":0,"allow_stock_lt_moq":0,"allow_price_null":0,"futures_allow_stock_lte_0":0,"futures_allow_moq_lte_0":0,"futures_allow_price_null":0}';
} }
public static function normalizeCrmSkuUploadRuler($ruler)
{
if (empty($ruler)) {
$ruler = config('fixed.SkuUploadDefaultRuler');
} elseif (is_string($ruler)) {
$ruler = json_decode($ruler, true);
}
if (!is_array($ruler)) {
$ruler = config('fixed.SkuUploadDefaultRuler');
}
foreach (self::getCrmSkuUploadRulerKeys() as $key) {
$ruler[$key] = 1;
}
return $ruler;
}
public static function getCrmSkuUploadRulerKeys()
{
return [
'allow_stock_lte_0',
'allow_moq_lte_0',
'allow_price_null',
'futures_allow_stock_lte_0',
'futures_allow_moq_lte_0',
'futures_allow_price_null',
];
}
private function saveReversePurchaser($supplierId, $reversePurchaser)
{
$extend = SupplierExtendModel::where('supplier_id', $supplierId)->first();
if ($extend) {
SupplierExtendModel::where('supplier_id', $supplierId)->update([
'reverse_purchaser' => $reversePurchaser,
'update_time' => time(),
]);
return;
}
if ($reversePurchaser === '' || $reversePurchaser === null) {
return;
}
SupplierExtendModel::insert([
'supplier_id' => $supplierId,
'reverse_purchaser' => $reversePurchaser,
'create_time' => time(),
'update_time' => time(),
]);
}
//修改供应商名称 //修改供应商名称
public function changeSupplierName($supplierId, $supplierName) public function changeSupplierName($supplierId, $supplierName)
{ {
...@@ -1426,4 +1543,4 @@ class SupplierService ...@@ -1426,4 +1543,4 @@ class SupplierService
return $result; return $result;
} }
} }
\ No newline at end of file
...@@ -315,6 +315,9 @@ class SupplierTransformer ...@@ -315,6 +315,9 @@ class SupplierTransformer
$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'));
$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']);
if ($supplier['supplier_source'] == SupplierChannelModel::SUPPLIER_SOURCE_CRM) {
$supplier['sku_upload_ruler'] = SupplierService::normalizeCrmSkuUploadRuler($supplier['sku_upload_ruler']);
}
$ruleService = new SupplierSkuAuditRulerService(); $ruleService = new SupplierSkuAuditRulerService();
$supplier['sku_audit_ruler'] = $ruleService->getSkuAuditRuler(array_get($supplier, 'sku_audit_ruler')); $supplier['sku_audit_ruler'] = $ruleService->getSkuAuditRuler(array_get($supplier, 'sku_audit_ruler'));
$supplier = $this->transformDeliveryTimeData($supplier); $supplier = $this->transformDeliveryTimeData($supplier);
......
...@@ -50,6 +50,7 @@ return [ ...@@ -50,6 +50,7 @@ return [
4 => '询价现货', 4 => '询价现货',
5 => '原厂直售', 5 => '原厂直售',
6 => '猎芯精选', 6 => '猎芯精选',
7 => '呆料库存',
-1 => '代购现货' -1 => '代购现货'
], ],
...@@ -60,6 +61,7 @@ return [ ...@@ -60,6 +61,7 @@ return [
4 => '询价现货', 4 => '询价现货',
5 => '原厂直售', 5 => '原厂直售',
6 => '猎芯精选', 6 => '猎芯精选',
7 => '呆料库存',
-1 => '代购现货' -1 => '代购现货'
], ],
......
<script>
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin'], function () {
let admin = layui.admin;
let form = layui.form;
form.on('submit(allocateReversePurchaser)', function (data) {
admin.showLoading({
type: 3
});
let supplierIds = getQueryVariable('supplier_ids');
let url = '/api/supplier/BatchAllocateReversePurchaser?supplier_ids=' + supplierIds;
$.ajax({
url: url,
type: 'GET',
async: true,
data: data.field,
dataType: 'json',
timeout: 20000,
success: function (res) {
admin.removeLoading();
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
},
error: function () {
admin.removeLoading();
parent.layer.msg('网络错误', {icon: 5});
}
});
return false;
});
form.on('submit(cancel)', function () {
admin.closeThisDialog();
});
});
</script>
...@@ -6,8 +6,13 @@ ...@@ -6,8 +6,13 @@
let element = layui.element; let element = layui.element;
let xmSelect = layui.xmSelect; let xmSelect = layui.xmSelect;
let tagsInput = layui.tagsInput; let tagsInput = layui.tagsInput;
let deadStockGoodsLabel = '{{ \App\Http\Services\SkuService::GOODS_LABEL_DEAD_STOCK }}';
form.on('submit(updateGoodsLabel)', function (data) { form.on('submit(updateGoodsLabel)', function (data) {
if (data.field.goods_label === deadStockGoodsLabel) {
layer.msg('呆料库存不可以设置显示类型', {icon: 5});
return false;
}
if (data.field.type == 1 && data.field.sku_tags === '') { if (data.field.type == 1 && data.field.sku_tags === '') {
} }
admin.showLoading({ admin.showLoading({
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
let initCondition = {source_type: 'all'}; let initCondition = {source_type: 'all'};
let whereCondition = initCondition; let whereCondition = initCondition;
let type = 'all'; let type = 'all';
let colSettingsData = {!! $colSettings !!};
let colSettingsUserId = '{{request()->user->userId}}';
let colSettingsPageKey = 'sku_list';
//点击罗盘筛选 //点击罗盘筛选
$('.main_filter').click(function () { $('.main_filter').click(function () {
...@@ -90,6 +93,7 @@ ...@@ -90,6 +93,7 @@
}, },
{field: 'encoded_user_name', title: '线上采购员', align: 'center', width: 100}, {field: 'encoded_user_name', title: '线上采购员', align: 'center', width: 100},
{field: 'purchase_username', title: '数据维护员', align: 'center', width: 100}, {field: 'purchase_username', title: '数据维护员', align: 'center', width: 100},
{field: 'reverse_purchaser', title: '逆向采购员', align: 'center', width: 120},
{field: 'spu_name', title: 'spu型号', align: 'center', width: 200}, {field: 'spu_name', title: 'spu型号', align: 'center', width: 200},
{ {
field: 'goods_name', title: '商品型号', align: 'center', width: 200, templet: function (data) { field: 'goods_name', title: '商品型号', align: 'center', width: 200, templet: function (data) {
...@@ -187,6 +191,14 @@ ...@@ -187,6 +191,14 @@
{field: 'cp_time', title: '上架有效期', align: 'center', width: 180}, {field: 'cp_time', title: '上架有效期', align: 'center', width: 180},
{field: 'is_expire_name', title: '是否过期', align: 'center', width: 90}, {field: 'is_expire_name', title: '是否过期', align: 'center', width: 90},
]; ];
if (colSettingsData && Object.keys(colSettingsData).length > 0) {
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && colSettingsData[field] !== undefined) {
cols[i].hide = !colSettingsData[field];
}
}
}
let currentPage = 0; let currentPage = 0;
table.render({ table.render({
elem: '#skuList' elem: '#skuList'
...@@ -207,6 +219,84 @@ ...@@ -207,6 +219,84 @@
} }
}); });
$("#col_setting").click(function () {
let html = '<div style="padding: 15px;">';
html += '<div style="margin-bottom: 10px;">';
html += '<button type="button" class="layui-btn layui-btn-xs layui-btn-info" id="col_select_all">全选</button>';
html += '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="col_invert_select">反选</button>';
html += '</div>';
html += '<div style="max-height: 600px; overflow-y: auto;">';
html += '<form class="layui-form" lay-filter="colSettingForm">';
for (let i = 0; i < cols.length; i++) {
if (cols[i].type === 'checkbox') continue;
let field = cols[i].field;
let title = cols[i].title || '';
let checked = cols[i].hide ? '' : 'checked';
html += '<div class="layui-form-item" style="display:inline-block;width:33%;margin-bottom:5px;">';
html += '<input type="checkbox" name="' + field + '" lay-skin="primary" title="' + title + '" ' + checked + '>';
html += '</div>';
}
html += '</form></div></div>';
layer.open({
type: 1,
title: '显示列设置',
area: ['600px', '600px'],
content: html,
btn: ['确定', '取消'],
success: function (layero, index) {
form.render('checkbox', 'colSettingForm');
layero.find('#col_select_all').on('click', function () {
layero.find('input[type="checkbox"]').prop('checked', true);
form.render('checkbox', 'colSettingForm');
});
layero.find('#col_invert_select').on('click', function () {
layero.find('input[type="checkbox"]').each(function () {
$(this).prop('checked', !$(this).is(':checked'));
});
form.render('checkbox', 'colSettingForm');
});
},
yes: function (index, layero) {
let settings = {};
let checkboxes = layero.find('input[type="checkbox"]');
checkboxes.each(function () {
let name = $(this).attr('name');
let checked = $(this).is(':checked');
settings[name] = checked;
});
$.ajax({
url: '/api/external/SaveColSettings',
type: 'post',
data: {
user_id: colSettingsUserId,
page_key: colSettingsPageKey,
settings: JSON.stringify(settings)
},
dataType: 'json',
async: false
});
colSettingsData = settings;
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && settings[field] !== undefined) {
cols[i].hide = !settings[field];
}
}
table.reload('skuList', {
cols: [cols],
page: {curr: currentPage},
where: whereCondition
});
layer.close(index);
}
});
});
//渲染多选 //渲染多选
let brandSelect = xmSelect.render({ let brandSelect = xmSelect.render({
el: '#brandSelect', el: '#brandSelect',
......
...@@ -788,6 +788,34 @@ ...@@ -788,6 +788,34 @@
} }
}) })
$("#batch_allocate_reverse_purchaser").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
let supplierIds = Array.from(data, ({supplier_id}) => supplier_id);
supplierIds = supplierIds.join(',');
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
let hasCrmSupplier = data.some(function (item) {
return Number(item.supplier_source) === 2;
});
if (hasCrmSupplier) {
layer.msg('CRM来源的供应商不允许分配逆向采购员', {icon: 5})
return;
}
layer.open({
type: 2,
content: '/supplier/BatchAllocateReversePurchaser?view=iframe&supplier_ids=' + supplierIds,
area: ['700px', '70%'],
title: '批量分配逆向采购员',
end: function () {
table.reload('list');
supplierStatistics();
}
});
}
})
//禁用供应商 //禁用供应商
$("#disable_supplier").click(function () { $("#disable_supplier").click(function () {
let checkStatus = table.checkStatus('list'); let checkStatus = table.checkStatus('list');
......
<style>
.layui-form-item {
margin-bottom: 5px;
}
</style>
<div class="layui-card">
<div class="layui-card-header" style="height: 170px">
<blockquote class="layui-elem-quote layui-text">
<b>逆向采购员设置</b>
</blockquote>
<form class="layui-form" action="">
<input type="hidden" name="supplier_ids" value="{{$supplierIds}}">
<div class="layui-form-item">
<div class="layui-inline" style="margin-left: -30px">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('reverse_purchaser','逆向采购员',null,
$reversePurchaserOptions,['required'=>true,'width'=>'260px']) !!}
</div>
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 10px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="allocateReversePurchaser">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
</button>
</div>
</div>
</form>
</div>
<div class="layui-card-body">
<blockquote class="layui-elem-quote layui-text">
<b>当前选中需要批量修改逆向采购员的供应商列表</b>
</blockquote>
<table class="layui-table">
<colgroup>
<col width="280">
<col width="120">
<col width="140">
<col>
</colgroup>
<thead>
<tr>
<th>供应商名称</th>
<th>供应商来源</th>
<th>当前逆向采购员</th>
</tr>
</thead>
<tbody>
@foreach($suppliers as $supplier)
<tr>
<td>{{$supplier['supplier_name']}}</td>
<td>{{$supplier['supplier_source_name']}}</td>
<td>{{$supplier['reverse_purchaser'] ?: '未设置'}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
...@@ -152,6 +152,11 @@ ...@@ -152,6 +152,11 @@
供应商英文名称 :{{$supplier['supplier_name_en']}} 供应商英文名称 :{{$supplier['supplier_name_en']}}
</div> </div>
<div class="layui-row"> <div class="layui-row">
<div class="layui-col-md3">
逆向采购员 :{{$supplier['reverse_purchaser'] ?: '未设置'}}
</div>
</div>
<div class="layui-row">
<span class="required_field">*</span>注册资金 <span class="required_field">*</span>注册资金
:{{$supplier['registered_capital']?$supplier['registered_capital']."(万)":'未设置'}} :{{$supplier['registered_capital']?$supplier['registered_capital']."(万)":'未设置'}}
</div> </div>
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
@if(checkPerm('BatchAllocatePurchaseUser')) @if(checkPerm('BatchAllocatePurchaseUser'))
{{-- <button type="button" class="layui-btn layui-btn-sm" id="batch_allocate_purchase_user">批量分配数据维护员</button>--}} {{-- <button type="button" class="layui-btn layui-btn-sm" id="batch_allocate_purchase_user">批量分配数据维护员</button>--}}
<button type="button" class="layui-btn layui-btn-sm" id="batch_allocate_purchase_user">分配数据维护员</button> <button type="button" class="layui-btn layui-btn-sm" id="batch_allocate_purchase_user">分配数据维护员</button>
<button type="button" class="layui-btn layui-btn-sm" id="batch_allocate_reverse_purchaser">分配逆向采购员</button>
@endif @endif
@if(checkPerm('AllocateChannelUser')) @if(checkPerm('AllocateChannelUser'))
<button type="button" class="layui-btn layui-btn-sm" id="allocate_channel_user">分配采购员</button> <button type="button" class="layui-btn layui-btn-sm" id="allocate_channel_user">分配采购员</button>
...@@ -82,7 +83,6 @@ ...@@ -82,7 +83,6 @@
@if(checkPerm('ConfirmCrmSupplier')) @if(checkPerm('ConfirmCrmSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="confirm_crm_supplier">确认客户转化供应商</button> <button type="button" class="layui-btn layui-btn-sm" id="confirm_crm_supplier">确认客户转化供应商</button>
@endif @endif
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="col_setting">展示列设置</button>
</div> </div>
<button type="button" id="refreshWindow" style="display: none">刷新页面</button> <button type="button" id="refreshWindow" style="display: none">刷新页面</button>
<table class="layui-table" id="list" lay-filter="list"></table> <table class="layui-table" id="list" lay-filter="list"></table>
......
...@@ -183,6 +183,7 @@ ...@@ -183,6 +183,7 @@
<button type="button" class="layui-btn layui-btn-sm layui-btn" lay-submit="" lay-filter="reset">重置 <button type="button" class="layui-btn layui-btn-sm layui-btn" lay-submit="" lay-filter="reset">重置
</button> </button>
<button type="button" class="layui-btn layui-btn-sm layui-btn hide_filter_type">隐藏罗盘</button> <button type="button" class="layui-btn layui-btn-sm layui-btn hide_filter_type">隐藏罗盘</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="col_setting">展示列设置</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn show_filter_type" <button type="button" class="layui-btn layui-btn-sm layui-btn show_filter_type"
style="display: none">显示罗盘 style="display: none">显示罗盘
</button> </button>
......
...@@ -119,13 +119,6 @@ ...@@ -119,13 +119,6 @@
{!! $statusPresenter->render('purchase_uid','数据维护员 : ',$supplier['purchase_uid'],$userCodes,['width'=>'150px']) !!} {!! $statusPresenter->render('purchase_uid','数据维护员 : ',$supplier['purchase_uid'],$userCodes,['width'=>'150px']) !!}
</div> </div>
<div class="layui-col-md3"> <div class="layui-col-md3">
<label class="layui-form-label">逆向采购员 : </label>
<div class="layui-input-block" style="width: 150px">
<input type="text" class="layui-input layui-disabled" disabled
value="{{$supplier['reverse_purchaser'] or ''}}">
</div>
</div>
<div class="layui-col-md3">
<label class="layui-form-label"><span class="require">*</span>注册资金(万): </label> <label class="layui-form-label"><span class="require">*</span>注册资金(万): </label>
<div class="layui-input-block" style="width: 150px"> <div class="layui-input-block" style="width: 150px">
<input type="text" name="registered_capital" id="registered_capital" <input type="text" name="registered_capital" id="registered_capital"
......
...@@ -294,15 +294,18 @@ ...@@ -294,15 +294,18 @@
</div> </div>
<div class="layui-row" style="margin-top:10px;margin-bottom: 10px;margin-left: 20px;"> <div class="layui-row" style="margin-top:10px;margin-bottom: 10px;margin-left: 20px;">
<button class="layui-btn layui-btn-sm layui-btn load" id="getSupplierListButton" lay-submit="" lay-filter="load">查询 <button class="layui-btn layui-btn-sm layui-btn load" id="getSupplierListButton" lay-submit=""
</button> lay-filter="load">查询
<button type="button" class="layui-btn layui-btn-sm layui-btn" lay-submit="" lay-filter="reset">重置 </button>
</button> <button type="button" class="layui-btn layui-btn-sm layui-btn" lay-submit="" lay-filter="reset">重置
<button type="button" class="layui-btn layui-btn-sm layui-btn hide_filter_type">隐藏罗盘</button> </button>
<button type="button" class="layui-btn layui-btn-sm layui-btn show_filter_type" style="display: none">显示罗盘 <button type="button" class="layui-btn layui-btn-sm layui-btn hide_filter_type">隐藏罗盘</button>
</button> <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="col_setting">展示列设置</button>
</div> <button type="button" class="layui-btn layui-btn-sm layui-btn show_filter_type"
</form> style="display: none">显示罗盘
</button>
</div>
</form>
@endif @endif
</div> </div>
...@@ -788,6 +788,34 @@ ...@@ -788,6 +788,34 @@
} }
}) })
$("#batch_allocate_reverse_purchaser").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
let supplierIds = Array.from(data, ({supplier_id}) => supplier_id);
supplierIds = supplierIds.join(',');
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
let hasCrmSupplier = data.some(function (item) {
return Number(item.supplier_source) === 2;
});
if (hasCrmSupplier) {
layer.msg('CRM来源的供应商不允许分配逆向采购员', {icon: 5})
return;
}
layer.open({
type: 2,
content: '/supplier/BatchAllocateReversePurchaser?view=iframe&supplier_ids=' + supplierIds,
area: ['700px', '70%'],
title: '批量分配逆向采购员',
end: function () {
table.reload('list');
supplierStatistics();
}
});
}
})
//禁用供应商 //禁用供应商
$("#disable_supplier").click(function () { $("#disable_supplier").click(function () {
let checkStatus = table.checkStatus('list'); let checkStatus = table.checkStatus('list');
......
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