add modifing image change style
This commit is contained in:
parent
9aea7f3bc5
commit
8cc15870d8
@ -29,7 +29,7 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
max-width: 1280px;
|
max-width: 1600px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -22,7 +22,9 @@ const toast = useToast();
|
|||||||
const formatDate = (date) => DateTime.fromISO(date).toLocaleString(DateTime.DATETIME_MED);
|
const formatDate = (date) => DateTime.fromISO(date).toLocaleString(DateTime.DATETIME_MED);
|
||||||
|
|
||||||
const products = ref([]);
|
const products = ref([]);
|
||||||
|
|
||||||
const productName = ref('');
|
const productName = ref('');
|
||||||
|
const productReference = ref('');
|
||||||
const productDescription = ref('');
|
const productDescription = ref('');
|
||||||
const productQuantity = ref(0);
|
const productQuantity = ref(0);
|
||||||
const productAlert = ref(false);
|
const productAlert = ref(false);
|
||||||
@ -44,6 +46,7 @@ async function create_product() {
|
|||||||
try {
|
try {
|
||||||
await createProduct({
|
await createProduct({
|
||||||
name: productName.value,
|
name: productName.value,
|
||||||
|
reference: productReference.value,
|
||||||
description: productDescription.value,
|
description: productDescription.value,
|
||||||
quantity: productQuantity.value,
|
quantity: productQuantity.value,
|
||||||
alert_enabled: productAlert.value,
|
alert_enabled: productAlert.value,
|
||||||
@ -65,6 +68,7 @@ async function create_product() {
|
|||||||
registerErrors.value = {
|
registerErrors.value = {
|
||||||
name: data.name ? data.name[0] : "",
|
name: data.name ? data.name[0] : "",
|
||||||
description: data.description ? data.description[0]: "",
|
description: data.description ? data.description[0]: "",
|
||||||
|
reference: data.reference ? data.reference[0]: "",
|
||||||
quantity: data.quantity ? data.quantity[0] : "",
|
quantity: data.quantity ? data.quantity[0] : "",
|
||||||
alert_enabled: data.alert_enabled ? data.alert_enabled[0] : "",
|
alert_enabled: data.alert_enabled ? data.alert_enabled[0] : "",
|
||||||
stock_limit: data.stock_limit ? data.stock_limit[0] : "",
|
stock_limit: data.stock_limit ? data.stock_limit[0] : "",
|
||||||
@ -80,6 +84,7 @@ async function create_product() {
|
|||||||
function resetForms() {
|
function resetForms() {
|
||||||
productName.value = '';
|
productName.value = '';
|
||||||
productDescription.value = '';
|
productDescription.value = '';
|
||||||
|
productReference.value = '';
|
||||||
productQuantity.value = 0;
|
productQuantity.value = 0;
|
||||||
productAlert.value = false;
|
productAlert.value = false;
|
||||||
productStockLimit.value = null;
|
productStockLimit.value = null;
|
||||||
@ -102,14 +107,17 @@ async function onRowEditSave(event) {
|
|||||||
await modifyProduct({
|
await modifyProduct({
|
||||||
id: newData.id,
|
id: newData.id,
|
||||||
name: newData.name,
|
name: newData.name,
|
||||||
|
reference: newData.reference,
|
||||||
description: newData.description,
|
description: newData.description,
|
||||||
quantity: newData.quantity,
|
quantity: newData.quantity,
|
||||||
|
image: base64Image.value,
|
||||||
warehouses: newData.warehouse.map((warehouse) => warehouse.id),
|
warehouses: newData.warehouse.map((warehouse) => warehouse.id),
|
||||||
},
|
},
|
||||||
newData.id);
|
newData.id);
|
||||||
warehouses.value = await getWarehouses();
|
warehouses.value = await getWarehouses();
|
||||||
products.value = await getProducts();
|
products.value = await getProducts();
|
||||||
products.value = enrichProducts();
|
products.value = enrichProducts();
|
||||||
|
resetForms();
|
||||||
toast.add({ severity: 'success', life: 2500, summary: 'Succès', detail: 'Produit modifié.' });
|
toast.add({ severity: 'success', life: 2500, summary: 'Succès', detail: 'Produit modifié.' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) {
|
if (error.response && error.response.data) {
|
||||||
@ -120,6 +128,7 @@ async function onRowEditSave(event) {
|
|||||||
modifyErrors.value[newData.id] = {
|
modifyErrors.value[newData.id] = {
|
||||||
name: data.name ? data.name[0] : "",
|
name: data.name ? data.name[0] : "",
|
||||||
description: data.description ? data.description[0]: "",
|
description: data.description ? data.description[0]: "",
|
||||||
|
reference: data.reference ? data.reference[0]: "",
|
||||||
quantity: data.quantity ? data.quantity[0] : "",
|
quantity: data.quantity ? data.quantity[0] : "",
|
||||||
alert_enabled: data.alert_enabled ? data.alert_enabled[0] : "",
|
alert_enabled: data.alert_enabled ? data.alert_enabled[0] : "",
|
||||||
stock_limit: data.stock_limit ? data.stock_limit[0] : "",
|
stock_limit: data.stock_limit ? data.stock_limit[0] : "",
|
||||||
@ -249,6 +258,23 @@ try {
|
|||||||
{{ registerErrors.name }}
|
{{ registerErrors.name }}
|
||||||
</p-message>
|
</p-message>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form">
|
||||||
|
<InputGroup>
|
||||||
|
<InputGroupAddon>Reference :</InputGroupAddon>
|
||||||
|
<InputText
|
||||||
|
type="text"
|
||||||
|
id="register-reference"
|
||||||
|
v-model="productReference"
|
||||||
|
/>
|
||||||
|
</InputGroup>
|
||||||
|
<p-message
|
||||||
|
v-if="registerErrors.description"
|
||||||
|
severity="error"
|
||||||
|
>
|
||||||
|
{{ registerErrors.description }}
|
||||||
|
</p-message>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
@ -278,12 +304,6 @@ try {
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
<p-message
|
|
||||||
v-if="registerErrors.quantity"
|
|
||||||
severity="error"
|
|
||||||
>
|
|
||||||
{{ registerErrors.quantity }}
|
|
||||||
</p-message>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form">
|
<div class="form">
|
||||||
@ -355,8 +375,20 @@ try {
|
|||||||
severity="error">
|
severity="error">
|
||||||
{{ registerErrors.warehouses }}
|
{{ registerErrors.warehouses }}
|
||||||
</p-message>
|
</p-message>
|
||||||
|
<p-message
|
||||||
|
v-if="registerErrors.quantity"
|
||||||
|
severity="error"
|
||||||
|
>
|
||||||
|
{{ registerErrors.quantity }}
|
||||||
|
</p-message>
|
||||||
|
<p-message
|
||||||
|
v-if="registerErrors.reference"
|
||||||
|
severity="error"
|
||||||
|
>
|
||||||
|
{{ registerErrors.reference }}
|
||||||
|
</p-message>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
label="Créer"
|
label="Créer"
|
||||||
type="submit"
|
type="submit"
|
||||||
class="p-button-primary"
|
class="p-button-primary"
|
||||||
@ -384,13 +416,27 @@ try {
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<Column field="image">
|
<Column field="image"editor="true">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<img
|
<img
|
||||||
:src="slotProps.data.image"
|
:src="slotProps.data.image"
|
||||||
style="width: 6rem"
|
style="width: 6rem"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
<template #editor>
|
||||||
|
<FileUpload
|
||||||
|
name="editProductImage"
|
||||||
|
accept="image/*"
|
||||||
|
mode="basic"
|
||||||
|
customUpload
|
||||||
|
:auto="true"
|
||||||
|
:multiple="false"
|
||||||
|
:maxFileSize="1000000"
|
||||||
|
:chooseLabel='"modifier image"'
|
||||||
|
@uploader="handleFileUpload"
|
||||||
|
>
|
||||||
|
</FileUpload>
|
||||||
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
||||||
<Column field="is_stock_low" header="Stock" sortable>
|
<Column field="is_stock_low" header="Stock" sortable>
|
||||||
@ -416,6 +462,17 @@ try {
|
|||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
||||||
|
<Column field="reference" header="reference" editor="true" sortable>
|
||||||
|
<template #body="slotProps">
|
||||||
|
<span v-if="!modifyErrors[slotProps.data.id]?.reference">{{ slotProps.data.reference }}</span>
|
||||||
|
<p-message v-if="modifyErrors[slotProps.data.id]?.reference" severity="error">{{ modifyErrors[slotProps.data.id].reference }}</p-message>
|
||||||
|
</template>
|
||||||
|
<template #editor="slotProps">
|
||||||
|
<InputText v-model="slotProps.data.reference" fluid />
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
|
||||||
|
|
||||||
<Column field="description" header="Description" editor="true">
|
<Column field="description" header="Description" editor="true">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<span v-if="!modifyErrors[slotProps.data.id]?.description" :title="slotProps.data.description">
|
<span v-if="!modifyErrors[slotProps.data.id]?.description" :title="slotProps.data.description">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user