如何在弹出框中显示表格?

时间:2018-05-17 10:32:58

标签: laravel laravel-4 laravel-5.2 laravel-5.1

我有下面的表格,有4个组合框和#34; Metier =专业" "环节=任务" " tacrification =定价"和#34; technicien = technician",我选择了一个Metier和一个环节,在此之后我想要一个弹出框出现并向我展示一个包含所有"技术"和他们的" tarification" (当然只有"技术人员和#34;已经选择了" tache"。

请参阅第二张表格。在此之后,我选择一名技术人员"从那张表中,现在表格完全被"技术员"它的定价"。

enter image description here

我想做的事情:

enter image description here

干预

    Schema::create('interventions', function (Blueprint $table) {
        $table->increments('id');
        $table->date('date_intervention')->nullable();
        $table->string('description');
        $table->dateTime('duree_prevu');
        $table->boolean('statut');
        $table->integer('technicien_id')->unsigned();
        $table->foreign('technicien_id')->references('id')- 
        >on('techniciens');
        $table->integer('tarification_id')->unsigned();
        $table->foreign('tarification_id')->references('id')- 
        >on('tarificationtaches');
        $table->integer('client_id')->unsigned();
        $table->foreign('client_id')->references('id')->on('Clients');


        $table->timestamps();
    });

tarificationtache

Schema::create('tarificationtaches', function (Blueprint $table) {
         $table->increments('id');
         $table->float('tarif', 8,2);
         $table->integer('tache_id')->unsigned();
         $table->foreign('tache_id')->references('id')->on('taches');
         $table->datetime('deleted_at')->nullable();
         $table->timestamps();
          });

干预课程

class Intervention extends Model
{
protected $fillable = [ ];
protected $guarded = [];

public function avisintervention()
{
    return $this->hasMany(AvisIntervention::class);
}

public function technicien()
{
    return $this->belongsTo(technicien::class);

}

public function client()
{
    return $this->belongsTo(Client::class);

}
 public function tarificationtache()
{
return $this->belongsTo('App\Tarificationtache','tarification_id');

}

tache class

class tache extends Model
{
use SoftDeletes;
protected $guarded = [];
 protected $dates = ['deleted_at'];

public function metier()
{
    return $this->belongsTo(Metier::class);
}

public function tarificationtache()
{
    return $this->hasMany(Tarificationtache::class);
}

}

metier class

class metier extends Model 
{
use SoftDeletes;
protected $guarded = [];
 protected $dates = ['deleted_at'];
public function taches()
{
    return $this->hasMany(Tache::class);
}
public function techniciens()
{
    return $this- 
    >belongsToMany('App\technicien','technicien_zone','metier_id','technicien_id');

}
}

tarificationtache类

class tarificationtache extends Model
{
use SoftDeletes;
protected $guarded = [];
 protected $dates = ['deleted_at'];
public function tache()
{
    return $this->belongsTo(Tache::class);
}


public function techniciens()
{
    return $this->belongsToMany('App\technicien','technicien_tarificationtache','tarificationtache_id','technicien_id');

}
public function intervention() {
    return $this->hasMany(intervention::class);
}

}

介入控制器

public function create()

{
    $client = client::orderBy('id', 'asc')->get();
    $metiers = metier::orderBy('id', 'asc')->get();
    $technicien = Technicien::orderBy('id', 'desc')->get();
    $tarifications = tarificationtache::orderBy('id', 'desc')->get();

    return view('intervention.create')->with('technicien', 
$technicien)->with('client',$client)->with('metiers',$metiers)- 
>with('tarifications',$tarifications);
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(InterventionRequest $request)
{
    $intervention = new Intervention();

    $intervention ->description =$request->input('description');
    $intervention ->duree_prevu =$request->input('duree_prevu');


    if($request->has('statut')){
    $intervention->statut = $request->input('statut');
    }else{
           $intervention->statut = 0;
    }

    $intervention ->technicien_id = $request->input('technicien_id');
    $intervention ->client_id = $request->input('client_id');
    $intervention ->tarification_id = $request->tarificationtache_id;
    $intervention->save();
    return redirect('intervention');

    }

1 个答案:

答案 0 :(得分:1)

选中此项以了解如何创建模态:Bootstrap Modal W3school

接下来把你的桌子放在这个div里面

<div class="modal-body">
    //put your table in here
</div>

使用此Javacript代码

填充表格后
$.ajax({
  type:'GET',
  url:your_url,
  dataType: 'json',
  success:function(employee_list){
    $table_body = $("#tbl_body_name");
    $table_body.empty();

    if (employee_list.length > 0) {
        div_no_data.style.display = 'none';
        $.each(employee_list, function (index, value) {
            $table_body.append('<tr class="deselected" onclick="rowSelect(this)">' +
                '<td style="text-align: left;">' + value.technician_id  + '</td>' +
                '<td style="text-align: left;">' + value.tache_id + '</td>' +
                '</tr>');
        });
    }
  }
});

接下来,使用此功能获取所选行信息并将其设置为所需的下拉列表

function rowSelect(currentRow){
    //this is the code to set a dropdown menu using jquery
    var technician_id = selectedRow.children[0].innerHTML;
    $("#your_technician_dropdown_menu_id").val(technician_id);
}