上传文件、视频、图片、全选、全不选、截屏直接粘贴图片

这篇博客介绍了如何实现文件、视频、图片的上传功能,包括全选、全不选操作,并且提到了截屏后直接粘贴图片的实现,详细讲解了控制器如ObUnitsController.php和UploadController.php,以及视图units_create.blade.php中的代码实现,还包含了上传文件的JavaScript部分。
摘要由CSDN通过智能技术生成

上传文件、视频、图片、全选、全不选、截屏直接粘贴图片

在这里插入图片描述

控制器代码: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
{
   
    /**
     * Title for current resource.
     * @var string
     */
    protected $title = 'OB工序分科表';
    protected $unit_title = '部件列表';
    protected $description = [
        'index'     => '列表',
        'create'    => '新增',
        'exit'      => '修改',
        'detail'    => '详情'
    ];
    /*
    |--------------------------------------------------------------------------
    | OB工序分科
    |--------------------------------------------------------------------------
    */
    public function index(Content $content)
    {
   
        return parent::index($content);
    }

    /**
     * Make a grid builder.
     *
     * @return Grid 
     */
    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">&nbsp;&nbsp;新增OB分科表</span>
                </a>');
        });
        return $grid;
    }

    /**
     * TODO OB工序分科表 新增
     * @param Content $content
     * @return Content 
     */
    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;
    }

    /**
     * TODO 获取部件明细列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    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 = [];
        // 台产 PCS/SEWER (班组日产量/班组车工人数)
        $data['psc_sewer'] = $line_output == 0 || ($sewers ==0)?0:round($line_output/$sewers,2);
        // 工作小时
        $data['workn_hr'] = $workn_hr;
        //  班组总人数
        $data['total_people'] = $total_people;
        // 目标产量 (班组总人数*工作小时*60)/工序标准工时
        $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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值