gpt4 book ai didi

javascript - 为什么我编辑发票时看不到我的发票项目?

转载 作者:行者123 更新时间:2023-11-30 20:05:19 26 4
gpt4 key购买 nike

我正在使用 Laravel 5.7 & VueJs 2.5.* ...

我正在使用单个 Bootstrap 模型来创建和编辑我的 TicketInvoice & 它是 TicketInvocieItems,但是当我点击编辑时,Bootstrap 模型打开并且我看到数据填写TicketInvoice但看不到TicketInvoiceItems的数据。我也不知道如何填充 TicketInvoiceItems 的数据。

我的 ticketInvoiceItems 输入字段:

<tbody>
<tr v-for="(ticketInvoiceItem, key) in form.ticketInvoiceItems" :key="key">
<!--Passenger Name-->
<td>
<input v-model="ticketInvoiceItem.passenger_name" size="40" type="text" name="passenger_name" class="table-control form-control" :class="{ 'is-invalid': form.errors.has('passenger_name') }">
<has-error :form="form" field="passenger_name"></has-error>
</td>
<!--Ticket No.-->
<td>
<input v-model="ticketInvoiceItem.ticket_no" size="24" type="text" name="ticket_no" class="table-control form-control" :class="{ 'is-invalid': form.errors.has('ticket_no') }">
<has-error :form="form" field="ticket_no"></has-error>
</td>
</tr>
<!----------- ANY MANY OTHER FIELDS DOWN BELOW ----------->

我的 HTML 编辑按钮:

<a href="#" @click="editModel(ticketInvoice)">
<i class="fas fa-user-edit fa-lg text-orange"></i>
</a>

我的 VueJs editModel() 代码:

<script>
/*==============EDIT INVOICE CODE==============*/
editModel(ticketInvoice) {
this.editmode = true;
this.form.reset();
this.form.clear();
$("#addNewTicketInvoice").modal("show");
this.form.fill(ticketInvoice);
},
/*==============END EDIT INVOICE CODE==============*/
</script>

我在 VueJs

中的 data()
<script>
export default {
data() {
return {
editmode: true,
ticketInvoices: {},
vendors: null,
form: new Form({
id: "",
vendor_id: "",
ticket_invoice_no: "",
ticket_invoice_date: "",
ticket_invoice_fares_total: "",
ticket_invoice_grand_total: "",

ticketInvoiceItems: [{
id: "",
ticket_invoice_id: "",
passenger_name: "",
ticket_no: "",
departure_date: "",
fares: "",
sub_total: 0
}]
})
};
},
</script>

更好理解的图像 enter image description here

最佳答案

在您的 editModel 方法中添加这些行:

   $("#addNewTicketInvoice").modal("show");
this.form.fill(ticketInvoice);
this.form.ticketInvoiceItems=ticketInvoice.ticket_invoice_items;

this.form.ticketInvoiceItems 将是一个循环遍历您应该使用的值的对象

   Object.values(this.form.ticketInvoiceItems).forEach(....

关于javascript - 为什么我编辑发票时看不到我的发票项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52998040/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com