如何在弹出框中显示table?
How to display a table in a popup box?
我有下面的表格,有 4 个组合框 "Metier=profession" "tache=task" "tacrification=pricing" 和 "technicien=technician",我 select 一个 Metier 和一个 tache,在此之后我希望出现一个弹出框并向我显示一个 table,其中包含所有 "techniciens" 及其 "tarification"(当然只有与 [=67 相关的 "techniciens" =] 已经 selected).
请看第二张表格。在此之后我 select 一个 "technician" 从那个 table 一个现在表格完全填满了 "technician" 并且它是 "pricing"。
我想做什么:
干预
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();
});
分类表
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
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');
}
计画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);
}
}
行业 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');
}
}
分类表 class
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');
}
检查此以了解如何创建模态框:Bootstrap Modal W3school
接下来将你的 table 放入这个 div
<div class="modal-body">
//put your table in here
</div>
使用此 Javacript 代码填充 table 之后
$.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);
}
我有下面的表格,有 4 个组合框 "Metier=profession" "tache=task" "tacrification=pricing" 和 "technicien=technician",我 select 一个 Metier 和一个 tache,在此之后我希望出现一个弹出框并向我显示一个 table,其中包含所有 "techniciens" 及其 "tarification"(当然只有与 [=67 相关的 "techniciens" =] 已经 selected).
请看第二张表格。在此之后我 select 一个 "technician" 从那个 table 一个现在表格完全填满了 "technician" 并且它是 "pricing"。
我想做什么:
干预
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();
});
分类表
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
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');
}
计画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);
}
}
行业 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');
}
}
分类表 class
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');
}
检查此以了解如何创建模态框:Bootstrap Modal W3school
接下来将你的 table 放入这个 div
<div class="modal-body">
//put your table in here
</div>
使用此 Javacript 代码填充 table 之后
$.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);
}