Files
tehran_tala/apps/admin-panel/src/views/promotion/autopromotion.vue
T
s.esmaeiliandClaude Sonnet 5 f0de478940 admin-panel: fix CSS bugs and dedupe scoped grid utilities
Approved departure from the port's byte-faithful rule (docs/ADMIN-PORT-PLAN.md
bug rows 4-6), fixed and logged rather than silently changed:
- farsi.less: bold/700 @font-face blocks now load iran-yekan-700.woff2
  instead of the 400 file, so bold text actually renders bold. No source
  file exists for weight 300, so that face is dropped rather than faked.
- format("woff") corrected to format("woff2") on all faces.
- Removed 'font-weight: inherit' from the body,* reset, which was flattening
  every heading's weight.

Also deduped 24 view files that each redeclared .grid-2/.grid-3/.grid-4 in
a scoped <style> block with drifted minmax values, though utilities.less
already defines all three globally. Removed the scoped copies; kept
PromotionForm's genuinely different 0.5rem gap as a small .grid-4--tight
modifier instead of a full redeclaration.

Verified: pnpm build passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-14 15:09:11 +03:30

79 lines
2.6 KiB
Vue

<template>
<!--
Ported from legacy henza_admin/src/views/promotion/autopromotion.vue —
the one-shot welcome discount for new customers. State toggle + percentage.
-->
<a-form layout="vertical" @submit.prevent="handleSubmit">
<a-spin :spinning="loading">
<a-card title="تخفیف اتوماتیک یکبار مصرف ویژه مشتریان جدید" class="mb-base">
<div class="grid-3">
<a-form-item label="وضعیت تخفیف اتوماتیک">
<a-switch v-model:checked="state" size="default" />
</a-form-item>
<a-form-item
label="درصد تخفیف اتوماتیک روی محصولات"
:validate-status="err.discount_percent ? 'error' : ''"
:help="err.discount_percent"
>
<a-input-number
v-model:value="form.discount_percent"
dir="ltr"
:min="0"
:max="100"
:formatter="(v: number | string) => `${v}%`"
:parser="(v: string) => v.replace('%', '')"
style="width: 100%"
/>
</a-form-item>
</div>
</a-card>
</a-spin>
<a-button type="primary" class="mr-4" @click="handleSubmit">ثبت اطلاعات</a-button>
</a-form>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue';
import { message } from 'ant-design-vue';
import api from '../../api/client';
const loading = ref(false);
const state = ref(false);
const form = reactive<Record<string, any>>({ discount_percent: undefined });
const err = reactive<Record<string, string>>({});
async function handleSubmit() {
Object.keys(err).forEach((k) => delete err[k]);
if (form.discount_percent === undefined || form.discount_percent === null) {
err.discount_percent = 'وارد کردن درصد تخفیف اتوماتیک الزامی است';
return;
}
try {
loading.value = true;
await api.post('autopromotion', {
state: state.value,
discount_percent: form.discount_percent,
});
message.success('اطلاعات با موفقیت به ثبت رسید.');
} catch (e: any) {
message.error(e?.response?.data?.message ?? 'خطا در ثبت اطلاعات.');
} finally {
loading.value = false;
}
}
onMounted(async () => {
try {
const { data } = await api.get('autopromotion');
state.value = Boolean(data.state);
form.discount_percent = data.discount_percent ?? undefined;
} catch (e) {
console.log(e);
}
});
</script>
<!-- .grid-3 now comes from the global utilities.less (dedup) -->