Fix #90
This commit is contained in:
@@ -633,6 +633,27 @@ const removePosition = (id) => {
|
||||
|
||||
}
|
||||
|
||||
const normalizeZip = (value) => String(value || "").replace(/\D/g, "")
|
||||
|
||||
const sanitizeAddressZipInput = () => {
|
||||
itemInfo.value.address.zip = normalizeZip(itemInfo.value.address.zip)
|
||||
}
|
||||
|
||||
const checkAddressZip = async () => {
|
||||
const zip = normalizeZip(itemInfo.value.address.zip)
|
||||
itemInfo.value.address.zip = zip
|
||||
|
||||
if (![4, 5].includes(zip.length)) return
|
||||
|
||||
const zipData = await useFunctions().useZipCheck(zip)
|
||||
if (zipData?.zip) {
|
||||
itemInfo.value.address.zip = zipData.zip
|
||||
}
|
||||
if (zipData?.short) {
|
||||
itemInfo.value.address.city = zipData.short
|
||||
}
|
||||
}
|
||||
|
||||
const findDocumentErrors = computed(() => {
|
||||
let errors = []
|
||||
|
||||
@@ -640,15 +661,15 @@ const findDocumentErrors = computed(() => {
|
||||
if (itemInfo.value.contact === null) errors.push({message: "Es ist kein Kontakt ausgewählt", type: "info"})
|
||||
if (itemInfo.value.letterhead === null) errors.push({message: "Es ist kein Briefpapier ausgewählt", type: "breaking"})
|
||||
if (itemInfo.value.created_by === null || !itemInfo.value.created_by) errors.push({message: "Es ist kein Mitarbeiter ausgewählt", type: "breaking"})
|
||||
if (itemInfo.value.address.street === null) errors.push({
|
||||
if (!itemInfo.value.address.street) errors.push({
|
||||
message: "Es ist keine Straße im Adressat angegeben",
|
||||
type: "breaking"
|
||||
})
|
||||
if (itemInfo.value.address.zip === null) errors.push({
|
||||
if (!itemInfo.value.address.zip) errors.push({
|
||||
message: "Es ist keine Postleitzahl im Adressat angegeben",
|
||||
type: "breaking"
|
||||
})
|
||||
if (itemInfo.value.address.city === null) errors.push({
|
||||
if (!itemInfo.value.address.city) errors.push({
|
||||
message: "Es ist keine Stadt im Adressat angegeben",
|
||||
type: "breaking"
|
||||
})
|
||||
@@ -1893,6 +1914,11 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
||||
<UInput
|
||||
class="flex-auto"
|
||||
v-model="itemInfo.address.zip"
|
||||
type="text"
|
||||
inputmode="numeric"
|
||||
maxlength="5"
|
||||
@input="sanitizeAddressZipInput"
|
||||
@change="checkAddressZip"
|
||||
:placeholder="itemInfo.customer ? customers.find(i => i.id === itemInfo.customer).infoData.zip : 'PLZ'"
|
||||
:color="itemInfo.address.zip ? 'primary' : 'rose'"
|
||||
/>
|
||||
@@ -3177,4 +3203,4 @@ td {
|
||||
height: 80vh;
|
||||
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -109,8 +109,11 @@ function recalculateWeeklyHours() {
|
||||
|
||||
const checkZip = async () => {
|
||||
const zipData = await useFunctions().useZipCheck(profile.value.address_zip)
|
||||
profile.value.address_city = zipData.short
|
||||
profile.value.state_code = zipData.state_code
|
||||
if (zipData) {
|
||||
profile.value.address_zip = zipData.zip || profile.value.address_zip
|
||||
profile.value.address_city = zipData.short
|
||||
profile.value.state_code = zipData.state_code
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(fetchProfile)
|
||||
@@ -314,5 +317,3 @@ onMounted(fetchProfile)
|
||||
<USkeleton v-if="pending" height="300px" />
|
||||
</UDashboardPanelContent>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user