FIx: delete champs par default
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
<div class="flex flex-wrap gap-2 mt-2">
|
||||
<span v-if="component.reference" class="badge badge-outline badge-sm">{{ component.reference }}</span>
|
||||
<span v-if="component.constructeur" class="badge badge-outline badge-sm">{{ component.constructeur?.name }}</span>
|
||||
<span v-if="component.emplacement" class="badge badge-outline badge-sm">{{ component.emplacement }}</span>
|
||||
<span v-if="component.prix" class="badge badge-primary badge-sm">{{ component.prix }}€</span>
|
||||
<span
|
||||
v-if="component.typeMachineComponentRequirement"
|
||||
@@ -70,17 +69,6 @@
|
||||
/>
|
||||
<div v-else class="input input-bordered input-sm bg-base-200">{{ component.reference || 'Non définie' }}</div>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<label class="label"><span class="label-text font-medium">Emplacement</span></label>
|
||||
<input
|
||||
v-if="isEditMode"
|
||||
v-model="component.emplacement"
|
||||
type="text"
|
||||
class="input input-bordered input-sm"
|
||||
@blur="updateComponent"
|
||||
/>
|
||||
<div v-else class="input input-bordered input-sm bg-base-200">{{ component.emplacement || 'Non défini' }}</div>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<label class="label"><span class="label-text font-medium">Prix</span></label>
|
||||
<input
|
||||
@@ -165,7 +153,6 @@
|
||||
v-if="field.type === 'text'"
|
||||
v-model="field.value"
|
||||
type="text"
|
||||
:placeholder="field.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="field.required"
|
||||
@blur="updateComponentCustomField(field)"
|
||||
@@ -174,7 +161,6 @@
|
||||
v-else-if="field.type === 'number'"
|
||||
v-model="field.value"
|
||||
type="number"
|
||||
:placeholder="field.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="field.required"
|
||||
@blur="updateComponentCustomField(field)"
|
||||
@@ -186,7 +172,7 @@
|
||||
:required="field.required"
|
||||
@change="updateComponentCustomField(field)"
|
||||
>
|
||||
<option value="">{{ field.defaultValue || 'Sélectionner...' }}</option>
|
||||
<option value="">Sélectionner...</option>
|
||||
<option v-for="option in field.options" :key="option" :value="option">{{ option }}</option>
|
||||
</select>
|
||||
<div v-else-if="field.type === 'boolean'" class="flex items-center gap-2">
|
||||
@@ -204,14 +190,13 @@
|
||||
v-else-if="field.type === 'date'"
|
||||
v-model="field.value"
|
||||
type="date"
|
||||
:placeholder="field.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="field.required"
|
||||
@blur="updateComponentCustomField(field)"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="input input-bordered input-sm bg-base-200">{{ field.value || field.defaultValue || 'Non défini' }}</div>
|
||||
<div class="input input-bordered input-sm bg-base-200">{{ field.value || 'Non défini' }}</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -34,17 +34,9 @@
|
||||
<option value="date">Date</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<label class="flex items-center gap-2 text-xs">
|
||||
<input v-model="field.required" type="checkbox" class="checkbox checkbox-xs" />
|
||||
Obligatoire
|
||||
</label>
|
||||
<input
|
||||
v-model="field.defaultValue"
|
||||
type="text"
|
||||
class="input input-bordered input-xs"
|
||||
placeholder="Valeur par défaut"
|
||||
/>
|
||||
<div class="flex items-center gap-2 text-xs">
|
||||
<input v-model="field.required" type="checkbox" class="checkbox checkbox-xs" />
|
||||
Obligatoire
|
||||
</div>
|
||||
<textarea
|
||||
v-if="field.type === 'select'"
|
||||
@@ -359,7 +351,6 @@ const addCustomField = () => {
|
||||
name: '',
|
||||
type: 'text',
|
||||
required: false,
|
||||
defaultValue: '',
|
||||
optionsText: '',
|
||||
options: [],
|
||||
})
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
v-if="field.type === 'text'"
|
||||
v-model="fieldValues[field.id]"
|
||||
type="text"
|
||||
:placeholder="field.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="field.required"
|
||||
@blur="updateCustomFieldValue(field.id)"
|
||||
@@ -28,7 +27,6 @@
|
||||
v-else-if="field.type === 'number'"
|
||||
v-model="fieldValues[field.id]"
|
||||
type="number"
|
||||
:placeholder="field.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="field.required"
|
||||
@blur="updateCustomFieldValue(field.id)"
|
||||
@@ -42,7 +40,7 @@
|
||||
:required="field.required"
|
||||
@change="updateCustomFieldValue(field.id)"
|
||||
>
|
||||
<option value="">{{ field.defaultValue || 'Sélectionner...' }}</option>
|
||||
<option value="">Sélectionner...</option>
|
||||
<option
|
||||
v-for="option in field.options"
|
||||
:key="option"
|
||||
@@ -69,7 +67,6 @@
|
||||
v-else-if="field.type === 'date'"
|
||||
v-model="fieldValues[field.id]"
|
||||
type="date"
|
||||
:placeholder="field.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="field.required"
|
||||
@blur="updateCustomFieldValue(field.id)"
|
||||
@@ -103,11 +100,11 @@ const emit = defineEmits(['update'])
|
||||
// Valeurs des champs personnalisés
|
||||
const fieldValues = reactive({})
|
||||
|
||||
// Initialiser les valeurs avec les valeurs par défaut
|
||||
// Initialiser les valeurs sans appliquer de valeur par défaut implicite
|
||||
const initializeFieldValues = () => {
|
||||
props.customFields.forEach(field => {
|
||||
if (!fieldValues[field.id]) {
|
||||
fieldValues[field.id] = field.defaultValue || ''
|
||||
if (!(field.id in fieldValues)) {
|
||||
fieldValues[field.id] = field.value ?? ''
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -132,4 +129,4 @@ watch(() => props.customFields, () => {
|
||||
onMounted(() => {
|
||||
initializeFieldValues()
|
||||
})
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<div>
|
||||
<p class="font-medium">Informations générales</p>
|
||||
<p class="text-xs text-base-content/60">
|
||||
Nom, emplacement, site et constructeur de la machine.
|
||||
Nom, site et constructeur de la machine.
|
||||
</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
@@ -71,18 +71,6 @@
|
||||
@update:modelValue="handleConstructeurChange"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<span class="font-medium">Emplacement:</span>
|
||||
<input
|
||||
v-if="isEditMode"
|
||||
:id="`piece-emplacement-${piece.id}`"
|
||||
v-model="pieceData.emplacement"
|
||||
type="text"
|
||||
class="input input-sm input-bordered ml-2"
|
||||
@blur="updatePiece"
|
||||
/>
|
||||
<span v-else class="ml-2">{{ pieceData.emplacement || 'Non défini' }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="font-medium">Prix:</span>
|
||||
<input
|
||||
@@ -146,7 +134,6 @@
|
||||
:value="fieldValue.value"
|
||||
@input="setCustomFieldValue(fieldValue.id, $event.target.value)"
|
||||
type="text"
|
||||
:placeholder="fieldValue.customField.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="fieldValue.customField.required"
|
||||
@blur="updateCustomFieldValue(fieldValue.id)"
|
||||
@@ -158,7 +145,6 @@
|
||||
:value="fieldValue.value"
|
||||
@input="setCustomFieldValue(fieldValue.id, $event.target.value)"
|
||||
type="number"
|
||||
:placeholder="fieldValue.customField.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="fieldValue.customField.required"
|
||||
@blur="updateCustomFieldValue(fieldValue.id)"
|
||||
@@ -173,7 +159,7 @@
|
||||
:required="fieldValue.customField.required"
|
||||
@blur="updateCustomFieldValue(fieldValue.id)"
|
||||
>
|
||||
<option value="">{{ fieldValue.customField.defaultValue || 'Sélectionner...' }}</option>
|
||||
<option value="">Sélectionner...</option>
|
||||
<option
|
||||
v-for="option in fieldValue.customField.options"
|
||||
:key="option"
|
||||
@@ -202,7 +188,6 @@
|
||||
:value="fieldValue.value"
|
||||
@input="setCustomFieldValue(fieldValue.id, $event.target.value)"
|
||||
type="date"
|
||||
:placeholder="fieldValue.customField.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="fieldValue.customField.required"
|
||||
@blur="updateCustomFieldValue(fieldValue.id)"
|
||||
@@ -212,7 +197,7 @@
|
||||
<!-- Mode lecture seule -->
|
||||
<template v-else>
|
||||
<div class="input input-bordered input-sm bg-base-200">
|
||||
{{ fieldValue.value || fieldValue.customField.defaultValue || 'Non défini' }}
|
||||
{{ fieldValue.value || 'Non défini' }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -321,7 +306,6 @@ const emit = defineEmits(['update', 'edit', 'custom-field-update', 'assign-model
|
||||
const pieceData = reactive({
|
||||
name: props.piece.name || '',
|
||||
reference: props.piece.reference || '',
|
||||
emplacement: props.piece.emplacement || '',
|
||||
prix: props.piece.prix || ''
|
||||
})
|
||||
|
||||
@@ -484,11 +468,10 @@ watch(() => props.piece.customFieldValues, () => {
|
||||
}, { deep: true })
|
||||
|
||||
watch(
|
||||
() => [props.piece.name, props.piece.reference, props.piece.emplacement, props.piece.prix],
|
||||
() => [props.piece.name, props.piece.reference, props.piece.prix],
|
||||
() => {
|
||||
pieceData.name = props.piece.name || ''
|
||||
pieceData.reference = props.piece.reference || ''
|
||||
pieceData.emplacement = props.piece.emplacement || ''
|
||||
pieceData.prix = props.piece.prix || ''
|
||||
},
|
||||
)
|
||||
@@ -497,7 +480,6 @@ onMounted(() => {
|
||||
// Initialiser les données avec les props
|
||||
pieceData.name = props.piece.name || ''
|
||||
pieceData.reference = props.piece.reference || ''
|
||||
pieceData.emplacement = props.piece.emplacement || ''
|
||||
pieceData.prix = props.piece.prix || ''
|
||||
|
||||
// Debug: vérifier si les champs personnalisés sont présents
|
||||
|
||||
@@ -37,17 +37,9 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<label class="flex items-center gap-2 text-xs">
|
||||
<input v-model="field.required" type="checkbox" class="checkbox checkbox-xs" />
|
||||
Obligatoire
|
||||
</label>
|
||||
<input
|
||||
v-model="field.defaultValue"
|
||||
type="text"
|
||||
class="input input-bordered input-xs"
|
||||
placeholder="Valeur par défaut"
|
||||
/>
|
||||
<div class="flex items-center gap-2 text-xs">
|
||||
<input v-model="field.required" type="checkbox" class="checkbox checkbox-xs" />
|
||||
Obligatoire
|
||||
</div>
|
||||
|
||||
<textarea
|
||||
@@ -108,7 +100,6 @@ const toEditorField = (input = {}) => ({
|
||||
name: typeof input.name === 'string' ? input.name : '',
|
||||
type: typeof input.type === 'string' && input.type ? input.type : 'text',
|
||||
required: Boolean(input.required),
|
||||
defaultValue: typeof input.defaultValue === 'string' ? input.defaultValue : '',
|
||||
optionsText: Array.isArray(input.options)
|
||||
? input.options.join('\n')
|
||||
: typeof input.optionsText === 'string'
|
||||
@@ -143,10 +134,6 @@ const normalizeFields = (fields) => {
|
||||
|
||||
const type = field.type || 'text'
|
||||
const required = Boolean(field.required)
|
||||
const defaultValue = typeof field.defaultValue === 'string'
|
||||
? field.defaultValue.trim() || undefined
|
||||
: undefined
|
||||
|
||||
let options
|
||||
if (type === 'select') {
|
||||
const raw = typeof field.optionsText === 'string' ? field.optionsText : ''
|
||||
@@ -158,9 +145,6 @@ const normalizeFields = (fields) => {
|
||||
}
|
||||
|
||||
const normalized = { name, type, required }
|
||||
if (defaultValue !== undefined) {
|
||||
normalized.defaultValue = defaultValue
|
||||
}
|
||||
if (options) {
|
||||
normalized.options = options
|
||||
}
|
||||
|
||||
@@ -78,17 +78,9 @@
|
||||
<option value="date">Date</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<label class="flex items-center gap-2 text-xs">
|
||||
<input v-model="field.required" type="checkbox" class="checkbox checkbox-xs" />
|
||||
Obligatoire
|
||||
</label>
|
||||
<input
|
||||
v-model="field.defaultValue"
|
||||
type="text"
|
||||
class="input input-bordered input-xs"
|
||||
placeholder="Valeur par défaut"
|
||||
/>
|
||||
<div class="flex items-center gap-2 text-xs">
|
||||
<input v-model="field.required" type="checkbox" class="checkbox checkbox-xs" />
|
||||
Obligatoire
|
||||
</div>
|
||||
<textarea
|
||||
v-if="field.type === 'select'"
|
||||
@@ -373,7 +365,6 @@ const addCustomField = () => {
|
||||
name: '',
|
||||
type: 'text',
|
||||
required: false,
|
||||
defaultValue: '',
|
||||
optionsText: '',
|
||||
options: [],
|
||||
})
|
||||
|
||||
@@ -120,21 +120,15 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div v-if="isSubComponentPieceCustomFieldExpanded(index, subIndex, pieceIndex, fieldIndex)" class="grid grid-cols-2 gap-1 mt-1">
|
||||
<div class="flex items-center gap-1">
|
||||
<div v-if="isSubComponentPieceCustomFieldExpanded(index, subIndex, pieceIndex, fieldIndex)" class="mt-1">
|
||||
<label class="flex items-center gap-1 text-xs">
|
||||
<input
|
||||
v-model="field.required"
|
||||
type="checkbox"
|
||||
class="checkbox checkbox-xs"
|
||||
/>
|
||||
<span class="text-xs">Obligatoire</span>
|
||||
</div>
|
||||
<input
|
||||
v-model="field.defaultValue"
|
||||
type="text"
|
||||
placeholder="Défaut"
|
||||
class="input input-bordered input-xs"
|
||||
/>
|
||||
Obligatoire
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="isSubComponentPieceCustomFieldExpanded(index, subIndex, pieceIndex, fieldIndex) && field.type === 'select'" class="mt-1">
|
||||
@@ -463,7 +457,6 @@ const addComponent = () => {
|
||||
name: '',
|
||||
reference: '',
|
||||
constructeur: '',
|
||||
emplacement: '',
|
||||
prix: null,
|
||||
pieces: [],
|
||||
customFields: [],
|
||||
@@ -511,7 +504,6 @@ const addComponentCustomField = (componentIndex) => {
|
||||
name: '',
|
||||
type: '',
|
||||
required: false,
|
||||
defaultValue: '',
|
||||
optionsText: ''
|
||||
})
|
||||
ensureComponentState(componentIndex)
|
||||
@@ -543,7 +535,6 @@ const addComponentPiece = (componentIndex) => {
|
||||
name: '',
|
||||
reference: '',
|
||||
constructeur: '',
|
||||
emplacement: '',
|
||||
prix: null,
|
||||
customFields: []
|
||||
})
|
||||
@@ -572,7 +563,6 @@ const addComponentPieceCustomField = (componentIndex, pieceIndex) => {
|
||||
name: '',
|
||||
type: '',
|
||||
required: false,
|
||||
defaultValue: '',
|
||||
optionsText: ''
|
||||
})
|
||||
ensureComponentPieceState(componentIndex, pieceIndex)
|
||||
@@ -604,7 +594,6 @@ const addSubComponent = (componentIndex) => {
|
||||
name: '',
|
||||
reference: '',
|
||||
constructeur: '',
|
||||
emplacement: '',
|
||||
prix: null,
|
||||
customFields: [],
|
||||
pieces: [],
|
||||
@@ -649,7 +638,6 @@ const addSubComponentCustomField = (componentIndex, subIndex) => {
|
||||
name: '',
|
||||
type: '',
|
||||
required: false,
|
||||
defaultValue: '',
|
||||
optionsText: ''
|
||||
})
|
||||
ensureSubComponentState(componentIndex, subIndex)
|
||||
@@ -674,7 +662,6 @@ const addSubComponentPiece = (componentIndex, subIndex) => {
|
||||
name: '',
|
||||
reference: '',
|
||||
constructeur: '',
|
||||
emplacement: '',
|
||||
prix: null,
|
||||
customFields: []
|
||||
})
|
||||
@@ -714,7 +701,6 @@ const addSubComponentPieceCustomField = (componentIndex, subIndex, pieceIndex) =
|
||||
name: '',
|
||||
type: '',
|
||||
required: false,
|
||||
defaultValue: '',
|
||||
optionsText: ''
|
||||
})
|
||||
ensureSubComponentPieceState(componentIndex, subIndex, pieceIndex)
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isFieldExpanded(fieldIndex)" class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-3">
|
||||
<div v-if="isFieldExpanded(fieldIndex)" class="mt-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -102,19 +102,6 @@
|
||||
/>
|
||||
<span class="text-sm">Champ obligatoire</span>
|
||||
</div>
|
||||
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text">Valeur par défaut</span>
|
||||
</label>
|
||||
<input
|
||||
:value="field.defaultValue"
|
||||
type="text"
|
||||
placeholder="Valeur par défaut"
|
||||
class="input input-bordered input-sm"
|
||||
@input="updateField(fieldIndex, { defaultValue: $event.target.value })"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -226,7 +213,6 @@ const addField = () => {
|
||||
name: '',
|
||||
type: '',
|
||||
required: false,
|
||||
defaultValue: '',
|
||||
optionsText: '',
|
||||
},
|
||||
]
|
||||
|
||||
@@ -137,7 +137,6 @@ const normalizeCustomFields = (fields = []) =>
|
||||
name: field.name,
|
||||
type: field.type || '',
|
||||
required: !!field.required,
|
||||
defaultValue: field.defaultValue || '',
|
||||
options: parseOptions(field)
|
||||
}))
|
||||
|
||||
|
||||
@@ -160,11 +160,7 @@
|
||||
<IconLucideTag class="w-3 h-3" aria-hidden="true" />
|
||||
<span>{{ machine.reference }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="machine.emplacement" class="flex items-center gap-1">
|
||||
<IconLucideBuilding class="w-3 h-3" aria-hidden="true" />
|
||||
<span>{{ machine.emplacement }}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-actions justify-end mt-3">
|
||||
@@ -355,18 +351,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-control mb-4">
|
||||
<label class="label">
|
||||
<span class="label-text">Emplacement</span>
|
||||
</label>
|
||||
<input
|
||||
v-model="newMachine.emplacement"
|
||||
type="text"
|
||||
placeholder="Ex: Atelier A, Zone 1"
|
||||
class="input input-bordered"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Type Preview -->
|
||||
<div v-if="selectedMachineType" class="mb-4 p-4 bg-gray-50 rounded-lg">
|
||||
<h4 class="font-semibold text-sm mb-2">Structure du type sélectionné :</h4>
|
||||
@@ -414,7 +398,6 @@ import IconLucideMapPinned from '~icons/lucide/map-pinned'
|
||||
import IconLucideChevronDown from '~icons/lucide/chevron-down'
|
||||
import IconLucideSettings2 from '~icons/lucide/settings-2'
|
||||
import IconLucideTag from '~icons/lucide/tag'
|
||||
import IconLucideBuilding from '~icons/lucide/building'
|
||||
|
||||
|
||||
const { sites, loading, loadSites, createSite } = useSites()
|
||||
@@ -442,8 +425,7 @@ const newMachine = reactive({
|
||||
name: '',
|
||||
siteId: '',
|
||||
typeMachineId: '',
|
||||
reference: '',
|
||||
emplacement: ''
|
||||
reference: ''
|
||||
})
|
||||
|
||||
// Computed
|
||||
@@ -545,8 +527,7 @@ const handleCreateMachine = async () => {
|
||||
const machineData = {
|
||||
name: newMachine.name,
|
||||
siteId: newMachine.siteId,
|
||||
reference: newMachine.reference,
|
||||
emplacement: newMachine.emplacement
|
||||
reference: newMachine.reference
|
||||
}
|
||||
|
||||
const result = await createMachineFromType(machineData, selectedMachineType.value)
|
||||
@@ -557,7 +538,6 @@ const handleCreateMachine = async () => {
|
||||
newMachine.siteId = ''
|
||||
newMachine.typeMachineId = ''
|
||||
newMachine.reference = ''
|
||||
newMachine.emplacement = ''
|
||||
showAddMachineModal.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,22 +403,6 @@
|
||||
{{ machineReference || 'Non définie' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text">Emplacement</span>
|
||||
</label>
|
||||
<input
|
||||
v-if="isEditMode"
|
||||
:id="getMachineFieldId('emplacement')"
|
||||
v-model="machineEmplacement"
|
||||
type="text"
|
||||
class="input input-bordered"
|
||||
@blur="updateMachineInfo"
|
||||
/>
|
||||
<div v-else class="input input-bordered bg-base-200">
|
||||
{{ machineEmplacement || 'Non défini' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text">Constructeur</span>
|
||||
@@ -462,7 +446,6 @@
|
||||
:value="fieldValue.value"
|
||||
@input="setMachineCustomFieldValue(fieldValue.id, $event.target.value)"
|
||||
type="text"
|
||||
:placeholder="fieldValue.customField.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="fieldValue.customField.required"
|
||||
@blur="updateMachineCustomField(fieldValue.id)"
|
||||
@@ -472,7 +455,6 @@
|
||||
:value="fieldValue.value"
|
||||
@input="setMachineCustomFieldValue(fieldValue.id, $event.target.value)"
|
||||
type="number"
|
||||
:placeholder="fieldValue.customField.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="fieldValue.customField.required"
|
||||
@blur="updateMachineCustomField(fieldValue.id)"
|
||||
@@ -485,7 +467,7 @@
|
||||
:required="fieldValue.customField.required"
|
||||
@blur="updateMachineCustomField(fieldValue.id)"
|
||||
>
|
||||
<option value="">{{ fieldValue.customField.defaultValue || 'Sélectionner...' }}</option>
|
||||
<option value="">Sélectionner...</option>
|
||||
<option
|
||||
v-for="option in fieldValue.customField.options"
|
||||
:key="option"
|
||||
@@ -510,7 +492,6 @@
|
||||
:value="fieldValue.value"
|
||||
@input="setMachineCustomFieldValue(fieldValue.id, $event.target.value)"
|
||||
type="date"
|
||||
:placeholder="fieldValue.customField.defaultValue || ''"
|
||||
class="input input-bordered input-sm"
|
||||
:required="fieldValue.customField.required"
|
||||
@blur="updateMachineCustomField(fieldValue.id)"
|
||||
@@ -518,7 +499,7 @@
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="input input-bordered input-sm bg-base-200">
|
||||
{{ fieldValue.value || fieldValue.customField.defaultValue || 'Non défini' }}
|
||||
{{ fieldValue.value || 'Non défini' }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -938,7 +919,6 @@ const { constructeurs, loadConstructeurs } = useConstructeurs()
|
||||
// Champs de la machine
|
||||
const machineName = ref('')
|
||||
const machineReference = ref('')
|
||||
const machineEmplacement = ref('')
|
||||
const machineConstructeurId = ref(null)
|
||||
const machineConstructeurDisplay = computed(() => {
|
||||
const id = machineConstructeurId.value || machine.value?.constructeur?.id || machine.value?.constructeurId
|
||||
@@ -1408,7 +1388,6 @@ const initMachineFields = () => {
|
||||
if (machine.value) {
|
||||
machineName.value = machine.value.name || ''
|
||||
machineReference.value = machine.value.reference || ''
|
||||
machineEmplacement.value = machine.value.emplacement || ''
|
||||
machineConstructeurId.value = machine.value.constructeurId || machine.value.constructeur?.id || null
|
||||
}
|
||||
}
|
||||
@@ -1747,7 +1726,6 @@ const printMachine = (currentSelection = printSelection) => {
|
||||
machine: machine.value,
|
||||
machineName: machineName.value,
|
||||
machineReference: machineReference.value,
|
||||
machineEmplacement: machineEmplacement.value,
|
||||
machinePieces: machinePieces.value,
|
||||
components: components.value,
|
||||
selection: currentSelection,
|
||||
@@ -1811,7 +1789,6 @@ const transformCustomFields = (pieces) => {
|
||||
name: cfv.customField.name,
|
||||
type: cfv.customField.type,
|
||||
required: cfv.customField.required,
|
||||
defaultValue: cfv.customField.defaultValue,
|
||||
options: cfv.customField.options || [],
|
||||
value: cfv.value
|
||||
})) || []
|
||||
@@ -1839,7 +1816,6 @@ const transformComponentCustomFields = (componentsData) => {
|
||||
name: cfv.customField.name,
|
||||
type: cfv.customField.type,
|
||||
required: cfv.customField.required,
|
||||
defaultValue: cfv.customField.defaultValue,
|
||||
options: cfv.customField.options || [],
|
||||
value: cfv.value
|
||||
})) || [];
|
||||
@@ -2242,7 +2218,6 @@ const updateMachineInfo = async () => {
|
||||
const result = await updateMachineApi(machine.value.id, {
|
||||
name: machineName.value,
|
||||
reference: machineReference.value,
|
||||
emplacement: machineEmplacement.value,
|
||||
constructeurId: machineConstructeurId.value || null
|
||||
})
|
||||
if (result.success) {
|
||||
@@ -2261,7 +2236,6 @@ const updateComponent = async (updatedComponent) => {
|
||||
name: updatedComponent.name,
|
||||
reference: updatedComponent.reference,
|
||||
constructeurId: updatedComponent.constructeurId || updatedComponent.constructeur?.id || null,
|
||||
emplacement: updatedComponent.emplacement,
|
||||
prix: prixValue && prixValue !== '' ? parseFloat(prixValue) : null,
|
||||
composantModelId: updatedComponent.composantModelId || updatedComponent.composantModel?.id || null,
|
||||
})
|
||||
@@ -2280,7 +2254,6 @@ const updatePieceFromComponent = async (updatedPiece) => {
|
||||
name: updatedPiece.name,
|
||||
reference: updatedPiece.reference,
|
||||
constructeurId: updatedPiece.constructeurId || updatedPiece.constructeur?.id || null,
|
||||
emplacement: updatedPiece.emplacement,
|
||||
prix: updatedPiece.prix && updatedPiece.prix !== '' ? parseFloat(updatedPiece.prix) : null,
|
||||
pieceModelId: updatedPiece.pieceModelId || updatedPiece.pieceModel?.id || null,
|
||||
})
|
||||
@@ -2312,7 +2285,6 @@ const updatePieceInfo = async (updatedPiece) => {
|
||||
name: updatedPiece.name,
|
||||
reference: updatedPiece.reference,
|
||||
constructeurId: updatedPiece.constructeurId || updatedPiece.constructeur?.id || null,
|
||||
emplacement: updatedPiece.emplacement,
|
||||
prix: updatedPiece.prix && updatedPiece.prix !== '' ? parseFloat(updatedPiece.prix) : null,
|
||||
pieceModelId: updatedPiece.pieceModelId || updatedPiece.pieceModel?.id || null,
|
||||
})
|
||||
|
||||
@@ -95,10 +95,6 @@
|
||||
<span class="text-gray-600">{{ machine.reference }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="machine.emplacement" class="flex items-center gap-2">
|
||||
<IconLucideBuilding class="w-4 h-4 text-purple-500" aria-hidden="true" />
|
||||
<span class="text-gray-600">{{ machine.emplacement }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions justify-end mt-4">
|
||||
@@ -130,7 +126,6 @@ import IconLucideFactory from '~icons/lucide/factory'
|
||||
import IconLucideMapPin from '~icons/lucide/map-pin'
|
||||
import IconLucideSettings2 from '~icons/lucide/settings-2'
|
||||
import IconLucideTag from '~icons/lucide/tag'
|
||||
import IconLucideBuilding from '~icons/lucide/building'
|
||||
|
||||
const { machines, loading, loadMachines, deleteMachine } = useMachines()
|
||||
const { sites, loadSites } = useSites()
|
||||
|
||||
@@ -66,18 +66,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text">Emplacement</span>
|
||||
</label>
|
||||
<input
|
||||
v-model="newMachine.emplacement"
|
||||
type="text"
|
||||
placeholder="Ex: Atelier A, Zone 1"
|
||||
class="input input-bordered"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedMachineType" class="p-4 bg-gray-50 rounded-lg space-y-2 text-sm">
|
||||
<h4 class="font-semibold text-sm">Structure du type sélectionné :</h4>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
@@ -670,7 +658,6 @@ const newMachine = reactive({
|
||||
siteId: '',
|
||||
typeMachineId: '',
|
||||
reference: '',
|
||||
emplacement: '',
|
||||
})
|
||||
|
||||
const componentRequirementSelections = reactive({})
|
||||
@@ -727,7 +714,6 @@ const machinePreview = computed(() => {
|
||||
? sites.value.find((site) => site.id === newMachine.siteId) || null
|
||||
: null
|
||||
const trimmedReference = (newMachine.reference || '').trim()
|
||||
const trimmedEmplacement = (newMachine.emplacement || '').trim()
|
||||
|
||||
const baseFields = [
|
||||
{
|
||||
@@ -754,12 +740,6 @@ const machinePreview = computed(() => {
|
||||
display: trimmedReference || 'Non renseignée',
|
||||
status: trimmedReference ? 'complete' : 'optional',
|
||||
},
|
||||
{
|
||||
key: 'emplacement',
|
||||
label: 'Emplacement',
|
||||
display: trimmedEmplacement || 'Non renseigné',
|
||||
status: trimmedEmplacement ? 'complete' : 'optional',
|
||||
},
|
||||
]
|
||||
|
||||
const baseIssues = []
|
||||
@@ -1307,7 +1287,6 @@ const finalizeMachineCreation = async () => {
|
||||
name: newMachine.name,
|
||||
siteId: newMachine.siteId,
|
||||
reference: newMachine.reference,
|
||||
emplacement: newMachine.emplacement,
|
||||
typeMachineId: type.id,
|
||||
}
|
||||
|
||||
@@ -1345,7 +1324,6 @@ const finalizeMachineCreation = async () => {
|
||||
newMachine.siteId = ''
|
||||
newMachine.typeMachineId = ''
|
||||
newMachine.reference = ''
|
||||
newMachine.emplacement = ''
|
||||
clearRequirementSelections()
|
||||
await navigateTo('/machines')
|
||||
} else if (result.error) {
|
||||
|
||||
@@ -94,7 +94,6 @@ const normalizeCustomFields = (fields = []) =>
|
||||
name: field.name,
|
||||
type: field.type || '',
|
||||
required: !!field.required,
|
||||
defaultValue: field.defaultValue || '',
|
||||
options: parseOptions(field)
|
||||
}))
|
||||
|
||||
|
||||
@@ -36,9 +36,6 @@ const sanitizeCustomFields = (fields: any[]): any[] => {
|
||||
|
||||
const type = typeof field?.type === 'string' && field.type ? field.type : 'text'
|
||||
const required = !!field?.required
|
||||
const defaultValue = typeof field?.defaultValue === 'string' && field.defaultValue.trim().length > 0
|
||||
? field.defaultValue.trim()
|
||||
: undefined
|
||||
|
||||
let options: string[] | undefined
|
||||
if (type === 'select') {
|
||||
@@ -55,9 +52,6 @@ const sanitizeCustomFields = (fields: any[]): any[] => {
|
||||
}
|
||||
|
||||
const result: Record<string, unknown> = { name, type, required }
|
||||
if (defaultValue !== undefined) {
|
||||
result.defaultValue = defaultValue
|
||||
}
|
||||
if (options) {
|
||||
result.options = options
|
||||
}
|
||||
@@ -178,7 +172,6 @@ const hydrateCustomFields = (fields: any[]): any[] => {
|
||||
name: field?.name ?? '',
|
||||
type: field?.type ?? 'text',
|
||||
required: !!field?.required,
|
||||
defaultValue: field?.defaultValue ?? '',
|
||||
options: Array.isArray(field?.options) ? field.options : [],
|
||||
optionsText: Array.isArray(field?.options) ? field.options.join('\n') : (field?.optionsText ?? ''),
|
||||
}))
|
||||
@@ -240,7 +233,6 @@ const mapComponentCustomFields = (fields: any[]) => {
|
||||
name: field?.name ?? '',
|
||||
type: field?.type ?? 'text',
|
||||
required: !!field?.required,
|
||||
defaultValue: field?.defaultValue ?? '',
|
||||
options: Array.isArray(field?.options) ? field.options : [],
|
||||
optionsText: toOptionsText(field),
|
||||
}))
|
||||
|
||||
@@ -179,7 +179,7 @@ const normalizeCustomFields = (values = []) => {
|
||||
return values.map((value) => ({
|
||||
id: value.id,
|
||||
label: value.customField?.name || 'Champ',
|
||||
value: value.value || value.customField?.defaultValue || '—',
|
||||
value: value.value || '—',
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -217,7 +217,6 @@ export const buildMachinePrintContext = ({
|
||||
machine,
|
||||
machineName,
|
||||
machineReference,
|
||||
machineEmplacement,
|
||||
machinePieces = [],
|
||||
components = [],
|
||||
selection,
|
||||
@@ -300,7 +299,6 @@ export const buildMachinePrintContext = ({
|
||||
description: machine?.description || '',
|
||||
typeDescription: machine?.typeMachine?.description || '',
|
||||
reference: machineReference,
|
||||
emplacement: machineEmplacement,
|
||||
site: machine?.site?.name || '',
|
||||
category: machine?.typeMachine?.category || '',
|
||||
badges: machineBadges,
|
||||
@@ -348,7 +346,6 @@ export const buildMachinePrintHtml = (context, styles) => {
|
||||
<div class="print-grid">
|
||||
${renderPrintField('Nom', context.machine.name)}
|
||||
${renderPrintField('Référence', context.machine.reference, 'Non définie')}
|
||||
${renderPrintField('Emplacement', context.machine.emplacement, 'Non défini')}
|
||||
${renderPrintField('Site', context.machine.site, 'Non défini')}
|
||||
${renderPrintField('Constructeur', context.machine.constructeur?.name, 'Non défini')}
|
||||
${renderPrintField('Contact Constructeur', context.machine.constructeur?.contact, 'Non défini')}
|
||||
@@ -564,4 +561,4 @@ export const buildMachinePrintHtml = (context, styles) => {
|
||||
</div>
|
||||
</body>
|
||||
</html>`
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user