2026-08-26 16:59:24 +03:30
|
|
|
|
<template>
|
2026-08-30 21:18:26 +03:30
|
|
|
|
<section
|
|
|
|
|
|
v-if="visible"
|
|
|
|
|
|
class="colleague-accounts w-full flex flex-col gap-2.5 rounded-lg border border-base p-2.5 sm:grid sm:grid-cols-2 sm:items-end sm:gap-3"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="min-w-0">
|
|
|
|
|
|
<h3 class="m-0 inline-flex items-center gap-1.5 text-sm font-600" style="color: var(--admin-text)">
|
|
|
|
|
|
کد حسابداری معامله با همکار
|
|
|
|
|
|
<AdminFieldHelp :text="colleagueAccountingCodeHelp" size="sm" />
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
<p class="m-0 mt-0.5 text-xs leading-5" style="color: var(--admin-text-secondary)">
|
|
|
|
|
|
سند خرید/فروش پوشششده روی این کد در حسابداری فعال ثبت میشود.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
2026-08-26 16:59:24 +03:30
|
|
|
|
|
2026-08-30 21:18:26 +03:30
|
|
|
|
<label v-if="activeField" class="m-0 flex w-full min-w-0 flex-col gap-1">
|
|
|
|
|
|
<span class="inline-flex items-center gap-1.5 text-xs font-600" style="color: var(--admin-text)">
|
2026-08-27 18:47:38 +03:30
|
|
|
|
{{ activeField.label }}
|
|
|
|
|
|
<span class="colleague-accounts__badge">فعال</span>
|
|
|
|
|
|
</span>
|
2026-08-30 21:18:26 +03:30
|
|
|
|
<div class="flex w-full min-w-0 items-center gap-2">
|
|
|
|
|
|
<a-input
|
|
|
|
|
|
v-model:value="values[activeField.key]"
|
|
|
|
|
|
:placeholder="activeField.placeholder"
|
|
|
|
|
|
allow-clear
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
class="min-w-0 flex-1"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<BaseButton type="primary" size="small" class="shrink-0" :loading="saving" @click="save">
|
|
|
|
|
|
ذخیره
|
|
|
|
|
|
</BaseButton>
|
|
|
|
|
|
</div>
|
2026-08-27 18:47:38 +03:30
|
|
|
|
</label>
|
2026-08-26 16:59:24 +03:30
|
|
|
|
</section>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { computed, onMounted, reactive, ref } from 'vue'
|
|
|
|
|
|
import { message } from 'ant-design-vue'
|
|
|
|
|
|
import { getConfiguration, setConfiguration } from '@/api/configuration'
|
|
|
|
|
|
import type { Const } from '@/model/configuration'
|
2026-08-30 21:18:26 +03:30
|
|
|
|
import { colleagueAccountingCodeHelp } from '@/utils/adminHelpCopy'
|
|
|
|
|
|
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
2026-08-26 16:59:24 +03:30
|
|
|
|
import {
|
|
|
|
|
|
accountingProviderSetting,
|
|
|
|
|
|
initWalletSettingsFromApi,
|
2026-08-27 18:47:38 +03:30
|
|
|
|
priceProviderSetting,
|
2026-08-26 16:59:24 +03:30
|
|
|
|
type AccountingProvider,
|
|
|
|
|
|
} from '@/utils/config'
|
|
|
|
|
|
|
2026-08-27 18:47:38 +03:30
|
|
|
|
const props = withDefaults(
|
|
|
|
|
|
defineProps<{
|
|
|
|
|
|
/**
|
|
|
|
|
|
* اگر ست شود فقط وقتی provider فعال همین باشد نشان بده
|
|
|
|
|
|
* (مثلاً روی صفحهٔ همگامسازی تهحساب: provider-only="tahesab")
|
|
|
|
|
|
*/
|
|
|
|
|
|
providerOnly?: AccountingProvider | null
|
|
|
|
|
|
/** پیشفرض: فقط وقتی منبع قیمت Montzar است */
|
|
|
|
|
|
requireMontzar?: boolean
|
|
|
|
|
|
}>(),
|
|
|
|
|
|
{
|
|
|
|
|
|
providerOnly: null,
|
|
|
|
|
|
requireMontzar: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-08-26 16:59:24 +03:30
|
|
|
|
const KEYS = {
|
|
|
|
|
|
zarin: 'montzar_account_zarin',
|
|
|
|
|
|
tahesab: 'montzar_account_tahesab',
|
|
|
|
|
|
pargar: 'montzar_account_pargar',
|
|
|
|
|
|
} as const
|
|
|
|
|
|
|
2026-08-27 18:47:38 +03:30
|
|
|
|
const META: Record<
|
|
|
|
|
|
Exclude<AccountingProvider, 'none'>,
|
|
|
|
|
|
{ key: string; label: string; placeholder: string; titleFa: string }
|
|
|
|
|
|
> = {
|
|
|
|
|
|
zarin: {
|
|
|
|
|
|
key: KEYS.zarin,
|
|
|
|
|
|
label: 'کد حساب زرین',
|
|
|
|
|
|
placeholder: 'کد حساب همکار در زرین',
|
|
|
|
|
|
titleFa: 'کد حساب همکار در زرین',
|
|
|
|
|
|
},
|
|
|
|
|
|
tahesab: {
|
|
|
|
|
|
key: KEYS.tahesab,
|
|
|
|
|
|
label: 'کد حساب تهحساب',
|
|
|
|
|
|
placeholder: 'کد حساب همکار در تهحساب',
|
|
|
|
|
|
titleFa: 'کد حساب همکار در تهحساب',
|
|
|
|
|
|
},
|
|
|
|
|
|
pargar: {
|
|
|
|
|
|
key: KEYS.pargar,
|
|
|
|
|
|
label: 'کد حساب پرگار',
|
|
|
|
|
|
placeholder: 'کد حساب همکار در پرگار',
|
|
|
|
|
|
titleFa: 'کد حساب همکار در پرگار',
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-26 16:59:24 +03:30
|
|
|
|
const values = reactive<Record<string, string>>({
|
|
|
|
|
|
[KEYS.zarin]: '',
|
|
|
|
|
|
[KEYS.tahesab]: '',
|
|
|
|
|
|
[KEYS.pargar]: '',
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const rowIds = reactive<Record<string, number | null>>({
|
|
|
|
|
|
[KEYS.zarin]: null,
|
|
|
|
|
|
[KEYS.tahesab]: null,
|
|
|
|
|
|
[KEYS.pargar]: null,
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const saving = ref(false)
|
|
|
|
|
|
|
2026-08-27 18:47:38 +03:30
|
|
|
|
const activeProvider = computed(() => accountingProviderSetting.value as AccountingProvider)
|
|
|
|
|
|
|
|
|
|
|
|
const activeField = computed(() => {
|
|
|
|
|
|
const provider = activeProvider.value
|
|
|
|
|
|
if (provider === 'none') return null
|
|
|
|
|
|
return META[provider] ?? null
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const visible = computed(() => {
|
|
|
|
|
|
if (props.requireMontzar && priceProviderSetting.value !== 'montzar') {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!activeField.value) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
if (props.providerOnly && activeProvider.value !== props.providerOnly) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
return true
|
2026-08-26 16:59:24 +03:30
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
async function load() {
|
|
|
|
|
|
await initWalletSettingsFromApi()
|
|
|
|
|
|
const rows = await getConfiguration()
|
|
|
|
|
|
const list = Array.isArray(rows) ? rows : []
|
|
|
|
|
|
for (const key of Object.values(KEYS)) {
|
|
|
|
|
|
const row = list.find((item) => item?.key === key)
|
|
|
|
|
|
values[key] = row?.value != null ? String(row.value) : ''
|
|
|
|
|
|
rowIds[key] = row?.id != null ? Number(row.id) : null
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function save() {
|
2026-08-27 18:47:38 +03:30
|
|
|
|
const field = activeField.value
|
|
|
|
|
|
if (!field) {
|
|
|
|
|
|
message.warning('سیستم حسابداری فعالی انتخاب نشده است')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-26 16:59:24 +03:30
|
|
|
|
saving.value = true
|
|
|
|
|
|
try {
|
2026-08-27 18:47:38 +03:30
|
|
|
|
await setConfiguration({
|
|
|
|
|
|
id: rowIds[field.key] ?? undefined,
|
|
|
|
|
|
key: field.key,
|
|
|
|
|
|
value: (values[field.key] ?? '').trim(),
|
|
|
|
|
|
title_fa: field.titleFa,
|
|
|
|
|
|
is_active: true,
|
|
|
|
|
|
can_edit: true,
|
|
|
|
|
|
type: 'text',
|
|
|
|
|
|
description:
|
|
|
|
|
|
'کد حساب طرف حساب همکار؛ سند خرید/فروش پوشششده روی Montzar روی این حساب ثبت میشود.',
|
|
|
|
|
|
} satisfies Const)
|
|
|
|
|
|
message.success('کد حساب همکار ذخیره شد')
|
2026-08-26 16:59:24 +03:30
|
|
|
|
await load()
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
message.error('ذخیره کد حساب همکار ناموفق بود')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
saving.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
void load()
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2026-08-30 21:18:26 +03:30
|
|
|
|
<style scoped>
|
2026-08-26 16:59:24 +03:30
|
|
|
|
.colleague-accounts {
|
2026-08-30 21:18:26 +03:30
|
|
|
|
background: var(--admin-bg-surface, var(--admin-bg-elevated, rgba(28, 28, 34, 0.92)));
|
2026-08-26 16:59:24 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.colleague-accounts__badge {
|
2026-08-30 21:18:26 +03:30
|
|
|
|
@apply inline-flex items-center rounded-full px-1.5 text-10px font-700;
|
2026-08-26 16:59:24 +03:30
|
|
|
|
background: rgba(212, 175, 55, 0.18);
|
|
|
|
|
|
color: #d4af37;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|