Commit 66bb8d31 by mushishixian

转正供应商

parent 64a2ece9
......@@ -278,14 +278,18 @@ class SupplierApiController extends Controller
$this->response(-1, '分配渠道开发员失败');
}
$this->response(0, '分配渠道开发员成功');
}
//导出供应商
public function Export()
//转正供应商
public function ChangeSupplierIsType($request)
{
$params = json_decode(\request()->get('params'), true);
$exporter = new SupplierListExporter($params);
$exporter->export();
$supplierId = $request->get('supplier_id');
$isType = $request->get('is_type');
$service = new SupplierService();
$result = $service->changeSupplierIsType($supplierId, $isType);
if (!$result) {
$this->response(-1, '转正供应商失败');
}
$this->response(0, '转正供应商成功');
}
}
<?php
namespace App\Http\Controllers\Filter;
use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService;
use App\Model\SupplierSyncModel;
use Illuminate\Support\Facades\DB;
class LogFilter
{
//查询条件
public function listFilter($request)
{
$map = $request->all();
$model = new SupplierSyncModel();
$query = $model->orderBy('id', 'desc');
$query = $this->defaultFilter($query);
return $query;
}
//默认要去处理的查询过滤(包含权限判断)
public function defaultFilter($query)
{
$canViewAllPeopleLog = checkPerm('ViewAllPeopleLog');
//可以查看所有人的日志
$canViewSubordinateLog = checkPerm('ViewSubordinateLog');
$adminId = request()->user->userId;
if ($canViewAllPeopleLog) {
//可以查看所有的话,默认不做任何限制
} else {
//如果能看部下的,那需要判断的地方就多了不少
if ($canViewSubordinateLog) {
$departmentService = new DepartmentService();
//下属用户id(结果包括自己的id)
$subordinateUserIds = $departmentService->getSubordinateUserIds($adminId);
$query->whereIn('admin_id', $subordinateUserIds);
} else {
//剩下的就只是看自己相关的
$query->where('admin_id', $adminId);
}
}
return $query;
}
}
\ No newline at end of file
......@@ -46,7 +46,9 @@ class SupplierFilter
if (!empty($map['status'])) {
$query->where('status', $map['status']);
}
if (!empty($map['is_type'])) {
$query->where('is_type', $map['is_type']);
}
if (!empty($map['has_sku'])) {
if ($map['has_sku'] == 1) {
$query->where('sku_num', '>', 0);
......@@ -86,8 +88,9 @@ class SupplierFilter
$codeId = request()->user->codeId;
$canViewAllSupplier = checkPerm('ViewAllSupplier');
$canViewSubordinateSupplier = checkPerm('ViewSubordinateSupplier');
$canViewFakeSupplier = checkPerm('ViewFakeSupplier');
if (request()->user->userId != 1443 || !$canViewAllSupplier) {
if (!$canViewFakeSupplier) {
$query->where('is_type', 0);
}
......
<?php
namespace App\Http\Controllers\Filter;
use App\Http\Services\DepartmentService;
use App\Model\SupplierSyncModel;
class SupplierLogFilter
{
//查询条件
public function listFilter($query)
{
$map = request()->all();
$query = $query->orderBy('id', 'desc');
$query = $this->defaultFilter($query);
return $query;
}
//默认要去处理的查询过滤(包含权限判断)
public function defaultFilter($query)
{
$canViewAllPeopleLog = checkPerm('ViewAllPeopleLog');
//可以查看所有人的日志
$canViewSubordinateLog = checkPerm('ViewSubordinateLog');
$adminId = request()->user->userId;
if ($canViewAllPeopleLog) {
//可以查看所有的话,默认不做任何限制
} elseif ($canViewSubordinateLog) {
//如果能看部下的,那需要判断的地方就多了不少
if ($canViewSubordinateLog) {
$departmentService = new DepartmentService();
//下属用户id(结果包括自己的id)
$subordinateUserIds = $departmentService->getSubordinateUserIds($adminId);
$query->whereIn('admin_id', $subordinateUserIds);
} else {
//剩下的就只是看自己相关的
$query->where('admin_id', $adminId);
}
}
return $query;
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use App\Http\Controllers\Filter\LogFilter;
use App\Http\Controllers\Filter\SupplierLogFilter;
use App\Model\ApplyExamineUserModel;
use App\Model\ApplyModel;
use App\Model\DingTalk;
......@@ -41,12 +43,18 @@ class LogController extends Controller
public function SupplierLog($request)
{
$supplierId = $request->get('supplier_id', 1);
$logModel = new LogModel();
$logs = $logModel->where('supplier_id', $supplierId)->orderBy('id', 'desc')->get();
$updateLogs = $logModel->where('supplier_id', $supplierId)->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->get();
$viewLogs = $logModel->where('supplier_id', $supplierId)->where('type', LogModel::VIEW_OPERATE)->orderBy('id', 'desc')->get();
$supplierLogModel = new SupplierLogModel();
$supplierLogs = $supplierLogModel->where('supplier_id', $supplierId)->orderBy('id', 'desc')->get();
$logs = $this->getLogs($supplierId);
$updateLogs = $this->getLogs($supplierId, LogModel::UPDATE_OPERATE);
$viewLogs = $this->getLogs($supplierId, LogModel::VIEW_OPERATE);
$supplierLogFilter = new SupplierLogFilter();
$query = $supplierLogFilter->listFilter(new SupplierLogModel());
$supplierLogs = $query->where('supplier_id', $supplierId)->get();
foreach ($supplierLogs as &$supplierLog) {
$supplierLog['desc'] = array_get(config('fixed.SupplierLogType'), $supplierLog['type']) . ' : ' . $supplierLog['desc'];
}
unset($supplierLog);
$this->data['logs'] = $logs;
$this->data['supplierId'] = $supplierId;
$this->data['updateLogs'] = $updateLogs;
......@@ -55,4 +63,18 @@ class LogController extends Controller
return $this->view('供应商日志');
}
private function getLogs($supplierId, $type = '')
{
$model = new LogModel();
$query = $model->where('id', '>', 0);
//显示默认的数据(有权限逻辑)
$filter = new LogFilter();
$query = $filter->defaultFilter($query);
if ($type) {
return $query->where('supplier_id', $supplierId)->where('type', $type)->get();
} else {
return $query->where('supplier_id', $supplierId)->get();
}
}
}
......@@ -10,7 +10,6 @@ use App\Model\SupplierAddressModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use Illuminate\Support\Facades\DB;
use RedisDB;
class SupplierService
{
......@@ -252,4 +251,20 @@ class SupplierService
return $result;
}
//修改is_type
public function changeSupplierIsType($supplierId, $isType)
{
$model = new SupplierChannelModel();
$result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(),
'is_type' => $isType,
'status' => -1,
]);
if ($result) {
$logService = new LogService();
$content = '转正供应商';
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '转正供应商', $content);
}
return $result;
}
}
\ No newline at end of file
......@@ -72,7 +72,7 @@ class SupplierTransformer
if (!empty($codeId)) {
$data[] = array_get($userCodes, $codeId);
}
}else{
} else {
if ($codeId == request()->user->codeId) {
$data[] = array_get($userCodes, $codeId);
}
......@@ -129,9 +129,10 @@ class SupplierTransformer
$supplier['extra_fee'] = $ExtendModel->getExtendExtra($supplier['supplier_code'], $supplier['supplier_id']);
//获取最近修改信息
$logModel = new LogModel();
$log = $logModel->where('supplier_id',$supplier['supplier_id'])->orderBy('id','desc')->first();
$log = $logModel->where('supplier_id', $supplier['supplier_id'])
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first();
$supplier['last_update_name'] = $log['admin_name'];
$supplier['last_update_time'] = date('Y-m-d H:i:s',$log['add_time']);
$supplier['last_update_time'] = date('Y-m-d H:i:s', $log['add_time']);
return $supplier;
}
......
......@@ -25,57 +25,67 @@
});
});
let cols = [
{type: 'radio'},
{field: 'supplier_id', title: '供应商ID', align: 'center', width: 80},
{
field: 'supplier_code', title: '供应商编码', align: 'center', width: 90, templet: function (data) {
return "<a ew-href='/supplier/SupplierDetail?view=iframe&supplier_id=" + data.supplier_id +
"' style='color: dodgerblue' ew-title='供应商详情 - " + data.supplier_code + "'>" + data.supplier_code + "</a>"
}
},
{field: 'supplier_name', title: '供应商名称', align: 'center'},
{field: 'supplier_group', title: '供应商性质', align: 'center', width: 120},
{
field: 'stockup_type', title: '合作类型', align: 'center', width: 120, templet: function (data) {
return "<span title='" + data.stockup_type + "'>" + data.stockup_type + "</span>"
}
},
{
field: 'contact_num', title: '联系人', align: 'center', width: 70, templet: function (data) {
return "<a ew-href='/supplier/SupplierDetail?view=iframe&tab=contact&supplier_id=" + data.supplier_id +
"' style='color: dodgerblue' ew-title='供应商详情 - " + data.supplier_code + "' title='点击跳转查看联系人列表'>" + data.contact_num + "</a>"
}
},
{field: 'has_sku', title: 'SKU上传', align: 'center', width: 80},
{
field: 'status_name', title: '状态', align: 'center', width: 80, templet: function (data) {
if (data.status === 3) {
return "<span style='color: red' title='" + data.reject_reason + "'>" + data.status_name + "</span>"
} else {
return data.status_name;
}
}
},
{field: 'channel_username', title: '采购员', align: 'center', width: 130},
{field: 'purchase_username', title: '渠道开发员', align: 'center', width: 120},
{field: 'create_name', title: '创建人', align: 'center', width: 80},
{field: 'update_time', title: '最近修改时间', align: 'center', width: 160},
{field: 'create_time', title: '创建时间', align: 'center', width: 150},
];
@if(checkPerm('ViewFakeSupplier'))
cols.push({
field: 'is_type', title: '正式供应商', align: 'center', width: 90, templet: function (data) {
return data.is_type === 0 ? '正式' : '<span style="color: red">竞调</span>';
}
})
@endif
table.render({
elem: '#list'
, url: '/api/supplier/GetSupplierList'
, method: 'post'
, size: 'sm'
, limit: 20
, cellMinWidth: 80 //全局定义常规单元格的最小宽度
, cellMinWidth: 50 //全局定义常规单元格的最小宽度
, where: whereCondition
, loading: true
, first: true //不显示首页
, last: false //不显示尾页
, cols: [[
{type: 'radio'},
{field: 'supplier_id', title: '供应商ID', align: 'center', width: 80},
{
field: 'supplier_code', title: '供应商编码', align: 'center', width: 90, templet: function (data) {
return "<a ew-href='/supplier/SupplierDetail?view=iframe&supplier_id=" + data.supplier_id +
"' style='color: dodgerblue' ew-title='供应商详情 - " + data.supplier_code + "'>" + data.supplier_code + "</a>"
}
},
{field: 'supplier_name', title: '供应商名称', align: 'center'},
{field: 'supplier_group', title: '供应商性质', align: 'center', width: 120},
{
field: 'stockup_type', title: '合作类型', align: 'center', width: 120, templet: function (data) {
return "<span title='" + data.stockup_type + "'>" + data.stockup_type + "</span>"
}
},
{
field: 'contact_num', title: '联系人', align: 'center', width: 80, templet: function (data) {
return "<a ew-href='/supplier/SupplierDetail?view=iframe&tab=contact&supplier_id=" + data.supplier_id +
"' style='color: dodgerblue' ew-title='供应商详情 - " + data.supplier_code + "' title='点击跳转查看联系人列表'>" + data.contact_num + "</a>"
}
},
{field: 'has_sku', title: 'SKU上传', align: 'center', width: 80},
{
field: 'status_name', title: '状态', align: 'center', width: 80, templet: function (data) {
if (data.status === 3) {
return "<span style='color: red' title='" + data.reject_reason + "'>" + data.status_name + "</span>"
} else {
return data.status_name;
}
}
},
{field: 'channel_username', title: '采购员', align: 'center', width: 150},
{field: 'purchase_username', title: '渠道开发员', align: 'center', width: 120},
{field: 'create_name', title: '创建人', align: 'center', width: 80},
{field: 'update_time', title: '最近修改时间', align: 'center', width: 160},
{field: 'create_time', title: '创建时间', align: 'center', width: 150},
]]
, cols: [cols]
, id: 'list'
, page: {}
});
......@@ -153,6 +163,7 @@
}
})
$("#disable_supplier").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
......@@ -180,6 +191,31 @@
}
});
$("#change_supplier_is_type").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
const isType = data[0].is_type;
if (isType === 0) {
layer.msg('该供应商已经是正式供应商', {'icon': 5});
return
}
layer.confirm('如果转成正式供应商,会进入待审核状态,需要补全相关信息申请审核,确定要转正该供应商吗?', function (index) {
let supplierId = data[0].supplier_id;
let res = ajax('/api/supplier/ChangeSupplierIsType', {supplier_id: supplierId, is_type: 0})
if (res.err_code === 0) {
table.reload('list')
supplierStatistics();
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
}
});
form.on('submit(load)', function (data) {
whereCondition = $.extend(false, initCondition, data.field);
......
......@@ -226,7 +226,7 @@
</div>
</div>
<blockquote class="layui-elem-quote layui-text">
<b>货期调整</b>
<b>上传商品规则</b>
</blockquote>
<div class="layui-row">
<div class="layui-form">
......
......@@ -13,6 +13,9 @@
@if(checkPerm('AllocatePurchaseUid'))
<button type="button" class="layui-btn layui-btn-sm" id="allocate_purchase_user">分配渠道员</button>
@endif
@if(checkPerm('ChangeSupplierIsType'))
<button type="button" class="layui-btn layui-btn-sm" title="该操作可以将竞调供应商转为正式供应商" id="change_supplier_is_type">转正供应商</button>
@endif
</div>
<table class="layui-table" id="list" lay-filter="list"></table>
......
<style>
.main_filter {
cursor:pointer;
cursor: pointer;
}
</style>
<div class="layui-fluid" id="type_filter">
......@@ -52,13 +52,15 @@
@endif
@if(checkPerm('SupplierInvalidChannelUidList'))
<div class="layui-row">
<a title="非禁止交易状态联系人绑定的采购员姓名不在组织架构中(采购员离职)的供应商" class="main_filter" id="invalid_channel_uid">
<a title="非禁止交易状态联系人绑定的采购员姓名不在组织架构中(采购员离职)的供应商" class="main_filter"
id="invalid_channel_uid">
</a>
</div>
@endif
@if(checkPerm('SupplierInvalidPurchaseUidList'))
<div class="layui-row">
<a title="非禁止交易状态联系人绑定的渠道开发员姓名不在组织架构中(渠道开发员离职)的供应商" class="main_filter" id="invalid_purchase_uid">
<a title="非禁止交易状态联系人绑定的渠道开发员姓名不在组织架构中(渠道开发员离职)的供应商" class="main_filter"
id="invalid_purchase_uid">
</a>
</div>
@endif
......@@ -66,7 +68,8 @@
<div class="split-item" id="s4" style="text-align: center">
@if(checkPerm('SupplierToFollowUpList'))
<div class="layui-row">
<a title="非禁止交易状态的供应商重新分配渠道员,且必填信息不完整;或者禁用状态的供应商重新分配渠道员" class="main_filter" id="to_follow_up">
<a title="非禁止交易状态的供应商重新分配渠道员,且必填信息不完整;或者禁用状态的供应商重新分配渠道员" class="main_filter"
id="to_follow_up">
</a>
</div>
@endif
......@@ -111,7 +114,12 @@
@inject('transformableSelectPresenter','App\Presenters\Filter\TransformableSelectPresenter')
{!! $transformableSelectPresenter->render(['channel_uid'=>'采购员','purchase_uid'=>'开发员','create_uid'=>'创建人'],$userCodes) !!}
</div>
@if(checkPerm('ViewFakeSupplier'))
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('is_type','正式供应商','',[0=>'是',1=>'否'],['width'=>'100px']) !!}
</div>
@endif
</div>
<div class="layui-row">
<div class="layui-inline">
......@@ -125,7 +133,7 @@
</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" lay-submit="" lay-filter="load">查询</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn" lay-submit="" lay-filter="reset" >重置</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn" lay-submit="" lay-filter="reset">重置</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn hide_filter_type">隐藏罗盘</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn show_filter_type"
style="display: none">显示罗盘
......
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