Commit 54833dee by 杨树贤

禁用启用删除子账号

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