Commit f1f193df by 杨树贤

IQC检测模块

parent 2fe3ba8c
......@@ -17,7 +17,7 @@ class SupplierExaminationApiController extends Controller
}
//获取供应商信息变更记录
public function GetSupplierLogList($request)
public function GetSupplierExaminationList($request)
{
$supplierId = $request->get('supplier_id');
$limit = $request->get('limit', 10);
......@@ -29,7 +29,7 @@ class SupplierExaminationApiController extends Controller
}
//添加
public function AddSupplierLog($request)
public function AddSupplierIQC($request)
{
$data = $request->only([
'supplier_id',
......
<?php
namespace App\Http\Controllers\Filter;
use App\Model\SupplierAccountModel;
use App\Model\SupplierChannelModel;
class SupplierExaminationFilter
{
//查询条件
public function listFilter($request)
{
$map = $request->all();
$model = new SupplierAccountModel();
$query = $model->orderBy('id', 'desc');
if (!empty($map['supplier_name'])) {
//先去供应商主表找出id
$supplierChannelModel = new SupplierChannelModel();
$supplierIds = $supplierChannelModel->where('supplier_name', 'like',
"%${map['supplier_name']}%")->pluck('supplier_id');
$query->whereIn('supplier_id', $supplierIds);
}
if (!empty($map['supplier_code'])) {
$query->where('supplier_code', 'like', "%${map['supplier_code']}%");
}
if ((isset($map['a_status']) && $map['a_status'] === '0') || !empty($map['a_status'])) {
$query->where('a_status', $map['a_status']);
}
if (!empty($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'])) {
$times = explode('~', $map['create_time']);
$startTime = strtotime($times[0]);
$endTime = strtotime($times[1]);
$query->whereBetween('create_time', [$startTime, $endTime]);
}
if (!empty($map['update_time'])) {
$times = explode('~', $map['update_time']);
$startTime = strtotime($times[0]);
$endTime = strtotime($times[1]);
$query->whereBetween('update_time', [$startTime, $endTime]);
}
return $query;
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use App\Http\Services\RoleService;
use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierService;
use App\Http\Services\ViewCheckService;
use App\Model\IntracodeModel;
use App\Model\SupplierAccountModel;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class SupplierExaminationController extends Controller
{
public function info(Request $request, $id = '')
{
if ($request->path() == '/') {
$path = 'web/index';
} else {
$path = $request->path();
}
$this->data = [
'menus' => $request->menus,
'header' => $request->user->header,
'username' => $request->user->email,
'user_email' => $request->user->email,
'uri' => '/' . $path,
'id' => $id
];
return $this->$id($request);
}
public function __call($name, $arr)
{
$data['errinfo'] = '访问路径错误';
return view('errors.error', $data);
}
//操作日志列表
public function SupplierExaminationList($request)
{
$this->data['title'] = 'IQC检测列表';
return $this->view('IQC检测列表');
}
public function AddSupplierExamination($request)
{
//获取所有启用的供应商编码,而且类型是包括云芯
$model = new SupplierChannelModel();
$suppliers = $model->where('is_type', 0)
->whereRaw('stockup_type like "%5%"')
->where('status', SupplierChannelModel::STATUS_PASSED)
->select(['supplier_name', 'supplier_code'])->get();
$supplierCodes = [];
foreach ($suppliers as $supplier) {
$supplier = $supplier->toArray();
$supplierCodes[$supplier['supplier_code']] = $supplier['supplier_name'] . '(' . $supplier['supplier_code'] . ')';
}
$this->data['supplierCodes'] = $supplierCodes;
$this->data['title'] = '添加供应商账号';
return $this->view('添加供应商账号');
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
use App\Http\Controllers\Filter\SupplierAccountFilter;
use App\Http\Transformers\SupplierAccountTransformer;
use App\Model\LogModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use Carbon\Carbon;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
class SupplierExaminationService
{
public function getSupplierAccountList($request)
{
$limit = $request->get('limit', 10);
$filter = new SupplierAccountFilter();
$query = $filter->listFilter($request);
$list = $query->paginate($limit)->toArray();
$transformer = new SupplierAccountTransformer();
$list['data'] = $transformer->transformList($list['data']);
return $list;
}
//推送队列告诉搜索要去初始化数据
public function pushToInitData($supplierCode)
{
return true;
//还要去推送给搜索做品牌初始化任务
$conn = new AMQPStreamConnection(config('database.connections.rabbitmq.host'),
config('database.connections.rabbitmq.port'),
config('database.connections.rabbitmq.login'),
config('database.connections.rabbitmq.password'));
$channel = $conn->channel();
$channel->queue_declare('yunxin_supplier_add', false, true, false, false);
$time = strtotime("2021-01-01 00:00:00");
$body = json_encode([
'canal' => $supplierCode,
'update_time' => $time
]);
$msg = new AMQPMessage($body,
['content_type' => 'text/plain', 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT]);
$result = $channel->basic_publish($msg, '', 'yunxin_supplier_add');
$channel->close();
$conn->close();
}
}
\ No newline at end of file
<?php
namespace App\Http\Transformers;
use App\Model\SupplierChannelModel;
class SupplierExaminationTransformer
{
public function transformList($list)
{
//获取供应商名称
$supplierIds = array_column($list, 'supplier_id');
$supplierModel = new SupplierChannelModel();
$suppliers = $supplierModel->whereIn('supplier_id', $supplierIds)->pluck('supplier_name', 'supplier_id');
foreach ($list as &$item) {
$item['supplier_name'] = array_get($suppliers, $item['supplier_id']);
$item['type_name'] = array_get(config('field.SupplierAccountType'), $item['a_type']);
$item['create_time'] = $item['create_time'] ? date('Y-m-d H:i:s', $item['create_time']) : '';
$item['update_time'] = $item['update_time'] ? date('Y-m-d H:i:s', $item['update_time']) : '';
}
unset($item);
return $list;
}
}
\ No newline at end of file
<?php
namespace App\Http\Validators;
use App\Model\SupplierAccountModel;
use App\Model\SupplierChannelModel;
use Validator;
class SupplierExaminationValidator
{
//保存相关的验证,别问我为什么不用laravel自带的form-request类
//因为控制器那边已经被之前的人魔改的难用的一比,而且控制器那边还接收了一大堆统一变量
public function checkSave($request)
{
//整理下请求数据
$account = $request->all();
$rules = [
"supplier_code" => "required",
"mobile" => "required|regex:/^1[0-9][0-9]{9}$/",
"password_raw" => "required",
"a_type" => "required",
];
$messages = $this->messages();
$validator = Validator::make($account, $rules, $messages);
//判断联系方式的表单验证
if ($validator->fails()) {
return $validator->errors()->first();
}
if (empty($account['id'])) {
$supplierModel = new SupplierChannelModel();
$yunxinChannelUid = $supplierModel->where('supplier_code',
$account['supplier_code'])->value('yunxin_channel_uid');
if (empty($yunxinChannelUid)) {
return '该供应商没有绑定云芯采购,请完善相关信息';
}
$model = new SupplierAccountModel();
$supplierCount = $model->where('supplier_code', $account['supplier_code'])
->count();
if ($supplierCount > 0) {
return '该供应商已经存在账号';
}
$mobileCount = $model->where('mobile', $account['mobile'])
->count();
if ($mobileCount > 0) {
return '该手机号已经被注册';
}
}
return true;
}
private function messages()
{
return [
'supplier_code.required' => '请选择一个供应商',
'a_type.required' => '类型必须勾选为云芯商家',
'mobile.required' => '登录账号不能为空',
'mobile.regex' => '账号格式必须为手机号',
'password_raw.required' => '账号密码不能为空',
];
}
}
\ No newline at end of file
......@@ -25,11 +25,10 @@ Route::group(['middleware' => ['web', 'menu']], function () {
Route::match(['get', 'post'], '/supplier_account/{key}', 'SupplierAccountController@info');
Route::match(['get', 'post'], '/supplier_share_apply/{key}', 'SupplierShareApplyController@Entrance');
Route::match(['get', 'post'], '/supplier_tag/{key}', 'SupplierTagController@Entrance');
Route::match(['get', 'post'], '/supplier_examination/{key}', 'SupplierExaminationController@info');
Route::match(['get', 'post'], '/index/{key}', 'IndexController@Entrance');
Route::match(['get', 'post'], '/sku/{key}', 'SkuController@Entrance');
Route::match(['get', 'post'], '/log/{key}', 'LogController@Entrance');
Route::get('/pushAmq', 'QueuedController@pushAmq');
Route::get('/pullAmq', 'QueuedController@pullAmq');
});
Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
......@@ -47,6 +46,7 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/supplier_account/{key}', 'SupplierAccountApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_tag/{key}', 'SupplierTagApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_share_apply/{key}', 'SupplierShareApplyApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_examination/{key}', 'SupplierExaminationApiController@Entrance');
});
//提供给其它系统使用的接口
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class SupplierExaminationModel extends Model
{
protected $connection = 'web';
protected $table = 'supplier_examination';
protected $primaryKey = 'id';
public $timestamps = false;
}
<script>
layui.use(['table', 'form', 'element', 'layer', 'Split', 'admin', 'xmSelect'], function () {
let $ = layui.jquery;
let Split = layui.Split;
let table = layui.table;
let form = layui.form;
let admin = layui.admin;
let xmSelect = layui.xmSelect;
let initCondition = {source_type: 'all'};
let whereCondition = initCondition;
let type = 'all';
let cols = [
{type: 'radio'},
{field: 'id', title: 'ID', align: 'center', width: 80},
{
field: 'examine_time', title: '检货时间', align: 'center', width: 150
},
{field: 'purchase_name', title: '采购员', align: 'center', width: 110},
{
field: 'supplier_name', title: '供应商', align: 'center', width: 200
},
{field: 'sku_name', title: '型号', align: 'center', width: 160},
{field: 'brand_name', title: '品牌', align: 'center', width: 160},
{field: 'amount', title: '数量', align: 'center', width: 100},
{field: 'examine_amount', title: '检测数量', align: 'center', width: 100},
{field: 'unhealthy_amount', title: '不良数', align: 'center', width: 100},
{field: 'unhealthy_content', title: '不良现象', align: 'center', width: 150},
{field: 'examine_result', title: '检验结果', align: 'center', width: 150},
{field: 'abnormal_level', title: '异常等级', align: 'center', width: 150},
{field: 'handle_way', title: '处理方式', align: 'center', width: 150},
{field: 'remark', title: '备注', align: 'center', width: 150},
];
let currentPage = 0;
table.render({
elem: '#supplierExaminationList'
, url: '/api/supplier_examination/GetSupplierExaminationList'
, method: 'post'
, size: 'sm'
, limit: 20
, cellMinWidth: 50 //全局定义常规单元格的最小宽度
, where: whereCondition
, loading: true
, first: true //不显示首页
, last: false //不显示尾页
, cols: [cols]
, id: 'supplierExaminationList'
, page: {}
, done: function (res, curr, count) {
currentPage = curr;
}
});
//删除
$("#delete_supplier_examination").click(function () {
let checkStatus = table.checkStatus('supplierExaminationList');
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/DisableSupplierExamination', {id: id})
if (res.err_code === 0) {
table.reload('supplierExaminationList');
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
}
});
//根据供应商编码已经品牌等去基石调用接口下架
$("#add_supplier_account").click(function () {
layer.open({
type: 2,
content: '/supplier_examination/AddSupplierExamination?view=iframe',
area: ['800px', '600px'],
title: '添加IQC检测记录',
end: function () {
table.reload('supplierExaminationList');
}
});
});
form.on('submit(load)', function (data) {
whereCondition = $.extend(false, initCondition, data.field);
//执行重载
table.reload('supplierExaminationList', {
page: {
curr: 1
}
, where: whereCondition
});
return false;
});
form.on('submit(reset)', function (data) {
layer.load(1);
location.reload();
});
});
</script>
\ No newline at end of file
<div class="layui-collapse">
<form class="layui-form" style="margin-top: 15px">
<?php
$routerName = explode('/', request()->path())[1];
?>
<div class="layui-row">
<div class="layui-inline">
<label class="layui-form-label">供应商名称</label>
<div class="layui-input-inline">
<input type="text" value="" name="supplier_name" placeholder="支持模糊匹配" autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">供应商编码</label>
<div class="layui-input-inline">
<input type="text" value="" name="supplier_code" placeholder="支持模糊匹配" autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('a_status','账号状态',request()->get('status'),[0=>'禁用',1=>'启用']) !!}
</div>
</div>
<div class="layui-row">
<div class="layui-inline">
<label class="layui-form-label">账号</label>
<div class="layui-input-inline">
<input type="text" value="" name="mobile" placeholder="支持模糊匹配" autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-inline" style="width: 600px">
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['create_time'=>'创建时间','update_time'=>'更新时间']) !!}
</div>
</div>
<div class="layui-row" style="margin-top:10px;margin-bottom: 10px;margin-left: 20px;">
<button class="layui-btn layui-btn-sm layui-btn load" id="getSupplierListButton" lay-submit=""
lay-filter="load">查询
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn" lay-submit="" lay-filter="reset">重置
</button>
</div>
</form>
</div>
<div style="margin-left: 20px;margin-right: 20px">
<div class="layui-btn-group demoTable" style="margin-top: 15px">
<button type="button" class="layui-btn layui-btn-sm" id="add_supplier_examination">新增账号</button>
<button type="button" class="layui-btn layui-btn-sm" id="update_supplier_examination">修改</button>
<button type="button" class="layui-btn layui-btn-sm" id="delete_supplier_examination">启用</button>
</div>
<table class="layui-table" id="supplierExaminationList" lay-filter="supplierExaminationList"></table>
</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