InvoiceProductEdit.vue
4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!-- eslint-disable vue/no-mutating-props -->
<script setup>
const props = defineProps({
id: {
type: Number,
required: true,
},
data: {
type: Object,
required: true,
default: () => ({
title: 'App Design',
cost: 24,
hours: 1,
description: 'Designed UI kit & app pages.',
}),
},
})
const emit = defineEmits([
'removeProduct',
'totalAmount',
])
const itemsOptions = [
{
title: 'App Design',
cost: 24,
hours: 1,
description: 'Designed UI kit & app pages.',
},
{
title: 'App Customization',
cost: 26,
hours: 1,
description: 'Customization & Bug Fixes.',
},
{
title: 'ABC Template',
cost: 28,
hours: 1,
description: 'Vuetify admin template.',
},
{
title: 'App Development',
cost: 32,
hours: 1,
description: 'Native App Development.',
},
]
const selectedItem = ref('App Customization')
const localProductData = ref(structuredClone(toRaw(props.data)))
watch(selectedItem, () => {
const item = itemsOptions.filter(obj => {
return obj.title === selectedItem.value
})
localProductData.value = item[0]
})
const removeProduct = () => {
emit('removeProduct', props.id)
}
const totalPrice = computed(() => Number(localProductData.value.cost) * Number(localProductData.value.hours))
watch(totalPrice, () => {
emit('totalAmount', totalPrice.value)
}, { immediate: true })
</script>
<template>
<!-- eslint-disable vue/no-mutating-props -->
<div class="add-products-header mb-2 d-none d-md-flex mb-4">
<VRow class="me-10">
<VCol
cols="12"
md="6"
>
<h6 class="text-h6">
Item
</h6>
</VCol>
<VCol
cols="12"
md="2"
>
<h6 class="text-h6 ps-2">
Cost
</h6>
</VCol>
<VCol
cols="12"
md="2"
>
<h6 class="text-h6 ps-2">
Hours
</h6>
</VCol>
<VCol
cols="12"
md="2"
>
<h6 class="text-h6">
Price
</h6>
</VCol>
</VRow>
</div>
<VCard
flat
border
class="d-flex flex-sm-row flex-column-reverse"
>
<!-- 👉 Left Form -->
<div class="pa-5 flex-grow-1">
<VRow>
<VCol
cols="12"
md="6"
>
<VSelect
v-model="selectedItem"
:items="itemsOptions"
item-title="title"
item-value="title"
label="Select Item"
placeholder="Select Item"
class="mb-5"
/>
<VTextarea
v-model="localProductData.description"
rows="2"
label="Description"
placeholder="Item description"
/>
</VCol>
<VCol
cols="12"
md="2"
sm="4"
>
<VTextField
v-model="localProductData.cost"
type="number"
label="Cost"
placeholder="100"
/>
<div class="text-high-emphasis mt-4">
<p class="mb-1">
Discount
</p>
<span>0%</span>
<span class="mx-2">
0%
<VTooltip activator="parent">Tax 1</VTooltip>
</span>
<span>
0%
<VTooltip activator="parent">Tax 2</VTooltip>
</span>
</div>
</VCol>
<VCol
cols="12"
md="2"
sm="4"
>
<VTextField
v-model="localProductData.hours"
type="number"
label="Hours"
placeholder="5"
/>
</VCol>
<VCol
cols="12"
md="2"
sm="4"
>
<p class="my-2">
<span class="d-inline d-md-none">Price: </span>
<span class="text-high-emphasis">${{ totalPrice }}</span>
</p>
</VCol>
</VRow>
</div>
<!-- 👉 Item Actions -->
<div
class="d-flex flex-column align-end item-actions"
:class="$vuetify.display.smAndUp ? 'border-s' : 'border-b' "
>
<IconBtn
class="align-self-end"
@click="removeProduct"
>
<VIcon
:size="20"
icon="ri-close-line"
/>
</IconBtn>
</div>
</VCard>
</template>