I have been looking for a way to drag and drop rows on a Bootstrap Vue table. I was able to find a working version here: Codepen
I have tried to implement this code to my own table:
Template:
<b-table v-sortable="sortableOptions" @click="(row) => $toast.open(`Clicked ${row.item.name}`)" :per-page="perPage" :current-page="currentPage" striped hover :items="blis" :fields="fields" :filter="filter" :sort-by.sync="sortBy" :sort-desc.sync="sortDesc" :sort-direction="sortDirection" @filtered="onFiltered">
<template slot="move" slot-scope="row">
<i class="fa fa-arrows-alt"></i>
</template>
<template slot="actions" slot-scope="row">
<b-btn :href="'/bli/'+row.item.id" variant="light" size="sm" @click.stop="details(cell.item,cell.index,$event.target)"><i class="fa fa-pencil"></i></b-btn>
<b-btn variant="light" size="sm" @click.stop="details(cell.item,cell.index,$event.target)"><i class="fa fa-trash"></i></b-btn>
</template> …Run Code Online (Sandbox Code Playgroud) 我的表Blis中有一栏称为"截止日期".类型是时间戳.我正在使用MySQL db.
当我以"yy-mm-dd h:i:s"格式保存日期时,它保存得很好,但每当我尝试将其更新到其他日期时,它就不会保存.
假设我有2019-02-17 00:00:00在一行,并希望更新到2019-05-05 09:30:00,即使行的其余部分确实更新,也不会进行更改.
移民:
public function up()
{
Schema::table('blis', function (Blueprint $table) {
$table->timestamp('deadline')->default(null)->nullable();
});
}
Run Code Online (Sandbox Code Playgroud)
控制器:
public function update(Bli $bli)
{
$attributes = request()->validate(
[
'title' => ['required', 'min:3'],
'description' => ['nullable'],
'status_id' => ['required'],
'deadline' => ['date_format:Y-m-d H:i:s']
]
);
$bli->update(request(['title', 'description', 'status_id', 'deadline']));
return redirect("/bli/$bli->id");
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="form-group ">
<label for="deadline">Deadline:</label>
<input class="form-control" type="text" id="datepicker" name="deadline" placeholder="Date" value="{{$bli->deadline}}">
</div>
Run Code Online (Sandbox Code Playgroud)
我正在使用jquery UI的datepicker作为输入字段:
$( "#datepicker" ).datepicker({
dateFormat: "yy-mm-dd 00:00:00"
});
Run Code Online (Sandbox Code Playgroud)
即使我删除验证,"截止日期"的值仍然不会更新.
时间戳是否是在这种情况下使用的正确类型?如果是这样,为什么在行的其余部分不会更新?如果没有,在这种情况下使用哪个正确的日期类型?