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>
<!-- Items with Warranty Allocation - Full Width -->
<v-row>
<v-row v-if="isPluginActive('warranty')">
<v-col cols="12">
<v-card>
<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>
<div>پروسه با موفقیت تکمیل شد</div>
</v-card-title>
<v-card-text class="text-center">
<v-card-text v-if="isPluginActive('warranty')" class="text-center">
حواله انبار با موفقیت تکمیل شد و گارانتیها تخصیص داده شدند.
</v-card-text>
<v-card-actions>
@ -412,6 +412,7 @@ const warrantySettings = ref({
requireWarrantyOnDelivery: false,
matchWarrantyToSerial: false
})
const plugins = ref<any>({})
const item = ref<Item>({
ticket: {
@ -462,13 +463,16 @@ const currentBarcodeScannerContext = ref<{ rowIndex: number; lineIndex: number }
const loadData = async () => {
loading.value = true
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/business/get/info/${localStorage.getItem('activeBid')}`),
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.person = ticketResponse.data.person
item.value.transferType = ticketResponse.data.transferType
@ -687,7 +691,7 @@ const canComplete = computed(() => {
if (loading.value || completing.value) return false
// 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) {
if (isWarrantyRequired(row)) {
for (const line of row.warrantyLines || []) {
@ -765,6 +769,10 @@ const formatDate = (dateVal: any) => {
onMounted(() => {
loadData()
})
const isPluginActive = (plugName: string) => {
return plugins.value[plugName] !== undefined
}
</script>
<style scoped>