Commit c483e6a1 by mushishixian

只能选采购员

parent 5759f1fe
......@@ -61,8 +61,8 @@ class SupplierContactController extends Controller
$this->data['receipt'] = $model->where('contact_id', $contactId)->first()->toArray();
}
$intracodeModel = new IntracodeModel();
$userCodes = $intracodeModel->getSampleEncode();
$this->data['userCodes'] = $userCodes;
// $userCodes = $intracodeModel->getSampleEncode();
$this->data['userCodes'] = $intracodeModel->getChannelUsersEncode();
return $this->view('添加联系方式');
}
......@@ -74,7 +74,7 @@ class SupplierContactController extends Controller
$model = new SupplierContactModel();
$this->data['contact'] = $model->where('contact_id', $contactId)->first()->toArray();
$intracodeModel = new IntracodeModel();
$userCodes = $intracodeModel->getSampleEncode();
$userCodes = $intracodeModel->getChannelUsersEncode();
$this->data['userCodes'] = $userCodes;
return $this->view('添加联系方式');
}
......
......@@ -58,7 +58,7 @@ class SupplierController extends Controller
public function SupplierList($request)
{
$intracodeModel = new IntracodeModel();
$this->data['userCodes'] = $intracodeModel->getSampleEncode();
$this->data['userCodes'] = $intracodeModel->getChannelUsersEncode();
$this->data['users'] = $intracodeModel->getAdminUserAndCode();
$supplierStatisticsService = new SupplierStatisticsService();
$statistics = $supplierStatisticsService->getSupplierListStatistics();
......@@ -99,7 +99,7 @@ class SupplierController extends Controller
$intracodeModel = new IntracodeModel();
$this->data['outside_contact_status'] = Config('fixed.OutsideContactStatus');
$this->data['outside_contact_type'] = Config('fixed.OutsideContactType');
$userCodes = $intracodeModel->getSampleEncode();
$userCodes = $intracodeModel->getChannelUsersEncode();
$this->data['userCodes'] = $userCodes;
$this->data['user'] = $userCodes;
$this->data['purchase_users'] = [];
......@@ -131,7 +131,7 @@ class SupplierController extends Controller
{
$intracodeModel = new IntracodeModel();
$userCodes = $intracodeModel->getSampleEncode();
$this->data['userCodes'] = $userCodes;
$this->data['userCodes'] = $intracodeModel->getChannelUsersEncode();
$this->data['user'] = $userCodes;
$this->data['purchase_users'] = [];
$this->data['operate'] = 'update';
......@@ -183,7 +183,7 @@ class SupplierController extends Controller
$supplier = $transformer->transformInfo($supplier);
$this->data['supplier'] = $supplier;
$intracodeModel = new IntracodeModel();
$this->data['userCodes'] = $intracodeModel->getPurchaseUserCodes();
$this->data['userCodes'] = $intracodeModel->getChannelUsersEncode();
$logModel = new LogModel();
$this->data['logs'] = $logModel->where('supplier_id', $supplierId)
->where('action', '分配渠道开发员')->orderBy('id', 'desc')
......
......@@ -3,6 +3,7 @@
namespace App\Model;
use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService;
use Illuminate\Database\Eloquent\Model;
class IntracodeModel extends Model
......@@ -16,7 +17,8 @@ class IntracodeModel extends Model
$codeList = json_decode($redis->get('EncodedList_supplier'), true);
if (!$codeList) {
$codeList = $this->where('admin_id', '>', 0)->join('user_info', 'lie_intracode.admin_id', '=',
'user_info.userId')->select('code_id', 'admin_id', 'name', 'email')->get();
'user_info.userId')->where('user_info.status', '!=', 4)->select('code_id', 'admin_id', 'name',
'email')->get();
if ($codeList) {
$codeList = $codeList->toArray();
foreach ($codeList as $k => &$v) {
......@@ -31,6 +33,7 @@ class IntracodeModel extends Model
return $codeList;
}
//获取简单的内部用户数据
public function getSampleEncode()
{
......@@ -42,13 +45,22 @@ class IntracodeModel extends Model
return $result;
}
//获取开发员的编码(渠道开发部门的优先排序)
public function getAdminIdEncode()
//获取采购员和对应的编码
public function getChannelUsersEncode()
{
$codeList = $this->getEncode();
$departmentService = new DepartmentService();
//市场部
$usersMarket = $departmentService->getUserByDepartmentId(4);
//运营部
$usersOperation = $departmentService->getUserByDepartmentId(9);
//采购部
$userChannel = $departmentService->getUserByDepartmentId(8);
$users = array_merge(array_merge($usersMarket, $usersOperation),$userChannel);
$userIds = array_column($users, 'userId');
$users = $this->getEncodeByUserIds($userIds);
$result = [];
foreach ($codeList as $code) {
$result[$code['admin_id']] = $code['name'] . '(' . $code['code_id'] . ')';
foreach ($users as $code) {
$result[$code['code_id']] = $code['name'] . '(' . $code['code_id'] . ')';
}
return $result;
}
......@@ -88,7 +100,7 @@ class IntracodeModel extends Model
}
$temp = [];
foreach ($codes as $code => $name) {
if (in_array($code,$codeIds)) {
if (in_array($code, $codeIds)) {
unset($codes[$code]);
$temp[$code] = $name;
}
......@@ -102,7 +114,7 @@ class IntracodeModel extends Model
{
$encodedUsers = [];
$codes = $this->select('code_id', 'admin_id')
->whereIn('code_id',$encodedList)
->whereIn('code_id', $encodedList)
->get();
if (empty($codes)) {
return [];
......@@ -110,8 +122,8 @@ class IntracodeModel extends Model
$codes = $codes->toArray();
$adminIds = array_column($codes, 'admin_id');
$userModel = new UserInfoModel();
$users = $userModel->whereIn('userId',$adminIds)->pluck('name', 'userId');
foreach ($codes as $key=>$code) {
$users = $userModel->whereIn('userId', $adminIds)->pluck('name', 'userId');
foreach ($codes as $key => $code) {
$encodedUsers[$code['code_id']] = array_get($users, $code['admin_id']);
}
return $encodedUsers;
......
......@@ -46,7 +46,7 @@
area: ['600px', '525px'],
title: '新增联系人',
end: function () { // 监听弹窗关闭
location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
// location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
table.reload('contactList');
}
});
......@@ -66,7 +66,7 @@
area: ['600px', '525px'],
title: '编辑联系人',
end: function () { // 监听弹窗关闭
location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
// location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
table.reload('contactList');
}
});
......@@ -92,7 +92,7 @@
return false;
}
if (resp.err_code === 0) {
location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
// location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
table.reload('contactList');
layer.closeAll();
layer.msg(resp.err_msg, {'icon': 6});
......
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