feat: gérer les constructeurs multiples
This commit is contained in:
@@ -98,10 +98,10 @@
|
||||
<span class="label-text">Constructeur</span>
|
||||
</label>
|
||||
<ConstructeurSelect
|
||||
v-model="editionForm.constructeurId"
|
||||
v-model="editionForm.constructeurIds"
|
||||
class="w-full"
|
||||
:disabled="saving"
|
||||
placeholder="Rechercher un constructeur..."
|
||||
placeholder="Rechercher un ou plusieurs constructeurs..."
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -365,6 +365,7 @@ import { useDocuments } from '~/composables/useDocuments'
|
||||
import { getFileIcon } from '~/utils/fileIcons'
|
||||
import { canPreviewDocument, isImageDocument, isPdfDocument } from '~/utils/documentPreview'
|
||||
import { formatPieceStructurePreview } from '~/shared/modelUtils'
|
||||
import { uniqueConstructeurIds } from '~/shared/constructeurUtils'
|
||||
import type { PieceModelStructure } from '~/shared/types/inventory'
|
||||
import type { ModelType } from '~/services/modelTypes'
|
||||
|
||||
@@ -407,7 +408,7 @@ const selectedTypeId = ref<string>('')
|
||||
const editionForm = reactive({
|
||||
name: '' as string,
|
||||
reference: '' as string,
|
||||
constructeurId: null as string | null,
|
||||
constructeurIds: [] as string[],
|
||||
prix: '' as string,
|
||||
})
|
||||
|
||||
@@ -602,7 +603,11 @@ watch(
|
||||
|
||||
editionForm.name = currentPiece.name || ''
|
||||
editionForm.reference = currentPiece.reference || ''
|
||||
editionForm.constructeurId = currentPiece.constructeur?.id || currentPiece.constructeurId || null
|
||||
editionForm.constructeurIds = uniqueConstructeurIds(
|
||||
currentPiece,
|
||||
Array.isArray(currentPiece.constructeurs) ? currentPiece.constructeurs : [],
|
||||
currentPiece.constructeur ? [currentPiece.constructeur] : [],
|
||||
)
|
||||
editionForm.prix = currentPiece.prix !== null && currentPiece.prix !== undefined ? String(currentPiece.prix) : ''
|
||||
|
||||
customFieldInputs.value = buildCustomFieldInputs(
|
||||
@@ -642,7 +647,7 @@ const submitEdition = async () => {
|
||||
|
||||
const reference = editionForm.reference.trim()
|
||||
payload.reference = reference ? reference : null
|
||||
payload.constructeurId = editionForm.constructeurId || null
|
||||
payload.constructeurIds = uniqueConstructeurIds(editionForm.constructeurIds)
|
||||
|
||||
if (rawPrice) {
|
||||
const parsed = Number(rawPrice)
|
||||
|
||||
@@ -260,6 +260,7 @@ import { useToast } from '~/composables/useToast'
|
||||
import { useCustomFields } from '~/composables/useCustomFields'
|
||||
import { useDocuments } from '~/composables/useDocuments'
|
||||
import { formatPieceStructurePreview } from '~/shared/modelUtils'
|
||||
import { uniqueConstructeurIds } from '~/shared/constructeurUtils'
|
||||
import type { PieceModelStructure } from '~/shared/types/inventory'
|
||||
import type { ModelType } from '~/services/modelTypes'
|
||||
|
||||
@@ -283,7 +284,7 @@ const submitting = ref(false)
|
||||
const creationForm = reactive({
|
||||
name: '' as string,
|
||||
reference: '' as string,
|
||||
constructeurId: null as string | null,
|
||||
constructeurIds: [] as string[],
|
||||
prix: '' as string,
|
||||
})
|
||||
|
||||
@@ -381,7 +382,7 @@ const getStructureCustomFields = (structure: PieceModelStructure | null) => Arra
|
||||
const clearCreationForm = () => {
|
||||
creationForm.name = ''
|
||||
creationForm.reference = ''
|
||||
creationForm.constructeurId = null
|
||||
creationForm.constructeurIds = []
|
||||
creationForm.prix = ''
|
||||
lastSuggestedName.value = ''
|
||||
}
|
||||
@@ -401,8 +402,8 @@ const submitCreation = async () => {
|
||||
payload.reference = reference
|
||||
}
|
||||
|
||||
if (creationForm.constructeurId) {
|
||||
payload.constructeurId = creationForm.constructeurId
|
||||
if (creationForm.constructeurIds.length) {
|
||||
payload.constructeurIds = uniqueConstructeurIds(creationForm.constructeurIds)
|
||||
}
|
||||
|
||||
const rawPrice = typeof creationForm.prix === 'string'
|
||||
|
||||
Reference in New Issue
Block a user