71 lines
2.1 KiB
Vue
71 lines
2.1 KiB
Vue
<template>
|
||||
|
|
<BasicModal
|
|||
|
|
v-model:visible="visible"
|
|||
|
|
title="ثبت مشتری در شایگان"
|
|||
|
|
ok-text="ثبت در شایگان"
|
|||
|
|
:loading="loading"
|
|||
|
|
width="32rem"
|
|||
|
|
@ok="confirm"
|
|||
|
|
@close="visible = false"
|
|||
|
|
>
|
|||
|
|
<div class="space-y-3 text-sm">
|
|||
|
|
<div v-for="item in items" :key="item.label" class="flex justify-between gap-3 border-b border-gray-100 pb-2">
|
|||
|
|
<span class="text-gray-500">{{ item.label }}</span>
|
|||
|
|
<span class="text-left break-all">{{ item.value ?? '-' }}</span>
|
|||
|
|
</div>
|
|||
|
|
<p class="m-0 text-xs leading-5" style="color: var(--admin-text-secondary)">
|
|||
|
|
با تأیید، حساب تفصیلی با معین تنظیمشده در «حسابداری شایگان» ساخته میشود و کد در پروفایل مشتری ذخیره میگردد.
|
|||
|
|
</p>
|
|||
|
|
</div>
|
|||
|
|
</BasicModal>
|
|||
|
|
</template>
|
|||
|
|
|
|||
|
|
<script setup lang="ts">
|
|||
|
|
import { computed, ref } from 'vue'
|
|||
|
|
import BasicModal from '@/components/BasicModal.vue'
|
|||
|
|
import { message } from 'ant-design-vue/es'
|
|||
|
|
import { registerCustomerInShayegan } from '@/api/shayegan'
|
|||
|
|
|
|||
|
|
const props = defineProps<{
|
|||
|
|
modelValue: boolean
|
|||
|
|
customerId?: number
|
|||
|
|
customerName?: string
|
|||
|
|
}>()
|
|||
|
|
|
|||
|
|
const emit = defineEmits<{
|
|||
|
|
(e: 'update:modelValue', value: boolean): void
|
|||
|
|
(e: 'success'): void
|
|||
|
|
}>()
|
|||
|
|
|
|||
|
|
const loading = ref(false)
|
|||
|
|
|
|||
|
|
const visible = computed({
|
|||
|
|
get: () => props.modelValue,
|
|||
|
|
set: (value: boolean) => emit('update:modelValue', value)
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
const items = computed(() => [
|
|||
|
|
{ label: 'نام مشتری', value: props.customerName },
|
|||
|
|
{ label: 'شناسه مشتری', value: props.customerId },
|
|||
|
|
])
|
|||
|
|
|
|||
|
|
async function confirm() {
|
|||
|
|
if (!props.customerId) return
|
|||
|
|
loading.value = true
|
|||
|
|
try {
|
|||
|
|
const result = await registerCustomerInShayegan(props.customerId)
|
|||
|
|
if (!result.ok) {
|
|||
|
|
message.error(result.message || 'ثبت مشتری ناموفق بود')
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
message.success(result.message || 'مشتری در شایگان ثبت شد')
|
|||
|
|
visible.value = false
|
|||
|
|
emit('success')
|
|||
|
|
} catch (e) {
|
|||
|
|
console.error(e)
|
|||
|
|
} finally {
|
|||
|
|
loading.value = false
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
</script>
|