Commit 2b9b1347 by mushishixian

联系人校验规则修改

parent c45dd732
......@@ -87,7 +87,6 @@ class SupplierFilter
}
});
}
//默认过滤带有-1字符串的供应商名称的数据
$query->whereRaw('supplier_name NOT LIKE "%-1"');
return $query;
......
......@@ -4,6 +4,7 @@
namespace App\Http\Validators;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use Validator;
class SupplierContactValidator
......@@ -23,6 +24,28 @@ class SupplierContactValidator
$messages = $this->messages();
$validator = Validator::make($data, $rules, $messages);
$contactModel = new SupplierContactModel();
//如果是原厂或者代理商性质的供应商,联系人不能重复
$supplierModel = new SupplierChannelModel();
$supplier = $supplierModel->where('supplier_id', $data['supplier_id'])->first()->toArray();
if ($supplier['supplier_group'] == 1 || $supplier['supplier_group'] == 4) {
$query = $contactModel->where('supplier_id', $data['supplier_id'])
->where(function ($q) use ($data) {
$q->where('supplier_email', $data['supplier_email'])
->orWhere('supplier_mobile', $data['supplier_mobile']);
});
//新增
if (empty($data['contact_id'])) {
$count = $query->count();
} else {
//修改
$count = $query->where('contact_id', '!=', $data['contact_id'])->count();
}
if ($count) {
return '供应商已经存在手机号或者邮箱一样的联系人,请联系管理人员查看具体详情';
}
}
//判断联系方式的表单验证
if ($validator->fails()) {
return $validator->errors()->first();
......
......@@ -7,7 +7,9 @@
let table = layui.table;
let form = layui.form;
let admin = layui.admin;
let whereCondition = {source_type: 'all'};
let initCondition = {source_type: 'all'};
let whereCondition = initCondition;
let type = 'all';
let currentPage = 1;
......@@ -338,6 +340,8 @@
});
form.on('submit(load)', function (data) {
initCondition.source_type = whereCondition.source_type;
whereCondition = $.extend(false, initCondition, data.field);
//执行重载
table.reload('list', {
page: {
......
......@@ -39,7 +39,7 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">座机</label>
<label class="layui-form-label"><span class="require">*</span>座机</label>
<div class="layui-input-block block-42">
<input type="text" name="supplier_telephone" id="supplier_telephone"
placeholder="请输入座机" class="layui-input"
......
......@@ -41,7 +41,7 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">座机</label>
<label class="layui-form-label"><span class="require">*</span>座机</label>
<div class="layui-input-block block-42">
<input type="text" name="supplier_telephone" id="supplier_telephone"
placeholder="请输入座机" class="layui-input"
......
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