Commit 7a2f9d2f by mushishixian

fix

parent b3f76148
...@@ -75,7 +75,7 @@ class SupplierAccountApiController extends Controller ...@@ -75,7 +75,7 @@ class SupplierAccountApiController extends Controller
]); ]);
$validator = new SupplierAccountValidator(); $validator = new SupplierAccountValidator();
$check = $validator->checkSave($request); $check = $validator->checkSave($request);
if (!$check) { if ($check !== true) {
$this->response(-1, $check); $this->response(-1, $check);
} }
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
...@@ -96,6 +96,20 @@ class SupplierAccountApiController extends Controller ...@@ -96,6 +96,20 @@ class SupplierAccountApiController extends Controller
$this->response(-1, '修改失败', $result); $this->response(-1, '修改失败', $result);
} }
//启用
public function EnableSupplierAccount($request)
{
$id = $request->get('id');
$model = new SupplierAccountModel();
$data['update_time'] = date('Y-m-d H:i:s');
$data['a_status'] = 1;
$result = $model->where('id', $id)->update($data);
if ($result) {
$this->response(0, '启用成功');
}
$this->response(-1, '启用失败', $result);
}
//禁用 //禁用
public function DisableSupplierAccount($request) public function DisableSupplierAccount($request)
{ {
......
...@@ -23,7 +23,7 @@ class SupplierAccountFilter ...@@ -23,7 +23,7 @@ class SupplierAccountFilter
} }
if (!empty($map['supplier_code'])) { if (!empty($map['supplier_code'])) {
$query->whereLike('supplier_code', "%${map['supplier_code']}%"); $query->where('supplier_code', 'like', "%${map['supplier_code']}%");
} }
if ((isset($map['status']) && $map['status'] === '0') || !empty($map['status'])) { if ((isset($map['status']) && $map['status'] === '0') || !empty($map['status'])) {
...@@ -31,7 +31,11 @@ class SupplierAccountFilter ...@@ -31,7 +31,11 @@ class SupplierAccountFilter
} }
if (!empty($map['mobile'])) { if (!empty($map['mobile'])) {
$query->whereLike('mobile', "%${map['mobile']}%"); $query->where('mobile', 'like', "%${map['mobile']}%");
}
if ((isset($map['a_type']) && $map['a_type'] === '0') || !empty($map['a_type'])) {
$query->where('a_type', $map['a_type']);
} }
if (!empty($map['create_time'])) { if (!empty($map['create_time'])) {
......
...@@ -17,8 +17,8 @@ class SupplierAccountTransformer ...@@ -17,8 +17,8 @@ class SupplierAccountTransformer
foreach ($list as &$item) { foreach ($list as &$item) {
$item['supplier_name'] = array_get($suppliers, $item['supplier_id']); $item['supplier_name'] = array_get($suppliers, $item['supplier_id']);
$item['type_name'] = array_get(config('field.SupplierAccountType'), $item['a_type']); $item['type_name'] = array_get(config('field.SupplierAccountType'), $item['a_type']);
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']); $item['create_time'] = $item['create_time'] ? date('Y-m-d H:i:s', $item['create_time']) : '';
$item['update_time'] = date('Y-m-d H:i:s', $item['update_time']); $item['update_time'] = $item['update_time'] ? date('Y-m-d H:i:s', $item['update_time']) : '';
} }
unset($item); unset($item);
......
...@@ -19,10 +19,10 @@ class SupplierAccountValidator ...@@ -19,10 +19,10 @@ class SupplierAccountValidator
"supplier_code" => "required", "supplier_code" => "required",
"mobile" => "required|regex:/^1[0-9][0-9]{9}$/", "mobile" => "required|regex:/^1[0-9][0-9]{9}$/",
"password_raw" => "required", "password_raw" => "required",
"a_type" => "required",
]; ];
$messages = $this->messages(); $messages = $this->messages();
$validator = Validator::make($account, $rules, $messages); $validator = Validator::make($account, $rules, $messages);
//判断联系方式的表单验证 //判断联系方式的表单验证
if ($validator->fails()) { if ($validator->fails()) {
return $validator->errors()->first(); return $validator->errors()->first();
...@@ -55,6 +55,7 @@ class SupplierAccountValidator ...@@ -55,6 +55,7 @@ class SupplierAccountValidator
{ {
return [ return [
'supplier_code.required' => '请选择一个供应商', 'supplier_code.required' => '请选择一个供应商',
'a_type.required' => '类型必须勾选为云芯商家',
'mobile.required' => '登陆账号不能为空', 'mobile.required' => '登陆账号不能为空',
'mobile.regex' => '账号格式必须为手机号', 'mobile.regex' => '账号格式必须为手机号',
'password_raw.required' => '账号密码不能为空', 'password_raw.required' => '账号密码不能为空',
......
...@@ -51,6 +51,27 @@ ...@@ -51,6 +51,27 @@
} }
}); });
//启用
$("#enable_supplier_account").click(function () {
let checkStatus = table.checkStatus('supplierAccountList');
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/EnableSupplierAccount', {id: id})
if (res.err_code === 0) {
table.reload('supplierAccountList');
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
}
});
//禁用 //禁用
$("#disable_supplier_account").click(function () { $("#disable_supplier_account").click(function () {
let checkStatus = table.checkStatus('supplierAccountList'); let checkStatus = table.checkStatus('supplierAccountList');
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
<div class="layui-btn-group demoTable" style="margin-top: 15px"> <div class="layui-btn-group demoTable" style="margin-top: 15px">
<button type="button" class="layui-btn layui-btn-sm" id="add_supplier_account">新增账号</button> <button type="button" class="layui-btn layui-btn-sm" id="add_supplier_account">新增账号</button>
<button type="button" class="layui-btn layui-btn-sm" id="update_supplier_account">修改</button> <button type="button" class="layui-btn layui-btn-sm" id="update_supplier_account">修改</button>
<button type="button" class="layui-btn layui-btn-sm" id="enable_supplier_account">启用</button>
<button type="button" class="layui-btn layui-btn-sm" id="disable_supplier_account">禁用</button> <button type="button" class="layui-btn layui-btn-sm" id="disable_supplier_account">禁用</button>
</div> </div>
......
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