上传文件、视频、图片、全选、全不选、截屏直接粘贴图片
控制器代码:ObUnitsController.php
<?php
namespace App\Admin\Controllers;
use App\Admin\Actions\Units\UnitsImportAction;
use App\Models\AdminUsers;
use App\Models\PubCountry;
use App\Models\ObUnits;
use App\Models\PubUnitsList;
use App\Models\PubProcess;
use App\Models\PubUnits;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\UploadsController;
use Encore\Admin\Widgets\Table;
use Encore\Admin\Facades\Admin;
class ObUnitsController extends AdminController
{
protected $title = 'OB工序分科表';
protected $unit_title = '部件列表';
protected $description = [
'index' => '列表',
'create' => '新增',
'exit' => '修改',
'detail' => '详情'
];
public function index(Content $content)
{
return parent::index($content);
}
protected function grid()
{
$grid = new Grid(new ObUnits());
$grid->model()->with(['prepared_name']);
$grid->disableCreateButton();
$grid->column('id', __('Id'));
$grid->column('exploit_id', __('exploit_no'));
$grid->column('order_no', __('order_no'));
$grid->column('branch_no', __('client_branch'));
$grid->column('country_id', __('country_name'))->using(ob_country());
$grid->column('supplier', __('supplier'));
$grid->column('unit_factory', __('unit_factory'));
$grid->column('prepared_name.username', __('prepared_name'));
$grid->column('revised_name.username', __('revised_name'));
$grid->column('line_output', __('line_output'));
$grid->column('planed_tgt', __('planed_tgt'));
$grid->column('planed_eff', __('planed_eff'));
$grid->column('psc_sewer', __('psc_sewer'));
$grid->column('workn_hr', __('workn_hr'));
$grid->column('sewers', __('sewers'));
$grid->column('helpers', __('helpers'));
$grid->column('lroners', __('lroners'));
$grid->column('sewing_sam', __('sewing_sam'));
$grid->column('cutting_remark', __('cutting_remark'));
$grid->column('sewing_remark', __('sewing_remark'));
$grid->column('finish_remark', __('finish_remark'));
$grid->tools(function (Grid\Tools $tools) {
$tools->append(new UnitsImportAction());
$tools->append('<a href="/admin/units/ob_create" class="btn btn-sm btn-success" title="新增OB分科表">
<i class="fa fa-plus"></i><span class="hidden-xs"> 新增OB分科表</span>
</a>');
});
return $grid;
}
public function ob_create(Content $content)
{
$admin_users = AdminUsers::select('id','username')->where('depart_id',68)->get()->toArray();
$units = PubUnits::select('id','name','classify')->get();
$array = [];
foreach ($units as $k => $v) {
$array[] = [
'id' => $v->id,
'name' => $v->name,
'classify' => $v->classify==0?'':units_classify()[$v->classify]
];
}
$units_list = json_encode($array);
$return = [
'admin_users' => $admin_users,
'units_list' => $units_list
];
$content->header($this->title)
->description($this->description['create'])
->breadcrumb(
['text' => $this->title, 'url' => '/units'],
['text' => $this->description['create']]
)
->row(view('tpl.units.ob_create',$return));
return $content;
}
public function data_ajax_process(Request $request)
{
$id = $request->id;
$units_list = PubUnitsList::where('units_id',$id)->with(['process.processtype'])->get()->toArray();
$units = PubUnits::select('name','id')->where('id',$id)->first();
$data = [];
foreach ($units_list as $k => $v) {
$data[] = $v['process'];
}
$return = [
'status' => 100,
'data' => $data,
'count' => count($data),
'units' => $units
];
return response()->json($return);
}
public function units_compute(Request $request)
{
$sam_count = [];
if ($request->sam_count != null) {
$sam_count = $request->sam_count;
}
$sam_count = array_sum($sam_count);
$line_output = $request->line_output;
$sewers = $request->sewers?$request->sewers:0;
$lroners = $request->lroners?$request->lroners:0;
$helpers = $request->helpers?$request->helpers:0;
$workn_hr = isset($request->country)?ob_country_hour()[$request->country]:0;
$total_people = ($sewers+$lroners+$helpers);
$data = [];
$data['psc_sewer'] = $line_output == 0 || ($sewers ==0)?0:round($line_output/$sewers,2);
$data['workn_hr'] = $workn_hr;
$data['total_people'] = $total_people;
$data['planed_tgt'] = $total_people == 0 || $workn_hr ==0?0:round(($total_people*$workn_hr*60)/$sam_count,2);
$data['planed_eff'] = $data['planed_tgt']==0?0:round($total_people/$data['planed_tgt'],2);
$data['sewing_sam'] = $sam_count;
return response()->json(['status'=>100,'data'=>$data]);
}
public function units_compute_operate(Request $request)
{
$uploads = new UploadsController();
DB::beginTransaction();
try {
$pictures = isset($request->pictures)?$uploads->uploadsiImgMobile($request->pictures):'';
$data = [
'prepared_id' => $request->prepared_id,
'revised_id' => $request->revised_id,
'supplier' => $request->supplier,
'unit_factory' => $request->unit_factory,
'pictures' => $request->pictures,
'exploit_no' => $request->exploit_no,
'order_no' => $request->order_no,
'country_id' => $request->country_id,
'line_output' => $request->line_output,
'planed_tgt' =>$request->planed_tgt,
'planed_eff' =>$request->planed_eff,
'psc_sewer' => $request->psc_sewer,
'workn_hr' => $request->workn_hr,
'sewers' => $request->sewers,
'helpers' => $request->helpers,
'lroners' => $request->lroners,
'sewing_sam' => $request->sewing_sam,
'cutting_remark' => $request->cutting_remark,
'sewing_remark' => $request->sewing_remark,
'finish_remark' => $request->finish_remark,
'user_id' => getAdminID(),
'created_at' => getDateH(0),
'flag' => 0
];
$units = DB::table('ob_units')->insertGetId($data);
DB::commit();
admin_toastr(trans('admin.save_succeeded