|
|
@@ -2,23 +2,25 @@
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
+use App\Authority;
|
|
|
use App\Components\AsyncResponse;
|
|
|
use App\Facilitator;
|
|
|
use App\DischargeTask;
|
|
|
use App\Filters\DischargeTaskFilters;
|
|
|
use App\Http\Requests\DischargeTask\DischargeTaskRequest;
|
|
|
-use App\Imports\CommodityImport;
|
|
|
use App\Imports\DischargeTaskImport;
|
|
|
use App\Owner;
|
|
|
-use App\Services\common\ExportService;
|
|
|
+use App\Role;
|
|
|
use App\Services\OwnerService;
|
|
|
+use App\Services\UserService;
|
|
|
+use App\User;
|
|
|
use App\Warehouse;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\Auth;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
use Oursdreams\Export\Export;
|
|
|
-use function Sodium\compare;
|
|
|
|
|
|
class DischargeTaskController extends Controller
|
|
|
{
|
|
|
@@ -30,18 +32,22 @@ class DischargeTaskController extends Controller
|
|
|
if (!Gate::allows('人事管理-卸货-查询')) {
|
|
|
return redirect(url('/'));
|
|
|
}
|
|
|
- if(Gate::allows('人事管理-卸货-货主可见全部')){
|
|
|
+ if (Gate::allows('人事管理-卸货-货主可见全部')) {
|
|
|
$owners = Owner::query()->get();
|
|
|
$dischargeTasks = DischargeTask::query()->with(['facilitator', 'owner', 'warehouse'])->filter($filters)->orderByDesc('income_at')->paginate($request['paginate'] ?? 50);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$owners = app(OwnerService::class)->getAuthorizedOwners();
|
|
|
- $dischargeTasks = DischargeTask::query()->with(['facilitator', 'owner', 'warehouse'])->filter($filters)->whereIn('owner_id',data_get($owners,'*.id'))->orderByDesc('income_at')->paginate($request['paginate'] ?? 50);
|
|
|
+ $dischargeTasks = DischargeTask::query()->with(['facilitator', 'owner', 'warehouse'])->filter($filters)->whereIn('owner_id', data_get($owners, '*.id'))->orderByDesc('income_at')->paginate($request['paginate'] ?? 50);
|
|
|
+ }
|
|
|
+ $roles = Role::query()->where('name','like','人事%')->get();
|
|
|
+ $personnel = app(UserService::class)->hasRoles(Auth::user(),$roles);
|
|
|
+ if(array_search(Auth::user()["name"],config("users.superAdmin"))!==false){
|
|
|
+ $personnel = true;
|
|
|
}
|
|
|
-
|
|
|
$warehouses = Warehouse::query()->select('id', 'name')->get();
|
|
|
$facilitators = Facilitator::query()->select('name', 'id')->get();
|
|
|
|
|
|
- return view('personnel.discharge.task.index', compact('dischargeTasks', 'owners', 'facilitators', 'warehouses'));
|
|
|
+ return view('personnel.discharge.task.index', compact('dischargeTasks', 'owners', 'facilitators', 'warehouses','personnel'));
|
|
|
}
|
|
|
|
|
|
// 结算报表
|
|
|
@@ -125,11 +131,11 @@ class DischargeTaskController extends Controller
|
|
|
{
|
|
|
$this->gate('人事管理-卸货-查询');
|
|
|
|
|
|
- if(Gate::allows('人事管理-卸货-货主可见全部')){
|
|
|
+ if (Gate::allows('人事管理-卸货-货主可见全部')) {
|
|
|
$dischargeTasks = DischargeTask::query()->with(['Facilitator', 'owner'])->filter($filters)->orderByDesc('id')->get();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$owners = app(OwnerService::class)->getAuthorizedOwners();
|
|
|
- $dischargeTasks = DischargeTask::query()->with(['Facilitator', 'owner'])->filter($filters)->whereIn('owner_id',data_get($owners,'*.id'))->orderByDesc('id')->get();
|
|
|
+ $dischargeTasks = DischargeTask::query()->with(['Facilitator', 'owner'])->filter($filters)->whereIn('owner_id', data_get($owners, '*.id'))->orderByDesc('id')->get();
|
|
|
}
|
|
|
|
|
|
$row = ['日期', '客户名称', '作业名称', '入库单号', '数量', '单位', '单价', '收费', '状态', '备注'];
|
|
|
@@ -165,7 +171,7 @@ class DischargeTaskController extends Controller
|
|
|
|
|
|
$extension = $request->file()['file']->getClientOriginalExtension();
|
|
|
if (in_array($extension, ['xlsx', 'xlsm', 'xltx', 'xltm', 'xls', 'xlt', 'ods', 'ots', 'slk', 'xml', 'gnumeric', 'htm', 'html', 'csv', 'tsv']))
|
|
|
- return ['success' => false,'message'=>'请检查导入文件是否符合要求'];
|
|
|
+ return ['success' => false, 'message' => '请检查导入文件是否符合要求'];
|
|
|
$extension[0] = strtoupper($extension[0]);
|
|
|
try {
|
|
|
Excel::import(new DischargeTaskImport(), $request->file()['file']->path(), null, $extension);
|