[英]vuetify data-table computed property into sql
I have a simple attendance app which stores data in sql.我有一个简单的考勤应用程序,它将数据存储在 sql 中。 This is working fine but I need to store one computed property in sql too.
这工作正常,但我也需要在 sql 中存储一个计算属性。 Here is a part of config:
这是配置的一部分:
<v-menu
v-model="start1"
:close-on-content-click="false"
:nudge-right="40"
transition="scale-transition"
offset-y
min-width="290px"
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="editedItem.start1"
prepend-icon="event"
readonly
label="Čas od *"
:rules="timeRules"
required
v-on="on"
></v-text-field>
</template>
<v-time-picker
format="24hr"
:max="editedItem.end1"
:allowed-minutes="allowedStep"
v-model="editedItem.start1"
@input="start1 = false"
></v-time-picker>
</v-menu>
</v-col>
editedItem: {
date: "",
start1: "",
end1: "",
start2: "00:00:00",
end2: "00:00:00",
start3: "00:00:00",
end3: "00:00:00",
totaltime: "",
km: "",
place: "",
note: ""
},
computed:
totaltime() {
return this.moment
.utc()
.startOf("day")
.add(this.computedTime66, "minutes")
.format("HH:mm");
},
If I use {{ totaltime }} this is working correctly on site but I need it to be stored in sql table totaltime like other fields.如果我使用 {{ totaltime }} 这在现场可以正常工作,但我需要像其他字段一样将它存储在 sql 表 totaltime 中。
Keep totalTime
as field of the editedItem
property and update it using watcher property instead of computed one:将
totalTime
保留为editedItem
属性的字段,并使用 watcher 属性而不是计算属性对其进行更新:
watch:{
editedItem:{
handler(val){
this.editedItem.totaltime =this.moment
.utc()
.startOf("day")
.add(this.computedTime66, "minutes")
.format("HH:mm");
},
deep:true
}
}
This makes that property available in the model when you want to submit it to the backend当您要将其提交到后端时,这使得该属性在 model 中可用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.