Commit f69a1d67 by mushishixian

fix

parent 4ebc38d1
......@@ -27,7 +27,7 @@ class SupplierShareApplyApiController extends Controller
//校验申请的供应商,并且还要返回所属部门列表
public function CheckApplySupplierShare($request)
{
$supplierName = $request->get('supplier_name');
$supplierName = trim($request->get('supplier_name'));
if (empty($supplierName)) {
$this->response(-1, '供应商名称不能为空');
}
......@@ -36,14 +36,25 @@ class SupplierShareApplyApiController extends Controller
if (empty($supplier)) {
$this->response(-1, '该供应商名称不存在,请输入正确供应商名称');
}
$userId = $request->user->userId;
$codeId = $request->user->codeId;
//要判断自己是不是有这个供应商了,有的话没必要申请
$isOwn = $supplierModel->where('supplier_name', $supplierName)->where(function ($q) use ($userId, $codeId) {
$q->where('create_uid', $userId)
->orWhere('purchase_uid', $codeId)
->orwhere('channel_uid', 'like', "%$codeId%");
})->where('is_type', 0)->count();
if ($isOwn) {
$this->response(-1, '你已经可以管理该供应商,无需申请共用');
}
if (empty($supplier['create_uid']) && empty($supplier['channel_uid']) && empty($supplier['purchase_uid'])) {
$this->response(-1, '该供应商没有相关的所属人信息,请联系管理员');
}
$departmentService = new DepartmentService();
$department = $departmentService->getTopDepartmentByUserId($request->user->userId);
$applyService = new SupplierShareApplyService();
$departments = $applyService->getApplyCanUseDepartments($supplier);
//获取当前人的部门id,如果部门列表里面包含自己的部门,则提示该供应商属于自己部门,请找主管分配
$departmentService = new DepartmentService();
$department = $departmentService->getTopDepartmentByUserId($request->user->userId);
if (in_array($department, $departments)) {
$this->response(-1, '该供应商属于自己部门,请找主管分配');
}
......
......@@ -75,6 +75,10 @@ class DepartmentService
return $department;
}
$department = $departmentModel->where('department_id', $department['parent_id'])->first()->toArray();
// //还不是顶级的话,继续找
// if ($department['parent_id'] != 0) {
// $department = $departmentModel->where('department_id', $department['parent_id'])->first()->toArray();
// }
return $department;
}
return [];
......
......@@ -21,12 +21,21 @@
}
},
{
field: 'department_name', title: '被申请部门', width: 150, align: 'center',templet: function (d) {
field: 'department_name', title: '被申请部门', width: 150, align: 'center', templet: function (d) {
return d.apply_department ? d.apply_department.department_name : '';
}
},
{field: 'create_time', title: '申请时间', width: 150, align: 'center'},
{field: 'status_name', title: '状态', width: 150, align: 'center'},
{
field: 'status_name', title: '状态', width: 150, align: 'center', templet: function (d) {
console.log(d);
if (d.status === -1 || d.status === -2) {
return "<span style='color: red'>" + d.status_name + "</span>"
} else {
return d.status_name;
}
}
},
]]
, id: 'applyList'
, page: {}
......
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