update for Warranty plugin

This commit is contained in:
Gloomy 2025-08-21 22:33:44 +00:00
parent 2d6919c660
commit 35add500ca

View file

@ -123,7 +123,7 @@
</v-row> </v-row>
<!-- Items with Warranty Allocation - Full Width --> <!-- Items with Warranty Allocation - Full Width -->
<v-row> <v-row v-if="isPluginActive('warranty')">
<v-col cols="12"> <v-col cols="12">
<v-card> <v-card>
<v-card-title class="d-flex align-center mb-4"> <v-card-title class="d-flex align-center mb-4">
@ -302,7 +302,7 @@
<v-icon color="success" size="large" class="mb-2">mdi-check-circle</v-icon> <v-icon color="success" size="large" class="mb-2">mdi-check-circle</v-icon>
<div>پروسه با موفقیت تکمیل شد</div> <div>پروسه با موفقیت تکمیل شد</div>
</v-card-title> </v-card-title>
<v-card-text class="text-center"> <v-card-text v-if="isPluginActive('warranty')" class="text-center">
حواله انبار با موفقیت تکمیل شد و گارانتیها تخصیص داده شدند. حواله انبار با موفقیت تکمیل شد و گارانتیها تخصیص داده شدند.
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
@ -412,6 +412,7 @@ const warrantySettings = ref({
requireWarrantyOnDelivery: false, requireWarrantyOnDelivery: false,
matchWarrantyToSerial: false matchWarrantyToSerial: false
}) })
const plugins = ref<any>({})
const item = ref<Item>({ const item = ref<Item>({
ticket: { ticket: {
@ -462,13 +463,16 @@ const currentBarcodeScannerContext = ref<{ rowIndex: number; lineIndex: number }
const loadData = async () => { const loadData = async () => {
loading.value = true loading.value = true
try { try {
const [ticketResponse, businessResponse, warrantyResponse, allocatedWarrantiesResponse] = await Promise.all([ const [ticketResponse, businessResponse, warrantyResponse, allocatedWarrantiesResponse, pluginsResponse] = await Promise.all([
axios.post(`/api/storeroom/tickets/info/${route.params.id}`), axios.post(`/api/storeroom/tickets/info/${route.params.id}`),
axios.post(`/api/business/get/info/${localStorage.getItem('activeBid')}`), axios.post(`/api/business/get/info/${localStorage.getItem('activeBid')}`),
axios.get('/api/plugins/warranty/settings/get').catch(() => ({ data: { requireWarrantyOnDelivery: false, matchWarrantyToSerial: false } })), axios.get('/api/plugins/warranty/settings/get').catch(() => ({ data: { requireWarrantyOnDelivery: false, matchWarrantyToSerial: false } })),
axios.get(`/api/plugins/warranty/serials/by-storeroom-ticket/${route.params.id}`).catch(() => ({ data: { items: [] } })) axios.get(`/api/plugins/warranty/serials/by-storeroom-ticket/${route.params.id}`).catch(() => ({ data: { items: [] } })),
axios.post('/api/plugin/get/actives')
]) ])
plugins.value = pluginsResponse.data
item.value.ticket = ticketResponse.data.ticket item.value.ticket = ticketResponse.data.ticket
item.value.person = ticketResponse.data.person item.value.person = ticketResponse.data.person
item.value.transferType = ticketResponse.data.transferType item.value.transferType = ticketResponse.data.transferType
@ -483,7 +487,7 @@ const loadData = async () => {
bid.value = businessResponse.data bid.value = businessResponse.data
warrantySettings.value.requireWarrantyOnDelivery = !!(warrantyResponse?.data?.requireWarrantyOnDelivery) warrantySettings.value.requireWarrantyOnDelivery = !!(warrantyResponse?.data?.requireWarrantyOnDelivery)
warrantySettings.value.matchWarrantyToSerial = !!(warrantyResponse?.data?.matchWarrantyToSerial) warrantySettings.value.matchWarrantyToSerial = !!(warrantyResponse?.data?.matchWarrantyToSerial)
// Get already allocated warranties // Get already allocated warranties
const allocatedWarranties = allocatedWarrantiesResponse?.data?.items || [] const allocatedWarranties = allocatedWarrantiesResponse?.data?.items || []
@ -687,7 +691,7 @@ const canComplete = computed(() => {
if (loading.value || completing.value) return false if (loading.value || completing.value) return false
// Only check warranty requirements if requireWarrantyOnDelivery is enabled // Only check warranty requirements if requireWarrantyOnDelivery is enabled
if (warrantySettings.value.requireWarrantyOnDelivery) { if (isPluginActive('warranty') && warrantySettings.value.requireWarrantyOnDelivery) {
for (const row of item.value.rows) { for (const row of item.value.rows) {
if (isWarrantyRequired(row)) { if (isWarrantyRequired(row)) {
for (const line of row.warrantyLines || []) { for (const line of row.warrantyLines || []) {
@ -765,6 +769,10 @@ const formatDate = (dateVal: any) => {
onMounted(() => { onMounted(() => {
loadData() loadData()
}) })
const isPluginActive = (plugName: string) => {
return plugins.value[plugName] !== undefined
}
</script> </script>
<style scoped> <style scoped>