���Root Mod By V1rus_Alfa
User / IP
:
216.73.217.78
Host / Server
:
195.214.235.115 / npln.ir
System
:
Linux damavand.pws-dns.net 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64
Command
|
Upload
|
Mass Deface
|
Create
:
/
home2
/
cutunixc
/
.trash
/
pages.1
/
unit
/
Viewing: [id].vue
<script setup lang="ts"> import {useMainStore} from '~/stores'; const {t, locale} = useI18n() const toast = useToast(); const localePath = useLocalePath(); const config = useRuntimeConfig(); // const {$api} = useNuxtApp(); const MainStore = useMainStore(); const {id} = useRoute().params; const loading = ref(true); let registrationLoading = reactive({ value: false }) const sheetsDB = useLocalForage('sheets') let newItems = reactive([ { sheet_full_name: '', name_sheet: '', name: '', length: '', rotation: 0, value: 0, width: 0 } ]); type res = { label: string, label_en: string, length: string, width: string, var_1: number, var_2: number, count: number, } const payload: any = reactive({ x: 0, y: 0, z: 0, c: 0, count: 0, }); const computingUnit = ref(null as null | res[]); const route = useRoute() const unit = ref({ id: null, key: null, title: null, title_en: null, variables: [ { address: '', key: '', label: '', label_en: '', type: 0, options: [], } ], image_2_d: { address: '' }, }); const selectedMaterial = ref({ length: 0, name: '', name_en: '', name_sheet: '', rotation: 0, sheet_full_name: '', value: 0, width: 0 }); onBeforeMount(async () => { let fetchedItems: any = await sheetsDB.getItem('new'); fetchedItems = JSON.parse(fetchedItems); for (let key in fetchedItems) { newItems[key] = fetchedItems[key] newItems[key].sheet_full_name = fetchedItems[key].name + '(' + fetchedItems[key].name_sheet + ')'; } selectedMaterial.value = newItems.find(i => i.value == payload.c); }) async function getAnalyzeUnitData() { const {data} = await useAPI('/analyze/unit', { query: { unit_id: id }, immediate: true, server: true, onRequestError({error}) { toast.add({title: t(error.message), color: 'red'}); toast.add({title: t('if your are using vpn, disable it and try again'), color: 'red'}) }, onResponseError({response}) { toast.add({title: t(response.status), color: 'red'}); toast.add({title: t('if your are using vpn, disable it and try again'), color: 'red'}) }, }) unit.value = data.value ? data.value.unit : []; payload['count'] = 1; unit.value?.variables?.forEach((row: any) => { payload[row.key] = row.default; }); } await getAnalyzeUnitData(); function payloadValidated() { let isValid = true; let sheetHasRotation = selectedMaterial.value.rotation == 1; const messages = []; if (sheetHasRotation) { if (payload.x > selectedMaterial.value.length - 1) { isValid = false; toast.add({title: 'عرض تکه ای که وارد کرده اید نباید از طول ورق بیشتر باشد', color: 'red'}) } else if (payload.z > selectedMaterial.value.width - 1) { isValid = false; toast.add({title: 'طول تکه ای که وارد کرده اید نباید از عرض ورق بیشتر باشد', color: 'red'}) } } else { if (payload.x > selectedMaterial.value.width - 1) { isValid = false; toast.add({title: 'عرض تکه ای که وارد کرده اید نباید از عرض ورق بیشتر باشد', color: 'red'}) } else if (payload.z > selectedMaterial.value.length - 1) { isValid = false; toast.add({title: 'طول تکه ای که وارد کرده اید نباید از طول ورق بیشتر باشد', color: 'red'}) } } if (payload.x <= 0) { isValid = false; messages.push(t('width_is_required')); } if (payload.y <= 0) { isValid = false; messages.push(t('length_is_required')); } if (payload.z <= 0) { isValid = false; messages.push(t('height_is_required')); } if (payload.c <= 0) { isValid = false; messages.push(t('color_is_required')); } if (payload.count <= 0) { isValid = false; messages.push(t('count_is_required')); } if (messages.length > 0) { console.log('messages', messages); messages.forEach(msg => { toast.add({title: msg, color: 'red'}); }) } loading.value = false; return isValid; } async function computing(type: any, title: any, url: any) { registrationLoading.value = true; if (!payloadValidated()) return; payload['unit_id'] = id; payload['type'] = type; payload['unit_title'] = title; const {data}: any = await useAPI('/analyze/computing-unit', { method: 'POST', immediate: true, server: true, body: payload }); computingUnit.value = data.value.result; if (url && data.value) { navigateTo(localePath(url)); } registrationLoading.value = false; } watch(payload, (newValue) => { selectedMaterial.value = newItems.find(i => i.value == newValue.c); console.log('selected material', selectedMaterial.value); }) let validateKeys = (keyCode: any) => { return [ 'ArrowUp', 'ArrowLeft', 'ArrowRight', 'ArrowDown', ].includes(keyCode); } const handleKeyDown = (event: any) => { if (event.target.tagName == 'SELECT' && validateKeys(event.code)) { event.preventDefault(); } if (validateKeys(event.code)) { let id = parseInt(event.target.id); let target: any; switch (event.code) { case 'ArrowUp': case 'ArrowRight': if (id > 1) target = id - 1; else return; break; case 'ArrowDown': case 'ArrowLeft': if (id < 7) target = id + 1; else return; break; default: } let element: any = document.getElementById(target); element.focus(); } } definePageMeta({ title: '', layout: 'with-out-footer', middleware: ['auth'], }) onMounted(() => { route.meta.title = unit.value?.title; useHead({ title: unit.value?.title }); loading.value = false; }); </script> <template> <div v-if="loading" class="flex items-center justify-center"> <SharedLoading/> </div> <div class=" mb-2 pt-3 px-2 mt-1" v-else> <section :dir="locale == 'en' ? 'ltr' : 'rtl'"> <div class=" flex justify-between items-start"> <div class=" w-full flex justify-between items-start mb-3"> <div class="w-5/12 " v-if="0 < unit.variables?.length"> <div class="flex justify-between items-center w-full mb-3" :key="i" v-for="(variable,i) in unit?.variables"> <label class="block w-5/12 text-gray-500 bg-white text-sm "> {{ locale == 'en' ? variable.label_en : variable.label }} </label> <div class="w-7/12 " v-if="variable.type == 1"> <UInput :loading="false" variant="outline" @keydown="handleKeyDown" :inputClass="' w-10/12 sm:w-full !shadow-none focus:ring-1 rounded-sm focus:ring-orange-600 h-7 py-0 text-xs' " v-on:keypress="MainStore.NumbersOnly" v-model="payload[variable.key]" /> </div> <div class="w-7/12 " v-else> <USelect :options="newItems" :option-attribute="'sheet_full_name'" value-attribute="value" @keydown="handleKeyDown" class="w-full" :selectClass="' w-full !shadow-none focus:ring-1 rounded-sm focus:ring-orange-600 h-7 pl-2 py-0 text-xs' " v-model="payload[variable.key]" /> </div> </div> <div class="w-8/11 flex justify-between text-gray-500 bg-white text-sm"> <div class="flex justify-between"> <span>عرض ورق:</span> <span>{{ selectedMaterial.width }}</span> </div> <div class="flex justify-between"> <span>طول ورق:</span> <span>{{ selectedMaterial.length }}</span> </div> </div> </div> <div class="h-32 w-[13rem] mb-3"> <template v-if="unit.image_2_d"> <img :src="config.public.FILE_URL+ unit.image_2_d?.address" class=" w-full h-full " :alt="t('Add Unit')"> </template> <UButton :loading="false" square @keydown="handleKeyDown" id="5" @click="computing('computing',unit.title,null)" class="w-full flex text-main-700 rounded-sm border border-red-600 h-7 bg-white items-center justify-center"> <span v-text="computingUnit?.length ? t('Recalculate') : t('Computing')" class=" block px-2 text-sm truncate "> </span> </UButton> </div> </div> </div> </section> <section class=" mb-2 "> <div v-if="loading"> <Snipper/> </div> <table class="w-full p-0" v-if="computingUnit" dir="ltr"> <thead> <tr class="bg-gray-300"> <th> {{ t('length') }} </th> <th></th> <th> {{ t('width') }} </th> <th></th> <th> {{ t('count') }} </th> <th> {{ t('unit_title') }} </th> </tr> </thead> <tbody> <tr :key="key" v-for="(res, key) in computingUnit" class="even:bg-gray-100"> <td> {{ res.length }} </td> <td> <UIcon name="i-heroicons-x-mark" class="text-[11px]"/> </td> <td> {{ res.width }} </td> <td> = </td> <td> {{ res.count }} </td> <td> {{ locale == 'en' ? res.label_en : res.label }} </td> </tr> </tbody> </table> </section> <footer :dir="locale == 'en' ? 'ltr' : 'rtl'" class="px-3 bg-white flex justify-between items-center pb-2 pt-2 sm:border-r sm:border-l w-full sm:w-9/12 md:w-7/12 lg:w-6/12 2xl:w-5/12 mx-auto fixed bottom-0 right-0 left-0 border-t"> <div class="px-1 w-3/12"> <label class="block text-gray-500 bg-white text-base "> {{ t('Number_Units') }} : </label> </div> <div class="px-1 w-4/12"> <UInput :loading="registrationLoading.value" variant="outline" :disabled="registrationLoading.value" :inputClass="'w-full text-center text-main-700 rounded-sm ring-gray-400 !shadow-none focus:ring-1 focus:ring-orange-600 h-7 text-base ' " v-model="payload.count" v-on:keypress="MainStore.NumbersOnly" @keydown="handleKeyDown" id="6" /> </div> <div class="px-1 w-4/12"> <UButton :loading="registrationLoading.value" square @keydown="handleKeyDown" id="7" @click="computing('set', unit.title,'/analyze/list')" class="w-full flex text-main-700 border-red-700 rounded-sm border h-7 bg-white items-center justify-center"> <span class=" block px-2 text-base truncate "> {{ t('registration') }} </span> </UButton> </div> </footer> </div> </template> <style scoped> table td, table th { text-align: center; font-size: 12px !important; padding: 10px 0; border-bottom: 1px solid #ccc; } table td { color: #666 } </style>
Coded With 💗 by
0x6ick Mod By V1rus_Alfa