generated from liutk/owl-admin-base
sign
parent
058b6b1e41
commit
287f709635
|
|
@ -57,3 +57,5 @@ VITE_PUSHER_HOST="${PUSHER_HOST}"
|
||||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
||||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||||
|
|
||||||
|
BAIDU_JS_SECRET=
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ class SignController extends AdminController
|
||||||
amisMake()->TableColumn()->name('remarks')->label(__('employee_sign.remarks')),
|
amisMake()->TableColumn()->name('remarks')->label(__('employee_sign.remarks')),
|
||||||
$this->rowActions([
|
$this->rowActions([
|
||||||
$this->rowShowButton()->visible(Admin::user()->can('admin.hr.signs.view')),
|
$this->rowShowButton()->visible(Admin::user()->can('admin.hr.signs.view')),
|
||||||
|
$this->rowDeleteButton()->visible(Admin::user()->can('admin.hr.signs.delete')),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -80,13 +81,13 @@ class SignController extends AdminController
|
||||||
amisMake()->BaseApi()->method('get')->url(admin_url('api/employee-sign-logs'))->data(['date' => '${date}', 'employee_id' => '${employee_id}'])
|
amisMake()->BaseApi()->method('get')->url(admin_url('api/employee-sign-logs'))->data(['date' => '${date}', 'employee_id' => '${employee_id}'])
|
||||||
)
|
)
|
||||||
->body(
|
->body(
|
||||||
amisMake()->Table()->columns([
|
amisMake()->Table()->columnsTogglable(false)->columns([
|
||||||
amisMake()->TableColumn()->name('sign_time')->label(__('employee_sign_log.sign_time'))->set('type', 'mapping')->map(SignTime::options()),
|
amisMake()->TableColumn()->name('sign_time')->label(__('employee_sign_log.sign_time'))->set('type', 'mapping')->map(SignTime::options()),
|
||||||
amisMake()->TableColumn()->name('time')->label(__('employee_sign_log.time')),
|
amisMake()->TableColumn()->name('time')->label(__('employee_sign_log.time')),
|
||||||
amisMake()->TableColumn()->name('sign_type')->label(__('employee_sign_log.sign_type'))->set('type', 'mapping')->map(SignType::options()),
|
amisMake()->TableColumn()->name('sign_type')->label(__('employee_sign_log.sign_type'))->set('type', 'mapping')->map(SignType::options()),
|
||||||
amisMake()->TableColumn()->name('remarks')->label(__('employee_sign_log.remarks')),
|
amisMake()->TableColumn()->name('remarks')->label(__('employee_sign_log.remarks')),
|
||||||
amisMake()->TableColumn()->name('position.address')->label(__('employee_sign_log.position')),
|
amisMake()->TableColumn()->name('position.address')->label(__('employee_sign_log.position')),
|
||||||
amisMake()->TableColumn()->name('is_repair')->label(__('employee_sign_log.is_repair'))->set('type', 'status'),
|
amisMake()->TableColumn()->name('is_repair')->label(__('employee_sign_log.is_repair'))->set('type', 'mapping')->map(['否', '是']),
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class StoreController extends AdminController
|
||||||
->valueField('key')
|
->valueField('key')
|
||||||
->required(),
|
->required(),
|
||||||
amisMake()->InputCityControl()->name('region')->label(__('store.region'))->allowDistrict(false)->extractValue(false)->required(),
|
amisMake()->InputCityControl()->name('region')->label(__('store.region'))->allowDistrict(false)->extractValue(false)->required(),
|
||||||
amisMake()->LocationControl()->name('location')->label(__('store.location'))->ak('xDTLJ15QG6zt3f6VQcaNBfN8q3MsWBsE')->autoSelectCurrentLoc(),
|
amisMake()->LocationControl()->name('location')->label(__('store.location'))->ak(config('baidu.js_secret'))->autoSelectCurrentLoc(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,10 @@ class EmployeeService extends BaseService
|
||||||
|
|
||||||
$model = $this->modelName::create($data);
|
$model = $this->modelName::create($data);
|
||||||
|
|
||||||
if (isset($data['jobs']) && is_string($data['jobs'])) {
|
// 职位修改
|
||||||
$this->resloveJob($model, explode(',', $data['jobs']));
|
if (isset($data['jobs'])) {
|
||||||
|
$jobs = is_array($data['jobs']) ? $data['jobs'] : explode(',', $data['jobs']);
|
||||||
|
$model->jobs()->sync($jobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -66,8 +68,10 @@ class EmployeeService extends BaseService
|
||||||
return $this->setError($adminUserService->getError());
|
return $this->setError($adminUserService->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data['jobs']) && is_string($data['jobs'])) {
|
// 职位修改
|
||||||
$this->resloveJob($model, explode(',', $data['jobs']));
|
if (isset($data['jobs'])) {
|
||||||
|
$jobs = is_array($data['jobs']) ? $data['jobs'] : explode(',', $data['jobs']);
|
||||||
|
$model->jobs()->sync($jobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $model->update($data);
|
return $model->update($data);
|
||||||
|
|
@ -98,41 +102,27 @@ class EmployeeService extends BaseService
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理职位关联
|
|
||||||
*
|
|
||||||
* @param Employee $model
|
|
||||||
* @param array $jobs(字典表 key 组成的数组)
|
|
||||||
*/
|
|
||||||
public function resloveJob($model, $jobs)
|
|
||||||
{
|
|
||||||
$model->jobs()->sync($jobs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function preDelete(array $ids): void
|
public function preDelete(array $ids): void
|
||||||
{
|
{
|
||||||
if (in_array(1, $ids)) {
|
|
||||||
admin_abort('超级管理员不能删除');
|
|
||||||
}
|
|
||||||
// 无打卡记录
|
// 无打卡记录
|
||||||
if (EmployeeSignLog::whereIn('employee_id', $ids)->exists()) {
|
if (EmployeeSignLog::whereIn('employee_id', $ids)->exists()) {
|
||||||
admin_abort('请先删除员工打卡记录');
|
admin_abort('请先删除员工打卡记录');
|
||||||
}
|
}
|
||||||
// 无请假申请
|
// 无请假申请
|
||||||
if (HolidayApply::whereIn('employee_id', $ids)->exists()) {
|
if (HolidayApply::whereIn('employee_id', $ids)->exists()) {
|
||||||
admin_abort('请先删除员工打卡记录');
|
admin_abort('请先删除员工请假申请');
|
||||||
}
|
}
|
||||||
// 无出差申请
|
// 无出差申请
|
||||||
if (OfficalBusiness::whereIn('employee_id', $ids)->exists()) {
|
if (OfficalBusiness::whereIn('employee_id', $ids)->exists()) {
|
||||||
admin_abort('请先删除员工打卡记录');
|
admin_abort('请先删除员工出差申请');
|
||||||
}
|
}
|
||||||
// 加班申请
|
// 加班申请
|
||||||
if (OvertimeApply::whereIn('employee_id', $ids)->exists()) {
|
if (OvertimeApply::whereIn('employee_id', $ids)->exists()) {
|
||||||
admin_abort('请先删除员工打卡记录');
|
admin_abort('请先删除员工加班申请');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 店员关联
|
// 店员关联
|
||||||
if (DB::table('store_employees')->whereIn('employee_id', $ids)->exists()) {
|
if (Employee::whereIn('id', $ids)->where('store_id', '>', 0)->exists()) {
|
||||||
admin_abort('员工已关联门店, 请先从门店中删除');
|
admin_abort('员工已关联门店, 请先从门店中删除');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +139,7 @@ class EmployeeService extends BaseService
|
||||||
{
|
{
|
||||||
$createRules = [
|
$createRules = [
|
||||||
'name' => ['required'],
|
'name' => ['required'],
|
||||||
'phone' => ['required'],
|
'phone' => ['required', 'phone'],
|
||||||
'username' => ['required'],
|
'username' => ['required'],
|
||||||
'password' => ['required'],
|
'password' => ['required'],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,8 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\EmployeeSignFilter;
|
use App\Admin\Filters\EmployeeSignFilter;
|
||||||
use App\Enums\SignStatus;
|
use App\Enums\{SignStatus, SignTime, SignType};
|
||||||
use App\Enums\SignTime;
|
use App\Models\{Employee, EmployeeRest, EmployeeSign, EmployeeSignLog, EmployeeSignRepair};
|
||||||
use App\Enums\SignType;
|
|
||||||
use App\Models\Employee;
|
|
||||||
use App\Models\EmployeeRest;
|
|
||||||
use App\Models\EmployeeSign;
|
|
||||||
use App\Models\EmployeeSignLog;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class EmployeeSignService extends BaseService
|
class EmployeeSignService extends BaseService
|
||||||
|
|
@ -20,6 +15,14 @@ class EmployeeSignService extends BaseService
|
||||||
|
|
||||||
protected string $modelFilterName = EmployeeSignFilter::class;
|
protected string $modelFilterName = EmployeeSignFilter::class;
|
||||||
|
|
||||||
|
public function preDelete(array $ids): void
|
||||||
|
{
|
||||||
|
// 删除打卡日志
|
||||||
|
EmployeeSignLog::whereIn('employee_id', $ids)->delete();
|
||||||
|
// 删除补卡申请
|
||||||
|
EmployeeSignRepair::whereIn('employee_id', $ids)->delete();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 整理昨天的打卡流水, 生成对应的打卡记录
|
* 整理昨天的打卡流水, 生成对应的打卡记录
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ Route::group([
|
||||||
// 休息管理
|
// 休息管理
|
||||||
$router->resource('rests', RestController::class)->only(['index', 'create', 'store', 'destroy']);
|
$router->resource('rests', RestController::class)->only(['index', 'create', 'store', 'destroy']);
|
||||||
// 打卡情况
|
// 打卡情况
|
||||||
$router->resource('signs', SignController::class)->only(['index', 'show']);
|
$router->resource('signs', SignController::class)->only(['index', 'show', 'destroy']);
|
||||||
// 补卡申请
|
// 补卡申请
|
||||||
$router->resource('repairs', SignRepairController::class);
|
$router->resource('repairs', SignRepairController::class);
|
||||||
// 请假申请
|
// 请假申请
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace App\Providers;
|
||||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
@ -24,6 +25,10 @@ class AppServiceProvider extends ServiceProvider
|
||||||
JsonResource::withoutWrapping();
|
JsonResource::withoutWrapping();
|
||||||
|
|
||||||
$this->definePolymorphicTypes();
|
$this->definePolymorphicTypes();
|
||||||
|
|
||||||
|
Validator::extend('phone', function ($attribute, $value, $parameters, $validator) {
|
||||||
|
return preg_match('/^1[\d]{10}$/', $value);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'js_secret' => env('BAIDU_JS_SECRET', 'xDTLJ15QG6zt3f6VQcaNBfN8q3MsWBsE'),
|
||||||
|
];
|
||||||
|
|
@ -135,7 +135,7 @@ class AdminPermissionSeeder extends Seeder
|
||||||
'name' => '考勤打卡',
|
'name' => '考勤打卡',
|
||||||
'icon' => 'material-symbols:calendar-clock-outline',
|
'icon' => 'material-symbols:calendar-clock-outline',
|
||||||
'uri' => '/hr/signs',
|
'uri' => '/hr/signs',
|
||||||
'resource' => ['list', 'view'],
|
'resource' => ['list', 'view'. 'delete'],
|
||||||
'order' => 4,
|
'order' => 4,
|
||||||
],
|
],
|
||||||
'repairs' => [
|
'repairs' => [
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,15 @@ class AdminSeeder extends Seeder
|
||||||
'password' => bcrypt('admin'),
|
'password' => bcrypt('admin'),
|
||||||
'name' => 'Administrator',
|
'name' => 'Administrator',
|
||||||
]);
|
]);
|
||||||
DB::table('employees')->truncate();
|
// DB::table('employees')->truncate();
|
||||||
DB::table('employees')->insert([
|
// DB::table('employees')->insert([
|
||||||
'name' => 'admin',
|
// 'name' => 'admin',
|
||||||
'phone' => '12345678900',
|
// 'phone' => '12345678900',
|
||||||
'admin_user_id' => 1,
|
// 'admin_user_id' => 1,
|
||||||
'join_at' => $now,
|
// 'join_at' => $now,
|
||||||
'created_at' => $now,
|
// 'created_at' => $now,
|
||||||
'updated_at' => $now,
|
// 'updated_at' => $now,
|
||||||
]);
|
// ]);
|
||||||
|
|
||||||
// 创建初始角色
|
// 创建初始角色
|
||||||
DB::table('admin_roles')->truncate();
|
DB::table('admin_roles')->truncate();
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,10 @@ class WorkflowSeeder extends Seeder
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$now = now();
|
$now = now();
|
||||||
$config = json_encode([
|
// $config = json_encode([
|
||||||
['sort' => 1, 'type' => 'user', 'user' => 1, 'title' => '员工', 'value' => 1, 'subTitle' => 'Admin'],
|
// ['sort' => 1, 'type' => 'user', 'user' => 1, 'title' => '员工', 'value' => 1, 'subTitle' => 'Admin'],
|
||||||
]);
|
// ]);
|
||||||
|
$config = null;
|
||||||
Workflow::truncate();
|
Workflow::truncate();
|
||||||
Workflow::insert([
|
Workflow::insert([
|
||||||
['key' => 'employee_sign_repair', 'name' => '补卡申请', 'config' => $config, 'created_at' => now(), 'updated_at' => now()],
|
['key' => 'employee_sign_repair', 'name' => '补卡申请', 'config' => $config, 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue