Commit df357e26 by 孙龙
parents afd24318 9b4543c1
......@@ -2,7 +2,7 @@ APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:Qez7GnqgT9Obb1V+FbzqgYIkkbSUeffZVsZsK+B3lkw=
APP_DEBUG=true
APP_URL=http://localhost
APP_URL=http://admin.semourdev.net/admin
LOG_CHANNEL=stack
......
<?php
namespace App\Admin\Actions;
use App\Admin\Forms\AdminSetting as AdminSettingForm;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Widgets\Modal;
class AdminInfo extends Action
{
public function render()
{
return <<<HTML
<li class="dropdown dropdown-user nav-item">
<a class="dropdown-toggle nav-link dropdown-user-link" href="#" data-toggle="dropdown">
<div class="user-nav d-sm-flex d-none">
<span class="user-name text-bold-600">{{ request()->user->name }}</span>
<span class="user-status"><i class="fa fa-circle text-success"></i> {{ trans('admin.online') }}</span>
</div>
<span>
<img class="round" src="{{ $user->getAvatar() }}" alt="avatar" height="40" width="40" />
</span>
</a>
<div class="dropdown-menu dropdown-menu-right">
<a href="{{ admin_url('auth/setting') }}" class="dropdown-item">
<i class="feather icon-user"></i> {{ trans('admin.setting') }}
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{ admin_url('auth/logout') }}">
<i class="feather icon-power"></i> {{ trans('admin.logout') }}
</a>
</div>
</li>
HTML;
}
}
......@@ -20,22 +20,16 @@ class UserAssignAction extends BatchAction
protected $htmlClasses = ['btn btn-primary btn-sm btn-mini'];
// 注意action的构造方法参数一定要给默认值
public function __construct($title = null, $action = 1)
public function __construct()
{
$this->title = $title;
$this->action = $action;
}
// 确认弹窗信息
public function confirm()
{
return '您确定要已选中的文章吗?';
$this->title = "";
$this->action = 1;
}
public function render()
{
$form = AssignUserHandle::make();
$buttonName = trans('user.labels.handle');
$buttonName = trans('user.labels.assign');
return Modal::make()->lg()->title($this->title)->body($form->payload([]))->onLoad($this->getModalScript())->button('<button class="btn btn-primary">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline" style="margin-left: 5px">' . $buttonName . '</span>
</button>');
......
......@@ -29,9 +29,9 @@ class UserStatusAction extends RowAction
*/
public function title()
{
$buttonName = "启用";
$buttonName = admin_trans("enable");
if ($this->row->status == User::STATUS_NORMAL) {
$buttonName = "禁用";
$buttonName = admin_trans("disable");
}
return $buttonName;
}
......@@ -59,11 +59,11 @@ class UserStatusAction extends RowAction
*/
public function confirm()
{
$buttonName = "启用";
$buttonName = admin_trans("enable");
if ($this->row->status == User::STATUS_NORMAL) {
$buttonName = "禁用";
$buttonName = admin_trans("disable");
}
return ["是否确认 {$buttonName} ?"];
return ["confirm {$buttonName} ?"];
}
/**
......@@ -85,7 +85,7 @@ class UserStatusAction extends RowAction
} catch (\Throwable $e) {
return $this->response()->error($e->getMessage());
}
return $this->response()->success('操作成功')->refresh();
return $this->response()->success(admin_trans("succeeded"))->refresh();
}
/**
......
......@@ -19,22 +19,16 @@ class UserTransferAction extends BatchAction
protected $htmlClasses = ['btn btn-primary btn-sm btn-mini'];
// 注意action的构造方法参数一定要给默认值
public function __construct($title = null, $action = 1)
public function __construct()
{
$this->title = $title;
$this->action = $action;
}
// 确认弹窗信息
public function confirm()
{
return '您确定要已选中的文章吗?';
$this->title = trans('user.labels.transfer');
$this->action = 1;
}
public function render()
{
$form = AssignUserHandle::make();
$buttonName = trans('user.labels.handle');
$buttonName = trans('user.labels.transfer');
return Modal::make()->lg()->title($this->title)->body($form->payload([]))->onLoad($this->getModalScript())->button('<button class="btn btn-primary">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline" style="margin-left: 5px">' . $buttonName . '</span>
</button>');
......@@ -62,14 +56,7 @@ JS;
// 处理请求
public function handle(Request $request)
{
// 获取选中的文章ID数组
$keys = $this->getKey();
// 获取请求参数
$action = $request->get('action');
$message = $action ? '文章发布成功' : '文章下线成功';
$message = admin_trans("succeeded");
return $this->response()->success($message)->refresh();
}
......
......@@ -21,16 +21,16 @@ class UserAddressCreateAction extends AbstractTool
protected $action;
protected $htmlClasses = ['btn btn-sm btn-primary'];
// 注意action的构造方法参数一定要给默认值
public function __construct($title = null, $action = 1)
public function __construct()
{
$this->title = $title;
$this->action = $action;
$this->title = trans("user-address.labels.create_user_address");
$this->action = 1;
}
public function render()
{
$form = SaveUserAddressHandle::make(['user_id'=>$this->getKey()]);
$buttonName = trans('user.labels.handle');
$buttonName = trans("user-address.labels.create_user_address");
return Modal::make()->lg()->title($this->title)->body($form->payload(['user_id'=>$this->getKey()]))->onLoad
($this->getModalScript())->button('<button style="margin-right: 5px" class="btn btn-sm btn-primary">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline" style="margin-left: 5px">' .
......
......@@ -30,7 +30,7 @@ class UserAddressDeleteAction extends RowAction
*/
public function title()
{
$buttonName = "删除";
$buttonName = trans("user-address.labels.delete_user_address");
return $buttonName;
}
......@@ -54,8 +54,7 @@ class UserAddressDeleteAction extends RowAction
*/
public function confirm()
{
$buttonName = "删除";
return ["是否确认 {$buttonName} ?"];
return admin_trans("confirm");
}
/**
......@@ -73,7 +72,7 @@ class UserAddressDeleteAction extends RowAction
} catch (\Throwable $e) {
return $this->response()->error($e->getMessage());
}
return $this->response()->success('操作成功')->refresh();
return $this->response()->success(admin_trans("succeeded"))->refresh();
}
/**
......
......@@ -21,16 +21,16 @@ class UserAddressEditAction extends RowAction
protected $htmlClasses = ['btn btn-sm btn-primary'];
// 注意action的构造方法参数一定要给默认值
public function __construct($title = null, $action = 1)
public function __construct()
{
$this->title = $title;
$this->action = $action;
$this->title = trans("user-address.labels.edit_user_address");
$this->action = 1;
}
public function render()
{
$form = SaveUserAddressHandle::make(['address_id' => $this->getRow()['address_id']]);
$buttonName = trans('user.labels.handle');
$buttonName = trans("user-address.labels.edit_user_address");
return Modal::make()->lg()->title($this->title)->body($form->payload(['address_id' => $this->getRow()['address_id']]))
->onLoad
($this->getModalScript())->button('<button style="margin-right: 5px" class="btn btn-sm btn-primary">
......
......@@ -3,6 +3,7 @@
namespace App\Admin\Controllers;
use App\Admin\Metrics\Examples;
use App\Admin\Service\AutoAssignCustomerService;
use App\Http\Controllers\Controller;
use Dcat\Admin\Http\Controllers\Dashboard;
use Dcat\Admin\Layout\Column;
......
......@@ -26,10 +26,10 @@ class InquiryController extends AdminController
{
return Grid::make(new Inquiry(['user','sales_user']), function (Grid $grid) {
$grid->showFilter();
// $grid->disableActions();
$grid->disableActions();
$grid->disableFilterButton();
$grid->disableRefreshButton();
// $grid->disableCreateButton();
$grid->disableCreateButton();
$grid->filter(function ($filter) {
$filter->expand(true);
$filter->whereBetween('create_time', function ($q) {
......
......@@ -114,23 +114,14 @@ class UserController extends AdminController
}
UserService::createUserAndAddress($params);
} catch (\Throwable $throwable) {
return $this->form()->response()
// var_dump((string)$throwable);
return Form::make()->response()
->error(trans('admin.save_failed'))
->withExceptionIf($throwable->getMessage(), $throwable);
}
$url = admin_url("/users/list");
return $this->form()->response()->success('操作成功')->redirect($url)->refresh();
$url = admin_url("/users");
return Form::make()->response()->success(admin_trans("succeeded"))->redirect($url);
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::dialog("测试");
// return $form;
}
}
......@@ -31,6 +31,8 @@ class HandleInquiry extends Form implements LazyRenderable
}
Inquiry::where('inquiry_id', $input['inquiry_id'])->update([
'status' => $input['status'],
'processing_time' => time(),
'update_time' => time(),
'processing_result' => $input['handle_result']
]);
return $this
......
......@@ -45,29 +45,32 @@ class CreateUser extends \Dcat\Admin\Support\LazyRenderable
$form->row(function (Form\Row $form) {
$form->array('user_address_list', function ($table) {
$table->row(function (Form\Row $table) {
$table->width(3)->text('first_name')->required();
$table->width(3)->text('last_name')->required();
$table->width(3)->text('first_name')->label(trans("user-address.fields.first_name"))->required();
$table->width(3)->text('last_name')->label(trans("user-address.fields.last_name"))->required();
});
$table->row(function (Form\Row $table) {
$table->width(3)->select('address_type')->options(admin_trans('user-address.options.address_type'))
$table->width(3)->select('address_type')->label(trans("user-address.fields.address_type"))->options
(admin_trans('user-address.options.address_type'))
->required();
$table->width(3)->text('company_name');
$table->width(3)->text('company_name')->label(trans("user-address.fields.company_name"));
});
$table->row(function (Form\Row $table) {
$table->width(3)->email('email')->required();
$table->width(3)->text('phone')->required();
$table->width(3)->email('email')->label(trans("user-address.fields.email"))->required();
$table->width(3)->text('phone')->label(trans("user-address.fields.phone"))->required();
});
$table->row(function (Form\Row $table) {
$table->width(3)->select('country')->options(Country::getCountryMap())->required();
$table->width(3)->text('province');
$table->width(3)->text('city')->required();
$table->width(2)->text('post_code')->required();
$table->width(3)->select('country')->label(trans("user-address.fields.country"))->options
(Country::getCountryMap())
->required();
$table->width(3)->text('province')->label(trans("user-address.fields.province"));
$table->width(3)->text('city')->label(trans("user-address.fields.city"))->required();
$table->width(2)->text('post_code')->label(trans("user-address.fields.post_code"))->required();
});
$table->row(function (Form\Row $table) {
$table->width(12)->textarea('detail_address')->required();
$table->width(12)->textarea('detail_address')->label(trans("user-address.fields.detail_address"))->required();
});
$table->row(function (Form\Row $table) {
$table->width(3)->switch('is_default')->required();
$table->width(3)->switch('is_default')->label(trans("user-address.fields.is_default"))->required();
});
});
});
......
......@@ -33,7 +33,7 @@ class UserAddress extends \Dcat\Admin\Support\LazyRenderable
$grid->disableEditButton();
UserAddressService::listField($grid);
$userAddressCreateAction = new UserAddressCreateAction("新增用户地址");
$userAddressCreateAction = new UserAddressCreateAction();
$userAddressCreateAction->setKey($this->key);
$grid->tools([
$userAddressCreateAction,
......
......@@ -4,17 +4,18 @@ namespace App\Admin\Service;
use Illuminate\Support\Facades\DB;
class AutoAssignCustomer
class AutoAssignCustomerService
{
public static function getNowAssignInfo()
{
try {
DB::beginTransaction();
$assignInfo = \App\Models\AutoAssignCustomer::getNowAssignInfo();
if (empty($res)) {
if (empty($assignInfo)) {
$assignInfo = \App\Models\AutoAssignCustomer::getInfoByOrderSort();
\App\Models\AutoAssignCustomer::updateAll(['is_now' => \App\Models\AutoAssignCustomer::IS_NOW_NO]);
\App\Models\AutoAssignCustomer::updateById($assignInfo['id'], ['is_now' => \App\Models\AutoAssignCustomer::IS_NOW_YES]);
\App\Models\AutoAssignCustomer::updateById($assignInfo['id'],
['is_now' => \App\Models\AutoAssignCustomer::IS_NOW_YES]);
}
DB::commit();
return $assignInfo;
......@@ -30,21 +31,66 @@ class AutoAssignCustomer
if (empty($assignInfo)) {
return false;
}
$nowNum = $assignInfo['now_num'] + $num;
if ($nowNum > $assignInfo['max_num']) {
if ($assignInfo['is_now'] == \App\Models\AutoAssignCustomer::IS_NOW_NO) {
return false;
}
if ($nowNum == $assignInfo['max_num']) {
$nowNum = $assignInfo['now_num'] + $num;
if ($nowNum > $assignInfo['max_num']) {
$nextAssignInfo = \App\Models\AutoAssignCustomer::getInfoByOrderSort($assignInfo['sort']);
if (empty($nextAssignInfo)) {
$nextAssignInfo = \App\Models\AutoAssignCustomer::getInfoByOrderSort(-999999999);
}
if (empty($nextAssignInfo)) {
return false;
}
\App\Models\AutoAssignCustomer::updateAll(['is_now' => \App\Models\AutoAssignCustomer::IS_NOW_NO]);
\App\Models\AutoAssignCustomer::updateAll([
'is_now' => \App\Models\AutoAssignCustomer::IS_NOW_NO,
"now_num" => 0
]);
\App\Models\AutoAssignCustomer::updateById($nextAssignInfo['id'],
['is_now' => \App\Models\AutoAssignCustomer::IS_NOW_YES]);
return false;
}
return \App\Models\AutoAssignCustomer::updateById($assignInfo['id'], ['now_num' => $nowNum]);
}
public static function updateDepartmentNum()
{
//获取自动分配部门
$assignList = \App\Models\AutoAssignCustomer::getList();
if (empty($assignList)) {
return false;
}
//获取部门人员
foreach ($assignList as $assign) {
$departmentId = $assign['department_id'];
$departmentIds = [];
$departmentIds = self::getChildDepartmentList($departmentId, $departmentIds);
$departmentIds[] = $departmentId;
$departmentIds = array_unique($departmentIds);
//获取该部门下的用户
$userList = \App\Models\Cms\CmsUser::getUserListByDepartmentId($departmentIds);
$updateData = [
'max_num' => count($userList),
];
var_dump($updateData);
\App\Models\AutoAssignCustomer::updateById($assign['id'], $updateData);
}
}
public static function getChildDepartmentList($departmentId, &$departmentIds)
{
// 获取下级部门
$sub_department = \App\Models\Cms\CmsUserDepartmentModel::getDepartmentByParentId($departmentId);
if ($sub_department) {
foreach ($sub_department as $key => $v) {
self::getChildDepartmentList($key, $departmentIds);
}
}
$departmentIds[] = $departmentId;
return $departmentIds;
}
}
......@@ -23,10 +23,10 @@ class UserService
{
$grid->filter(function ($filter) {
$filter->expand(true);
$filter->whereBetween('create_time', function ($q) {
$filter->whereBetween('created_time', function ($q) {
$start = strtotime($this->input['start'] ?? null);
$end = strtotime($this->input['end'] ?? null);
$q->whereBetween('create_time', [$start, $end]);
$q->whereBetween('created_time', [$start, $end]);
})->datetime()->width(3);
$filter->startWith('company_name')->width(2);
......@@ -59,8 +59,8 @@ class UserService
public static function userListTool(Grid $grid)
{
$grid->tools([
new UserTransferAction("转让销售"),
new UserAssignAction("分配销售"),
new UserTransferAction(),
new UserAssignAction(),
]);
}
......@@ -78,7 +78,7 @@ class UserService
// 获取当前行主键值
$id = $actions->getKey();
$actions->append('<a style="margin-right: 5px" href="' . admin_url("/users/{$id}") . '" class="btn btn-primary btn-sm
btn-mini">detail</a>');
btn-mini">' . admin_trans("detail") . '</a>');
//状态按钮
$actions->append(new UserStatusAction());
});
......@@ -103,18 +103,22 @@ class UserService
"last_name" => $params["last_name"],
"phone" => $params["phone"],
"email" => $params["email"],
"name" => $params["email"],
"reg_source" => User::REG_SOURCE_MANUAL,
"remark" => $params["remark"],
"password" => "1234567",
"remark" => $params["remark"] ?? "",
"password" => "",
"status" => User::STATUS_NORMAL,
"sale_id" => request()->user['userId'] ?? "1000",
"sale_name" => request()->user['name'] ?? "admin",
"sale_id" => request()->user->userId ?? "1000",
"sale_name" => request()->user->name ?? "admin",
"created_time" => time(),
"update_time" => time(),
];
$userId = User::insertData($userData);
foreach ($params['user_address_list'] as $address) {
if ($address['_remove_']) {
continue;
}
$validator = Validator::make($address, [
'first_name' => 'required',
'last_name' => 'required',
......@@ -128,22 +132,22 @@ class UserService
]);
if ($validator->fails()) {
$error = $validator->errors()->first();
throw new \Exception("客户地址错误:" . $error);
throw new \Exception("user addressList failed:" . $error);
}
$addressData = [
"user_id" => $userId,
"first_name" => $address["first_name"]??"",
"last_name" => $address["last_name"]??"",
"address_type" => $address["address_type"]??"",
"company_name" => $address["company_name"]??"",
"email" => $address["email"]??"",
"phone" => $address["phone"]??"",
"country" => $address["country"]??"",
"province" => $address["province"]??"",
"city" => $address["city"]??"",
"post_code" => $address["post_code"]??"",
"detail_address" => $address["detail_address"]??"",
"is_default" => $address["is_default"]??"",
"first_name" => $address["first_name"] ?? "",
"last_name" => $address["last_name"] ?? "",
"address_type" => $address["address_type"] ?? "",
"company_name" => $address["company_name"] ?? "",
"email" => $address["email"] ?? "",
"phone" => $address["phone"] ?? "",
"country" => $address["country"] ?? "",
"province" => $address["province"] ?? "",
"city" => $address["city"] ?? "",
"post_code" => $address["post_code"] ?? "",
"detail_address" => $address["detail_address"] ?? "",
"is_default" => $address["is_default"] ?? "",
"create_time" => time(),
"update_time" => time(),
];
......
......@@ -183,19 +183,21 @@ HTML
if (!Dcat\Admin\Support\Helper::isAjaxRequest()) {
$navbar->$method(App\Admin\Actions\AdminSetting::make()->render());
}
$navbar->right(
<<<HTML
HTML
);
// $navbar->right('');
});
admin_inject_section(Admin::SECTION['NAVBAR_USER_PANEL'], function () {
return view('admin.navbar-user-panel', ['user' => request()->user]);
});
Admin::menu(function (Menu $menu) {
//权限系统的菜单
$permMenus = request()->menus;
$permMenus = (array) $permMenus;
$permMenus = (array)$permMenus;
$addMenus = [];
foreach ($permMenus as $key => &$permMenu) {
$permMenu = (array) $permMenu;
$permMenu = (array)$permMenu;
//为了区分本系统手动添加的菜单
$key = $key + 1000;
$permMenu['id'] = $key + 1;
......@@ -205,7 +207,7 @@ Admin::menu(function (Menu $menu) {
$addMenus[] = $permMenu;
if (!empty($permMenu['childs'])) {
foreach ($permMenu['childs'] as $k => &$child) {
$child = (array) $child;
$child = (array)$child;
//为了让字菜单的id不和父菜单的id冲突
$child['id'] = $k + ($key + 1) * 100;
$child['parent_id'] = $key + 1;
......@@ -235,7 +237,6 @@ Grid::resolving(function (Grid $grid) {
});
});
//拓展组件
Field::extend('textarea', Textarea::class);
......@@ -32,31 +32,38 @@ class AutoAssignCustomer extends Model
return self::insertGetId($data);
}
//获取列表
public static function getList()
{
$res = self::orderBy('sort', 'asc')->get();
return ($res) ? $res->toArray() : [];
}
public static function getNowAssignInfo()
{
$res = self::where('is_now', self::IS_NOW_YES)->get();
$res = self::where('is_now', self::IS_NOW_YES)->first();
return ($res) ? $res->toArray() : [];
}
public static function getInfoByOrderSort($sort = 0)
{
$res = self::where('sort', ">=", $sort)->orderBy("sort", "ASC")->get();
$res = self::where('sort', ">", $sort)->orderBy("sort", "ASC")->first();
return ($res) ? $res->toArray() : [];
}
public static function deleteById($addressId)
{
return self::where('address_id', $addressId)->delete();
return self::where('id', $addressId)->delete();
}
public static function updateById($id, $update)
{
return self::where("address_id", $id)->update($update);
return self::where("id", $id)->update($update);
}
public static function updateAll( $update)
public static function updateAll($update)
{
return self::update($update);
return self::where([])->update($update);
}
public static function updateByUserId($userId, $update)
......@@ -69,6 +76,7 @@ class AutoAssignCustomer extends Model
$res = self::where('id', $id)->first();
return ($res) ? $res->toArray() : [];
}
public static function getInfoByDepartmentId($id)
{
$res = self::where('department_id', $id)->first();
......
<?php
namespace App\Models\Cms;
use Illuminate\Database\Eloquent\Model;
class CmsDepartmentModel extends Model
{
protected $table = 'department';
public $timestamps = false;
protected $primaryKey = 'departmentId';
//采购部门的总ID
const PURCHASE_DEPARTMENT_ID = 8;
//销售部门的总ID
const SALES_DEPARTMENT_ID = 7;
// 获取部门人员
public static function getUsersByDepartmentId($departmentId, $status = '', $filter = '')
{
$departmentIds = [];
self::getSubDepartmentId($departmentId, $departmentIds);
return CmsUserInfoModel::whereIn('department_id', $departmentIds)
->where(function ($query) use ($status) {
if ($status !== '') {
$query->where('status', '=', $status);
}
})
->where(function ($query) use ($filter) {
if ($filter) {
$query->whereRaw($filter);
}
})
->get()->toArray();
}
// 获取下级部门ID
public static function getSubDepartmentId($departmentId, &$departmentIds)
{
// 获取下级部门
$sub_department = CmsUserDepartmentModel::where('parent_id', $departmentId)->select([
'department_id',
'department_name'
])->get();
if ($sub_department) {
foreach ($sub_department as $v) {
self::getSubDepartmentId($v['department_id'], $departmentIds);
}
}
$departmentIds[] = $departmentId;
return $departmentIds;
}
}
......@@ -15,4 +15,11 @@ class CmsUser extends Model
$res = self::where('userId', $userId)->first();
return ($res) ? $res->toArray() : [];
}
//根据部门id获取列表
public static function getUserListByDepartmentId($departmentIds)
{
$res = self::whereIn('department_id', $departmentIds)->get();
return ($res) ? $res->toArray() : [];
}
}
<?php
namespace App\Models\Cms;
use Illuminate\Database\Eloquent\Model;
class CmsUserDepartmentModel extends Model
{
protected $connection = 'cms';
protected $table = 'user_department';
public $timestamps = false;
public static function getDepartmentIdsParrentIds($parrent_ids = [])
{
$res = self::whereIn('parent_id', $parrent_ids)->pluck('department_id');
return ($res) ? $res->toArray() : [];
}
// 根据父ID获取指定的部门
public static function getDepartmentByParentId($parent_id)
{
if (is_array($parent_id)) {
$list = self::whereIn('parent_id', $parent_id);
} else {
$list = self::where('parent_id', $parent_id);
}
return $list->pluck('department_name', 'department_id')->toArray();
}
public static function getDepartmentInfo($department_id)
{
$res = self::where('department_id', $department_id)->first();
return ($res) ? $res->toArray() : [];
}
public static function getDepartmentListByDepartmentIdArr($departmentIdArr)
{
$res = self::whereIn('department_id', $departmentIdArr)->get();
return ($res) ? $res->toArray() : [];
}
public static function getDepartmentList($departmentName, $departmentIds)
{
$res = self::select('department_name')->where('department_name', 'like',
'%' . $departmentName . '%')->whereIn('department_id', $departmentIds)->get();
return ($res) ? $res->toArray() : [];
}
public static function getDepartmentListByName($departmentName)
{
$res = self::select('department_name')->distinct('department_name')->where('department_name', 'like',
"%{$departmentName}%")->orderByDesc('department_id')->pluck('department_name');
return ($res) ? $res->toArray() : [];
}
// 根据部门名称获取部门ID
public static function getDepartmentIdByName($department_name)
{
return self::where('department_name', $department_name)->value('department_id');
}
public static function getDepartmentId($department)
{
$res = self::select('department_id')->distinct('department_name')->where('department_name',
$department)->pluck('department_id');
return ($res) ? $res->toArray() : [];
}
// 获取部门人员
public static function getUserByDepartmentId($departmentId, $status = '', $filter = '')
{
$departmentIds = [];
self::getSubDepartmentId($departmentId, $departmentIds);
return CmsUserInfoModel::whereIn('department_id', $departmentIds)
->where(function ($query) use ($status) {
if ($status !== '') {
$query->where('status', '=', $status);
}
})
->where(function ($query) use ($filter) {
if ($filter) {
$query->whereRaw($filter);
}
})
->select('userId', 'name', 'status')
->get();
}
// 获取下级部门ID
public static function getSubDepartmentId($departmentId, &$departmentIds)
{
// 获取下级部门
$sub_department = self::where('parent_id', $departmentId)->select('department_id',
'department_name')->get();
if ($sub_department) {
foreach ($sub_department as $v) {
self::getSubDepartmentId($v['department_id'], $departmentIds);
}
}
$departmentIds[] = $departmentId;
return $departmentIds;
}
/*
* 获取上级部门,只需要往上找一层
* 比如:线上一组=》线上销售部
*/
public static function getParentDepartment($dep_id)
{
$parent_id = self::where("department_id", intval($dep_id))->value("parent_id");
if(!$parent_id){
return [];
}
$parentInfo = self::where("department_id",$parent_id)->select("department_id", "department_name")->first();
return $parentInfo ? $parentInfo->toArray():[];
}
// 获取下级部门
public static function getSubDepartmentById($department_id)
{
return self::where('parent_id', $department_id)->select('department_id', 'department_name')->get()->toArray();
}
// 获取顶级部门名称
public static function getTopDepartmentNameById($department_id)
{
return self::where('department_id', $department_id)->where('parent_id', 0)->value('department_name');
}
}
......@@ -4,22 +4,28 @@ return [
'labels' => [
'UserAddress' => 'UserAddress',
'user-address' => 'UserAddress',
'create_user_address' => 'Create user address',
'edit_user_address' => 'Edit',
'delete_user_address' => 'Delete',
],
'fields' => [
"address_id" => "用户用户地址ID",
"user_id" => "会员ID",
"address_type" => "地址类型;0:个人,1:公司",
"consignee" => "收货人/收货公司",
"address_type" => "地址类型",
"consignee" => "收货人",
"email" => "邮箱",
"post_code" => "邮政编码",
"phone" => "手机/电话",
"phone" => "手机",
"country" => "国家",
"province" => "省份",
"city" => "城市",
"detail_address" => "详细地址",
"is_default" => "是否默认(1=是|0=否)",
"is_default" => "是否默认",
"create_time" => "创建时间",
"update_time" => "修改时间",
"last_name" => "姓",
"first_name" => "名",
"company_name" => "公司名称",
],
'options' => [
"address_type"=> [
......
<?php
return [
'labels' => [
'User' => 'User',
'user' => 'User',
'labels' => [
'User' => 'User',
'user' => 'User',
'user_detail' => 'User Detail',
'handle' => 'Handle',
'transfer' => 'Transfer',
'assign' => 'Assign',
],
'fields' => [
'user_sn' => '客户编码',
'name' => '用户名',
'email' => '邮箱',
'email_verified_at' => '邮箱校验时间',
'password' => '密码',
'remark' => '备注',
'phone' => '手机号码',
'remember_token' => '记住登陆token',
'fields' => [
'user_sn' => '客户编码',
'name' => '用户名',
'email' => '邮箱',
'email_verified_at' => '邮箱校验时间',
'password' => '密码',
'remark' => '备注',
'phone' => '手机号码',
'remember_token' => '记住登陆token',
'account_properties' => '账号属性',
'status' => '状态',
'company_name' => '公司名称',
'first_name' => '名字',
'sale_id' => '业务员',
'sale_name' => '业务员名字',
'last_name' => '姓氏',
'created_time' => '创建时间',
'update_time' => '更新时间',
'reg_source' => '注册来源',
'user_address' => [
'status' => '状态',
'company_name' => '公司名称',
'first_name' => '名字',
'sale_id' => '业务员',
'sale_name' => '业务员名字',
'last_name' => '姓氏',
'created_time' => '创建时间',
'update_time' => '更新时间',
'reg_source' => '注册来源',
'user_address' => [
'consignee' => 'Sales Name',
]
],
'options' => [
"status"=>[
"1"=>"正常",
"-1"=>"禁用"
"status" => [
"1" => "正常",
"-1" => "禁用"
],
"reg_source"=>[
"1"=>"网站",
"2"=>"人工新增"
"reg_source" => [
"1" => "网站",
"2" => "人工新增"
],
"account_properties"=>[
"1"=>"个人",
"2"=>"企业"
"account_properties" => [
"1" => "个人",
"2" => "企业"
],
],
];
......@@ -8,25 +8,28 @@ return [
'fields' => [
"address_id" => "用户用户地址ID",
"user_id" => "会员ID",
"address_type" => "地址类型;0:个人,1:公司",
"consignee" => "收货人/收货公司",
"address_type" => "地址类型",
"consignee" => "收货人",
"email" => "邮箱",
"post_code" => "邮政编码",
"phone" => "手机/电话",
"phone" => "手机",
"country" => "国家",
"province" => "省份",
"city" => "城市",
"detail_address" => "详细地址",
"is_default" => "是否默认(1=是|0=否)",
"is_default" => "是否默认",
"create_time" => "创建时间",
"update_time" => "修改时间",
"last_name" => "姓",
"first_name" => "名",
"company_name" => "公司名称",
],
'options' => [
"address_type"=> [
"address_type" => [
"0" => "个人",
"1" => "公司",
],
"is_default"=> [
"is_default" => [
"1" => "是",
"0" => "否",
],
......
@if($user)
<li class="dropdown dropdown-user nav-item">
<a class="dropdown-toggle nav-link dropdown-user-link" href="#" data-toggle="dropdown">
<div class="user-nav d-sm-flex d-none">
<span class="user-name text-bold-600">{{ $user->name }}</span>
<span class="user-status"><i class="fa fa-circle text-success"></i> {{ trans('admin.online') }}</span>
</div>
<span>
<img class="round" src="/vendor/dcat-admin/images/default-avatar.jpg" alt="avatar" height="40" width="40" />
</span>
</a>
<div class="dropdown-menu dropdown-menu-right">
{{-- <a href="{{ admin_url('auth/setting') }}" class="dropdown-item">--}}
{{-- <i class="feather icon-user"></i> {{ trans('admin.setting') }}--}}
{{-- </a>--}}
{{-- <div class="dropdown-divider"></div>--}}
<a class="dropdown-item" href="{{ config('website.login.logout').'?redirect='.config('app.url') }}">
<i class="feather icon-power"></i> {{ trans('admin.logout') }}
</a>
</div>
</li>
@endif
......@@ -25,7 +25,7 @@
{{config('iframe_tab.lazy_load')?1:0}}
@endif
">
<input type="hidden" id="use_id" value="{{Admin::user()->id}}">
<input type="hidden" id="use_id" value="{{request()->user->userId}}">
{{--右键菜单监控--}}
<div class="mouse-click-menu">
<ul>
......
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