crud update
parent
58ce2c01ac
commit
478ef5b991
|
@ -56,7 +56,7 @@
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="inventoryStatus" header="Status" :sortable="true">
|
<Column field="inventoryStatus" header="Status" :sortable="true">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<span :class="'product-badge status-' + slotProps.data.inventoryStatus.toLowerCase()">{{slotProps.data.inventoryStatus}}</span>
|
<span :class="'product-badge status-' + (slotProps.data.inventoryStatus ? slotProps.data.inventoryStatus.toLowerCase() : '')">{{slotProps.data.inventoryStatus}}</span>
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column :exportable="false">
|
<Column :exportable="false">
|
||||||
|
@ -80,6 +80,23 @@
|
||||||
<Textarea id="description" v-model="product.description" required="true" rows="3" cols="20" />
|
<Textarea id="description" v-model="product.description" required="true" rows="3" cols="20" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="p-field">
|
||||||
|
<label for="inventoryStatus" class="p-mb-3">Inventory Status</label>
|
||||||
|
<Dropdown id="inventoryStatus" v-model="product.inventoryStatus" :options="statuses" optionLabel="label" placeholder="Select a Status">
|
||||||
|
<template #value="slotProps">
|
||||||
|
<div v-if="slotProps.value && slotProps.value.value">
|
||||||
|
<span :class="'product-badge status-' +slotProps.value.value">{{slotProps.value.label}}</span>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="slotProps.value && !slotProps.value.value">
|
||||||
|
<span :class="'product-badge status-' +slotProps.value.toLowerCase()">{{slotProps.value}}</span>
|
||||||
|
</div>
|
||||||
|
<span v-else>
|
||||||
|
{{slotProps.placeholder}}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="p-field">
|
<div class="p-field">
|
||||||
<label class="p-mb-3">Category</label>
|
<label class="p-mb-3">Category</label>
|
||||||
<div class="p-formgrid p-grid">
|
<div class="p-formgrid p-grid">
|
||||||
|
@ -194,7 +211,7 @@
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="inventoryStatus" header="Status" :sortable="true">
|
<Column field="inventoryStatus" header="Status" :sortable="true">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<span :class="'product-badge status-' + slotProps.data.inventoryStatus.toLowerCase()">{{slotProps.data.inventoryStatus}}</span>
|
<span :class="'product-badge status-' + (slotProps.data.inventoryStatus ? slotProps.data.inventoryStatus.toLowerCase() : '')">{{slotProps.data.inventoryStatus}}</span>
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column :exportable="false">
|
<Column :exportable="false">
|
||||||
|
@ -218,6 +235,20 @@
|
||||||
<Textarea id="description" v-model="product.description" required="true" rows="3" cols="20" />
|
<Textarea id="description" v-model="product.description" required="true" rows="3" cols="20" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Dropdown id="inventoryStatus" v-model="product.inventoryStatus" :options="statuses" optionLabel="label" placeholder="Select a Status">
|
||||||
|
<template #value="slotProps">
|
||||||
|
<div v-if="slotProps.value && slotProps.value.value">
|
||||||
|
<span :class="'product-badge status-' +slotProps.value.value">{{slotProps.value.label}}</span>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="slotProps.value && !slotProps.value.value">
|
||||||
|
<span :class="'product-badge status-' +slotProps.value.toLowerCase()">{{slotProps.value}}</span>
|
||||||
|
</div>
|
||||||
|
<span v-else>
|
||||||
|
{{slotProps.placeholder}}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</Dropdown>
|
||||||
|
|
||||||
<div class="p-field">
|
<div class="p-field">
|
||||||
<label class="p-mb-3">Category</label>
|
<label class="p-mb-3">Category</label>
|
||||||
<div class="p-formgrid p-grid">
|
<div class="p-formgrid p-grid">
|
||||||
|
@ -306,7 +337,9 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatCurrency(value) {
|
formatCurrency(value) {
|
||||||
return value.toLocaleString('en-US', {style: 'currency', currency: 'USD'});
|
if(value)
|
||||||
|
return value.toLocaleString('en-US', {style: 'currency', currency: 'USD'});
|
||||||
|
return;
|
||||||
},
|
},
|
||||||
openNew() {
|
openNew() {
|
||||||
this.product = {};
|
this.product = {};
|
||||||
|
@ -320,21 +353,24 @@ export default {
|
||||||
saveProduct() {
|
saveProduct() {
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
|
|
||||||
if (this.product.name.trim()) {
|
if (this.product.name.trim()) {
|
||||||
if (this.product.id) {
|
if (this.product.id) {
|
||||||
|
this.product.inventoryStatus = this.product.inventoryStatus.value ? this.product.inventoryStatus.value: this.product.inventoryStatus;
|
||||||
this.products[this.findIndexById(this.product.id)] = this.product;
|
this.products[this.findIndexById(this.product.id)] = this.product;
|
||||||
this.$toast.add({severity:'success', summary: 'Successful', detail: 'Product Updated', life: 3000});
|
this.$toast.add({severity:'success', summary: 'Successful', detail: 'Product Updated', life: 3000});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.product.id = this.createId();
|
this.product.id = this.createId();
|
||||||
|
this.product.code = this.createId();
|
||||||
this.product.image = 'product-placeholder.svg';
|
this.product.image = 'product-placeholder.svg';
|
||||||
|
this.product.inventoryStatus = this.product.inventoryStatus ? this.product.inventoryStatus.value : 'INSTOCK';
|
||||||
this.products.push(this.product);
|
this.products.push(this.product);
|
||||||
this.$toast.add({severity:'success', summary: 'Successful', detail: 'Product Created', life: 3000});
|
this.$toast.add({severity:'success', summary: 'Successful', detail: 'Product Created', life: 3000});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.productDialog = false;
|
this.productDialog = false;
|
||||||
this.product = {};
|
this.product = {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editProduct(product) {
|
editProduct(product) {
|
||||||
this.product = {...product};
|
this.product = {...product};
|
||||||
|
@ -404,7 +440,12 @@ export default {
|
||||||
product: {},
|
product: {},
|
||||||
selectedProducts: null,
|
selectedProducts: null,
|
||||||
filters: {},
|
filters: {},
|
||||||
submitted: false
|
submitted: false,
|
||||||
|
statuses: [
|
||||||
|
{label: 'INSTOCK', value: 'instock'},
|
||||||
|
{label: 'LOWSTOCK', value: 'lowstock'},
|
||||||
|
{label: 'OUTOFSTOCK', value: 'outofstock'}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
productService: null,
|
productService: null,
|
||||||
|
@ -416,7 +457,9 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatCurrency(value) {
|
formatCurrency(value) {
|
||||||
return value.toLocaleString('en-US', {style: 'currency', currency: 'USD'});
|
if(value)
|
||||||
|
return value.toLocaleString('en-US', {style: 'currency', currency: 'USD'});
|
||||||
|
return;
|
||||||
},
|
},
|
||||||
openNew() {
|
openNew() {
|
||||||
this.product = {};
|
this.product = {};
|
||||||
|
@ -430,14 +473,17 @@ export default {
|
||||||
saveProduct() {
|
saveProduct() {
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
|
|
||||||
if (this.product.name.trim()) {
|
if (this.product.name.trim()) {
|
||||||
if (this.product.id) {
|
if (this.product.id) {
|
||||||
|
this.product.inventoryStatus = this.product.inventoryStatus.value ? this.product.inventoryStatus.value: this.product.inventoryStatus;
|
||||||
this.products[this.findIndexById(this.product.id)] = this.product;
|
this.products[this.findIndexById(this.product.id)] = this.product;
|
||||||
this.$toast.add({severity:'success', summary: 'Successful', detail: 'Product Updated', life: 3000});
|
this.$toast.add({severity:'success', summary: 'Successful', detail: 'Product Updated', life: 3000});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.product.id = this.createId();
|
this.product.id = this.createId();
|
||||||
|
this.product.code = this.createId();
|
||||||
this.product.image = 'product-placeholder.svg';
|
this.product.image = 'product-placeholder.svg';
|
||||||
|
this.product.inventoryStatus = this.product.inventoryStatus ? this.product.inventoryStatus.value : 'INSTOCK';
|
||||||
this.products.push(this.product);
|
this.products.push(this.product);
|
||||||
this.$toast.add({severity:'success', summary: 'Successful', detail: 'Product Created', life: 3000});
|
this.$toast.add({severity:'success', summary: 'Successful', detail: 'Product Created', life: 3000});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue