Commit b6ad507d by 杨树贤

批量上下架修改

parent 9a7f1de6
......@@ -74,7 +74,7 @@ REDIS_USER_HOST=192.168.1.234
REDIS_USER_PASSWORD=icDb29mLy2s
REDIS_USER_PORT=6379
REDIS_READ_HOST=192.168.1.237
REDIS_READ_HOST=192.168.1.234
REDIS_READ_PASSWORD=icDb29mLy2s
REDIS_READ_PORT=6379
......
......@@ -98,12 +98,12 @@ class SkuApiController extends Controller
]);
if ($data['operate_type'] == SkuService::OPERATE_TYPE_PUTAWAY) {
if ($data['is_long_term'] == -1 && empty($data['cp_time'])) {
return $this->setError('请设置上架有效期');
$this->response(-1, '请设置上架有效期');
}
}
(new SkuService())->batchUpdateSkuStatus($data);
return $this->setSuccess('操作成功,请等待后台上下架任务完成刷新查看');
$this->response(0, '操作成功,请等待后台上下架任务完成刷新查看');
}
......
......@@ -73,4 +73,8 @@ class SkuController extends Controller
return $this->view('批量下架');
}
public function BatchUpdateSkuStatus($request)
{
return $this->view('批量上架');
}
}
......@@ -2,7 +2,6 @@
namespace App\Http\Services;
use App\Http\Models\Cms\ConfigModel;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
......
......@@ -174,7 +174,7 @@ class SkuService
//上架
$queueData = [];
if ($data['operate_type'] == self::OPERATE_TYPE_PUTAWAY) {
$queueName = 'lie_batch_upsku_queue';
$queueName = 'lie_footstone_batch_upsku_queue';
$data['cp_time'] = $data['is_long_term'] == 1 ? self::LONG_TERM_TIMESTAMP : strtotime($data['cp_time']);
foreach ($skuIds as $skuId) {
$queueData[] = [
......@@ -183,7 +183,7 @@ class SkuService
];
}
} else {
$queueName = 'lie_batch_downsku_queue';
$queueName = 'lie_footstone_batch_downsku_queue';
$queueData['down_type'] = 2;
$queueData['data'] = $skuIds;
}
......
......@@ -14,6 +14,7 @@ return [
'BatchOffShelf',
'AddSupplierAttachment',
'UpdateSupplierAttachment',
'BatchUpdateSkuStatus',
]//不用验证权限的方法
],
];
<script>
layui.use(['table', 'form', 'laydate', 'layer', 'upload', 'element', 'admin'], function () {
let form = layui.form;
let admin = layui.admin;
let table = layui.table;
let element = layui.element;
let upload = layui.upload;
let layer = layui.layer;
let laydate = layui.laydate;
let $ = layui.$;
laydate.render({
elem: '#cp_time_selector', //指定元素
type: 'datetime'
});
form.render();
form.on('switch(is_long_term)', function (data) {
let element = $('#cp_time_selector');
if (data.elem.checked) {
element.addClass('layui-disabled');
element.attr('disabled', true);
$('#cp_time_selector_div').hide();
$('#none_time_div').show();
form.render();
} else {
element.removeClass('layui-disabled');
element.attr('disabled', false);
$('#cp_time_selector_div').show();
$('#none_time_div').hide();
form.render();
}
});
form.on('submit(batchUpdateSkuStatus)', function (data) {
let operate = data.field.operate_type > 0 ? '上架' : '下架';
layer.confirm('确定要' + operate + '商品吗', function (index) {
const url = '/api/sku/batchUpdateSkuStatus';
$.ajax({
type: 'post',
url: url,
timeout: 30000, //超时时间设置,单位毫秒
data: {
sku_ids: data.field.sku_ids,
is_long_term: data.field.is_long_term ? 1 : -1,
operate_type: data.field.operate_type,
cp_time: data.field.cp_time
},
dataType: 'json',
success: function (res) {
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
layer.msg(res.err_msg, {icon: 5});
}
}
});
});
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>
\ No newline at end of file
......@@ -241,7 +241,7 @@
offset: '100px',
fixed: false, //不固定
maxmin: true,
content: '/web/sku/batchUpdateSkuStatus?window=true&sku_ids=' + skuIds + '&operate_type=' + operateType,
content: '/sku/BatchUpdateSkuStatus?view=iframe&sku_ids=' + skuIds + '&operate_type=' + operateType,
title: statusName + '商品',
end: function () {
table.reload('skuList', {
......@@ -253,23 +253,32 @@
});
}else{
layer.confirm('确定要下架选中的商品吗', function (index) {
$.post('/api/sku/batchUpdateSkuStatus', {
'sku_ids': skuIds.join(','),
'operate_type': -1,
}, function (res) {
if (res.code === 0) {
layer.msg(res.msg, {icon: 6});
table.reload('skuList', {
page: {
curr: currentPage
},
});
}else{
layer.msg(res.msg, {icon: 5});
return false;
$.ajax({
type: 'post',
url: '/api/sku/batchUpdateSkuStatus',
timeout: 30000, //超时时间设置,单位毫秒
data: {
'sku_ids': skuIds.join(','),
'operate_type': -1,
},
dataType: 'json',
success: function (res) {
console.log(res);
if (res.err_code === 0) {
layer.msg(res.err_msg, {icon: 6});
table.reload('skuList', {
page: {
curr: currentPage
},
});
}else{
layer.msg(res.err_msg, {icon: 5});
return false;
}
}
});
});
}
}
......
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