Commit 54833dee by 杨树贤

禁用启用删除子账号

parent be171628
...@@ -186,9 +186,9 @@ class SupplierAccountApiController extends Controller ...@@ -186,9 +186,9 @@ class SupplierAccountApiController extends Controller
if ($validator->fails()) { if ($validator->fails()) {
$this->response(-1, $validator->errors()->first()); $this->response(-1, $validator->errors()->first());
} }
$data['user_rule'] = $data['user_rule']?:[]; $data['user_rule'] = $data['user_rule'] ?: [];
$data['user_rule'] = json_encode($data['user_rule']); $data['user_rule'] = json_encode($data['user_rule']);
$data['user_message_rule'] = $data['user_message_rule']?:[]; $data['user_message_rule'] = $data['user_message_rule'] ?: [];
$data['user_message_rule'] = json_encode($data['user_message_rule']); $data['user_message_rule'] = json_encode($data['user_message_rule']);
$accountId = $data['account_id']; $accountId = $data['account_id'];
unset($data['account_id']); unset($data['account_id']);
...@@ -205,18 +205,17 @@ class SupplierAccountApiController extends Controller ...@@ -205,18 +205,17 @@ class SupplierAccountApiController extends Controller
} }
} }
//禁用子账号 //修改子账号状态
public function DisableSupplierSubAccount($request) public function ChangeSupplierSubAccountStatus($request)
{ {
$id = $request->get('id'); $accountId = $request->input('account_id');
$model = new SupplierAccountModel(); $sbatId = $request->input('sbat_id');
$data['update_time'] = date('Y-m-d H:i:s'); $status = $request->input('status');
$data['a_status'] = 0; $result = (new SupplierSubAccountService())->changeSupplierSubAccountStatus($accountId, $sbatId, $status);
$result = $model->where('id', $id)->update($data);
if ($result) { if ($result) {
$this->response(0, '禁用成功'); $this->response(0, '操作成功');
} }
$this->response(-1, '禁用失败', $result); $this->response(-1, '操作失败', $result);
} }
//删除子账号 //删除子账号
......
...@@ -87,11 +87,11 @@ class SupplierSubAccountService ...@@ -87,11 +87,11 @@ class SupplierSubAccountService
public function getSupplierAccountPermList($accountId, $sbatId) public function getSupplierAccountPermList($accountId, $sbatId)
{ {
$url = config('website.CloudUrl') . '/inner/subAccount/getMenu'; $url = config('website.CloudUrl') . '/inner/subAccount/getMenu';
$params = $this->generateRequestAuthData($accountId); $params = $this->generateRequestAuthData($accountId);
if ($sbatId) { if ($sbatId) {
$params['sbat_id'] = $sbatId; $params['sbat_id'] = $sbatId;
}else{ } else {
$params['method'] = 'add'; $params['method'] = 'add';
} }
$result = json_decode(curl($url, $params), true); $result = json_decode(curl($url, $params), true);
...@@ -158,11 +158,13 @@ class SupplierSubAccountService ...@@ -158,11 +158,13 @@ class SupplierSubAccountService
//修改子账号状态 //修改子账号状态
//1启动2禁用0删除 //1启动2禁用0删除
public function changeSupplierSubAccountStatus($accountId, $status) public function changeSupplierSubAccountStatus($accountId, $sbatId, $status)
{ {
$url = config('website.CloudUrl') . '/inner/subAccount/changeStatus'; $url = config('website.CloudUrl') . '/inner/subAccount/changeStatus';
$params = $this->generateRequestAuthData($accountId); $params = $this->generateRequestAuthData($accountId);
$result = json_decode(curl($url, $params), true); $params['status'] = $status;
$params['sbat_id'] = $sbatId;
$result = json_decode(curl($url, $params, true), true);
if (isset($result['code']) && $result['code'] == 0) { if (isset($result['code']) && $result['code'] == 0) {
return true; return true;
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
{field: 'create_type_cn', title: '创建人', align: 'center', width: 150}, {field: 'create_type_cn', title: '创建人', align: 'center', width: 150},
{field: 'create_time_cn', title: '创建时间', align: 'center', width: 150}, {field: 'create_time_cn', title: '创建时间', align: 'center', width: 150},
{field: 'update_time_cn', title: '修改时间', align: 'center', width: 150}, {field: 'update_time_cn', title: '修改时间', align: 'center', width: 150},
{field: 'operate', title: '操作', align: 'left', templet: '#edit'},
]; ];
let currentPage = 0; let currentPage = 0;
table.render({ table.render({
...@@ -45,95 +46,105 @@ ...@@ -45,95 +46,105 @@
} }
}); });
//启用 table.on('tool(supplierSubAccountList)', function (obj) {
$("#enable_supplier_sub_account").click(function () { let event = obj.event;
let checkStatus = table.checkStatus('supplierSubAccountList'); let sbatId = obj.data.sbat_id;
let data = checkStatus.data; let ynatId = obj.data.ynat_id;
if (!data.length) { let accountId = getQueryVariable('account_id');
layer.msg('请先选择要操作的供应商账号', {icon: 5}) if (event === 'detail') {
} else { layer.open({
layer.confirm('确定要启用该供应商账号吗?', function (index) { type: 2,
let id = data[0].id; area: ['95%', '95%'],
let res = ajax('/api/supplier_account/EnableSupplierSubAccount', {id: id}) fixed: false,
if (res.err_code === 0) { title: '编辑子账号',
table.reload('supplierSubAccountList'); content: '/supplier_account/SaveSupplierSubAccount?view=iframe&account_id=' + accountId + '&sbat_id=' + sbatId + '&ynat_id=' + ynatId,
layer.closeAll(); end: function () {
layer.msg(res.err_msg, {icon: 6}) table.reload('supplierSubAccountList', {
} else { page: {
layer.msg(res.err_msg, {icon: 5}) curr: 1 //重新从第 1 页开始
},
});
} }
}); });
} }
}); if (event === 'delete') {
layer.confirm('你确定要删除该子账号吗?', {
btn: ['确定', '取消'] //按钮
}, function (index) {
const url = '/api/supplier_account/ChangeSupplierSubAccountStatus';
const data = {
account_id: accountId,
sbat_id: sbatId,
status: 0,
};
layer.closeAll();
$.post(url, data, function (res) {
res = JSON.parse(res);
if (res.code === 0) {
table.reload('supplierSubAccountList');
layer.msg("删除成功", {icon: 6});
}
});
});
}
if (event === 'enable') {
layer.confirm('你确定要启用该子账号吗?', {
btn: ['确定', '取消'] //按钮
}, function (index) {
const url = '/api/supplier_account/ChangeSupplierSubAccountStatus';
const data = {
account_id: accountId,
sbat_id: sbatId,
status: 1,
};
layer.closeAll();
$.post(url, data, function (res) {
res = JSON.parse(res);
if (res.code === 0) {
table.reload('supplierSubAccountList');
layer.msg("启用成功", {icon: 6});
}
});
});
//禁用 }
$("#disable_supplier_sub_account").click(function () {
let checkStatus = table.checkStatus('supplierSubAccountList'); if (event === 'disable') {
let data = checkStatus.data; layer.confirm('你确定要禁用该子账号吗?', {
if (!data.length) { btn: ['确定', '取消'] //按钮
layer.msg('请先选择要操作的供应商账号', {icon: 5}) }, function (index) {
} else { const url = '/api/supplier_account/ChangeSupplierSubAccountStatus';
layer.confirm('确定要禁用该供应商账号吗?', function (index) { const data = {
let id = data[0].id; account_id: accountId,
let res = ajax('/api/supplier_account/DisableSupplierSubAccount', {id: id}) sbat_id: sbatId,
if (res.err_code === 0) { status: 2,
table.reload('supplierSubAccountList'); };
layer.closeAll(); layer.closeAll();
layer.msg(res.err_msg, {icon: 6}) $.post(url, data, function (res) {
} else { res = JSON.parse(res);
layer.msg(res.err_msg, {icon: 5}) if (res.code === 0) {
} console.log(res.code);
table.reload('supplierSubAccountList');
layer.msg("禁用成功", {icon: 6});
}
});
}); });
} }
}); });
//根据供应商编码已经品牌等去基石调用接口下架
$("#add_supplier_sub_account").click(function () { $("#add_supplier_sub_account").click(function () {
layer.open({ layer.open({
type: 2, type: 2,
content: '/supplier_account/SaveSupplierSubAccount?view=iframe&account_id='+getQueryVariable('account_id'), content: '/supplier_account/SaveSupplierSubAccount?view=iframe&account_id=' + getQueryVariable('account_id'),
area: ['70%', '80%'], area: ['70%', '80%'],
title: '添加供应商账号', title: '添加供应商账号',
end: function () { end: function () {
table.reload('supplierSubAccountList'); table.reload('supplierSubAccountList');
// supplierStatistics();
}
});
});
$("#updateSupplierAccountPerm").click(function () {
layer.open({
type: 2,
content: '/supplier_sub_account/AddSupplierSubAccount?view=iframe',
area: ['800px', '600px'],
title: '添加供应商账号',
end: function () {
table.reload('supplierSubAccountList');
// supplierStatistics();
} }
}); });
}); });
$("#update_supplier_sub_account").click(function () {
let checkStatus = table.checkStatus('supplierSubAccountList');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
let id = data[0].id;
layer.open({
type: 2,
content: '/supplier_sub_account/UpdateSupplierSubAccount?view=iframe&id=' + id,
area: ['800px', '600px'],
title: '批量下架SKU',
end: function () {
table.reload('supplierSubAccountList');
// supplierStatistics();
}
});
}
});
form.on('submit(load)', function (data) { form.on('submit(load)', function (data) {
whereCondition = $.extend(false, initCondition, data.field); whereCondition = $.extend(false, initCondition, data.field);
......
...@@ -73,5 +73,18 @@ ...@@ -73,5 +73,18 @@
<table class="layui-table" id="supplierSubAccountList" lay-filter="supplierSubAccountList"></table> <table class="layui-table" id="supplierSubAccountList" lay-filter="supplierSubAccountList"></table>
</div> </div>
<script type="text/html" id="edit">
<button class="layui-btn layui-btn-xs"
lay-event="detail" value="@{{ d.id }}"><strong>详情</strong></button>
@{{# if(d.status == 1){ }}
<button class="layui-btn layui-btn-xs layui-btn-outline layui-btn-danger" lay-event="disable"><strong>禁用</strong>
</button>
@{{# }else{ }}
<button class="layui-btn layui-btn-xs layui-btn-outline" lay-event="enable"><strong>启用</strong></button>
@{{# } }}
<button class="layui-btn layui-btn-xs layui-btn-danger delete" lay-event="delete" value="@{{ d.id }}">
<strong>删除</strong></button>
</script>
<script> <script>
</script> </script>
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