Split desktop and mobile layouts with shared page data so APIs fetch once per context.
Add layout shells, desktop views, module-level page caches, and UI fixes for auth, home, wallet, transactions, address, and related pages. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,224 +1,14 @@
|
||||
<template>
|
||||
<div>
|
||||
<div ref="el" class="px-3 pt-15"
|
||||
>
|
||||
<div class="flex gap-2">
|
||||
<BasicSelect v-model:value="selectedProduct" :items="items"
|
||||
class="w-full"
|
||||
key-name="id"
|
||||
:show-search="false"
|
||||
value-name="title"
|
||||
size="large"
|
||||
placeholder="لطفا محصول را انتخاب کنید"
|
||||
:has-tooltip="false"/>
|
||||
<BasicButton :disabled-b="selectedProduct==null" type="primary" @click="handleAdd">افزودن</BasicButton>
|
||||
</div>
|
||||
<div class="h-70vh rounded-lg bg-white mt-2 border-gray-200 border-1 overflow-y-auto p-2">
|
||||
<div v-for="(val,index) in selectedProducts" class="rounded-lg p-2 bg-gray-100 mb-2">
|
||||
<div class="flex">
|
||||
<div class="bg-gray-100 m-2 rounded-lg w-28 h-28 flex justify-center p-2">
|
||||
<img v-if="val.product.group_type=='گوی'" :src="goyImg">
|
||||
<img v-if="val.product.group_type=='مکعب'" :src="mokaabImg">
|
||||
<img v-if="val.product.group_type=='سکه'" :src="sekkeImg">
|
||||
<img v-if="val.product.group_type=='مس'" :src="mesImg">
|
||||
<img v-if="val.product.group_type=='نقره'" :src="noghrehImg">
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<div class="flex justify-between">
|
||||
<div class="font-bold text-lg">
|
||||
{{ val.product.title }}
|
||||
</div>
|
||||
<BasicButton icon="vuesax-linear:trash" icon-class="text-red" @click="handleRemove(val.product.id)"/>
|
||||
</div>
|
||||
<div class="flex mt-3 justify-between items-center">
|
||||
<div>تعداد موجودی:</div>
|
||||
<div class="flex flex-col items-end gap-0.5">
|
||||
<div class="flex gap-1 items-center">
|
||||
<div class="font-bold">{{ val.product.wallet.gold }}</div>
|
||||
<div>{{ getProductQuantityUnit(val.product) }}</div>
|
||||
</div>
|
||||
<div v-if="getProductUnitWeightLabel(val.product)" class="text-xs text-gray-500">
|
||||
هر عدد {{ getProductUnitWeightLabel(val.product) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center mt-2">
|
||||
<div>تعداد درخواستی:</div>
|
||||
<div class="flex gap-1 items-center w-40%">
|
||||
<BasicInput v-model:value="val.count" :addon-before="getProductQuantityUnit(val.product)"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<BasicButton :disabled-b="selectedProducts.length==0" class="w-full absolute bottom-10 mt-2"
|
||||
@click="handelFirstSubmit()">ثبت
|
||||
</BasicButton>
|
||||
</div>
|
||||
<!-- <ActionSheet v-model:show="editPassVisible">salam</ActionSheet>-->
|
||||
</div>
|
||||
<BasicActionSheet v-model:show="showAddress">
|
||||
<div class="h-120 flex flex-col ">
|
||||
<div class="text-center">
|
||||
انتخاب آدرس
|
||||
</div>
|
||||
<div class="overflow-y-scroll h-85">
|
||||
<ARadioGroup v-model:value="selectedAddressID">
|
||||
<div class="flex flex-col ">
|
||||
<div class="text-base rounded-lg p-4 m-2 shadow-md font-medium" v-for="item in address">
|
||||
<ARadio :value="item.id">{{ item.province }} / {{ item.city }} / {{ item.address }}</ARadio>
|
||||
</div>
|
||||
</div>
|
||||
</ARadioGroup>
|
||||
</div>
|
||||
<div class="flex gap-2 pt-2">
|
||||
|
||||
<BasicButton class=" " @click="showAddress=false;addAddressVisible=true">افزودن آدرس +</BasicButton>
|
||||
<BasicButton class="w-2/3 " type="primary" @click="handelsubmit">ثبت نهایی</BasicButton>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</BasicActionSheet>
|
||||
<BasicActionSheet v-model:show="addAddressVisible" >
|
||||
<div class=" ">
|
||||
<New_EditAddress @onOk="handleAddress"></New_EditAddress>
|
||||
</div>
|
||||
|
||||
</BasicActionSheet>
|
||||
<MobileNewRequestView v-show="!isDesktop" />
|
||||
<DesktopNewRequestView v-show="isDesktop" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
||||
import {onMounted, ref} from 'vue'
|
||||
import {loading} from '@/utils'
|
||||
import {getProductInventory} from '@/api/products'
|
||||
import type {CountPInventory, PInventory} from '@/models/products'
|
||||
import goyImg from '@/assets/img/goyImg.svg'
|
||||
import mokaabImg from '@/assets/img/mokaabImg.svg'
|
||||
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||
import {cloneDeep} from 'lodash'
|
||||
import BasicActionSheet from "@/components/BasicPacks/BasicActionSheet.vue"
|
||||
import {tableAddress} from "@/api/address"
|
||||
import type {Address} from "@/models/address"
|
||||
import {physicalReceiveApi} from "@/api/physicalreceive"
|
||||
import {message} from "ant-design-vue"
|
||||
import New_EditAddress from "@/views/base/address/components/New_EditAddress.vue"
|
||||
import mesImg from "@/assets/img/mesImg.jpg";
|
||||
import noghrehImg from "@/assets/img/noghrehImg.webp";
|
||||
import { getProductQuantityUnit, getProductUnitWeightLabel } from '@/utils/productDealMethod'
|
||||
|
||||
const items = ref<PInventory[]>()
|
||||
const baseItems = ref<PInventory[]>()
|
||||
const selectedAddressID = ref<number>()
|
||||
const selectedProduct = ref<number>()
|
||||
const productsByWalletId = ref<Array>([])
|
||||
const address = ref<Address>()
|
||||
const selectedProducts = ref<CountPInventory[]>([])
|
||||
const showAddress = ref<boolean>(false)
|
||||
const addAddressVisible = ref<boolean>(false)
|
||||
|
||||
function handleAdd() {
|
||||
console.log(selectedProducts.value)
|
||||
selectedProducts.value?.push({
|
||||
count: 0,
|
||||
product: items.value?.find(x => x.id === selectedProduct.value)
|
||||
})
|
||||
items.value?.splice(items.value?.findIndex(x => x.id === selectedProduct.value), 1)
|
||||
selectedProduct.value = undefined
|
||||
}
|
||||
function handleAddress() {
|
||||
getAddress()
|
||||
addAddressVisible.value = false
|
||||
showAddress.value = true
|
||||
}
|
||||
|
||||
function handleRemove(id: number) {
|
||||
const findItem = baseItems.value?.find(x => x.id === id)
|
||||
console.log(baseItems.value, id)
|
||||
if (findItem) {
|
||||
items.value?.push(findItem)
|
||||
}
|
||||
selectedProducts.value?.splice(selectedProducts.value?.findIndex(x => x.product.id === id), 1)
|
||||
}
|
||||
|
||||
async function initProductWallet() {
|
||||
try {
|
||||
loading.value = true
|
||||
items.value = (await getProductInventory()).rows
|
||||
baseItems.value = cloneDeep(items.value)
|
||||
console.log('baseItems.value',baseItems.value)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handelFirstSubmit() {
|
||||
try {
|
||||
const zeroAmount = selectedProducts.value.map(item => item.count <= 0)
|
||||
if (zeroAmount.includes(true)) {
|
||||
message.error(`لطفاً تعداد درخواستی محصول را وارد کنید.`)
|
||||
}
|
||||
else {
|
||||
showAddress.value = true
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function handelsubmit() {
|
||||
try {
|
||||
loading.value = true
|
||||
productsByWalletId.value = selectedProducts.value.map((val) => {
|
||||
return {
|
||||
wallet_id: val.product.wallet.id,
|
||||
value: val.count
|
||||
}
|
||||
})
|
||||
await physicalReceiveApi({
|
||||
address_id: selectedAddressID.value,
|
||||
wallets: productsByWalletId.value
|
||||
}
|
||||
)
|
||||
await initProductWallet()
|
||||
message.success("درخواست شما با موفقیت ارسال شد")
|
||||
selectedProducts.value = []
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
showAddress.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await initProductWallet()
|
||||
await getAddress()
|
||||
})
|
||||
async function getAddress(){
|
||||
let {rows} = await tableAddress({page: 0, limit: 150})
|
||||
address.value = rows
|
||||
}
|
||||
import { useNewPhysicalRequestPage } from '../composables/useNewPhysicalRequestPage'
|
||||
import { usePhysicalReceiveShellContext } from '../composables/usePhysicalReceiveShell'
|
||||
import DesktopNewRequestView from '../desktop/DesktopNewRequestView.vue'
|
||||
import MobileNewRequestView from '../mobile/MobileNewRequestView.vue'
|
||||
|
||||
const { isDesktop } = usePhysicalReceiveShellContext()
|
||||
useNewPhysicalRequestPage()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/*.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}*/
|
||||
/*.trans{
|
||||
transition: height 1s;
|
||||
}*/
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<div :class="variant === 'desktop' ? 'dpr-address-picker dpr-address-picker--desktop' : 'h-120 flex flex-col'">
|
||||
<div v-if="variant !== 'desktop'" class="text-center">انتخاب آدرس</div>
|
||||
<div :class="variant === 'desktop' ? 'dpr-address-picker__list' : 'overflow-y-scroll h-85'">
|
||||
<ARadioGroup v-model:value="selectedAddressID">
|
||||
<div class="flex flex-col">
|
||||
<div
|
||||
v-for="addr in addresses"
|
||||
:key="addr.id"
|
||||
:class="variant === 'desktop' ? 'dpr-address-picker__item' : 'text-base rounded-lg p-4 m-2 shadow-md font-medium'"
|
||||
>
|
||||
<ARadio :value="addr.id">
|
||||
{{ addr.province }} / {{ addr.city }} / {{ addr.address }}
|
||||
</ARadio>
|
||||
</div>
|
||||
</div>
|
||||
</ARadioGroup>
|
||||
</div>
|
||||
<div :class="variant === 'desktop' ? 'dpr-address-picker__actions' : 'flex gap-2 pt-2'">
|
||||
<BasicButton @click="emit('addAddress')">افزودن آدرس +</BasicButton>
|
||||
<BasicButton
|
||||
:class="variant === 'desktop' ? '' : 'w-2/3'"
|
||||
type="primary"
|
||||
@click="emit('submit')"
|
||||
>
|
||||
ثبت نهایی
|
||||
</BasicButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import type { Address } from '@/models/address'
|
||||
|
||||
interface Props {
|
||||
addresses?: Address[]
|
||||
variant?: 'mobile' | 'desktop'
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
variant: 'mobile',
|
||||
})
|
||||
|
||||
const selectedAddressID = defineModel<number | undefined>('selectedAddressID')
|
||||
|
||||
const emit = defineEmits<{
|
||||
addAddress: []
|
||||
submit: []
|
||||
}>()
|
||||
</script>
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex">
|
||||
<div class="bg-gray-100 m-2 rounded-lg w-28 h-28 flex justify-center p-2 shrink-0">
|
||||
<img v-if="item.product.group_type == 'گوی'" :src="goyImg" alt="" />
|
||||
<img v-if="item.product.group_type == 'مکعب'" :src="mokaabImg" alt="" />
|
||||
<img v-if="item.product.group_type == 'سکه'" :src="sekkeImg" alt="" />
|
||||
<img v-if="item.product.group_type == 'مس'" :src="mesImg" alt="" />
|
||||
<img v-if="item.product.group_type == 'نقره'" :src="noghrehImg" alt="" />
|
||||
</div>
|
||||
<div class="w-full min-w-0">
|
||||
<div class="flex justify-between gap-2">
|
||||
<div class="font-bold text-lg truncate">{{ item.product.title }}</div>
|
||||
<BasicButton
|
||||
icon="vuesax-linear:trash"
|
||||
icon-class="text-red"
|
||||
@click="emit('remove', item.product.id)"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex mt-3 justify-between items-center">
|
||||
<div>تعداد موجودی:</div>
|
||||
<div class="flex flex-col items-end gap-0.5">
|
||||
<div class="flex gap-1 items-center">
|
||||
<div class="font-bold">{{ item.product.wallet.gold }}</div>
|
||||
<div>{{ getProductQuantityUnit(item.product) }}</div>
|
||||
</div>
|
||||
<div v-if="getProductUnitWeightLabel(item.product)" class="text-xs text-gray-500">
|
||||
هر عدد {{ getProductUnitWeightLabel(item.product) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center mt-2 gap-2">
|
||||
<div>تعداد درخواستی:</div>
|
||||
<div
|
||||
class="flex gap-1 items-center"
|
||||
:class="variant === 'desktop' ? 'dpr-cart-row__input' : 'w-40%'"
|
||||
>
|
||||
<BasicInput
|
||||
v-model:value="item.count"
|
||||
:addon-before="getProductQuantityUnit(item.product)"
|
||||
:addon-bg-color="config.config?.color"
|
||||
addon-text-color="white"
|
||||
:size="variant === 'desktop' ? 'large' : undefined"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
||||
import { useConfigStore } from '@/store/configStore'
|
||||
import type { CountPInventory } from '@/models/products'
|
||||
import goyImg from '@/assets/img/goyImg.svg'
|
||||
import mokaabImg from '@/assets/img/mokaabImg.svg'
|
||||
import sekkeImg from '@/assets/img/sekkeImg.svg'
|
||||
import mesImg from '@/assets/img/mesImg.jpg'
|
||||
import noghrehImg from '@/assets/img/noghrehImg.webp'
|
||||
import { getProductQuantityUnit, getProductUnitWeightLabel } from '@/utils/productDealMethod'
|
||||
|
||||
interface Props {
|
||||
item: CountPInventory
|
||||
variant?: 'mobile' | 'desktop'
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
variant: 'mobile',
|
||||
})
|
||||
|
||||
const config = useConfigStore()
|
||||
|
||||
const emit = defineEmits<{
|
||||
remove: [id: number]
|
||||
}>()
|
||||
</script>
|
||||
@@ -1,26 +1,33 @@
|
||||
<template>
|
||||
<div class="rounded-lg shadow-md mx-2 bg-gradient-to-l from-primary rounded-lg p-[2px] to-transparent ">
|
||||
<div class="rounded-lg flex flex-col gap-2 bg-white p-2 ">
|
||||
<div class="flex justify-between ">
|
||||
<div
|
||||
class="rounded-lg shadow-md mx-2 bg-gradient-to-l from-primary rounded-lg p-[2px] to-transparent"
|
||||
:class="{ 'dpr-item': variant === 'desktop' }"
|
||||
>
|
||||
<div class="rounded-lg flex flex-col gap-2 bg-white p-2">
|
||||
<div class="flex justify-between">
|
||||
<div class="font-bold">شماره سند: {{ props.item.id }}</div>
|
||||
<div class="font-bold">{{ toJalali(props.item.created_at) }}</div>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
|
||||
<div class="flex flex-col w-full gap-1 ">
|
||||
<div class="w-full flex justify-between" v-for="item in props.item.transaction">
|
||||
<div class="flex items-center gap-1 ">
|
||||
<div class="w-7 h-7 flex justify-center rounded-lg bg-gray-100 ">
|
||||
<img width="30" class="p-1" :src="item.product.group_type=='گوی'?goyImg:mokaabImg">
|
||||
<div class="flex flex-col w-full gap-1">
|
||||
<div
|
||||
v-for="tx in props.item.transaction"
|
||||
:key="tx.id ?? tx.title"
|
||||
class="w-full flex justify-between"
|
||||
>
|
||||
<div class="flex items-center gap-1">
|
||||
<div class="w-7 h-7 flex justify-center rounded-lg bg-gray-100">
|
||||
<img
|
||||
width="30"
|
||||
class="p-1"
|
||||
:src="tx.product.group_type == 'گوی' ? goyImg : mokaabImg"
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
<div>{{ item.title }}</div>
|
||||
|
||||
|
||||
|
||||
<div>{{ tx.title }}</div>
|
||||
</div>
|
||||
<div>{{ item.gold * -1 }} عدد</div>
|
||||
<div>{{ tx.gold * -1 }} عدد</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
@@ -28,30 +35,30 @@
|
||||
<ATag color="blue" class="!py-1 !px-2 !ml-0">
|
||||
{{ props.item.sts_str }}
|
||||
</ATag>
|
||||
|
||||
</div>
|
||||
<ADivider class="!m-1"></ADivider>
|
||||
<ADivider class="!m-1" />
|
||||
<div class="flex flex-col justify-between">
|
||||
<div class="font-bold">آدرس:</div>
|
||||
<div>{{ props.item.address.province }}/{{ props.item.address.city }}/{{ props.item.address.address }}</div>
|
||||
<div>
|
||||
{{ props.item.address.province }}/{{ props.item.address.city }}/{{ props.item.address.address }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type {Physicalreceive} from "@/models/physicalreceive";
|
||||
import {toJalali} from "../../../../utils/useDateTime";
|
||||
import goyImg from "@/assets/img/goyImg.svg"
|
||||
import mokaabImg from "@/assets/img/mokaabImg.svg"
|
||||
import type { Physicalreceive } from '@/models/physicalreceive'
|
||||
import { toJalali } from '@/utils/useDateTime'
|
||||
import goyImg from '@/assets/img/goyImg.svg'
|
||||
import mokaabImg from '@/assets/img/mokaabImg.svg'
|
||||
|
||||
interface Prop {
|
||||
item: Physicalreceive
|
||||
variant?: 'mobile' | 'desktop'
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Prop>(), {})</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
const props = withDefaults(defineProps<Prop>(), {
|
||||
variant: 'mobile',
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,36 +1,14 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex flex-col gap-4 pt-13 px-2 pb-[calc(var(--app-bottom-chrome-height)+var(--app-add-card-height)+1rem)]">
|
||||
<RequestItem v-for="item in requestItems" :item="item"></RequestItem>
|
||||
</div>
|
||||
<Teleport to="body">
|
||||
<div class="add-request app-dock-add-bar" @click="openAdd()">
|
||||
<div>افزودن درخواست جدید</div>
|
||||
<BasicIcon icon="vuesax-linear:add" />
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
<MobileRequestListView v-show="!isDesktop" />
|
||||
<DesktopRequestListView v-show="isDesktop" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {onMounted, ref} from "vue";
|
||||
import {getPhysicalReceiveList} from "@/api/physicalreceive";
|
||||
import type {Physicalreceive} from "@/models/physicalreceive";
|
||||
import RequestItem from "@/views/base/physicalReceive/components/RequestItem.vue";
|
||||
import BasicIcon from "@/components/BasicPacks/BasicIcon.vue";
|
||||
import router from "@/router";
|
||||
import { usePhysicalReceiveList } from '../composables/usePhysicalReceiveList'
|
||||
import { usePhysicalReceiveShellContext } from '../composables/usePhysicalReceiveShell'
|
||||
import DesktopRequestListView from '../desktop/DesktopRequestListView.vue'
|
||||
import MobileRequestListView from '../mobile/MobileRequestListView.vue'
|
||||
|
||||
const requestItems = ref<Physicalreceive[]>([])
|
||||
const openAdd = () => {
|
||||
router.push('physicalReceive/new')
|
||||
}
|
||||
onMounted(async () => {
|
||||
let {rows} = await getPhysicalReceiveList()
|
||||
requestItems.value = rows
|
||||
console.log(rows)
|
||||
})
|
||||
const { isDesktop } = usePhysicalReceiveShellContext()
|
||||
usePhysicalReceiveList()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,153 @@
|
||||
import { inject, onMounted, provide, ref, type InjectionKey, type Ref } from 'vue'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { getProductInventory } from '@/api/products'
|
||||
import { physicalReceiveApi } from '@/api/physicalreceive'
|
||||
import { tableAddress } from '@/api/address'
|
||||
import type { CountPInventory, PInventory } from '@/models/products'
|
||||
import type { Address } from '@/models/address'
|
||||
import { loading } from '@/utils'
|
||||
import { usePhysicalReceiveShellContext } from './usePhysicalReceiveShell'
|
||||
|
||||
export interface NewPhysicalRequestContext {
|
||||
isDesktop: Ref<boolean>
|
||||
items: Ref<PInventory[] | undefined>
|
||||
selectedProduct: Ref<number | undefined>
|
||||
selectedProducts: Ref<CountPInventory[]>
|
||||
address: Ref<Address[] | undefined>
|
||||
selectedAddressID: Ref<number | undefined>
|
||||
showAddress: Ref<boolean>
|
||||
addAddressVisible: Ref<boolean>
|
||||
handleAdd: () => void
|
||||
handleRemove: (id: number) => void
|
||||
handelFirstSubmit: () => Promise<void>
|
||||
handelsubmit: () => Promise<void>
|
||||
handleAddress: () => void
|
||||
}
|
||||
|
||||
export const NEW_PHYSICAL_REQUEST_KEY: InjectionKey<NewPhysicalRequestContext> =
|
||||
Symbol('newPhysicalRequest')
|
||||
|
||||
export function useNewPhysicalRequestPage() {
|
||||
const { isDesktop } = usePhysicalReceiveShellContext()
|
||||
|
||||
const items = ref<PInventory[]>()
|
||||
const baseItems = ref<PInventory[]>()
|
||||
const selectedAddressID = ref<number>()
|
||||
const selectedProduct = ref<number>()
|
||||
const productsByWalletId = ref<Array<{ wallet_id: number; value: number }>>([])
|
||||
const address = ref<Address[]>()
|
||||
const selectedProducts = ref<CountPInventory[]>([])
|
||||
const showAddress = ref(false)
|
||||
const addAddressVisible = ref(false)
|
||||
|
||||
function handleAdd() {
|
||||
selectedProducts.value?.push({
|
||||
count: 0,
|
||||
product: items.value?.find((x) => x.id === selectedProduct.value)!,
|
||||
})
|
||||
items.value?.splice(items.value?.findIndex((x) => x.id === selectedProduct.value)!, 1)
|
||||
selectedProduct.value = undefined
|
||||
}
|
||||
|
||||
function handleAddress() {
|
||||
getAddress()
|
||||
addAddressVisible.value = false
|
||||
showAddress.value = true
|
||||
}
|
||||
|
||||
function handleRemove(id: number) {
|
||||
const findItem = baseItems.value?.find((x) => x.id === id)
|
||||
if (findItem) {
|
||||
items.value?.push(findItem)
|
||||
}
|
||||
selectedProducts.value?.splice(
|
||||
selectedProducts.value?.findIndex((x) => x.product.id === id),
|
||||
1
|
||||
)
|
||||
}
|
||||
|
||||
async function initProductWallet() {
|
||||
try {
|
||||
loading.value = true
|
||||
items.value = (await getProductInventory()).rows
|
||||
baseItems.value = cloneDeep(items.value)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handelFirstSubmit() {
|
||||
try {
|
||||
const zeroAmount = selectedProducts.value.map((item) => item.count <= 0)
|
||||
if (zeroAmount.includes(true)) {
|
||||
message.error('لطفاً تعداد درخواستی محصول را وارد کنید.')
|
||||
} else {
|
||||
showAddress.value = true
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function handelsubmit() {
|
||||
try {
|
||||
loading.value = true
|
||||
productsByWalletId.value = selectedProducts.value.map((val) => ({
|
||||
wallet_id: val.product.wallet.id,
|
||||
value: val.count,
|
||||
}))
|
||||
await physicalReceiveApi({
|
||||
address_id: selectedAddressID.value,
|
||||
wallets: productsByWalletId.value,
|
||||
})
|
||||
await initProductWallet()
|
||||
message.success('درخواست شما با موفقیت ارسال شد')
|
||||
selectedProducts.value = []
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
showAddress.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAddress() {
|
||||
const { rows } = await tableAddress({ page: 0, limit: 150 })
|
||||
address.value = rows
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await initProductWallet()
|
||||
await getAddress()
|
||||
})
|
||||
|
||||
const context: NewPhysicalRequestContext = {
|
||||
isDesktop,
|
||||
items,
|
||||
selectedProduct,
|
||||
selectedProducts,
|
||||
address,
|
||||
selectedAddressID,
|
||||
showAddress,
|
||||
addAddressVisible,
|
||||
handleAdd,
|
||||
handleRemove,
|
||||
handelFirstSubmit,
|
||||
handelsubmit,
|
||||
handleAddress,
|
||||
}
|
||||
|
||||
provide(NEW_PHYSICAL_REQUEST_KEY, context)
|
||||
return context
|
||||
}
|
||||
|
||||
export function useNewPhysicalRequestContext() {
|
||||
const context = inject(NEW_PHYSICAL_REQUEST_KEY)
|
||||
if (!context) {
|
||||
throw new Error('useNewPhysicalRequestContext must be used within useNewPhysicalRequestPage')
|
||||
}
|
||||
return context
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { inject, onMounted, provide, ref, type InjectionKey, type Ref } from 'vue'
|
||||
import { getPhysicalReceiveList } from '@/api/physicalreceive'
|
||||
import type { Physicalreceive } from '@/models/physicalreceive'
|
||||
import router from '@/router'
|
||||
|
||||
export interface PhysicalReceiveListContext {
|
||||
requestItems: Ref<Physicalreceive[]>
|
||||
openAdd: () => void
|
||||
}
|
||||
|
||||
export const PHYSICAL_RECEIVE_LIST_KEY: InjectionKey<PhysicalReceiveListContext> =
|
||||
Symbol('physicalReceiveList')
|
||||
|
||||
export function usePhysicalReceiveList() {
|
||||
const requestItems = ref<Physicalreceive[]>([])
|
||||
|
||||
function openAdd() {
|
||||
router.push('physicalReceive/new')
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const { rows } = await getPhysicalReceiveList()
|
||||
requestItems.value = rows
|
||||
})
|
||||
|
||||
const context: PhysicalReceiveListContext = { requestItems, openAdd }
|
||||
provide(PHYSICAL_RECEIVE_LIST_KEY, context)
|
||||
return context
|
||||
}
|
||||
|
||||
export function usePhysicalReceiveListContext() {
|
||||
const context = inject(PHYSICAL_RECEIVE_LIST_KEY)
|
||||
if (!context) {
|
||||
throw new Error('usePhysicalReceiveListContext must be used within usePhysicalReceiveList')
|
||||
}
|
||||
return context
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { inject, provide, type InjectionKey } from 'vue'
|
||||
import { useDesktopBreakpoint } from '@/layouts/composables/useAppLayout'
|
||||
|
||||
export interface PhysicalReceiveShellContext {
|
||||
isDesktop: ReturnType<typeof useDesktopBreakpoint>
|
||||
}
|
||||
|
||||
export const PHYSICAL_RECEIVE_SHELL_KEY: InjectionKey<PhysicalReceiveShellContext> =
|
||||
Symbol('physicalReceiveShell')
|
||||
|
||||
export function usePhysicalReceiveShell() {
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
provide(PHYSICAL_RECEIVE_SHELL_KEY, { isDesktop })
|
||||
return { isDesktop }
|
||||
}
|
||||
|
||||
export function usePhysicalReceiveShellContext() {
|
||||
const context = inject(PHYSICAL_RECEIVE_SHELL_KEY)
|
||||
if (!context) {
|
||||
throw new Error('usePhysicalReceiveShellContext must be used within physical receive shell')
|
||||
}
|
||||
return context
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<div class="dpr-new">
|
||||
<div class="dpr-new__grid">
|
||||
<section class="dpr-surface dpr-new__picker">
|
||||
<h2 class="dpr-new__section-title">انتخاب محصول</h2>
|
||||
<div class="dpr-new__picker-row">
|
||||
<BasicSelect
|
||||
v-model:value="selectedProduct"
|
||||
:items="items"
|
||||
class="w-full"
|
||||
key-name="id"
|
||||
:show-search="false"
|
||||
value-name="title"
|
||||
size="large"
|
||||
placeholder="لطفا محصول را انتخاب کنید"
|
||||
:has-tooltip="false"
|
||||
/>
|
||||
<BasicButton :disabled-b="selectedProduct == null" type="primary" @click="handleAdd">
|
||||
افزودن
|
||||
</BasicButton>
|
||||
</div>
|
||||
<p v-if="items?.length" class="dpr-new__hint">
|
||||
{{ items.length }} محصول با موجودی قابل تحویل
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="dpr-surface dpr-new__cart">
|
||||
<div class="dpr-new__cart-header">
|
||||
<h2 class="dpr-new__section-title">سبد درخواست</h2>
|
||||
<span class="dpr-new__cart-count">{{ selectedProducts.length }} مورد</span>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedProducts.length" class="dpr-new__cart-items">
|
||||
<div
|
||||
v-for="val in selectedProducts"
|
||||
:key="val.product.id"
|
||||
class="dpr-new__cart-item"
|
||||
>
|
||||
<PhysicalReceiveCartRow :item="val" variant="desktop" @remove="handleRemove" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="dpr-new__cart-empty">
|
||||
<BasicIcon icon="vuesax-linear:box" size="32" />
|
||||
<p>محصولی به سبد اضافه نشده است.</p>
|
||||
</div>
|
||||
|
||||
<div class="dpr-new__actions">
|
||||
<BasicButton
|
||||
:disabled-b="selectedProducts.length == 0"
|
||||
class="w-full"
|
||||
type="primary"
|
||||
@click="handelFirstSubmit()"
|
||||
>
|
||||
ادامه و انتخاب آدرس
|
||||
</BasicButton>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<BasicModal
|
||||
v-model:visible="showAddress"
|
||||
title="انتخاب آدرس"
|
||||
width="520px"
|
||||
destroy-on-close
|
||||
custom-footer
|
||||
>
|
||||
<PhysicalReceiveAddressPicker
|
||||
v-model:selected-address-id="selectedAddressID"
|
||||
:addresses="address"
|
||||
variant="desktop"
|
||||
@add-address="addAddressVisible = true; showAddress = false"
|
||||
@submit="handelsubmit"
|
||||
/>
|
||||
<template #footer>
|
||||
<div></div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
|
||||
<BasicModal
|
||||
v-model:visible="addAddressVisible"
|
||||
title="افزودن آدرس"
|
||||
width="520px"
|
||||
destroy-on-close
|
||||
custom-footer
|
||||
>
|
||||
<New_EditAddress @onOk="handleAddress" />
|
||||
<template #footer>
|
||||
<div></div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
||||
import BasicModal from '@/components/BasicPacks/BasicModal.vue'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import New_EditAddress from '@/views/base/address/components/New_EditAddress.vue'
|
||||
import PhysicalReceiveCartRow from '../components/PhysicalReceiveCartRow.vue'
|
||||
import PhysicalReceiveAddressPicker from '../components/PhysicalReceiveAddressPicker.vue'
|
||||
import { useNewPhysicalRequestContext } from '../composables/useNewPhysicalRequestPage'
|
||||
|
||||
const {
|
||||
items,
|
||||
selectedProduct,
|
||||
selectedProducts,
|
||||
address,
|
||||
selectedAddressID,
|
||||
showAddress,
|
||||
addAddressVisible,
|
||||
handleAdd,
|
||||
handleRemove,
|
||||
handelFirstSubmit,
|
||||
handelsubmit,
|
||||
handleAddress,
|
||||
} = useNewPhysicalRequestContext()
|
||||
</script>
|
||||
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<header class="dpr-topbar">
|
||||
<button type="button" class="dpr-topbar__back" @click="router.back()">
|
||||
<BasicIcon icon="vuesax-linear:arrow-right-1" size="18" />
|
||||
بازگشت
|
||||
</button>
|
||||
<div class="dpr-topbar__meta">
|
||||
<p class="dpr-topbar__eyebrow">سفارش</p>
|
||||
<h1 class="dpr-topbar__title">{{ pageTitle }}</h1>
|
||||
<p class="dpr-topbar__subtitle">{{ pageSubtitle }}</p>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import router from '@/router'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const pageTitle = computed(() =>
|
||||
route.name === 'list' ? 'دریافت فیزیکی' : 'درخواست جدید'
|
||||
)
|
||||
|
||||
const pageSubtitle = computed(() =>
|
||||
route.name === 'list'
|
||||
? 'پیگیری درخواستهای تحویل فیزیکی محصول'
|
||||
: 'انتخاب محصول و ثبت آدرس تحویل'
|
||||
)
|
||||
</script>
|
||||
@@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<div class="dpr-list">
|
||||
<div class="dpr-list__toolbar">
|
||||
<span class="dpr-list__count">{{ requestItems.length }} درخواست</span>
|
||||
<button type="button" class="dpr-list__add" @click="openAdd()">
|
||||
<BasicIcon icon="vuesax-linear:add" size="16" />
|
||||
درخواست جدید
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="requestItems.length" class="dpr-list__items">
|
||||
<RequestItem
|
||||
v-for="item in requestItems"
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
variant="desktop"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-else class="dpr-list__empty">
|
||||
<BasicIcon icon="vuesax-linear:box" size="40" />
|
||||
<p>هنوز درخواستی ثبت نشده است.</p>
|
||||
<button type="button" class="dpr-list__empty-btn" @click="openAdd()">
|
||||
ثبت اولین درخواست
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import RequestItem from '../components/RequestItem.vue'
|
||||
import { usePhysicalReceiveListContext } from '../composables/usePhysicalReceiveList'
|
||||
|
||||
const { requestItems, openAdd } = usePhysicalReceiveListContext()
|
||||
</script>
|
||||
@@ -0,0 +1,301 @@
|
||||
/* Premium desktop physical receive */
|
||||
|
||||
.dpr {
|
||||
min-height: 100%;
|
||||
background: #f6f7f9;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.dpr__container {
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
padding: 28px 36px 40px;
|
||||
}
|
||||
|
||||
.dpr-topbar {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
margin-bottom: 28px;
|
||||
padding-bottom: 24px;
|
||||
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
|
||||
|
||||
&__back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #6b7280;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
padding: 8px 0;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:hover {
|
||||
color: #111827;
|
||||
}
|
||||
}
|
||||
|
||||
&__meta {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__eyebrow {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: #9ca3af;
|
||||
margin: 0 0 4px;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 26px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.03em;
|
||||
color: #111827;
|
||||
margin: 0;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
&__subtitle {
|
||||
font-size: 14px;
|
||||
color: #6b7280;
|
||||
margin: 6px 0 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
|
||||
.dpr-surface {
|
||||
background: #fff;
|
||||
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||
}
|
||||
|
||||
.dpr-list {
|
||||
padding: 24px;
|
||||
background: #fff;
|
||||
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||
|
||||
&__toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
&__count {
|
||||
font-size: 14px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
&__add {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 18px;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
background: @App-primary-color;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
filter: brightness(0.95);
|
||||
}
|
||||
}
|
||||
|
||||
&__items {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
&__empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
min-height: 240px;
|
||||
padding: 32px 16px;
|
||||
color: #6b7280;
|
||||
text-align: center;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
&__empty-btn {
|
||||
margin-top: 8px;
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
background: @App-primary-color;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.dpr-item {
|
||||
margin: 0 !important;
|
||||
border-radius: 16px !important;
|
||||
}
|
||||
|
||||
.dpr-new {
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
|
||||
gap: 20px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
&__picker,
|
||||
&__cart {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
&__section-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #111827;
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
|
||||
&__picker-row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
&__hint {
|
||||
margin: 12px 0 0;
|
||||
font-size: 13px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
&__cart-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
&__cart-count {
|
||||
font-size: 13px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
&__cart-items {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
max-height: 420px;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
&__cart-item {
|
||||
padding: 14px;
|
||||
border-radius: 12px;
|
||||
background: #f9fafb;
|
||||
border: 1px solid rgba(15, 23, 42, 0.05);
|
||||
}
|
||||
|
||||
&__cart-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
min-height: 200px;
|
||||
color: #9ca3af;
|
||||
text-align: center;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
}
|
||||
|
||||
.dpr-cart-row__input {
|
||||
width: min(100%, 240px);
|
||||
min-width: 220px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.noname-input,
|
||||
.ant-input-group-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ant-input-group-addon {
|
||||
min-width: 4.75rem;
|
||||
padding-inline: 10px;
|
||||
white-space: nowrap;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.dpr-address-picker {
|
||||
&--desktop {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
&__list {
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
&__item {
|
||||
padding: 14px 16px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(15, 23, 42, 0.08);
|
||||
background: #f9fafb;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
padding-top: 8px;
|
||||
|
||||
> button:last-child {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.dpr-list__items {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.dpr-new__grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +1,36 @@
|
||||
<template>
|
||||
<div style="max-height: calc(100vh - 50px)">
|
||||
<div class="bg-white py-3 px-3 z-100000 text-primary font-bold drop-shadow flex flex-col wrap-fix">
|
||||
<div class="flex">
|
||||
<div @click="router.back()">
|
||||
<BasicIcon icon="vuesax-linear:arrow-right-1"/>
|
||||
</div>
|
||||
<div v-if="route.name=='list'" class="mr-2">دریافت فیزیکی</div>
|
||||
<div v-else class="mr-2">دریافت فیزیکی-درخواست جدید</div>
|
||||
<div class="physical-receive-page-root" :class="{ 'physical-receive-page-root--desktop': isDesktop }">
|
||||
<MobilePhysicalReceiveChrome v-show="!isDesktop" />
|
||||
|
||||
<div :class="isDesktop ? 'dpr' : ''">
|
||||
<div :class="isDesktop ? 'dpr__container' : 'physical-receive-page-root__content'">
|
||||
<DesktopPhysicalReceiveChrome v-show="isDesktop" />
|
||||
<router-view />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<router-view></router-view>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref} from "vue";
|
||||
import RequestList from "@/views/base/physicalReceive/components/RequestList.vue";
|
||||
import NewRequest from "@/views/base/physicalReceive/components/NewRequest.vue";
|
||||
import router from "@/router";
|
||||
import BasicIcon from "@/components/BasicPacks/BasicIcon.vue";
|
||||
import {useRoute} from "vue-router";
|
||||
import { usePhysicalReceiveShell } from './composables/usePhysicalReceiveShell'
|
||||
import DesktopPhysicalReceiveChrome from './desktop/DesktopPhysicalReceiveChrome.vue'
|
||||
import MobilePhysicalReceiveChrome from './mobile/MobilePhysicalReceiveChrome.vue'
|
||||
|
||||
const activekey=ref(1)
|
||||
const route=useRoute()
|
||||
const { isDesktop } = usePhysicalReceiveShell()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/*.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
.physical-receive-page-root {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}*/
|
||||
/*.trans{
|
||||
transition: height 1s;
|
||||
}*/
|
||||
.physical-receive-page-root__content {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.physical-receive-page-root--desktop {
|
||||
height: auto;
|
||||
min-height: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div>
|
||||
<div ref="el" class="px-3 pt-15">
|
||||
<div class="flex gap-2">
|
||||
<BasicSelect
|
||||
v-model:value="selectedProduct"
|
||||
:items="items"
|
||||
class="w-full"
|
||||
key-name="id"
|
||||
:show-search="false"
|
||||
value-name="title"
|
||||
size="large"
|
||||
placeholder="لطفا محصول را انتخاب کنید"
|
||||
:has-tooltip="false"
|
||||
/>
|
||||
<BasicButton :disabled-b="selectedProduct == null" type="primary" @click="handleAdd">
|
||||
افزودن
|
||||
</BasicButton>
|
||||
</div>
|
||||
<div class="h-70vh rounded-lg bg-white mt-2 border-gray-200 border-1 overflow-y-auto p-2">
|
||||
<div
|
||||
v-for="val in selectedProducts"
|
||||
:key="val.product.id"
|
||||
class="rounded-lg p-2 bg-gray-100 mb-2"
|
||||
>
|
||||
<PhysicalReceiveCartRow :item="val" @remove="handleRemove" />
|
||||
</div>
|
||||
</div>
|
||||
<BasicButton
|
||||
:disabled-b="selectedProducts.length == 0"
|
||||
class="w-full absolute bottom-10 mt-2"
|
||||
@click="handelFirstSubmit()"
|
||||
>
|
||||
ثبت
|
||||
</BasicButton>
|
||||
</div>
|
||||
|
||||
<BasicActionSheet v-model:show="showAddress">
|
||||
<PhysicalReceiveAddressPicker
|
||||
v-model:selected-address-id="selectedAddressID"
|
||||
:addresses="address"
|
||||
@add-address="addAddressVisible = true; showAddress = false"
|
||||
@submit="handelsubmit"
|
||||
/>
|
||||
</BasicActionSheet>
|
||||
|
||||
<BasicActionSheet v-model:show="addAddressVisible">
|
||||
<New_EditAddress @onOk="handleAddress" />
|
||||
</BasicActionSheet>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import New_EditAddress from '@/views/base/address/components/New_EditAddress.vue'
|
||||
import PhysicalReceiveCartRow from '../components/PhysicalReceiveCartRow.vue'
|
||||
import PhysicalReceiveAddressPicker from '../components/PhysicalReceiveAddressPicker.vue'
|
||||
import { useNewPhysicalRequestContext } from '../composables/useNewPhysicalRequestPage'
|
||||
|
||||
const {
|
||||
items,
|
||||
selectedProduct,
|
||||
selectedProducts,
|
||||
address,
|
||||
selectedAddressID,
|
||||
showAddress,
|
||||
addAddressVisible,
|
||||
handleAdd,
|
||||
handleRemove,
|
||||
handelFirstSubmit,
|
||||
handelsubmit,
|
||||
handleAddress,
|
||||
} = useNewPhysicalRequestContext()
|
||||
</script>
|
||||
@@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<div class="physical-receive-mobile-chrome" style="max-height: calc(100vh - 50px)">
|
||||
<div class="bg-white py-3 px-3 z-100000 text-primary font-bold drop-shadow flex flex-col wrap-fix">
|
||||
<div class="flex">
|
||||
<div @click="router.back()">
|
||||
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
||||
</div>
|
||||
<div v-if="route.name === 'list'" class="mr-2">دریافت فیزیکی</div>
|
||||
<div v-else class="mr-2">دریافت فیزیکی-درخواست جدید</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import router from '@/router'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
const route = useRoute()
|
||||
</script>
|
||||
@@ -0,0 +1,23 @@
|
||||
<template>
|
||||
<div>
|
||||
<div
|
||||
class="flex flex-col gap-4 pt-13 px-2 pb-[calc(var(--app-bottom-chrome-height)+var(--app-add-card-height)+1rem)]"
|
||||
>
|
||||
<RequestItem v-for="item in requestItems" :key="item.id" :item="item" />
|
||||
</div>
|
||||
<Teleport to="body">
|
||||
<div class="add-request app-dock-add-bar" @click="openAdd()">
|
||||
<div>افزودن درخواست جدید</div>
|
||||
<BasicIcon icon="vuesax-linear:add" />
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import RequestItem from '../components/RequestItem.vue'
|
||||
import { usePhysicalReceiveListContext } from '../composables/usePhysicalReceiveList'
|
||||
|
||||
const { requestItems, openAdd } = usePhysicalReceiveListContext()
|
||||
</script>
|
||||
Reference in New Issue
Block a user