Commit 9d87174c by mushishixian

修整

parent f3014987
...@@ -25,12 +25,12 @@ class SupplierContactApiController extends Controller ...@@ -25,12 +25,12 @@ class SupplierContactApiController extends Controller
$supplierId = $request->get('supplier_id'); $supplierId = $request->get('supplier_id');
$limit = $request->get('limit', 10); $limit = $request->get('limit', 10);
$model = new SupplierContactModel(); $model = new SupplierContactModel();
$model->where('supplier_id',$supplierId)->paginate(); $model->where('supplier_id', $supplierId)->paginate();
$list = $model->where('supplier_id', $supplierId)->orderBy('contact_id', 'desc') $list = $model->where('supplier_id', $supplierId)->orderBy('contact_id', 'desc')
->paginate($limit)->toArray(); ->paginate($limit)->toArray();
$transformer = new SupplierContactTransformer(); $transformer = new SupplierContactTransformer();
$list['data'] = $transformer->transformList($list['data']); $list['data'] = $transformer->transformList($list['data']);
$this->response(0, 'ok', $list['data'],$list['total']); $this->response(0, 'ok', $list['data'], $list['total']);
} }
public function SaveSupplierContact($request) public function SaveSupplierContact($request)
...@@ -59,18 +59,22 @@ class SupplierContactApiController extends Controller ...@@ -59,18 +59,22 @@ class SupplierContactApiController extends Controller
$this->response(-1, '操作失败'); $this->response(-1, '操作失败');
} }
$this->response(0, '保存成功'); $this->response(0, '保存成功');
} }
public function DeleteSupplierContact($request) public function DeleteSupplierContact($request)
{ {
$contactId = $request->get('contact_id'); $contactId = $request->get('contact_id');
if ($contactId) { if ($contactId) {
$model = new SupplierContactModel(); $model = new SupplierContactModel();
$supplierId = $model->where('contact_id', $contactId)->value('supplier_id');
$contactCount = $model->where('supplier_id', $supplierId)->count();
if ($contactCount == 1) {
$this->response(-1, '供应商至少要有一个联系方式');
}
$result = $model->whereIn('contact_id', $contactId)->delete(); $result = $model->whereIn('contact_id', $contactId)->delete();
if (!$result) { if (!$result) {
$this->response(-1, '删除失败'); $this->response(-1, '删除失败');
} }
$supplierId = $model->where('contact_id', $contactId)->value('supplier_id');
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
$supplierModel->where('supplier_id', $supplierId)->update([ $supplierModel->where('supplier_id', $supplierId)->update([
'update_time' => time(), 'update_time' => time(),
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
namespace App\Http\Validators; namespace App\Http\Validators;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use Validator; use Validator;
class SupplierValidator class SupplierValidator
...@@ -23,6 +24,10 @@ class SupplierValidator ...@@ -23,6 +24,10 @@ class SupplierValidator
'region' => 'required', 'region' => 'required',
'cn_delivery_time' => 'regex:/^\d+\-\d$/', 'cn_delivery_time' => 'regex:/^\d+\-\d$/',
'us_delivery_time' => 'regex:/^\d+\-\d$/', 'us_delivery_time' => 'regex:/^\d+\-\d$/',
'shipping_address' => 'max:100',
'return_address' => 'max:100',
'return_consignee' => 'max:50',
'return_phone' => 'max:50',
'cn_ratio' => 'min:1', 'cn_ratio' => 'min:1',
'us_ratio' => 'min:1', 'us_ratio' => 'min:1',
'contact.supplier_consignee.*' => 'required|max:50', 'contact.supplier_consignee.*' => 'required|max:50',
...@@ -55,6 +60,12 @@ class SupplierValidator ...@@ -55,6 +60,12 @@ class SupplierValidator
} else { } else {
$count = $supplierModel->where('supplier_name', $request->get('supplier_name')) $count = $supplierModel->where('supplier_name', $request->get('supplier_name'))
->where('supplier_id', '!=', $request->get('supplier_id'))->count(); ->where('supplier_id', '!=', $request->get('supplier_id'))->count();
//至少要有一个联系方式
$contactModel = new SupplierContactModel();
$contactCount = $contactModel->where('supplier_id',$request->get('supplier_id'))->count();
if ($contactCount) {
return "供应商至少要有一个联系方式,请补全";
}
} }
if ($count) { if ($count) {
return "该供应商名称已经存在,请核验后再提交"; return "该供应商名称已经存在,请核验后再提交";
...@@ -86,6 +97,10 @@ class SupplierValidator ...@@ -86,6 +97,10 @@ class SupplierValidator
'contact.supplier_mobile.*.max' => '联系方式的手机号不能超过30个字符', 'contact.supplier_mobile.*.max' => '联系方式的手机号不能超过30个字符',
'contact.supplier_email.*.required' => '联系方式的邮箱不能为空', 'contact.supplier_email.*.required' => '联系方式的邮箱不能为空',
'contact.supplier_email.*.email' => '联系方式的邮箱格式不对', 'contact.supplier_email.*.email' => '联系方式的邮箱格式不对',
'shipping_address.max' => '发货地址不能超过100个字符',
'return_address.max' => '退货地址不能超过100个字符',
'return_consignee.max' => '退货收货人不能超过50个字符',
'return_phone.max' => '退货收货人电话不能超过50个字符',
]; ];
} }
......
...@@ -15,7 +15,7 @@ layui.config({ // common.js是配置layui扩展模块的目录,每个页面 ...@@ -15,7 +15,7 @@ layui.config({ // common.js是配置layui扩展模块的目录,每个页面
citypicker: 'city-picker/city-picker', citypicker: 'city-picker/city-picker',
introJs: 'introJs/introJs', introJs: 'introJs/introJs',
zTree: 'zTree/zTree', zTree: 'zTree/zTree',
xmSelect: 'xmSelect/xm-select' xmSelect: 'xmSelect'
}).use(['layer', 'admin'], function () { }).use(['layer', 'admin'], function () {
var $ = layui.jquery; var $ = layui.jquery;
var layer = layui.layer; var layer = layui.layer;
......
<script> <script>
layui.use(['table', 'form', 'element', 'layer','admin'], function () { layui.use(['table', 'form', 'element', 'layer', 'admin'], function () {
let admin = layui.admin; let admin = layui.admin;
let form = layui.form; let form = layui.form;
let element = layui.element; let element = layui.element;
form.on('submit(load)', function (data) { form.on('submit(load)', function (data) {
let supplierId = getQueryVariable('supplier_id'); layer.confirm('确定要保存联系人吗?一旦保存,该供应商就会再次进入审核阶段', function (index) {
let url = '/api/supplier_contact/SaveSupplierContact?supplier_id=' + supplierId; let supplierId = getQueryVariable('supplier_id');
let res = ajax(url, data.field); let url = '/api/supplier_contact/SaveSupplierContact?supplier_id=' + supplierId;
if (!res) { let res = ajax(url, data.field);
layer.msg('网络错误,请重试', {icon: 6}); if (!res) {
} else { layer.msg('网络错误,请重试', {icon: 6});
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else { } else {
parent.layer.msg(res.err_msg, {icon: 5}); if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
} }
} });
return false; return false;
}); });
}); });
......
{!! Autograph() !!} {!! Autograph() !!}
<script> <script>
layui.use(['form', 'upload','admin'], function () { layui.use(['form', 'upload', 'admin'], function () {
const form = layui.form const form = layui.form
const upload = layui.upload; const upload = layui.upload;
const admin = layui.admin; const admin = layui.admin;
//提交数据 //提交数据
form.on('submit(addSupplierReceipt)', function (data) { form.on('submit(addSupplierReceipt)', function (data) {
let res = ajax('/api/supplier_receipt/AddSupplierReceipt', data.field); layer.confirm('确定要保存银行信息吗?一旦保存,该供应商就会再次进入审核阶段', function (index) {
if (!res) { let res = ajax('/api/supplier_receipt/AddSupplierReceipt', data.field);
layer.msg('网络错误,请重试', {icon: 6}); if (!res) {
} else { layer.msg('网络错误,请重试', {icon: 6});
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else { } else {
parent.layer.msg(res.err_msg, {icon: 5}); if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
} }
} return false;
});
return false; return false;
}) })
//图片上传 //图片上传
......
...@@ -139,9 +139,9 @@ ...@@ -139,9 +139,9 @@
</div> </div>
</div> </div>
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">退电话 : </label> <label class="layui-form-label">退货收货人电话 : </label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" name="return_phone" id="return_phone" placeholder="请输入收件电话" <input type="text" name="return_phone" id="return_phone" placeholder="请输入退货收货人电话"
class="layui-input" value="{{$address['return_phone']}}"> class="layui-input" value="{{$address['return_phone']}}">
</div> </div>
</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